├── .circleci ├── Dockerfile └── config.yml ├── .gitignore ├── .pre-commit-config.yaml ├── LICENSE ├── README.md ├── STYLE ├── TPS.md ├── ethereum └── pow │ ├── ethash.py │ ├── ethash_utils.py │ ├── ethpow.py │ └── tests │ └── test_ethash.py ├── fixtures ├── 0001-Necessary-changes-to-let-evm-tests-pass.patch ├── GeneralStateTests │ ├── stAttackTest │ │ ├── ContractCreationSpam.json │ │ └── CrashingTransaction.json │ ├── stBadOpcode │ │ └── badOpcodes.json │ ├── stCallCodes │ │ ├── call_OOG_additionalGasCosts1.json │ │ ├── call_OOG_additionalGasCosts2.json │ │ ├── callcall_00.json │ │ ├── callcall_00_OOGE.json │ │ ├── callcall_00_OOGE_valueTransfer.json │ │ ├── callcall_00_SuicideEnd.json │ │ ├── callcallcall_000.json │ │ ├── callcallcall_000_OOGE.json │ │ ├── callcallcall_000_OOGMAfter.json │ │ ├── callcallcall_000_OOGMBefore.json │ │ ├── callcallcall_000_SuicideEnd.json │ │ ├── callcallcall_000_SuicideMiddle.json │ │ ├── callcallcall_ABCB_RECURSIVE.json │ │ ├── callcallcallcode_001.json │ │ ├── callcallcallcode_001_OOGE.json │ │ ├── callcallcallcode_001_OOGMAfter.json │ │ ├── callcallcallcode_001_OOGMBefore.json │ │ ├── callcallcallcode_001_SuicideEnd.json │ │ ├── callcallcallcode_001_SuicideMiddle.json │ │ ├── callcallcallcode_ABCB_RECURSIVE.json │ │ ├── callcallcode_01.json │ │ ├── callcallcode_01_OOGE.json │ │ ├── callcallcode_01_SuicideEnd.json │ │ ├── callcallcodecall_010.json │ │ ├── callcallcodecall_010_OOGE.json │ │ ├── callcallcodecall_010_OOGMAfter.json │ │ ├── callcallcodecall_010_OOGMBefore.json │ │ ├── callcallcodecall_010_SuicideEnd.json │ │ ├── callcallcodecall_010_SuicideMiddle.json │ │ ├── callcallcodecall_ABCB_RECURSIVE.json │ │ ├── callcallcodecallcode_011.json │ │ ├── callcallcodecallcode_011_OOGE.json │ │ ├── callcallcodecallcode_011_OOGMAfter.json │ │ ├── callcallcodecallcode_011_OOGMBefore.json │ │ ├── callcallcodecallcode_011_SuicideEnd.json │ │ ├── callcallcodecallcode_011_SuicideMiddle.json │ │ ├── callcallcodecallcode_ABCB_RECURSIVE.json │ │ ├── callcodeDynamicCode.json │ │ ├── callcodeDynamicCode2SelfCall.json │ │ ├── callcodeEmptycontract.json │ │ ├── callcodeInInitcodeToEmptyContract.json │ │ ├── callcodeInInitcodeToExisContractWithVTransferNEMoney.json │ │ ├── callcodeInInitcodeToExistingContract.json │ │ ├── callcodeInInitcodeToExistingContractWithValueTransfer.json │ │ ├── callcode_checkPC.json │ │ ├── callcodecall_10.json │ │ ├── callcodecall_10_OOGE.json │ │ ├── callcodecall_10_SuicideEnd.json │ │ ├── callcodecallcall_100.json │ │ ├── callcodecallcall_100_OOGE.json │ │ ├── callcodecallcall_100_OOGMAfter.json │ │ ├── callcodecallcall_100_OOGMBefore.json │ │ ├── callcodecallcall_100_SuicideEnd.json │ │ ├── callcodecallcall_100_SuicideMiddle.json │ │ ├── callcodecallcall_ABCB_RECURSIVE.json │ │ ├── callcodecallcallcode_101.json │ │ ├── callcodecallcallcode_101_OOGE.json │ │ ├── callcodecallcallcode_101_OOGMAfter.json │ │ ├── callcodecallcallcode_101_OOGMBefore.json │ │ ├── callcodecallcallcode_101_SuicideEnd.json │ │ ├── callcodecallcallcode_101_SuicideMiddle.json │ │ ├── callcodecallcallcode_ABCB_RECURSIVE.json │ │ ├── callcodecallcode_11.json │ │ ├── callcodecallcode_11_OOGE.json │ │ ├── callcodecallcode_11_SuicideEnd.json │ │ ├── callcodecallcodecall_110.json │ │ ├── callcodecallcodecall_110_OOGE.json │ │ ├── callcodecallcodecall_110_OOGMAfter.json │ │ ├── callcodecallcodecall_110_OOGMBefore.json │ │ ├── callcodecallcodecall_110_SuicideEnd.json │ │ ├── callcodecallcodecall_110_SuicideMiddle.json │ │ ├── callcodecallcodecall_ABCB_RECURSIVE.json │ │ ├── callcodecallcodecallcode_111.json │ │ ├── callcodecallcodecallcode_111_OOGE.json │ │ ├── callcodecallcodecallcode_111_OOGMAfter.json │ │ ├── callcodecallcodecallcode_111_OOGMBefore.json │ │ ├── callcodecallcodecallcode_111_SuicideEnd.json │ │ ├── callcodecallcodecallcode_111_SuicideMiddle.json │ │ └── callcodecallcodecallcode_ABCB_RECURSIVE.json │ ├── stCallCreateCallCodeTest │ │ ├── Call1024BalanceTooLow.json │ │ ├── Call1024OOG.json │ │ ├── Call1024PreCalls.json │ │ ├── CallLoseGasOOG.json │ │ ├── CallRecursiveBombPreCall.json │ │ ├── Callcode1024BalanceTooLow.json │ │ ├── Callcode1024OOG.json │ │ ├── CallcodeLoseGasOOG.json │ │ ├── callOutput1.json │ │ ├── callOutput2.json │ │ ├── callOutput3.json │ │ ├── callOutput3Fail.json │ │ ├── callOutput3partial.json │ │ ├── callOutput3partialFail.json │ │ ├── callWithHighValue.json │ │ ├── callWithHighValueAndGasOOG.json │ │ ├── callWithHighValueAndOOGatTxLevel.json │ │ ├── callWithHighValueOOGinCall.json │ │ ├── callcodeOutput1.json │ │ ├── callcodeOutput2.json │ │ ├── callcodeOutput3.json │ │ ├── callcodeOutput3Fail.json │ │ ├── callcodeOutput3partial.json │ │ ├── callcodeOutput3partialFail.json │ │ ├── callcodeWithHighValue.json │ │ ├── callcodeWithHighValueAndGasOOG.json │ │ ├── createFailBalanceTooLow.json │ │ ├── createInitFailBadJumpDestination.json │ │ ├── createInitFailStackSizeLargerThan1024.json │ │ ├── createInitFailStackUnderflow.json │ │ ├── createInitFailUndefinedInstruction.json │ │ ├── createInitFail_OOGduringInit.json │ │ ├── createInitOOGforCREATE.json │ │ ├── createJS_ExampleContract.json │ │ ├── createJS_NoCollision.json │ │ ├── createNameRegistratorPerTxs.json │ │ ├── createNameRegistratorPerTxsNotEnoughGas.json │ │ ├── createNameRegistratorPreStore1NotEnoughGas.json │ │ └── createNameRegistratorendowmentTooHigh.json │ ├── stCallDelegateCodesCallCodeHomestead │ │ ├── callcallcallcode_001.json │ │ ├── callcallcallcode_001_OOGE.json │ │ ├── callcallcallcode_001_OOGMAfter.json │ │ ├── callcallcallcode_001_OOGMBefore.json │ │ ├── callcallcallcode_001_SuicideEnd.json │ │ ├── callcallcallcode_001_SuicideMiddle.json │ │ ├── callcallcallcode_ABCB_RECURSIVE.json │ │ ├── callcallcode_01.json │ │ ├── callcallcode_01_OOGE.json │ │ ├── callcallcode_01_SuicideEnd.json │ │ ├── callcallcodecall_010.json │ │ ├── callcallcodecall_010_OOGE.json │ │ ├── callcallcodecall_010_OOGMAfter.json │ │ ├── callcallcodecall_010_OOGMBefore.json │ │ ├── callcallcodecall_010_SuicideEnd.json │ │ ├── callcallcodecall_010_SuicideMiddle.json │ │ ├── callcallcodecall_ABCB_RECURSIVE.json │ │ ├── callcallcodecallcode_011.json │ │ ├── callcallcodecallcode_011_OOGE.json │ │ ├── callcallcodecallcode_011_OOGMAfter.json │ │ ├── callcallcodecallcode_011_OOGMBefore.json │ │ ├── callcallcodecallcode_011_SuicideEnd.json │ │ ├── callcallcodecallcode_011_SuicideMiddle.json │ │ ├── callcallcodecallcode_ABCB_RECURSIVE.json │ │ ├── callcodecall_10.json │ │ ├── callcodecall_10_OOGE.json │ │ ├── callcodecall_10_SuicideEnd.json │ │ ├── callcodecallcall_100.json │ │ ├── callcodecallcall_100_OOGE.json │ │ ├── callcodecallcall_100_OOGMAfter.json │ │ ├── callcodecallcall_100_OOGMBefore.json │ │ ├── callcodecallcall_100_SuicideEnd.json │ │ ├── callcodecallcall_100_SuicideMiddle.json │ │ ├── callcodecallcall_ABCB_RECURSIVE.json │ │ ├── callcodecallcallcode_101.json │ │ ├── callcodecallcallcode_101_OOGE.json │ │ ├── callcodecallcallcode_101_OOGMAfter.json │ │ ├── callcodecallcallcode_101_OOGMBefore.json │ │ ├── callcodecallcallcode_101_SuicideEnd.json │ │ ├── callcodecallcallcode_101_SuicideMiddle.json │ │ ├── callcodecallcallcode_ABCB_RECURSIVE.json │ │ ├── callcodecallcode_11.json │ │ ├── callcodecallcode_11_OOGE.json │ │ ├── callcodecallcode_11_SuicideEnd.json │ │ ├── callcodecallcodecall_110.json │ │ ├── callcodecallcodecall_110_OOGE.json │ │ ├── callcodecallcodecall_110_OOGMAfter.json │ │ ├── callcodecallcodecall_110_OOGMBefore.json │ │ ├── callcodecallcodecall_110_SuicideEnd.json │ │ ├── callcodecallcodecall_110_SuicideMiddle.json │ │ ├── callcodecallcodecall_ABCB_RECURSIVE.json │ │ ├── callcodecallcodecallcode_111.json │ │ ├── callcodecallcodecallcode_111_OOGE.json │ │ ├── callcodecallcodecallcode_111_OOGMAfter.json │ │ ├── callcodecallcodecallcode_111_OOGMBefore.json │ │ ├── callcodecallcodecallcode_111_SuicideEnd.json │ │ ├── callcodecallcodecallcode_111_SuicideMiddle.json │ │ └── callcodecallcodecallcode_ABCB_RECURSIVE.json │ ├── stCallDelegateCodesHomestead │ │ ├── callcallcallcode_001.json │ │ ├── callcallcallcode_001_OOGE.json │ │ ├── callcallcallcode_001_OOGMAfter.json │ │ ├── callcallcallcode_001_OOGMBefore.json │ │ ├── callcallcallcode_001_SuicideEnd.json │ │ ├── callcallcallcode_001_SuicideMiddle.json │ │ ├── callcallcallcode_ABCB_RECURSIVE.json │ │ ├── callcallcode_01.json │ │ ├── callcallcode_01_OOGE.json │ │ ├── callcallcode_01_SuicideEnd.json │ │ ├── callcallcodecall_010.json │ │ ├── callcallcodecall_010_OOGE.json │ │ ├── callcallcodecall_010_OOGMAfter.json │ │ ├── callcallcodecall_010_OOGMBefore.json │ │ ├── callcallcodecall_010_SuicideEnd.json │ │ ├── callcallcodecall_010_SuicideMiddle.json │ │ ├── callcallcodecall_ABCB_RECURSIVE.json │ │ ├── callcallcodecallcode_011.json │ │ ├── callcallcodecallcode_011_OOGE.json │ │ ├── callcallcodecallcode_011_OOGMAfter.json │ │ ├── callcallcodecallcode_011_OOGMBefore.json │ │ ├── callcallcodecallcode_011_SuicideEnd.json │ │ ├── callcallcodecallcode_011_SuicideMiddle.json │ │ ├── callcallcodecallcode_ABCB_RECURSIVE.json │ │ ├── callcodecall_10.json │ │ ├── callcodecall_10_OOGE.json │ │ ├── callcodecall_10_SuicideEnd.json │ │ ├── callcodecallcall_100.json │ │ ├── callcodecallcall_100_OOGE.json │ │ ├── callcodecallcall_100_OOGMAfter.json │ │ ├── callcodecallcall_100_OOGMBefore.json │ │ ├── callcodecallcall_100_SuicideEnd.json │ │ ├── callcodecallcall_100_SuicideMiddle.json │ │ ├── callcodecallcall_ABCB_RECURSIVE.json │ │ ├── callcodecallcallcode_101.json │ │ ├── callcodecallcallcode_101_OOGE.json │ │ ├── callcodecallcallcode_101_OOGMAfter.json │ │ ├── callcodecallcallcode_101_OOGMBefore.json │ │ ├── callcodecallcallcode_101_SuicideEnd.json │ │ ├── callcodecallcallcode_101_SuicideMiddle.json │ │ ├── callcodecallcallcode_ABCB_RECURSIVE.json │ │ ├── callcodecallcode_11.json │ │ ├── callcodecallcode_11_OOGE.json │ │ ├── callcodecallcode_11_SuicideEnd.json │ │ ├── callcodecallcodecall_110.json │ │ ├── callcodecallcodecall_110_OOGE.json │ │ ├── callcodecallcodecall_110_OOGMAfter.json │ │ ├── callcodecallcodecall_110_OOGMBefore.json │ │ ├── callcodecallcodecall_110_SuicideEnd.json │ │ ├── callcodecallcodecall_110_SuicideMiddle.json │ │ ├── callcodecallcodecall_ABCB_RECURSIVE.json │ │ ├── callcodecallcodecallcode_111.json │ │ ├── callcodecallcodecallcode_111_OOGE.json │ │ ├── callcodecallcodecallcode_111_OOGMAfter.json │ │ ├── callcodecallcodecallcode_111_OOGMBefore.json │ │ ├── callcodecallcodecallcode_111_SuicideEnd.json │ │ ├── callcodecallcodecallcode_111_SuicideMiddle.json │ │ └── callcodecallcodecallcode_ABCB_RECURSIVE.json │ ├── stChangedEIP150 │ │ ├── Call1024BalanceTooLow.json │ │ ├── Call1024PreCalls.json │ │ ├── Callcode1024BalanceTooLow.json │ │ ├── callcall_00_OOGE_1.json │ │ ├── callcall_00_OOGE_2.json │ │ ├── callcall_00_OOGE_valueTransfer.json │ │ ├── callcallcall_000_OOGMAfter.json │ │ ├── callcallcallcode_001_OOGMAfter_1.json │ │ ├── callcallcallcode_001_OOGMAfter_2.json │ │ ├── callcallcallcode_001_OOGMAfter_3.json │ │ ├── callcallcodecall_010_OOGMAfter_1.json │ │ ├── callcallcodecall_010_OOGMAfter_2.json │ │ ├── callcallcodecall_010_OOGMAfter_3.json │ │ ├── callcallcodecallcode_011_OOGMAfter_1.json │ │ ├── callcallcodecallcode_011_OOGMAfter_2.json │ │ ├── callcodecallcall_100_OOGMAfter_1.json │ │ ├── callcodecallcall_100_OOGMAfter_2.json │ │ ├── callcodecallcall_100_OOGMAfter_3.json │ │ ├── callcodecallcallcode_101_OOGMAfter_1.json │ │ ├── callcodecallcallcode_101_OOGMAfter_2.json │ │ ├── callcodecallcallcode_101_OOGMAfter_3.json │ │ ├── callcodecallcodecall_110_OOGMAfter_1.json │ │ ├── callcodecallcodecall_110_OOGMAfter_2.json │ │ ├── callcodecallcodecall_110_OOGMAfter_3.json │ │ ├── callcodecallcodecallcode_111_OOGMAfter.json │ │ ├── callcodecallcodecallcode_111_OOGMAfter_1.json │ │ ├── callcodecallcodecallcode_111_OOGMAfter_2.json │ │ ├── callcodecallcodecallcode_111_OOGMAfter_3.json │ │ ├── contractCreationMakeCallThatAskMoreGasThenTransactionProvided.json │ │ └── createInitFail_OOGduringInit.json │ ├── stCodeSizeLimit │ │ ├── codesizeOOGInvalidSize.json │ │ └── codesizeValid.json │ ├── stCreateTest │ │ ├── CREATE_AcreateB_BSuicide_BStore.json │ │ ├── CREATE_ContractSSTOREDuringInit.json │ │ ├── CREATE_ContractSuicideDuringInit.json │ │ ├── CREATE_ContractSuicideDuringInit_ThenStoreThenReturn.json │ │ ├── CREATE_ContractSuicideDuringInit_WithValue.json │ │ ├── CREATE_ContractSuicideDuringInit_WithValueToItself.json │ │ ├── CREATE_EContractCreateEContractInInit_Tr.json │ │ ├── CREATE_EContractCreateNEContractInInitOOG_Tr.json │ │ ├── CREATE_EContractCreateNEContractInInit_Tr.json │ │ ├── CREATE_EContract_ThenCALLToNonExistentAcc.json │ │ ├── CREATE_EmptyContract.json │ │ ├── CREATE_EmptyContractAndCallIt_0wei.json │ │ ├── CREATE_EmptyContractAndCallIt_1wei.json │ │ ├── CREATE_EmptyContractWithBalance.json │ │ ├── CREATE_EmptyContractWithStorage.json │ │ ├── CREATE_EmptyContractWithStorageAndCallIt_0wei.json │ │ ├── CREATE_EmptyContractWithStorageAndCallIt_1wei.json │ │ └── CREATE_empty000CreateinInitCode_Transaction.json │ ├── stDelegatecallTestHomestead │ │ ├── Call1024BalanceTooLow.json │ │ ├── Call1024OOG.json │ │ ├── Call1024PreCalls.json │ │ ├── CallLoseGasOOG.json │ │ ├── CallRecursiveBombPreCall.json │ │ ├── CallcodeLoseGasOOG.json │ │ ├── Delegatecall1024.json │ │ ├── Delegatecall1024OOG.json │ │ ├── callOutput1.json │ │ ├── callOutput2.json │ │ ├── callOutput3.json │ │ ├── callOutput3Fail.json │ │ ├── callOutput3partial.json │ │ ├── callOutput3partialFail.json │ │ ├── callWithHighValueAndGasOOG.json │ │ ├── callcodeOutput1.json │ │ ├── callcodeOutput2.json │ │ ├── callcodeOutput3.json │ │ ├── callcodeOutput3Fail.json │ │ ├── callcodeOutput3partial.json │ │ ├── callcodeOutput3partialFail.json │ │ ├── callcodeWithHighValueAndGasOOG.json │ │ ├── deleagateCallAfterValueTransfer.json │ │ ├── delegatecallAndOOGatTxLevel.json │ │ ├── delegatecallBasic.json │ │ ├── delegatecallEmptycontract.json │ │ ├── delegatecallInInitcodeToEmptyContract.json │ │ ├── delegatecallInInitcodeToExistingContract.json │ │ ├── delegatecallInInitcodeToExistingContractOOG.json │ │ ├── delegatecallOOGinCall.json │ │ ├── delegatecallSenderCheck.json │ │ ├── delegatecallValueCheck.json │ │ ├── delegatecodeDynamicCode.json │ │ └── delegatecodeDynamicCode2SelfCall.json │ ├── stEIP150Specific │ │ ├── CallAndCallcodeConsumeMoreGasThenTransactionHas.json │ │ ├── CallAskMoreGasOnDepth2ThenTransactionHas.json │ │ ├── CallGoesOOGOnSecondLevel.json │ │ ├── CallGoesOOGOnSecondLevel2.json │ │ ├── CreateAndGasInsideCreate.json │ │ ├── DelegateCallOnEIP.json │ │ ├── ExecuteCallThatAskForeGasThenTrabsactionHas.json │ │ ├── NewGasPriceForCodes.json │ │ ├── SuicideToExistingContract.json │ │ ├── SuicideToNotExistingContract.json │ │ ├── Transaction64Rule_d64e0.json │ │ ├── Transaction64Rule_d64m1.json │ │ └── Transaction64Rule_d64p1.json │ ├── stEIP150singleCodeGasPrices │ │ ├── RawBalanceGas.json │ │ ├── RawCallCodeGas.json │ │ ├── RawCallCodeGasAsk.json │ │ ├── RawCallCodeGasMemory.json │ │ ├── RawCallCodeGasMemoryAsk.json │ │ ├── RawCallCodeGasValueTransfer.json │ │ ├── RawCallCodeGasValueTransferAsk.json │ │ ├── RawCallCodeGasValueTransferMemory.json │ │ ├── RawCallCodeGasValueTransferMemoryAsk.json │ │ ├── RawCallGas.json │ │ ├── RawCallGasAsk.json │ │ ├── RawCallGasValueTransfer.json │ │ ├── RawCallGasValueTransferAsk.json │ │ ├── RawCallGasValueTransferMemory.json │ │ ├── RawCallGasValueTransferMemoryAsk.json │ │ ├── RawCallMemoryGas.json │ │ ├── RawCallMemoryGasAsk.json │ │ ├── RawCreateFailGasValueTransfer.json │ │ ├── RawCreateFailGasValueTransfer2.json │ │ ├── RawCreateGas.json │ │ ├── RawCreateGasMemory.json │ │ ├── RawCreateGasValueTransfer.json │ │ ├── RawCreateGasValueTransferMemory.json │ │ ├── RawDelegateCallGas.json │ │ ├── RawDelegateCallGasAsk.json │ │ ├── RawDelegateCallGasMemory.json │ │ ├── RawDelegateCallGasMemoryAsk.json │ │ ├── RawExtCodeCopyGas.json │ │ ├── RawExtCodeCopyMemoryGas.json │ │ └── RawExtCodeSizeGas.json │ ├── stEIP158Specific │ │ ├── CALL_OneVCallSuicide.json │ │ ├── CALL_ZeroVCallSuicide.json │ │ ├── EXP_Empty.json │ │ ├── EXTCODESIZE_toEpmty.json │ │ ├── EXTCODESIZE_toNonExistent.json │ │ └── vitalikTransactionTest.json │ ├── stExample │ │ └── add11.json │ ├── stHomesteadSpecific │ │ ├── contractCreationOOGdontLeaveEmptyContract.json │ │ ├── contractCreationOOGdontLeaveEmptyContractViaTransaction.json │ │ ├── createContractViaContract.json │ │ ├── createContractViaContractOOGInitCode.json │ │ └── createContractViaTransactionCost53000.json │ ├── stInitCodeTest │ │ ├── CallContractToCreateContractAndCallItOOG.json │ │ ├── CallContractToCreateContractNoCash.json │ │ ├── CallContractToCreateContractOOG.json │ │ ├── CallContractToCreateContractOOGBonusGas.json │ │ ├── CallContractToCreateContractWhichWouldCreateContractIfCalled.json │ │ ├── CallContractToCreateContractWhichWouldCreateContractInInitCode.json │ │ ├── CallRecursiveContract.json │ │ ├── CallTheContractToCreateEmptyContract.json │ │ ├── NotEnoughCashContractCreation.json │ │ ├── OutOfGasContractCreation.json │ │ ├── OutOfGasPrefundedContractCreation.json │ │ ├── ReturnTest.json │ │ ├── ReturnTest2.json │ │ ├── StackUnderFlowContractCreation.json │ │ ├── TransactionCreateAutoSuicideContract.json │ │ ├── TransactionCreateRandomInitCode.json │ │ ├── TransactionCreateStopInInitcode.json │ │ └── TransactionCreateSuicideInInitcode.json │ ├── stLogTests │ │ ├── log0_emptyMem.json │ │ ├── log0_logMemStartTooHigh.json │ │ ├── log0_logMemsizeTooHigh.json │ │ ├── log0_logMemsizeZero.json │ │ ├── log0_nonEmptyMem.json │ │ ├── log0_nonEmptyMem_logMemSize1.json │ │ ├── log0_nonEmptyMem_logMemSize1_logMemStart31.json │ │ ├── log1_Caller.json │ │ ├── log1_MaxTopic.json │ │ ├── log1_emptyMem.json │ │ ├── log1_logMemStartTooHigh.json │ │ ├── log1_logMemsizeTooHigh.json │ │ ├── log1_logMemsizeZero.json │ │ ├── log1_nonEmptyMem.json │ │ ├── log1_nonEmptyMem_logMemSize1.json │ │ ├── log1_nonEmptyMem_logMemSize1_logMemStart31.json │ │ ├── log2_Caller.json │ │ ├── log2_MaxTopic.json │ │ ├── log2_emptyMem.json │ │ ├── log2_logMemStartTooHigh.json │ │ ├── log2_logMemsizeTooHigh.json │ │ ├── log2_logMemsizeZero.json │ │ ├── log2_nonEmptyMem.json │ │ ├── log2_nonEmptyMem_logMemSize1.json │ │ ├── log2_nonEmptyMem_logMemSize1_logMemStart31.json │ │ ├── log3_Caller.json │ │ ├── log3_MaxTopic.json │ │ ├── log3_PC.json │ │ ├── log3_emptyMem.json │ │ ├── log3_logMemStartTooHigh.json │ │ ├── log3_logMemsizeTooHigh.json │ │ ├── log3_logMemsizeZero.json │ │ ├── log3_nonEmptyMem.json │ │ ├── log3_nonEmptyMem_logMemSize1.json │ │ ├── log3_nonEmptyMem_logMemSize1_logMemStart31.json │ │ ├── log4_Caller.json │ │ ├── log4_MaxTopic.json │ │ ├── log4_PC.json │ │ ├── log4_emptyMem.json │ │ ├── log4_logMemStartTooHigh.json │ │ ├── log4_logMemsizeTooHigh.json │ │ ├── log4_logMemsizeZero.json │ │ ├── log4_nonEmptyMem.json │ │ ├── log4_nonEmptyMem_logMemSize1.json │ │ ├── log4_nonEmptyMem_logMemSize1_logMemStart31.json │ │ └── logInOOG_Call.json │ ├── stMemExpandingEIP150Calls │ │ ├── CallAndCallcodeConsumeMoreGasThenTransactionHasWithMemExpandingCalls.json │ │ ├── CallAskMoreGasOnDepth2ThenTransactionHasWithMemExpandingCalls.json │ │ ├── CallGoesOOGOnSecondLevel2WithMemExpandingCalls.json │ │ ├── CallGoesOOGOnSecondLevelWithMemExpandingCalls.json │ │ ├── CreateAndGasInsideCreateWithMemExpandingCalls.json │ │ ├── DelegateCallOnEIPWithMemExpandingCalls.json │ │ ├── ExecuteCallThatAskMoreGasThenTransactionHasWithMemExpandingCalls.json │ │ └── NewGasPriceForCodesWithMemExpandingCalls.json │ ├── stMemoryStressTest │ │ ├── CALLCODE_Bounds.json │ │ ├── CALLCODE_Bounds2.json │ │ ├── CALLCODE_Bounds3.json │ │ ├── CALLCODE_Bounds4.json │ │ ├── CALL_Bounds.json │ │ ├── CALL_Bounds2.json │ │ ├── CALL_Bounds2a.json │ │ ├── CALL_Bounds3.json │ │ ├── CREATE_Bounds.json │ │ ├── CREATE_Bounds2.json │ │ ├── CREATE_Bounds3.json │ │ ├── DELEGATECALL_Bounds.json │ │ ├── DELEGATECALL_Bounds2.json │ │ ├── DELEGATECALL_Bounds3.json │ │ ├── DUP_Bounds.json │ │ ├── FillStack.json │ │ ├── JUMPI_Bounds.json │ │ ├── JUMP_Bounds.json │ │ ├── JUMP_Bounds2.json │ │ ├── MLOAD_Bounds.json │ │ ├── MLOAD_Bounds2.json │ │ ├── MLOAD_Bounds3.json │ │ ├── MSTORE_Bounds.json │ │ ├── MSTORE_Bounds2.json │ │ ├── MSTORE_Bounds2a.json │ │ ├── POP_Bounds.json │ │ ├── RETURN_Bounds.json │ │ ├── SLOAD_Bounds.json │ │ ├── SSTORE_Bounds.json │ │ ├── mload32bitBound.json │ │ ├── mload32bitBound2.json │ │ ├── mload32bitBound_Msize.json │ │ ├── mload32bitBound_return.json │ │ ├── mload32bitBound_return2.json │ │ ├── static_CALL_Bounds.json │ │ ├── static_CALL_Bounds2.json │ │ ├── static_CALL_Bounds2a.json │ │ └── static_CALL_Bounds3.json │ ├── stMemoryTest │ │ ├── calldatacopy_dejavu.json │ │ ├── calldatacopy_dejavu2.json │ │ ├── codecopy_dejavu.json │ │ ├── codecopy_dejavu2.json │ │ ├── extcodecopy_dejavu.json │ │ ├── log1_dejavu.json │ │ ├── log2_dejavu.json │ │ ├── log3_dejavu.json │ │ ├── log4_dejavu.json │ │ ├── mem0b_singleByte.json │ │ ├── mem31b_singleByte.json │ │ ├── mem32b_singleByte.json │ │ ├── mem32kb+1.json │ │ ├── mem32kb+31.json │ │ ├── mem32kb+32.json │ │ ├── mem32kb+33.json │ │ ├── mem32kb-1.json │ │ ├── mem32kb-31.json │ │ ├── mem32kb-32.json │ │ ├── mem32kb-33.json │ │ ├── mem32kb.json │ │ ├── mem32kb_singleByte+1.json │ │ ├── mem32kb_singleByte+31.json │ │ ├── mem32kb_singleByte+32.json │ │ ├── mem32kb_singleByte+33.json │ │ ├── mem32kb_singleByte-1.json │ │ ├── mem32kb_singleByte-31.json │ │ ├── mem32kb_singleByte-32.json │ │ ├── mem32kb_singleByte-33.json │ │ ├── mem32kb_singleByte.json │ │ ├── mem33b_singleByte.json │ │ ├── mem64kb+1.json │ │ ├── mem64kb+31.json │ │ ├── mem64kb+32.json │ │ ├── mem64kb+33.json │ │ ├── mem64kb-1.json │ │ ├── mem64kb-31.json │ │ ├── mem64kb-32.json │ │ ├── mem64kb-33.json │ │ ├── mem64kb.json │ │ ├── mem64kb_singleByte+1.json │ │ ├── mem64kb_singleByte+31.json │ │ ├── mem64kb_singleByte+32.json │ │ ├── mem64kb_singleByte+33.json │ │ ├── mem64kb_singleByte-1.json │ │ ├── mem64kb_singleByte-31.json │ │ ├── mem64kb_singleByte-32.json │ │ ├── mem64kb_singleByte-33.json │ │ ├── mem64kb_singleByte.json │ │ ├── memReturn.json │ │ ├── mload16bitBound.json │ │ ├── mload8bitBound.json │ │ ├── mload_dejavu.json │ │ ├── mstore_dejavu.json │ │ ├── mstroe8_dejavu.json │ │ ├── sha3_dejavu.json │ │ ├── stackLimitGas_1023.json │ │ ├── stackLimitGas_1024.json │ │ ├── stackLimitGas_1025.json │ │ ├── stackLimitPush31_1023.json │ │ ├── stackLimitPush31_1024.json │ │ ├── stackLimitPush31_1025.json │ │ ├── stackLimitPush32_1023.json │ │ ├── stackLimitPush32_1024.json │ │ └── stackLimitPush32_1025.json │ ├── stNonZeroCallsTest │ │ ├── NonZeroValue_CALL.json │ │ ├── NonZeroValue_CALLCODE.json │ │ ├── NonZeroValue_CALLCODE_ToEmpty.json │ │ ├── NonZeroValue_CALLCODE_ToNonNonZeroBalance.json │ │ ├── NonZeroValue_CALLCODE_ToOneStorageKey.json │ │ ├── NonZeroValue_CALL_ToEmpty.json │ │ ├── NonZeroValue_CALL_ToNonNonZeroBalance.json │ │ ├── NonZeroValue_CALL_ToOneStorageKey.json │ │ ├── NonZeroValue_DELEGATECALL.json │ │ ├── NonZeroValue_DELEGATECALL_ToEmpty.json │ │ ├── NonZeroValue_DELEGATECALL_ToNonNonZeroBalance.json │ │ ├── NonZeroValue_DELEGATECALL_ToOneStorageKey.json │ │ ├── NonZeroValue_SUICIDE.json │ │ ├── NonZeroValue_SUICIDE_ToEmpty.json │ │ ├── NonZeroValue_SUICIDE_ToNonNonZeroBalance.json │ │ ├── NonZeroValue_SUICIDE_ToOneStorageKey.json │ │ ├── NonZeroValue_TransactionCALL.json │ │ ├── NonZeroValue_TransactionCALL_ToEmpty.json │ │ ├── NonZeroValue_TransactionCALL_ToNonNonZeroBalance.json │ │ ├── NonZeroValue_TransactionCALL_ToOneStorageKey.json │ │ ├── NonZeroValue_TransactionCALLwithData.json │ │ ├── NonZeroValue_TransactionCALLwithData_ToEmpty.json │ │ ├── NonZeroValue_TransactionCALLwithData_ToNonNonZeroBalance.json │ │ └── NonZeroValue_TransactionCALLwithData_ToOneStorageKey.json │ ├── stPreCompiledContracts │ │ ├── CALLCODEEcrecover0.json │ │ ├── CALLCODEEcrecover0_0input.json │ │ ├── CALLCODEEcrecover0_Gas2999.json │ │ ├── CALLCODEEcrecover0_NoGas.json │ │ ├── CALLCODEEcrecover0_completeReturnValue.json │ │ ├── CALLCODEEcrecover0_gas3000.json │ │ ├── CALLCODEEcrecover0_overlappingInputOutput.json │ │ ├── CALLCODEEcrecover1.json │ │ ├── CALLCODEEcrecover2.json │ │ ├── CALLCODEEcrecover3.json │ │ ├── CALLCODEEcrecover80.json │ │ ├── CALLCODEEcrecoverH_prefixed0.json │ │ ├── CALLCODEEcrecoverR_prefixed0.json │ │ ├── CALLCODEEcrecoverS_prefixed0.json │ │ ├── CALLCODEEcrecoverV_prefixed0.json │ │ ├── CALLCODEEcrecoverV_prefixedf0.json │ │ ├── CALLCODEIdentitiy_0.json │ │ ├── CALLCODEIdentitiy_1.json │ │ ├── CALLCODEIdentity_1_nonzeroValue.json │ │ ├── CALLCODEIdentity_2.json │ │ ├── CALLCODEIdentity_3.json │ │ ├── CALLCODEIdentity_4.json │ │ ├── CALLCODEIdentity_4_gas17.json │ │ ├── CALLCODEIdentity_4_gas18.json │ │ ├── CALLCODEIdentity_5.json │ │ ├── CALLCODERipemd160_0.json │ │ ├── CALLCODERipemd160_1.json │ │ ├── CALLCODERipemd160_2.json │ │ ├── CALLCODERipemd160_3.json │ │ ├── CALLCODERipemd160_3_postfixed0.json │ │ ├── CALLCODERipemd160_3_prefixed0.json │ │ ├── CALLCODERipemd160_4.json │ │ ├── CALLCODERipemd160_4_gas719.json │ │ ├── CALLCODERipemd160_5.json │ │ ├── CALLCODESha256_0.json │ │ ├── CALLCODESha256_1.json │ │ ├── CALLCODESha256_1_nonzeroValue.json │ │ ├── CALLCODESha256_2.json │ │ ├── CALLCODESha256_3.json │ │ ├── CALLCODESha256_3_postfix0.json │ │ ├── CALLCODESha256_3_prefix0.json │ │ ├── CALLCODESha256_4.json │ │ ├── CALLCODESha256_4_gas99.json │ │ ├── CALLCODESha256_5.json │ │ ├── CallEcrecover0.json │ │ ├── CallEcrecover0_0input.json │ │ ├── CallEcrecover0_Gas2999.json │ │ ├── CallEcrecover0_NoGas.json │ │ ├── CallEcrecover0_completeReturnValue.json │ │ ├── CallEcrecover0_gas3000.json │ │ ├── CallEcrecover0_overlappingInputOutput.json │ │ ├── CallEcrecover1.json │ │ ├── CallEcrecover2.json │ │ ├── CallEcrecover3.json │ │ ├── CallEcrecover80.json │ │ ├── CallEcrecoverCheckLength.json │ │ ├── CallEcrecoverCheckLengthWrongV.json │ │ ├── CallEcrecoverH_prefixed0.json │ │ ├── CallEcrecoverR_prefixed0.json │ │ ├── CallEcrecoverS_prefixed0.json │ │ ├── CallEcrecoverV_prefixed0.json │ │ ├── CallIdentitiy_0.json │ │ ├── CallIdentitiy_1.json │ │ ├── CallIdentity_1_nonzeroValue.json │ │ ├── CallIdentity_2.json │ │ ├── CallIdentity_3.json │ │ ├── CallIdentity_4.json │ │ ├── CallIdentity_4_gas17.json │ │ ├── CallIdentity_4_gas18.json │ │ ├── CallIdentity_5.json │ │ ├── CallRipemd160_0.json │ │ ├── CallRipemd160_1.json │ │ ├── CallRipemd160_2.json │ │ ├── CallRipemd160_3.json │ │ ├── CallRipemd160_3_postfixed0.json │ │ ├── CallRipemd160_3_prefixed0.json │ │ ├── CallRipemd160_4.json │ │ ├── CallRipemd160_4_gas719.json │ │ ├── CallRipemd160_5.json │ │ ├── CallSha256_0.json │ │ ├── CallSha256_1.json │ │ ├── CallSha256_1_nonzeroValue.json │ │ ├── CallSha256_2.json │ │ ├── CallSha256_3.json │ │ ├── CallSha256_3_postfix0.json │ │ ├── CallSha256_3_prefix0.json │ │ ├── CallSha256_4.json │ │ ├── CallSha256_4_gas99.json │ │ ├── CallSha256_5.json │ │ ├── modexp.json │ │ ├── modexp_0_0_0_1000000.json │ │ ├── modexp_0_0_0_155000.json │ │ ├── modexp_0_0_0_20500.json │ │ ├── modexp_0_0_0_22000.json │ │ ├── modexp_0_0_0_25000.json │ │ ├── modexp_0_0_0_35000.json │ │ ├── modexp_0_1_0_1000000.json │ │ ├── modexp_0_1_0_155000.json │ │ ├── modexp_0_1_0_20500.json │ │ ├── modexp_0_1_0_22000.json │ │ ├── modexp_0_1_0_25000.json │ │ ├── modexp_0_1_0_35000.json │ │ ├── modexp_0_3_100_1000000.json │ │ ├── modexp_0_3_100_155000.json │ │ ├── modexp_0_3_100_20500.json │ │ ├── modexp_0_3_100_22000.json │ │ ├── modexp_0_3_100_25000.json │ │ ├── modexp_0_3_100_35000.json │ │ ├── modexp_1_0_0_1000000.json │ │ ├── modexp_1_0_0_155000.json │ │ ├── modexp_1_0_0_20500.json │ │ ├── modexp_1_0_0_22000.json │ │ ├── modexp_1_0_0_25000.json │ │ ├── modexp_1_0_0_35000.json │ │ ├── modexp_1_0_1_1000000.json │ │ ├── modexp_1_0_1_155000.json │ │ ├── modexp_1_0_1_20500.json │ │ ├── modexp_1_0_1_22000.json │ │ ├── modexp_1_0_1_25000.json │ │ ├── modexp_1_0_1_35000.json │ │ ├── modexp_1_1_1_1000000.json │ │ ├── modexp_1_1_1_155000.json │ │ ├── modexp_1_1_1_20500.json │ │ ├── modexp_1_1_1_22000.json │ │ ├── modexp_1_1_1_25000.json │ │ ├── modexp_1_1_1_35000.json │ │ ├── modexp_37120_22411_22000.json │ │ ├── modexp_37120_37111_0_1000000.json │ │ ├── modexp_37120_37111_0_155000.json │ │ ├── modexp_37120_37111_0_20500.json │ │ ├── modexp_37120_37111_0_22000.json │ │ ├── modexp_37120_37111_0_25000.json │ │ ├── modexp_37120_37111_0_35000.json │ │ ├── modexp_37120_37111_1_1000000.json │ │ ├── modexp_37120_37111_1_155000.json │ │ ├── modexp_37120_37111_1_20500.json │ │ ├── modexp_37120_37111_1_25000.json │ │ ├── modexp_37120_37111_1_35000.json │ │ ├── modexp_37120_37111_37111_1000000.json │ │ ├── modexp_37120_37111_37111_155000.json │ │ ├── modexp_37120_37111_37111_20500.json │ │ ├── modexp_37120_37111_37111_22000.json │ │ ├── modexp_37120_37111_37111_25000.json │ │ ├── modexp_37120_37111_37111_35000.json │ │ ├── modexp_37120_37111_97_1000000.json │ │ ├── modexp_37120_37111_97_155000.json │ │ ├── modexp_37120_37111_97_20500.json │ │ ├── modexp_37120_37111_97_22000.json │ │ ├── modexp_37120_37111_97_25000.json │ │ ├── modexp_37120_37111_97_35000.json │ │ ├── modexp_39936_1_55201_1000000.json │ │ ├── modexp_39936_1_55201_155000.json │ │ ├── modexp_39936_1_55201_20500.json │ │ ├── modexp_39936_1_55201_22000.json │ │ ├── modexp_39936_1_55201_25000.json │ │ ├── modexp_39936_1_55201_35000.json │ │ ├── modexp_3_09984_39936_1000000.json │ │ ├── modexp_3_09984_39936_155000.json │ │ ├── modexp_3_09984_39936_22000.json │ │ ├── modexp_3_09984_39936_25000.json │ │ ├── modexp_3_09984_39936_35000.json │ │ ├── modexp_3_28948_11579_20500.json │ │ ├── modexp_3_5_100_1000000.json │ │ ├── modexp_3_5_100_155000.json │ │ ├── modexp_3_5_100_20500.json │ │ ├── modexp_3_5_100_22000.json │ │ ├── modexp_3_5_100_25000.json │ │ ├── modexp_3_5_100_35000.json │ │ ├── modexp_49_2401_2401_1000000.json │ │ ├── modexp_49_2401_2401_155000.json │ │ ├── modexp_49_2401_2401_20500.json │ │ ├── modexp_49_2401_2401_22000.json │ │ ├── modexp_49_2401_2401_25000.json │ │ ├── modexp_49_2401_2401_35000.json │ │ ├── modexp_55190_55190_42965_1000000.json │ │ ├── modexp_55190_55190_42965_155000.json │ │ ├── modexp_55190_55190_42965_20500.json │ │ ├── modexp_55190_55190_42965_22000.json │ │ ├── modexp_55190_55190_42965_25000.json │ │ ├── modexp_55190_55190_42965_35000.json │ │ ├── modexp_9_37111_37111_1000000.json │ │ ├── modexp_9_37111_37111_155000.json │ │ ├── modexp_9_37111_37111_20500.json │ │ ├── modexp_9_37111_37111_22000.json │ │ ├── modexp_9_37111_37111_35000.json │ │ ├── modexp_9_3711_37111_25000.json │ │ └── sec80.json │ ├── stQuadraticComplexityTest │ │ ├── Call1MB1024Calldepth.json │ │ ├── Call50000.json │ │ ├── Call50000_ecrec.json │ │ ├── Call50000_identity.json │ │ ├── Call50000_identity2.json │ │ ├── Call50000_rip160.json │ │ ├── Call50000_sha256.json │ │ ├── Call50000bytesContract50_1.json │ │ ├── Call50000bytesContract50_2.json │ │ ├── Call50000bytesContract50_3.json │ │ ├── Callcode50000.json │ │ ├── Create1000.json │ │ ├── QuadraticComplexitySolidity_CallDataCopy.json │ │ ├── Return50000.json │ │ └── Return50000_2.json │ ├── stRandom │ │ ├── randomStatetest.json │ │ ├── randomStatetest0.json │ │ ├── randomStatetest1.json │ │ ├── randomStatetest10.json │ │ ├── randomStatetest100.json │ │ ├── randomStatetest101.json │ │ ├── randomStatetest102.json │ │ ├── randomStatetest103.json │ │ ├── randomStatetest104.json │ │ ├── randomStatetest105.json │ │ ├── randomStatetest106.json │ │ ├── randomStatetest107.json │ │ ├── randomStatetest108.json │ │ ├── randomStatetest11.json │ │ ├── randomStatetest110.json │ │ ├── randomStatetest111.json │ │ ├── randomStatetest112.json │ │ ├── randomStatetest114.json │ │ ├── randomStatetest115.json │ │ ├── randomStatetest116.json │ │ ├── randomStatetest117.json │ │ ├── randomStatetest118.json │ │ ├── randomStatetest119.json │ │ ├── randomStatetest12.json │ │ ├── randomStatetest120.json │ │ ├── randomStatetest121.json │ │ ├── randomStatetest122.json │ │ ├── randomStatetest123.json │ │ ├── randomStatetest124.json │ │ ├── randomStatetest125.json │ │ ├── randomStatetest126.json │ │ ├── randomStatetest129.json │ │ ├── randomStatetest13.json │ │ ├── randomStatetest130.json │ │ ├── randomStatetest131.json │ │ ├── randomStatetest133.json │ │ ├── randomStatetest134.json │ │ ├── randomStatetest135.json │ │ ├── randomStatetest136.json │ │ ├── randomStatetest137.json │ │ ├── randomStatetest138.json │ │ ├── randomStatetest139.json │ │ ├── randomStatetest14.json │ │ ├── randomStatetest142.json │ │ ├── randomStatetest143.json │ │ ├── randomStatetest144.json │ │ ├── randomStatetest145.json │ │ ├── randomStatetest146.json │ │ ├── randomStatetest147.json │ │ ├── randomStatetest148.json │ │ ├── randomStatetest149.json │ │ ├── randomStatetest15.json │ │ ├── randomStatetest150.json │ │ ├── randomStatetest151.json │ │ ├── randomStatetest153.json │ │ ├── randomStatetest154.json │ │ ├── randomStatetest155.json │ │ ├── randomStatetest156.json │ │ ├── randomStatetest157.json │ │ ├── randomStatetest158.json │ │ ├── randomStatetest159.json │ │ ├── randomStatetest16.json │ │ ├── randomStatetest160.json │ │ ├── randomStatetest161.json │ │ ├── randomStatetest162.json │ │ ├── randomStatetest163.json │ │ ├── randomStatetest164.json │ │ ├── randomStatetest166.json │ │ ├── randomStatetest167.json │ │ ├── randomStatetest169.json │ │ ├── randomStatetest17.json │ │ ├── randomStatetest170.json │ │ ├── randomStatetest171.json │ │ ├── randomStatetest172.json │ │ ├── randomStatetest173.json │ │ ├── randomStatetest174.json │ │ ├── randomStatetest175.json │ │ ├── randomStatetest176.json │ │ ├── randomStatetest177.json │ │ ├── randomStatetest178.json │ │ ├── randomStatetest179.json │ │ ├── randomStatetest18.json │ │ ├── randomStatetest180.json │ │ ├── randomStatetest183.json │ │ ├── randomStatetest184.json │ │ ├── randomStatetest185.json │ │ ├── randomStatetest187.json │ │ ├── randomStatetest188.json │ │ ├── randomStatetest189.json │ │ ├── randomStatetest19.json │ │ ├── randomStatetest190.json │ │ ├── randomStatetest191.json │ │ ├── randomStatetest192.json │ │ ├── randomStatetest194.json │ │ ├── randomStatetest195.json │ │ ├── randomStatetest196.json │ │ ├── randomStatetest197.json │ │ ├── randomStatetest198.json │ │ ├── randomStatetest199.json │ │ ├── randomStatetest2.json │ │ ├── randomStatetest20.json │ │ ├── randomStatetest200.json │ │ ├── randomStatetest201.json │ │ ├── randomStatetest202.json │ │ ├── randomStatetest204.json │ │ ├── randomStatetest205.json │ │ ├── randomStatetest206.json │ │ ├── randomStatetest207.json │ │ ├── randomStatetest208.json │ │ ├── randomStatetest209.json │ │ ├── randomStatetest210.json │ │ ├── randomStatetest211.json │ │ ├── randomStatetest212.json │ │ ├── randomStatetest214.json │ │ ├── randomStatetest215.json │ │ ├── randomStatetest216.json │ │ ├── randomStatetest217.json │ │ ├── randomStatetest219.json │ │ ├── randomStatetest22.json │ │ ├── randomStatetest220.json │ │ ├── randomStatetest221.json │ │ ├── randomStatetest222.json │ │ ├── randomStatetest223.json │ │ ├── randomStatetest225.json │ │ ├── randomStatetest226.json │ │ ├── randomStatetest227.json │ │ ├── randomStatetest228.json │ │ ├── randomStatetest229.json │ │ ├── randomStatetest23.json │ │ ├── randomStatetest230.json │ │ ├── randomStatetest231.json │ │ ├── randomStatetest232.json │ │ ├── randomStatetest233.json │ │ ├── randomStatetest236.json │ │ ├── randomStatetest237.json │ │ ├── randomStatetest238.json │ │ ├── randomStatetest24.json │ │ ├── randomStatetest241.json │ │ ├── randomStatetest242.json │ │ ├── randomStatetest243.json │ │ ├── randomStatetest244.json │ │ ├── randomStatetest245.json │ │ ├── randomStatetest246.json │ │ ├── randomStatetest247.json │ │ ├── randomStatetest248.json │ │ ├── randomStatetest249.json │ │ ├── randomStatetest25.json │ │ ├── randomStatetest250.json │ │ ├── randomStatetest251.json │ │ ├── randomStatetest252.json │ │ ├── randomStatetest254.json │ │ ├── randomStatetest257.json │ │ ├── randomStatetest259.json │ │ ├── randomStatetest26.json │ │ ├── randomStatetest260.json │ │ ├── randomStatetest261.json │ │ ├── randomStatetest263.json │ │ ├── randomStatetest264.json │ │ ├── randomStatetest265.json │ │ ├── randomStatetest266.json │ │ ├── randomStatetest267.json │ │ ├── randomStatetest268.json │ │ ├── randomStatetest269.json │ │ ├── randomStatetest27.json │ │ ├── randomStatetest270.json │ │ ├── randomStatetest271.json │ │ ├── randomStatetest273.json │ │ ├── randomStatetest274.json │ │ ├── randomStatetest275.json │ │ ├── randomStatetest276.json │ │ ├── randomStatetest278.json │ │ ├── randomStatetest279.json │ │ ├── randomStatetest28.json │ │ ├── randomStatetest280.json │ │ ├── randomStatetest281.json │ │ ├── randomStatetest282.json │ │ ├── randomStatetest283.json │ │ ├── randomStatetest285.json │ │ ├── randomStatetest286.json │ │ ├── randomStatetest287.json │ │ ├── randomStatetest288.json │ │ ├── randomStatetest29.json │ │ ├── randomStatetest290.json │ │ ├── randomStatetest291.json │ │ ├── randomStatetest292.json │ │ ├── randomStatetest293.json │ │ ├── randomStatetest294.json │ │ ├── randomStatetest295.json │ │ ├── randomStatetest296.json │ │ ├── randomStatetest297.json │ │ ├── randomStatetest298.json │ │ ├── randomStatetest299.json │ │ ├── randomStatetest3.json │ │ ├── randomStatetest30.json │ │ ├── randomStatetest300.json │ │ ├── randomStatetest301.json │ │ ├── randomStatetest302.json │ │ ├── randomStatetest303.json │ │ ├── randomStatetest304.json │ │ ├── randomStatetest305.json │ │ ├── randomStatetest306.json │ │ ├── randomStatetest307.json │ │ ├── randomStatetest308.json │ │ ├── randomStatetest309.json │ │ ├── randomStatetest31.json │ │ ├── randomStatetest310.json │ │ ├── randomStatetest311.json │ │ ├── randomStatetest312.json │ │ ├── randomStatetest313.json │ │ ├── randomStatetest315.json │ │ ├── randomStatetest316.json │ │ ├── randomStatetest318.json │ │ ├── randomStatetest32.json │ │ ├── randomStatetest320.json │ │ ├── randomStatetest321.json │ │ ├── randomStatetest322.json │ │ ├── randomStatetest323.json │ │ ├── randomStatetest324.json │ │ ├── randomStatetest325.json │ │ ├── randomStatetest326.json │ │ ├── randomStatetest327.json │ │ ├── randomStatetest328.json │ │ ├── randomStatetest329.json │ │ ├── randomStatetest33.json │ │ ├── randomStatetest332.json │ │ ├── randomStatetest333.json │ │ ├── randomStatetest334.json │ │ ├── randomStatetest335.json │ │ ├── randomStatetest336.json │ │ ├── randomStatetest337.json │ │ ├── randomStatetest338.json │ │ ├── randomStatetest339.json │ │ ├── randomStatetest340.json │ │ ├── randomStatetest341.json │ │ ├── randomStatetest342.json │ │ ├── randomStatetest343.json │ │ ├── randomStatetest345.json │ │ ├── randomStatetest346.json │ │ ├── randomStatetest347.json │ │ ├── randomStatetest348.json │ │ ├── randomStatetest349.json │ │ ├── randomStatetest350.json │ │ ├── randomStatetest351.json │ │ ├── randomStatetest352.json │ │ ├── randomStatetest353.json │ │ ├── randomStatetest354.json │ │ ├── randomStatetest355.json │ │ ├── randomStatetest356.json │ │ ├── randomStatetest357.json │ │ ├── randomStatetest358.json │ │ ├── randomStatetest359.json │ │ ├── randomStatetest36.json │ │ ├── randomStatetest360.json │ │ ├── randomStatetest361.json │ │ ├── randomStatetest362.json │ │ ├── randomStatetest363.json │ │ ├── randomStatetest364.json │ │ ├── randomStatetest365.json │ │ ├── randomStatetest366.json │ │ ├── randomStatetest367.json │ │ ├── randomStatetest368.json │ │ ├── randomStatetest369.json │ │ ├── randomStatetest37.json │ │ ├── randomStatetest370.json │ │ ├── randomStatetest371.json │ │ ├── randomStatetest372.json │ │ ├── randomStatetest375.json │ │ ├── randomStatetest376.json │ │ ├── randomStatetest377.json │ │ ├── randomStatetest378.json │ │ ├── randomStatetest379.json │ │ ├── randomStatetest38.json │ │ ├── randomStatetest380.json │ │ ├── randomStatetest381.json │ │ ├── randomStatetest382.json │ │ ├── randomStatetest383.json │ │ ├── randomStatetest384.json │ │ ├── randomStatetest385.json │ │ ├── randomStatetest386.json │ │ ├── randomStatetest387.json │ │ ├── randomStatetest388.json │ │ ├── randomStatetest389.json │ │ ├── randomStatetest39.json │ │ ├── randomStatetest391.json │ │ ├── randomStatetest393.json │ │ ├── randomStatetest395.json │ │ ├── randomStatetest396.json │ │ ├── randomStatetest397.json │ │ ├── randomStatetest398.json │ │ ├── randomStatetest399.json │ │ ├── randomStatetest4.json │ │ ├── randomStatetest401.json │ │ ├── randomStatetest402.json │ │ ├── randomStatetest404.json │ │ ├── randomStatetest405.json │ │ ├── randomStatetest406.json │ │ ├── randomStatetest407.json │ │ ├── randomStatetest408.json │ │ ├── randomStatetest409.json │ │ ├── randomStatetest41.json │ │ ├── randomStatetest410.json │ │ ├── randomStatetest411.json │ │ ├── randomStatetest412.json │ │ ├── randomStatetest413.json │ │ ├── randomStatetest414.json │ │ ├── randomStatetest415.json │ │ ├── randomStatetest416.json │ │ ├── randomStatetest417.json │ │ ├── randomStatetest418.json │ │ ├── randomStatetest419.json │ │ ├── randomStatetest42.json │ │ ├── randomStatetest420.json │ │ ├── randomStatetest421.json │ │ ├── randomStatetest422.json │ │ ├── randomStatetest423.json │ │ ├── randomStatetest424.json │ │ ├── randomStatetest425.json │ │ ├── randomStatetest426.json │ │ ├── randomStatetest428.json │ │ ├── randomStatetest429.json │ │ ├── randomStatetest43.json │ │ ├── randomStatetest430.json │ │ ├── randomStatetest433.json │ │ ├── randomStatetest435.json │ │ ├── randomStatetest436.json │ │ ├── randomStatetest437.json │ │ ├── randomStatetest438.json │ │ ├── randomStatetest439.json │ │ ├── randomStatetest440.json │ │ ├── randomStatetest441.json │ │ ├── randomStatetest442.json │ │ ├── randomStatetest443.json │ │ ├── randomStatetest444.json │ │ ├── randomStatetest445.json │ │ ├── randomStatetest446.json │ │ ├── randomStatetest447.json │ │ ├── randomStatetest448.json │ │ ├── randomStatetest449.json │ │ ├── randomStatetest45.json │ │ ├── randomStatetest450.json │ │ ├── randomStatetest451.json │ │ ├── randomStatetest452.json │ │ ├── randomStatetest454.json │ │ ├── randomStatetest455.json │ │ ├── randomStatetest456.json │ │ ├── randomStatetest457.json │ │ ├── randomStatetest458.json │ │ ├── randomStatetest46.json │ │ ├── randomStatetest460.json │ │ ├── randomStatetest461.json │ │ ├── randomStatetest462.json │ │ ├── randomStatetest464.json │ │ ├── randomStatetest465.json │ │ ├── randomStatetest466.json │ │ ├── randomStatetest467.json │ │ ├── randomStatetest468.json │ │ ├── randomStatetest469.json │ │ ├── randomStatetest47.json │ │ ├── randomStatetest470.json │ │ ├── randomStatetest471.json │ │ ├── randomStatetest472.json │ │ ├── randomStatetest473.json │ │ ├── randomStatetest474.json │ │ ├── randomStatetest475.json │ │ ├── randomStatetest476.json │ │ ├── randomStatetest477.json │ │ ├── randomStatetest478.json │ │ ├── randomStatetest48.json │ │ ├── randomStatetest480.json │ │ ├── randomStatetest481.json │ │ ├── randomStatetest482.json │ │ ├── randomStatetest483.json │ │ ├── randomStatetest484.json │ │ ├── randomStatetest485.json │ │ ├── randomStatetest487.json │ │ ├── randomStatetest488.json │ │ ├── randomStatetest489.json │ │ ├── randomStatetest49.json │ │ ├── randomStatetest491.json │ │ ├── randomStatetest493.json │ │ ├── randomStatetest494.json │ │ ├── randomStatetest495.json │ │ ├── randomStatetest496.json │ │ ├── randomStatetest497.json │ │ ├── randomStatetest498.json │ │ ├── randomStatetest499.json │ │ ├── randomStatetest5.json │ │ ├── randomStatetest50.json │ │ ├── randomStatetest500.json │ │ ├── randomStatetest501.json │ │ ├── randomStatetest502.json │ │ ├── randomStatetest503.json │ │ ├── randomStatetest504.json │ │ ├── randomStatetest505.json │ │ ├── randomStatetest506.json │ │ ├── randomStatetest507.json │ │ ├── randomStatetest508.json │ │ ├── randomStatetest509.json │ │ ├── randomStatetest51.json │ │ ├── randomStatetest510.json │ │ ├── randomStatetest511.json │ │ ├── randomStatetest512.json │ │ ├── randomStatetest513.json │ │ ├── randomStatetest514.json │ │ ├── randomStatetest516.json │ │ ├── randomStatetest517.json │ │ ├── randomStatetest518.json │ │ ├── randomStatetest519.json │ │ ├── randomStatetest52.json │ │ ├── randomStatetest520.json │ │ ├── randomStatetest521.json │ │ ├── randomStatetest523.json │ │ ├── randomStatetest524.json │ │ ├── randomStatetest525.json │ │ ├── randomStatetest526.json │ │ ├── randomStatetest527.json │ │ ├── randomStatetest528.json │ │ ├── randomStatetest53.json │ │ ├── randomStatetest531.json │ │ ├── randomStatetest532.json │ │ ├── randomStatetest533.json │ │ ├── randomStatetest534.json │ │ ├── randomStatetest535.json │ │ ├── randomStatetest536.json │ │ ├── randomStatetest537.json │ │ ├── randomStatetest538.json │ │ ├── randomStatetest539.json │ │ ├── randomStatetest54.json │ │ ├── randomStatetest541.json │ │ ├── randomStatetest542.json │ │ ├── randomStatetest543.json │ │ ├── randomStatetest544.json │ │ ├── randomStatetest545.json │ │ ├── randomStatetest546.json │ │ ├── randomStatetest547.json │ │ ├── randomStatetest548.json │ │ ├── randomStatetest549.json │ │ ├── randomStatetest55.json │ │ ├── randomStatetest550.json │ │ ├── randomStatetest552.json │ │ ├── randomStatetest553.json │ │ ├── randomStatetest554.json │ │ ├── randomStatetest555.json │ │ ├── randomStatetest556.json │ │ ├── randomStatetest558.json │ │ ├── randomStatetest559.json │ │ ├── randomStatetest560.json │ │ ├── randomStatetest562.json │ │ ├── randomStatetest563.json │ │ ├── randomStatetest564.json │ │ ├── randomStatetest565.json │ │ ├── randomStatetest566.json │ │ ├── randomStatetest567.json │ │ ├── randomStatetest569.json │ │ ├── randomStatetest57.json │ │ ├── randomStatetest571.json │ │ ├── randomStatetest572.json │ │ ├── randomStatetest573.json │ │ ├── randomStatetest574.json │ │ ├── randomStatetest575.json │ │ ├── randomStatetest576.json │ │ ├── randomStatetest577.json │ │ ├── randomStatetest578.json │ │ ├── randomStatetest579.json │ │ ├── randomStatetest58.json │ │ ├── randomStatetest580.json │ │ ├── randomStatetest581.json │ │ ├── randomStatetest582.json │ │ ├── randomStatetest583.json │ │ ├── randomStatetest584.json │ │ ├── randomStatetest585.json │ │ ├── randomStatetest586.json │ │ ├── randomStatetest587.json │ │ ├── randomStatetest588.json │ │ ├── randomStatetest589.json │ │ ├── randomStatetest59.json │ │ ├── randomStatetest592.json │ │ ├── randomStatetest594.json │ │ ├── randomStatetest596.json │ │ ├── randomStatetest597.json │ │ ├── randomStatetest599.json │ │ ├── randomStatetest6.json │ │ ├── randomStatetest60.json │ │ ├── randomStatetest600.json │ │ ├── randomStatetest601.json │ │ ├── randomStatetest602.json │ │ ├── randomStatetest603.json │ │ ├── randomStatetest604.json │ │ ├── randomStatetest605.json │ │ ├── randomStatetest607.json │ │ ├── randomStatetest608.json │ │ ├── randomStatetest609.json │ │ ├── randomStatetest610.json │ │ ├── randomStatetest611.json │ │ ├── randomStatetest612.json │ │ ├── randomStatetest615.json │ │ ├── randomStatetest616.json │ │ ├── randomStatetest618.json │ │ ├── randomStatetest619.json │ │ ├── randomStatetest62.json │ │ ├── randomStatetest620.json │ │ ├── randomStatetest621.json │ │ ├── randomStatetest624.json │ │ ├── randomStatetest625.json │ │ ├── randomStatetest626.json │ │ ├── randomStatetest627.json │ │ ├── randomStatetest628.json │ │ ├── randomStatetest629.json │ │ ├── randomStatetest63.json │ │ ├── randomStatetest630.json │ │ ├── randomStatetest632.json │ │ ├── randomStatetest633.json │ │ ├── randomStatetest635.json │ │ ├── randomStatetest636.json │ │ ├── randomStatetest637.json │ │ ├── randomStatetest638.json │ │ ├── randomStatetest639.json │ │ ├── randomStatetest64.json │ │ ├── randomStatetest640.json │ │ ├── randomStatetest641.json │ │ ├── randomStatetest642.json │ │ ├── randomStatetest643.json │ │ ├── randomStatetest644.json │ │ ├── randomStatetest645.json │ │ ├── randomStatetest646.json │ │ ├── randomStatetest66.json │ │ ├── randomStatetest67.json │ │ ├── randomStatetest69.json │ │ ├── randomStatetest7.json │ │ ├── randomStatetest72.json │ │ ├── randomStatetest73.json │ │ ├── randomStatetest74.json │ │ ├── randomStatetest75.json │ │ ├── randomStatetest77.json │ │ ├── randomStatetest78.json │ │ ├── randomStatetest80.json │ │ ├── randomStatetest81.json │ │ ├── randomStatetest82.json │ │ ├── randomStatetest83.json │ │ ├── randomStatetest84.json │ │ ├── randomStatetest85.json │ │ ├── randomStatetest87.json │ │ ├── randomStatetest88.json │ │ ├── randomStatetest89.json │ │ ├── randomStatetest9.json │ │ ├── randomStatetest90.json │ │ ├── randomStatetest92.json │ │ ├── randomStatetest94.json │ │ ├── randomStatetest95.json │ │ ├── randomStatetest96.json │ │ ├── randomStatetest97.json │ │ └── randomStatetest98.json │ ├── stRecursiveCreate │ │ ├── recursiveCreate.json │ │ └── recursiveCreateReturnValue.json │ ├── stRefundTest │ │ ├── refund50_1.json │ │ ├── refund50_2.json │ │ ├── refund50percentCap.json │ │ ├── refund600.json │ │ ├── refundSuicide50procentCap.json │ │ ├── refund_CallA.json │ │ ├── refund_CallA_OOG.json │ │ ├── refund_CallA_notEnoughGasInCall.json │ │ ├── refund_CallToSuicideNoStorage.json │ │ ├── refund_CallToSuicideStorage.json │ │ ├── refund_CallToSuicideTwice.json │ │ ├── refund_NoOOG_1.json │ │ ├── refund_OOG.json │ │ ├── refund_TxToSuicide.json │ │ ├── refund_TxToSuicideOOG.json │ │ ├── refund_changeNonZeroStorage.json │ │ ├── refund_getEtherBack.json │ │ ├── refund_multimpleSuicide.json │ │ └── refund_singleSuicide.json │ ├── stReturnDataTest │ │ ├── call_outsize_then_create_successful_then_returndatasize.json │ │ ├── call_then_call_value_fail_then_returndatasize.json │ │ ├── call_then_create_successful_then_returndatasize.json │ │ ├── create_callprecompile_returndatasize.json │ │ ├── returndatacopy_0_0_following_successful_create.json │ │ ├── returndatacopy_after_failing_callcode.json │ │ ├── returndatacopy_after_failing_delegatecall.json │ │ ├── returndatacopy_after_failing_staticcall.json │ │ ├── returndatacopy_after_successful_callcode.json │ │ ├── returndatacopy_after_successful_delegatecall.json │ │ ├── returndatacopy_after_successful_staticcall.json │ │ ├── returndatacopy_following_call.json │ │ ├── returndatacopy_following_create.json │ │ ├── returndatacopy_following_failing_call.json │ │ ├── returndatacopy_following_revert.json │ │ ├── returndatacopy_following_successful_create.json │ │ ├── returndatacopy_initial.json │ │ ├── returndatacopy_initial_256.json │ │ ├── returndatacopy_initial_big_sum.json │ │ ├── returndatacopy_overrun.json │ │ ├── returndatasize_after_callcode.json │ │ ├── returndatasize_after_failing_callcode.json │ │ ├── returndatasize_after_failing_delegatecall.json │ │ ├── returndatasize_after_failing_staticcall.json │ │ ├── returndatasize_after_successful_callcode.json │ │ ├── returndatasize_after_successful_delegatecall.json │ │ ├── returndatasize_after_successful_staticcall.json │ │ ├── returndatasize_following_successful_create.json │ │ ├── returndatasize_initial.json │ │ └── returndatasize_initial_zero_read.json │ ├── stRevertTest │ │ ├── LoopCallsDepthThenRevert.json │ │ ├── LoopCallsDepthThenRevert2.json │ │ ├── LoopCallsDepthThenRevert3.json │ │ ├── LoopCallsThenRevert.json │ │ ├── LoopDelegateCallsDepthThenRevert.json │ │ ├── NashatyrevSuicideRevert.json │ │ ├── RevertDepth2.json │ │ ├── RevertDepthCreateAddressCollision.json │ │ ├── RevertDepthCreateOOG.json │ │ ├── RevertInCallCode.json │ │ ├── RevertOpcode.json │ │ ├── RevertOpcodeCalls.json │ │ ├── RevertOpcodeCreate.json │ │ ├── RevertOpcodeDirectCall.json │ │ ├── RevertOpcodeInCreateReturns.json │ │ ├── RevertOpcodeInInit.json │ │ ├── RevertOpcodeMultipleSubCalls.json │ │ ├── RevertOpcodeReturn.json │ │ ├── RevertPrecompiledTouch.json │ │ ├── RevertPrecompiledTouchCC.json │ │ ├── RevertPrecompiledTouchDC.json │ │ ├── RevertPrefound.json │ │ ├── RevertPrefoundCall.json │ │ ├── RevertPrefoundCallOOG.json │ │ ├── RevertPrefoundEmpty.json │ │ ├── RevertPrefoundEmptyCall.json │ │ ├── RevertPrefoundEmptyCallOOG.json │ │ ├── RevertPrefoundEmptyOOG.json │ │ ├── RevertPrefoundOOG.json │ │ ├── RevertRemoteSubCallStorageOOG.json │ │ ├── RevertRemoteSubCallStorageOOG2.json │ │ ├── RevertSubCallStorageOOG.json │ │ ├── RevertSubCallStorageOOG2.json │ │ ├── TouchToEmptyAccountRevert.json │ │ ├── TouchToEmptyAccountRevert2.json │ │ └── TouchToEmptyAccountRevert3.json │ ├── stSolidityTest │ │ ├── AmbiguousMethod.json │ │ ├── CallInfiniteLoop.json │ │ ├── CallLowLevelCreatesSolidity.json │ │ ├── CallRecursiveMethods.json │ │ ├── ContractInheritance.json │ │ ├── CreateContractFromMethod.json │ │ ├── RecursiveCreateContracts.json │ │ ├── RecursiveCreateContractsCreate4Contracts.json │ │ ├── TestBlockAndTransactionProperties.json │ │ ├── TestContractInteraction.json │ │ ├── TestContractSuicide.json │ │ ├── TestCryptographicFunctions.json │ │ ├── TestKeywords.json │ │ ├── TestOverflow.json │ │ ├── TestStoreGasPrices.json │ │ └── TestStructuresAndVariabless.json │ ├── stSpecialTest │ │ ├── JUMPDEST_Attack.json │ │ ├── JUMPDEST_AttackwithJump.json │ │ ├── OverflowGasMakeMoney.json │ │ ├── StackDepthLimitSEC.json │ │ ├── block504980.json │ │ ├── deploymentError.json │ │ ├── failed_tx_xcf416c53.json │ │ ├── gasPrice0.json │ │ ├── makeMoney.json │ │ ├── sha3_deja.json │ │ ├── txCost-sec73.json │ │ └── tx_e1c174e2.json │ ├── stStackTests │ │ ├── shallowStack.json │ │ ├── stackOverflow.json │ │ ├── stackOverflowDUP.json │ │ ├── stackOverflowM1.json │ │ ├── stackOverflowM1DUP.json │ │ ├── stackOverflowM1PUSH.json │ │ └── stackOverflowPUSH.json │ ├── stStaticCall │ │ ├── static_ABAcalls0.json │ │ ├── static_ABAcalls1.json │ │ ├── static_ABAcalls2.json │ │ ├── static_ABAcalls3.json │ │ ├── static_ABAcallsSuicide0.json │ │ ├── static_ABAcallsSuicide1.json │ │ ├── static_CALL_OneVCallSuicide.json │ │ ├── static_CALL_ZeroVCallSuicide.json │ │ ├── static_CREATE_ContractSuicideDuringInit.json │ │ ├── static_CREATE_ContractSuicideDuringInit_ThenStoreThenReturn.json │ │ ├── static_CREATE_ContractSuicideDuringInit_WithValue.json │ │ ├── static_CREATE_EmptyContractAndCallIt_0wei.json │ │ ├── static_CREATE_EmptyContractWithStorageAndCallIt_0wei.json │ │ ├── static_Call10.json │ │ ├── static_Call1024BalanceTooLow.json │ │ ├── static_Call1024BalanceTooLow2.json │ │ ├── static_Call1024OOG.json │ │ ├── static_Call1024PreCalls.json │ │ ├── static_Call1024PreCalls2.json │ │ ├── static_Call1024PreCalls3.json │ │ ├── static_Call1MB1024Calldepth.json │ │ ├── static_Call50000.json │ │ ├── static_Call50000_ecrec.json │ │ ├── static_Call50000_identity.json │ │ ├── static_Call50000_identity2.json │ │ ├── static_Call50000_rip160.json │ │ ├── static_Call50000_sha256.json │ │ ├── static_Call50000bytesContract50_1.json │ │ ├── static_Call50000bytesContract50_2.json │ │ ├── static_Call50000bytesContract50_3.json │ │ ├── static_CallAndCallcodeConsumeMoreGasThenTransactionHas.json │ │ ├── static_CallAskMoreGasOnDepth2ThenTransactionHas.json │ │ ├── static_CallContractToCreateContractAndCallItOOG.json │ │ ├── static_CallContractToCreateContractOOG.json │ │ ├── static_CallContractToCreateContractOOGBonusGas.json │ │ ├── static_CallContractToCreateContractWhichWouldCreateContractIfCalled.json │ │ ├── static_CallEcrecover0.json │ │ ├── static_CallEcrecover0_0input.json │ │ ├── static_CallEcrecover0_Gas2999.json │ │ ├── static_CallEcrecover0_NoGas.json │ │ ├── static_CallEcrecover0_completeReturnValue.json │ │ ├── static_CallEcrecover0_gas3000.json │ │ ├── static_CallEcrecover0_overlappingInputOutput.json │ │ ├── static_CallEcrecover1.json │ │ ├── static_CallEcrecover2.json │ │ ├── static_CallEcrecover3.json │ │ ├── static_CallEcrecover80.json │ │ ├── static_CallEcrecoverCheckLength.json │ │ ├── static_CallEcrecoverCheckLengthWrongV.json │ │ ├── static_CallEcrecoverH_prefixed0.json │ │ ├── static_CallEcrecoverR_prefixed0.json │ │ ├── static_CallEcrecoverS_prefixed0.json │ │ ├── static_CallEcrecoverV_prefixed0.json │ │ ├── static_CallGoesOOGOnSecondLevel.json │ │ ├── static_CallGoesOOGOnSecondLevel2.json │ │ ├── static_CallIdentitiy_1.json │ │ ├── static_CallIdentity_1_nonzeroValue.json │ │ ├── static_CallIdentity_2.json │ │ ├── static_CallIdentity_3.json │ │ ├── static_CallIdentity_4.json │ │ ├── static_CallIdentity_4_gas17.json │ │ ├── static_CallIdentity_4_gas18.json │ │ ├── static_CallIdentity_5.json │ │ ├── static_CallLoseGasOOG.json │ │ ├── static_CallRecursiveBomb0.json │ │ ├── static_CallRecursiveBomb0_OOG_atMaxCallDepth.json │ │ ├── static_CallRecursiveBomb1.json │ │ ├── static_CallRecursiveBomb2.json │ │ ├── static_CallRecursiveBomb3.json │ │ ├── static_CallRecursiveBombLog.json │ │ ├── static_CallRecursiveBombLog2.json │ │ ├── static_CallRecursiveBombPreCall.json │ │ ├── static_CallRecursiveBombPreCall2.json │ │ ├── static_CallRipemd160_1.json │ │ ├── static_CallRipemd160_2.json │ │ ├── static_CallRipemd160_3.json │ │ ├── static_CallRipemd160_3_postfixed0.json │ │ ├── static_CallRipemd160_3_prefixed0.json │ │ ├── static_CallRipemd160_4.json │ │ ├── static_CallRipemd160_4_gas719.json │ │ ├── static_CallRipemd160_5.json │ │ ├── static_CallSha256_1.json │ │ ├── static_CallSha256_1_nonzeroValue.json │ │ ├── static_CallSha256_2.json │ │ ├── static_CallSha256_3.json │ │ ├── static_CallSha256_3_postfix0.json │ │ ├── static_CallSha256_3_prefix0.json │ │ ├── static_CallSha256_4.json │ │ ├── static_CallSha256_4_gas99.json │ │ ├── static_CallSha256_5.json │ │ ├── static_CallToNameRegistrator0.json │ │ ├── static_CallToReturn1.json │ │ ├── static_CalltoReturn2.json │ │ ├── static_CheckCallCostOOG.json │ │ ├── static_CheckOpcodes.json │ │ ├── static_CheckOpcodes2.json │ │ ├── static_CheckOpcodes3.json │ │ ├── static_CheckOpcodes4.json │ │ ├── static_CheckOpcodes5.json │ │ ├── static_ExecuteCallThatAskForeGasThenTrabsactionHas.json │ │ ├── static_InternalCallHittingGasLimit.json │ │ ├── static_InternalCallHittingGasLimit2.json │ │ ├── static_InternlCallStoreClearsOOG.json │ │ ├── static_LoopCallsDepthThenRevert.json │ │ ├── static_LoopCallsDepthThenRevert2.json │ │ ├── static_LoopCallsDepthThenRevert3.json │ │ ├── static_LoopCallsThenRevert.json │ │ ├── static_PostToReturn1.json │ │ ├── static_RETURN_Bounds.json │ │ ├── static_RETURN_BoundsOOG.json │ │ ├── static_RawCallGasAsk.json │ │ ├── static_Return50000_2.json │ │ ├── static_ReturnTest.json │ │ ├── static_ReturnTest2.json │ │ ├── static_RevertDepth2.json │ │ ├── static_RevertOpcodeCalls.json │ │ ├── static_ZeroValue_CALL_OOGRevert.json │ │ ├── static_ZeroValue_SUICIDE_OOGRevert.json │ │ ├── static_callBasic.json │ │ ├── static_callChangeRevert.json │ │ ├── static_callCreate.json │ │ ├── static_callCreate2.json │ │ ├── static_callCreate3.json │ │ ├── static_callOutput1.json │ │ ├── static_callOutput2.json │ │ ├── static_callOutput3.json │ │ ├── static_callOutput3Fail.json │ │ ├── static_callOutput3partial.json │ │ ├── static_callOutput3partialFail.json │ │ ├── static_callToCallCodeOpCodeCheck.json │ │ ├── static_callToCallOpCodeCheck.json │ │ ├── static_callToDelCallOpCodeCheck.json │ │ ├── static_callToStaticOpCodeCheck.json │ │ ├── static_callWithHighValue.json │ │ ├── static_callWithHighValueAndGasOOG.json │ │ ├── static_callWithHighValueAndOOGatTxLevel.json │ │ ├── static_callWithHighValueOOGinCall.json │ │ ├── static_call_OOG_additionalGasCosts1.json │ │ ├── static_call_OOG_additionalGasCosts2.json │ │ ├── static_call_value_inherit.json │ │ ├── static_call_value_inherit_from_call.json │ │ ├── static_callcall_00.json │ │ ├── static_callcall_00_OOGE.json │ │ ├── static_callcall_00_OOGE_1.json │ │ ├── static_callcall_00_OOGE_2.json │ │ ├── static_callcall_00_SuicideEnd.json │ │ ├── static_callcallcall_000.json │ │ ├── static_callcallcall_000_OOGE.json │ │ ├── static_callcallcall_000_OOGMAfter.json │ │ ├── static_callcallcall_000_OOGMAfter2.json │ │ ├── static_callcallcall_000_OOGMBefore.json │ │ ├── static_callcallcall_000_SuicideEnd.json │ │ ├── static_callcallcall_000_SuicideMiddle.json │ │ ├── static_callcallcall_ABCB_RECURSIVE.json │ │ ├── static_callcallcallcode_001.json │ │ ├── static_callcallcallcode_001_2.json │ │ ├── static_callcallcallcode_001_OOGE.json │ │ ├── static_callcallcallcode_001_OOGE_2.json │ │ ├── static_callcallcallcode_001_OOGMAfter.json │ │ ├── static_callcallcallcode_001_OOGMAfter2.json │ │ ├── static_callcallcallcode_001_OOGMAfter_2.json │ │ ├── static_callcallcallcode_001_OOGMAfter_3.json │ │ ├── static_callcallcallcode_001_OOGMBefore.json │ │ ├── static_callcallcallcode_001_OOGMBefore2.json │ │ ├── static_callcallcallcode_001_SuicideEnd.json │ │ ├── static_callcallcallcode_001_SuicideEnd2.json │ │ ├── static_callcallcallcode_001_SuicideMiddle.json │ │ ├── static_callcallcallcode_001_SuicideMiddle2.json │ │ ├── static_callcallcallcode_ABCB_RECURSIVE.json │ │ ├── static_callcallcallcode_ABCB_RECURSIVE2.json │ │ ├── static_callcallcode_01_2.json │ │ ├── static_callcallcode_01_OOGE_2.json │ │ ├── static_callcallcode_01_SuicideEnd.json │ │ ├── static_callcallcode_01_SuicideEnd2.json │ │ ├── static_callcallcodecall_010.json │ │ ├── static_callcallcodecall_010_2.json │ │ ├── static_callcallcodecall_010_OOGE.json │ │ ├── static_callcallcodecall_010_OOGE_2.json │ │ ├── static_callcallcodecall_010_OOGMAfter.json │ │ ├── static_callcallcodecall_010_OOGMAfter2.json │ │ ├── static_callcallcodecall_010_OOGMAfter_2.json │ │ ├── static_callcallcodecall_010_OOGMAfter_3.json │ │ ├── static_callcallcodecall_010_OOGMBefore.json │ │ ├── static_callcallcodecall_010_OOGMBefore2.json │ │ ├── static_callcallcodecall_010_SuicideEnd.json │ │ ├── static_callcallcodecall_010_SuicideEnd2.json │ │ ├── static_callcallcodecall_010_SuicideMiddle.json │ │ ├── static_callcallcodecall_010_SuicideMiddle2.json │ │ ├── static_callcallcodecall_ABCB_RECURSIVE.json │ │ ├── static_callcallcodecall_ABCB_RECURSIVE2.json │ │ ├── static_callcallcodecallcode_011.json │ │ ├── static_callcallcodecallcode_011_2.json │ │ ├── static_callcallcodecallcode_011_OOGE.json │ │ ├── static_callcallcodecallcode_011_OOGE_2.json │ │ ├── static_callcallcodecallcode_011_OOGMAfter.json │ │ ├── static_callcallcodecallcode_011_OOGMAfter2.json │ │ ├── static_callcallcodecallcode_011_OOGMAfter_1.json │ │ ├── static_callcallcodecallcode_011_OOGMAfter_2.json │ │ ├── static_callcallcodecallcode_011_OOGMBefore.json │ │ ├── static_callcallcodecallcode_011_OOGMBefore2.json │ │ ├── static_callcallcodecallcode_011_SuicideEnd.json │ │ ├── static_callcallcodecallcode_011_SuicideEnd2.json │ │ ├── static_callcallcodecallcode_011_SuicideMiddle.json │ │ ├── static_callcallcodecallcode_011_SuicideMiddle2.json │ │ ├── static_callcallcodecallcode_ABCB_RECURSIVE.json │ │ ├── static_callcallcodecallcode_ABCB_RECURSIVE2.json │ │ ├── static_callcode_checkPC.json │ │ ├── static_callcodecall_10.json │ │ ├── static_callcodecall_10_2.json │ │ ├── static_callcodecall_10_OOGE.json │ │ ├── static_callcodecall_10_OOGE_2.json │ │ ├── static_callcodecall_10_SuicideEnd.json │ │ ├── static_callcodecall_10_SuicideEnd2.json │ │ ├── static_callcodecallcall_100.json │ │ ├── static_callcodecallcall_100_2.json │ │ ├── static_callcodecallcall_100_OOGE.json │ │ ├── static_callcodecallcall_100_OOGE2.json │ │ ├── static_callcodecallcall_100_OOGMAfter.json │ │ ├── static_callcodecallcall_100_OOGMAfter2.json │ │ ├── static_callcodecallcall_100_OOGMAfter_2.json │ │ ├── static_callcodecallcall_100_OOGMAfter_3.json │ │ ├── static_callcodecallcall_100_OOGMBefore.json │ │ ├── static_callcodecallcall_100_OOGMBefore2.json │ │ ├── static_callcodecallcall_100_SuicideEnd.json │ │ ├── static_callcodecallcall_100_SuicideEnd2.json │ │ ├── static_callcodecallcall_100_SuicideMiddle.json │ │ ├── static_callcodecallcall_100_SuicideMiddle2.json │ │ ├── static_callcodecallcall_ABCB_RECURSIVE.json │ │ ├── static_callcodecallcall_ABCB_RECURSIVE2.json │ │ ├── static_callcodecallcallcode_101.json │ │ ├── static_callcodecallcallcode_101_2.json │ │ ├── static_callcodecallcallcode_101_OOGE.json │ │ ├── static_callcodecallcallcode_101_OOGE_2.json │ │ ├── static_callcodecallcallcode_101_OOGMAfter.json │ │ ├── static_callcodecallcallcode_101_OOGMAfter2.json │ │ ├── static_callcodecallcallcode_101_OOGMAfter_1.json │ │ ├── static_callcodecallcallcode_101_OOGMAfter_3.json │ │ ├── static_callcodecallcallcode_101_OOGMBefore.json │ │ ├── static_callcodecallcallcode_101_OOGMBefore2.json │ │ ├── static_callcodecallcallcode_101_SuicideEnd.json │ │ ├── static_callcodecallcallcode_101_SuicideEnd2.json │ │ ├── static_callcodecallcallcode_101_SuicideMiddle.json │ │ ├── static_callcodecallcallcode_101_SuicideMiddle2.json │ │ ├── static_callcodecallcallcode_ABCB_RECURSIVE.json │ │ ├── static_callcodecallcallcode_ABCB_RECURSIVE2.json │ │ ├── static_callcodecallcodecall_110.json │ │ ├── static_callcodecallcodecall_1102.json │ │ ├── static_callcodecallcodecall_110_2.json │ │ ├── static_callcodecallcodecall_110_OOGE.json │ │ ├── static_callcodecallcodecall_110_OOGE2.json │ │ ├── static_callcodecallcodecall_110_OOGMAfter.json │ │ ├── static_callcodecallcodecall_110_OOGMAfter2.json │ │ ├── static_callcodecallcodecall_110_OOGMAfter_2.json │ │ ├── static_callcodecallcodecall_110_OOGMAfter_3.json │ │ ├── static_callcodecallcodecall_110_OOGMBefore.json │ │ ├── static_callcodecallcodecall_110_OOGMBefore2.json │ │ ├── static_callcodecallcodecall_110_SuicideEnd.json │ │ ├── static_callcodecallcodecall_110_SuicideEnd2.json │ │ ├── static_callcodecallcodecall_110_SuicideMiddle.json │ │ ├── static_callcodecallcodecall_110_SuicideMiddle2.json │ │ ├── static_callcodecallcodecall_ABCB_RECURSIVE.json │ │ ├── static_callcodecallcodecall_ABCB_RECURSIVE2.json │ │ ├── static_callcodecallcodecallcode_111_SuicideEnd.json │ │ ├── static_calldelcode_01.json │ │ ├── static_calldelcode_01_OOGE.json │ │ ├── static_contractCreationMakeCallThatAskMoreGasThenTransactionProvided.json │ │ ├── static_contractCreationOOGdontLeaveEmptyContractViaTransaction.json │ │ ├── static_log0_emptyMem.json │ │ ├── static_log0_logMemStartTooHigh.json │ │ ├── static_log0_logMemsizeTooHigh.json │ │ ├── static_log0_logMemsizeZero.json │ │ ├── static_log0_nonEmptyMem.json │ │ ├── static_log0_nonEmptyMem_logMemSize1.json │ │ ├── static_log0_nonEmptyMem_logMemSize1_logMemStart31.json │ │ ├── static_log1_MaxTopic.json │ │ ├── static_log1_emptyMem.json │ │ ├── static_log1_logMemStartTooHigh.json │ │ ├── static_log1_logMemsizeTooHigh.json │ │ ├── static_log1_logMemsizeZero.json │ │ ├── static_log_Caller.json │ │ ├── static_makeMoney.json │ │ ├── static_refund_CallA.json │ │ ├── static_refund_CallToSuicideNoStorage.json │ │ └── static_refund_CallToSuicideTwice.json │ ├── stSystemOperationsTest │ │ ├── ABAcalls0.json │ │ ├── ABAcalls1.json │ │ ├── ABAcalls2.json │ │ ├── ABAcalls3.json │ │ ├── ABAcallsSuicide0.json │ │ ├── ABAcallsSuicide1.json │ │ ├── Call10.json │ │ ├── CallRecursiveBomb0.json │ │ ├── CallRecursiveBomb0_OOG_atMaxCallDepth.json │ │ ├── CallRecursiveBomb1.json │ │ ├── CallRecursiveBomb2.json │ │ ├── CallRecursiveBomb3.json │ │ ├── CallRecursiveBombLog.json │ │ ├── CallRecursiveBombLog2.json │ │ ├── CallToNameRegistrator0.json │ │ ├── CallToNameRegistratorAddressTooBigLeft.json │ │ ├── CallToNameRegistratorAddressTooBigRight.json │ │ ├── CallToNameRegistratorMemOOGAndInsufficientBalance.json │ │ ├── CallToNameRegistratorNotMuchMemory0.json │ │ ├── CallToNameRegistratorNotMuchMemory1.json │ │ ├── CallToNameRegistratorOutOfGas.json │ │ ├── CallToNameRegistratorTooMuchMemory0.json │ │ ├── CallToNameRegistratorTooMuchMemory1.json │ │ ├── CallToNameRegistratorTooMuchMemory2.json │ │ ├── CallToNameRegistratorZeorSizeMemExpansion.json │ │ ├── CallToReturn1.json │ │ ├── CallToReturn1ForDynamicJump0.json │ │ ├── CallToReturn1ForDynamicJump1.json │ │ ├── CalltoReturn2.json │ │ ├── CreateHashCollision.json │ │ ├── PostToReturn1.json │ │ ├── TestNameRegistrator.json │ │ ├── balanceInputAddressTooBig.json │ │ ├── callValue.json │ │ ├── callcodeTo0.json │ │ ├── callcodeToNameRegistrator0.json │ │ ├── callcodeToNameRegistratorAddresTooBigLeft.json │ │ ├── callcodeToNameRegistratorAddresTooBigRight.json │ │ ├── callcodeToNameRegistratorZeroMemExpanion.json │ │ ├── callcodeToReturn1.json │ │ ├── callerAccountBalance.json │ │ ├── createNameRegistrator.json │ │ ├── createNameRegistratorOOG_MemExpansionOOV.json │ │ ├── createNameRegistratorOutOfMemoryBonds0.json │ │ ├── createNameRegistratorOutOfMemoryBonds1.json │ │ ├── createNameRegistratorValueTooHigh.json │ │ ├── createNameRegistratorZeroMem.json │ │ ├── createNameRegistratorZeroMem2.json │ │ ├── createNameRegistratorZeroMemExpansion.json │ │ ├── createWithInvalidOpcode.json │ │ ├── currentAccountBalance.json │ │ ├── extcodecopy.json │ │ ├── return0.json │ │ ├── return1.json │ │ ├── return2.json │ │ ├── suicideAddress.json │ │ ├── suicideCaller.json │ │ ├── suicideCallerAddresTooBigLeft.json │ │ ├── suicideCallerAddresTooBigRight.json │ │ ├── suicideCoinbase.json │ │ ├── suicideNotExistingAccount.json │ │ ├── suicideOrigin.json │ │ ├── suicideSendEtherPostDeath.json │ │ ├── suicideSendEtherToMe.json │ │ └── testRandomTest.json │ ├── stTransactionTest │ │ ├── ContractStoreClearsOOG.json │ │ ├── ContractStoreClearsSuccess.json │ │ ├── CreateMessageReverted.json │ │ ├── CreateMessageSuccess.json │ │ ├── CreateTransactionReverted.json │ │ ├── CreateTransactionSuccess.json │ │ ├── EmptyTransaction.json │ │ ├── EmptyTransaction2.json │ │ ├── EmptyTransaction3.json │ │ ├── HighGasLimit.json │ │ ├── InternalCallHittingGasLimit.json │ │ ├── InternalCallHittingGasLimit2.json │ │ ├── InternalCallHittingGasLimitSuccess.json │ │ ├── InternlCallStoreClearsOOG.json │ │ ├── InternlCallStoreClearsSucces.json │ │ ├── OverflowGasRequire.json │ │ ├── OverflowGasRequire2.json │ │ ├── RefundOverflow.json │ │ ├── RefundOverflow2.json │ │ ├── StoreClearsAndInternlCallStoreClearsOOG.json │ │ ├── StoreClearsAndInternlCallStoreClearsSuccess.json │ │ ├── StoreGasOnCreate.json │ │ ├── SuicidesAndInternlCallSuicidesBonusGasAtCall.json │ │ ├── SuicidesAndInternlCallSuicidesBonusGasAtCallFailed.json │ │ ├── SuicidesAndInternlCallSuicidesOOG.json │ │ ├── SuicidesAndInternlCallSuicidesSuccess.json │ │ ├── SuicidesAndSendMoneyToItselfEtherDestroyed.json │ │ ├── SuicidesMixingCoinbase.json │ │ ├── SuicidesStopAfterSuicide.json │ │ ├── TransactionDataCosts652.json │ │ ├── TransactionFromCoinbaseHittingBlockGasLimit.json │ │ ├── TransactionFromCoinbaseHittingBlockGasLimit1.json │ │ ├── TransactionFromCoinbaseNotEnoughFounds.json │ │ ├── TransactionNonceCheck.json │ │ ├── TransactionNonceCheck2.json │ │ ├── TransactionSendingToEmpty.json │ │ ├── TransactionSendingToZero.json │ │ ├── TransactionToAddressh160minusOne.json │ │ ├── TransactionToItself.json │ │ ├── TransactionToItselfNotEnoughFounds.json │ │ ├── UserTransactionGasLimitIsTooLowWhenZeroCost.json │ │ ├── UserTransactionZeroCost.json │ │ ├── UserTransactionZeroCostWithData.json │ │ ├── zeroSigTransacrionCreatePrice0.json │ │ ├── zeroSigTransaction.json │ │ ├── zeroSigTransaction0Price.json │ │ ├── zeroSigTransactionCreate.json │ │ ├── zeroSigTransactionCreatePrice0.json │ │ ├── zeroSigTransactionInvChainID.json │ │ ├── zeroSigTransactionInvNonce.json │ │ ├── zeroSigTransactionInvNonce2.json │ │ ├── zeroSigTransactionOOG.json │ │ ├── zeroSigTransactionOrigin.json │ │ ├── zeroSigTransactionToZero.json │ │ └── zeroSigTransactionToZero2.json │ ├── stTransitionTest │ │ ├── createNameRegistratorPerTxsAfter.json │ │ ├── createNameRegistratorPerTxsAt.json │ │ ├── createNameRegistratorPerTxsBefore.json │ │ ├── createNameRegistratorPerTxsNotEnoughGasAfter.json │ │ ├── createNameRegistratorPerTxsNotEnoughGasAt.json │ │ ├── createNameRegistratorPerTxsNotEnoughGasBefore.json │ │ ├── delegatecallAfterTransition.json │ │ ├── delegatecallAtTransition.json │ │ └── delegatecallBeforeTransition.json │ ├── stWalletTest │ │ ├── dayLimitConstruction.json │ │ ├── dayLimitConstructionOOG.json │ │ ├── dayLimitConstructionPartial.json │ │ ├── dayLimitResetSpentToday.json │ │ ├── dayLimitSetDailyLimit.json │ │ ├── dayLimitSetDailyLimitNoData.json │ │ ├── multiOwnedAddOwner.json │ │ ├── multiOwnedAddOwnerAddMyself.json │ │ ├── multiOwnedChangeOwner.json │ │ ├── multiOwnedChangeOwnerNoArgument.json │ │ ├── multiOwnedChangeOwner_fromNotOwner.json │ │ ├── multiOwnedChangeOwner_toIsOwner.json │ │ ├── multiOwnedChangeRequirementTo0.json │ │ ├── multiOwnedChangeRequirementTo1.json │ │ ├── multiOwnedChangeRequirementTo2.json │ │ ├── multiOwnedConstructionCorrect.json │ │ ├── multiOwnedConstructionNotEnoughGas.json │ │ ├── multiOwnedConstructionNotEnoughGasPartial.json │ │ ├── multiOwnedIsOwnerFalse.json │ │ ├── multiOwnedIsOwnerTrue.json │ │ ├── multiOwnedRemoveOwner.json │ │ ├── multiOwnedRemoveOwnerByNonOwner.json │ │ ├── multiOwnedRemoveOwner_mySelf.json │ │ ├── multiOwnedRemoveOwner_ownerIsNotOwner.json │ │ ├── multiOwnedRevokeNothing.json │ │ ├── walletAddOwnerRemovePendingTransaction.json │ │ ├── walletChangeOwnerRemovePendingTransaction.json │ │ ├── walletChangeRequirementRemovePendingTransaction.json │ │ ├── walletConfirm.json │ │ ├── walletConstruction.json │ │ ├── walletConstructionOOG.json │ │ ├── walletConstructionPartial.json │ │ ├── walletDefault.json │ │ ├── walletDefaultWithOutValue.json │ │ ├── walletExecuteOverDailyLimitMultiOwner.json │ │ ├── walletExecuteOverDailyLimitOnlyOneOwner.json │ │ ├── walletExecuteOverDailyLimitOnlyOneOwnerNew.json │ │ ├── walletExecuteUnderDailyLimit.json │ │ ├── walletKill.json │ │ ├── walletKillNotByOwner.json │ │ ├── walletKillToWallet.json │ │ └── walletRemoveOwnerRemovePendingTransaction.json │ ├── stZeroCallsRevert │ │ ├── ZeroValue_CALLCODE_OOGRevert.json │ │ ├── ZeroValue_CALLCODE_ToEmpty_OOGRevert.json │ │ ├── ZeroValue_CALLCODE_ToNonZeroBalance_OOGRevert.json │ │ ├── ZeroValue_CALLCODE_ToOneStorageKey_OOGRevert.json │ │ ├── ZeroValue_CALL_OOGRevert.json │ │ ├── ZeroValue_CALL_ToEmpty_OOGRevert.json │ │ ├── ZeroValue_CALL_ToNonZeroBalance_OOGRevert.json │ │ ├── ZeroValue_CALL_ToOneStorageKey_OOGRevert.json │ │ ├── ZeroValue_DELEGATECALL_OOGRevert.json │ │ ├── ZeroValue_DELEGATECALL_ToEmpty_OOGRevert.json │ │ ├── ZeroValue_DELEGATECALL_ToNonZeroBalance_OOGRevert.json │ │ ├── ZeroValue_DELEGATECALL_ToOneStorageKey_OOGRevert.json │ │ ├── ZeroValue_SUICIDE_OOGRevert.json │ │ ├── ZeroValue_SUICIDE_ToEmpty_OOGRevert.json │ │ ├── ZeroValue_SUICIDE_ToNonZeroBalance_OOGRevert.json │ │ ├── ZeroValue_SUICIDE_ToOneStorageKey_OOGRevert.json │ │ ├── ZeroValue_TransactionCALL_OOGRevert.json │ │ ├── ZeroValue_TransactionCALL_ToEmpty_OOGRevert.json │ │ ├── ZeroValue_TransactionCALL_ToNonZeroBalance_OOGRevert.json │ │ ├── ZeroValue_TransactionCALL_ToOneStorageKey_OOGRevert.json │ │ ├── ZeroValue_TransactionCALLwithData_OOGRevert.json │ │ ├── ZeroValue_TransactionCALLwithData_ToEmpty_OOGRevert.json │ │ ├── ZeroValue_TransactionCALLwithData_ToNonZeroBalance_OOGRevert.json │ │ └── ZeroValue_TransactionCALLwithData_ToOneStorageKey_OOGRevert.json │ ├── stZeroCallsTest │ │ ├── ZeroValue_CALL.json │ │ ├── ZeroValue_CALLCODE.json │ │ ├── ZeroValue_CALLCODE_ToEmpty.json │ │ ├── ZeroValue_CALLCODE_ToNonZeroBalance.json │ │ ├── ZeroValue_CALLCODE_ToOneStorageKey.json │ │ ├── ZeroValue_CALL_ToEmpty.json │ │ ├── ZeroValue_CALL_ToNonZeroBalance.json │ │ ├── ZeroValue_CALL_ToOneStorageKey.json │ │ ├── ZeroValue_DELEGATECALL.json │ │ ├── ZeroValue_DELEGATECALL_ToEmpty.json │ │ ├── ZeroValue_DELEGATECALL_ToNonZeroBalance.json │ │ ├── ZeroValue_DELEGATECALL_ToOneStorageKey.json │ │ ├── ZeroValue_SUICIDE.json │ │ ├── ZeroValue_SUICIDE_ToEmpty.json │ │ ├── ZeroValue_SUICIDE_ToNonZeroBalance.json │ │ ├── ZeroValue_SUICIDE_ToOneStorageKey.json │ │ ├── ZeroValue_TransactionCALL.json │ │ ├── ZeroValue_TransactionCALL_ToEmpty.json │ │ ├── ZeroValue_TransactionCALL_ToNonZeroBalance.json │ │ ├── ZeroValue_TransactionCALL_ToOneStorageKey.json │ │ ├── ZeroValue_TransactionCALLwithData.json │ │ ├── ZeroValue_TransactionCALLwithData_ToEmpty.json │ │ ├── ZeroValue_TransactionCALLwithData_ToNonZeroBalance.json │ │ └── ZeroValue_TransactionCALLwithData_ToOneStorageKey.json │ └── stZeroKnowledge │ │ ├── ecadd_0-0_0-0_21000_0.json │ │ ├── ecadd_0-0_0-0_21000_128.json │ │ ├── ecadd_0-0_0-0_21000_192.json │ │ ├── ecadd_0-0_0-0_21000_64.json │ │ ├── ecadd_0-0_0-0_21000_80.json │ │ ├── ecadd_0-0_0-0_25000_0.json │ │ ├── ecadd_0-0_0-0_25000_128.json │ │ ├── ecadd_0-0_0-0_25000_192.json │ │ ├── ecadd_0-0_0-0_25000_64.json │ │ ├── ecadd_0-0_0-0_25000_80.json │ │ ├── ecadd_0-0_1-2_21000_128.json │ │ ├── ecadd_0-0_1-2_21000_192.json │ │ ├── ecadd_0-0_1-2_25000_128.json │ │ ├── ecadd_0-0_1-2_25000_192.json │ │ ├── ecadd_0-0_1-3_21000_128.json │ │ ├── ecadd_0-0_1-3_25000_128.json │ │ ├── ecadd_0-3_1-2_21000_128.json │ │ ├── ecadd_0-3_1-2_25000_128.json │ │ ├── ecadd_1-2_0-0_21000_128.json │ │ ├── ecadd_1-2_0-0_21000_192.json │ │ ├── ecadd_1-2_0-0_21000_64.json │ │ ├── ecadd_1-2_0-0_25000_128.json │ │ ├── ecadd_1-2_0-0_25000_192.json │ │ ├── ecadd_1-2_0-0_25000_64.json │ │ ├── ecadd_1-2_1-2_21000_128.json │ │ ├── ecadd_1-2_1-2_21000_192.json │ │ ├── ecadd_1-2_1-2_25000_128.json │ │ ├── ecadd_1-2_1-2_25000_192.json │ │ ├── ecadd_1-3_0-0_21000_80.json │ │ ├── ecadd_1-3_0-0_25000_80.json │ │ ├── ecadd_1145-3932_1145-4651_21000_192.json │ │ ├── ecadd_1145-3932_1145-4651_25000_192.json │ │ ├── ecadd_1145-3932_2969-1336_21000_128.json │ │ ├── ecadd_1145-3932_2969-1336_25000_128.json │ │ ├── ecadd_6-9_19274124-124124_21000_128.json │ │ ├── ecadd_6-9_19274124-124124_25000_128.json │ │ ├── ecmul_0-0_0_21000_0.json │ │ ├── ecmul_0-0_0_21000_128.json │ │ ├── ecmul_0-0_0_21000_40.json │ │ ├── ecmul_0-0_0_21000_64.json │ │ ├── ecmul_0-0_0_21000_80.json │ │ ├── ecmul_0-0_0_21000_96.json │ │ ├── ecmul_0-0_0_28000_0.json │ │ ├── ecmul_0-0_0_28000_128.json │ │ ├── ecmul_0-0_0_28000_40.json │ │ ├── ecmul_0-0_0_28000_64.json │ │ ├── ecmul_0-0_0_28000_80.json │ │ ├── ecmul_0-0_0_28000_96.json │ │ ├── ecmul_0-0_1_21000_128.json │ │ ├── ecmul_0-0_1_21000_96.json │ │ ├── ecmul_0-0_1_28000_128.json │ │ ├── ecmul_0-0_1_28000_96.json │ │ ├── ecmul_0-0_2_21000_128.json │ │ ├── ecmul_0-0_2_21000_96.json │ │ ├── ecmul_0-0_2_28000_128.json │ │ ├── ecmul_0-0_2_28000_96.json │ │ ├── ecmul_0-0_340282366920938463463374607431768211456_21000_128.json │ │ ├── ecmul_0-0_340282366920938463463374607431768211456_21000_80.json │ │ ├── ecmul_0-0_340282366920938463463374607431768211456_21000_96.json │ │ ├── ecmul_0-0_340282366920938463463374607431768211456_28000_128.json │ │ ├── ecmul_0-0_340282366920938463463374607431768211456_28000_80.json │ │ ├── ecmul_0-0_340282366920938463463374607431768211456_28000_96.json │ │ ├── ecmul_0-0_5616_21000_128.json │ │ ├── ecmul_0-0_5616_21000_96.json │ │ ├── ecmul_0-0_5616_28000_128.json │ │ ├── ecmul_0-0_5616_28000_96.json │ │ ├── ecmul_0-0_5617_21000_128.json │ │ ├── ecmul_0-0_5617_21000_96.json │ │ ├── ecmul_0-0_5617_28000_128.json │ │ ├── ecmul_0-0_5617_28000_96.json │ │ ├── ecmul_0-0_9935_21000_128.json │ │ ├── ecmul_0-0_9935_21000_96.json │ │ ├── ecmul_0-0_9935_28000_128.json │ │ ├── ecmul_0-0_9935_28000_96.json │ │ ├── ecmul_0-0_9_21000_128.json │ │ ├── ecmul_0-0_9_21000_96.json │ │ ├── ecmul_0-0_9_28000_128.json │ │ ├── ecmul_0-0_9_28000_96.json │ │ ├── ecmul_0-3_0_21000_128.json │ │ ├── ecmul_0-3_0_21000_64.json │ │ ├── ecmul_0-3_0_21000_80.json │ │ ├── ecmul_0-3_0_21000_96.json │ │ ├── ecmul_0-3_0_28000_128.json │ │ ├── ecmul_0-3_0_28000_64.json │ │ ├── ecmul_0-3_0_28000_80.json │ │ ├── ecmul_0-3_0_28000_96.json │ │ ├── ecmul_0-3_1_21000_128.json │ │ ├── ecmul_0-3_1_21000_96.json │ │ ├── ecmul_0-3_1_28000_128.json │ │ ├── ecmul_0-3_1_28000_96.json │ │ ├── ecmul_0-3_2_21000_128.json │ │ ├── ecmul_0-3_2_21000_96.json │ │ ├── ecmul_0-3_2_28000_128.json │ │ ├── ecmul_0-3_2_28000_96.json │ │ ├── ecmul_0-3_340282366920938463463374607431768211456_21000_128.json │ │ ├── ecmul_0-3_340282366920938463463374607431768211456_21000_80.json │ │ ├── ecmul_0-3_340282366920938463463374607431768211456_21000_96.json │ │ ├── ecmul_0-3_340282366920938463463374607431768211456_28000_128.json │ │ ├── ecmul_0-3_340282366920938463463374607431768211456_28000_80.json │ │ ├── ecmul_0-3_340282366920938463463374607431768211456_28000_96.json │ │ ├── ecmul_0-3_5616_21000_128.json │ │ ├── ecmul_0-3_5616_21000_96.json │ │ ├── ecmul_0-3_5616_28000_128.json │ │ ├── ecmul_0-3_5616_28000_96.json │ │ ├── ecmul_0-3_5617_21000_128.json │ │ ├── ecmul_0-3_5617_21000_96.json │ │ ├── ecmul_0-3_5617_28000_128.json │ │ ├── ecmul_0-3_5617_28000_96.json │ │ ├── ecmul_0-3_9935_21000_128.json │ │ ├── ecmul_0-3_9935_21000_96.json │ │ ├── ecmul_0-3_9935_28000_128.json │ │ ├── ecmul_0-3_9935_28000_96.json │ │ ├── ecmul_0-3_9_21000_128.json │ │ ├── ecmul_0-3_9_21000_96.json │ │ ├── ecmul_0-3_9_28000_128.json │ │ ├── ecmul_0-3_9_28000_96.json │ │ ├── ecmul_1-2_0_21000_128.json │ │ ├── ecmul_1-2_0_21000_64.json │ │ ├── ecmul_1-2_0_21000_80.json │ │ ├── ecmul_1-2_0_21000_96.json │ │ ├── ecmul_1-2_0_28000_128.json │ │ ├── ecmul_1-2_0_28000_64.json │ │ ├── ecmul_1-2_0_28000_80.json │ │ ├── ecmul_1-2_0_28000_96.json │ │ ├── ecmul_1-2_1_21000_128.json │ │ ├── ecmul_1-2_1_21000_96.json │ │ ├── ecmul_1-2_1_28000_128.json │ │ ├── ecmul_1-2_1_28000_96.json │ │ ├── ecmul_1-2_2_21000_128.json │ │ ├── ecmul_1-2_2_21000_96.json │ │ ├── ecmul_1-2_2_28000_128.json │ │ ├── ecmul_1-2_2_28000_96.json │ │ ├── ecmul_1-2_340282366920938463463374607431768211456_21000_128.json │ │ ├── ecmul_1-2_340282366920938463463374607431768211456_21000_80.json │ │ ├── ecmul_1-2_340282366920938463463374607431768211456_21000_96.json │ │ ├── ecmul_1-2_340282366920938463463374607431768211456_28000_128.json │ │ ├── ecmul_1-2_340282366920938463463374607431768211456_28000_80.json │ │ ├── ecmul_1-2_340282366920938463463374607431768211456_28000_96.json │ │ ├── ecmul_1-2_5616_21000_128.json │ │ ├── ecmul_1-2_5616_21000_96.json │ │ ├── ecmul_1-2_5616_28000_128.json │ │ ├── ecmul_1-2_5617_21000_128.json │ │ ├── ecmul_1-2_5617_21000_96.json │ │ ├── ecmul_1-2_5617_28000_128.json │ │ ├── ecmul_1-2_5617_28000_96.json │ │ ├── ecmul_1-2_616_28000_96.json │ │ ├── ecmul_1-2_9935_21000_128.json │ │ ├── ecmul_1-2_9935_21000_96.json │ │ ├── ecmul_1-2_9935_28000_128.json │ │ ├── ecmul_1-2_9935_28000_96.json │ │ ├── ecmul_1-2_9_21000_128.json │ │ ├── ecmul_1-2_9_21000_96.json │ │ ├── ecmul_1-2_9_28000_128.json │ │ ├── ecmul_1-2_9_28000_96.json │ │ ├── ecmul_1-3_0_21000_128.json │ │ ├── ecmul_1-3_0_21000_64.json │ │ ├── ecmul_1-3_0_21000_80.json │ │ ├── ecmul_1-3_0_21000_96.json │ │ ├── ecmul_1-3_0_28000_128.json │ │ ├── ecmul_1-3_0_28000_64.json │ │ ├── ecmul_1-3_0_28000_80.json │ │ ├── ecmul_1-3_0_28000_96.json │ │ ├── ecmul_1-3_1_21000_128.json │ │ ├── ecmul_1-3_1_21000_96.json │ │ ├── ecmul_1-3_1_28000_128.json │ │ ├── ecmul_1-3_1_28000_96.json │ │ ├── ecmul_1-3_2_21000_128.json │ │ ├── ecmul_1-3_2_21000_96.json │ │ ├── ecmul_1-3_2_28000_128.json │ │ ├── ecmul_1-3_2_28000_96.json │ │ ├── ecmul_1-3_340282366920938463463374607431768211456_21000_128.json │ │ ├── ecmul_1-3_340282366920938463463374607431768211456_21000_80.json │ │ ├── ecmul_1-3_340282366920938463463374607431768211456_21000_96.json │ │ ├── ecmul_1-3_340282366920938463463374607431768211456_28000_128.json │ │ ├── ecmul_1-3_340282366920938463463374607431768211456_28000_80.json │ │ ├── ecmul_1-3_340282366920938463463374607431768211456_28000_96.json │ │ ├── ecmul_1-3_5616_21000_128.json │ │ ├── ecmul_1-3_5616_21000_96.json │ │ ├── ecmul_1-3_5616_28000_128.json │ │ ├── ecmul_1-3_5616_28000_96.json │ │ ├── ecmul_1-3_5617_21000_128.json │ │ ├── ecmul_1-3_5617_21000_96.json │ │ ├── ecmul_1-3_5617_28000_128.json │ │ ├── ecmul_1-3_5617_28000_96.json │ │ ├── ecmul_1-3_9935_21000_128.json │ │ ├── ecmul_1-3_9935_21000_96.json │ │ ├── ecmul_1-3_9935_28000_128.json │ │ ├── ecmul_1-3_9935_28000_96.json │ │ ├── ecmul_1-3_9_21000_128.json │ │ ├── ecmul_1-3_9_21000_96.json │ │ ├── ecmul_1-3_9_28000_128.json │ │ ├── ecmul_1-3_9_28000_96.json │ │ ├── ecmul_7827-6598_0_21000_128.json │ │ ├── ecmul_7827-6598_0_21000_64.json │ │ ├── ecmul_7827-6598_0_21000_80.json │ │ ├── ecmul_7827-6598_0_21000_96.json │ │ ├── ecmul_7827-6598_0_28000_128.json │ │ ├── ecmul_7827-6598_0_28000_64.json │ │ ├── ecmul_7827-6598_0_28000_80.json │ │ ├── ecmul_7827-6598_0_28000_96.json │ │ ├── ecmul_7827-6598_1456_21000_128.json │ │ ├── ecmul_7827-6598_1456_21000_80.json │ │ ├── ecmul_7827-6598_1456_21000_96.json │ │ ├── ecmul_7827-6598_1456_28000_128.json │ │ ├── ecmul_7827-6598_1456_28000_80.json │ │ ├── ecmul_7827-6598_1456_28000_96.json │ │ ├── ecmul_7827-6598_1_21000_128.json │ │ ├── ecmul_7827-6598_1_21000_96.json │ │ ├── ecmul_7827-6598_1_28000_128.json │ │ ├── ecmul_7827-6598_1_28000_96.json │ │ ├── ecmul_7827-6598_2_21000_128.json │ │ ├── ecmul_7827-6598_2_21000_96.json │ │ ├── ecmul_7827-6598_2_28000_128.json │ │ ├── ecmul_7827-6598_2_28000_96.json │ │ ├── ecmul_7827-6598_5616_21000_128.json │ │ ├── ecmul_7827-6598_5616_21000_96.json │ │ ├── ecmul_7827-6598_5616_28000_128.json │ │ ├── ecmul_7827-6598_5616_28000_96.json │ │ ├── ecmul_7827-6598_5617_21000_128.json │ │ ├── ecmul_7827-6598_5617_21000_96.json │ │ ├── ecmul_7827-6598_5617_28000_128.json │ │ ├── ecmul_7827-6598_5617_28000_96.json │ │ ├── ecmul_7827-6598_9935_21000_128.json │ │ ├── ecmul_7827-6598_9935_21000_96.json │ │ ├── ecmul_7827-6598_9935_28000_128.json │ │ ├── ecmul_7827-6598_9935_28000_96.json │ │ ├── ecmul_7827-6598_9_21000_128.json │ │ ├── ecmul_7827-6598_9_21000_96.json │ │ ├── ecmul_7827-6598_9_28000_128.json │ │ ├── ecmul_7827-6598_9_28000_96.json │ │ ├── ecpairing_bad_length_191.json │ │ ├── ecpairing_bad_length_193.json │ │ ├── ecpairing_empty_data.json │ │ ├── ecpairing_empty_data_insufficient_gas.json │ │ ├── ecpairing_one_point_fail.json │ │ ├── ecpairing_one_point_insufficient_gas.json │ │ ├── ecpairing_one_point_not_in_subgroup.json │ │ ├── ecpairing_one_point_with_g1_zero.json │ │ ├── ecpairing_one_point_with_g2_zero.json │ │ ├── ecpairing_perturb_g2_by_curve_order.json │ │ ├── ecpairing_perturb_g2_by_field_modulus.json │ │ ├── ecpairing_perturb_g2_by_field_modulus_again.json │ │ ├── ecpairing_perturb_g2_by_one.json │ │ ├── ecpairing_perturb_zeropoint_by_curve_order.json │ │ ├── ecpairing_perturb_zeropoint_by_field_modulus.json │ │ ├── ecpairing_perturb_zeropoint_by_one.json │ │ ├── ecpairing_three_point_fail_1.json │ │ ├── ecpairing_three_point_match_1.json │ │ ├── ecpairing_two_point_fail_1.json │ │ ├── ecpairing_two_point_fail_2.json │ │ ├── ecpairing_two_point_match_1.json │ │ ├── ecpairing_two_point_match_2.json │ │ ├── ecpairing_two_point_match_3.json │ │ ├── ecpairing_two_point_match_4.json │ │ ├── ecpairing_two_point_match_5.json │ │ ├── ecpairing_two_point_oog.json │ │ ├── ecpairing_two_points_with_one_g2_zero.json │ │ ├── pairingTest.json │ │ ├── pointAdd.json │ │ ├── pointAddTrunc.json │ │ ├── pointMulAdd.json │ │ └── pointMulAdd2.json └── TrieTests │ ├── hex_encoded_securetrie_test.json │ ├── trieanyorder.json │ ├── trieanyorder_secureTrie.json │ ├── trietest.json │ ├── trietest_secureTrie.json │ └── trietestnextprev.json ├── qkchash ├── Makefile ├── README.md ├── qkchash.cpp ├── qkchash.py ├── qkcpow.py ├── set_benchmark.cpp └── tests │ └── test_qkcpow.py ├── quarkchain ├── __init__.py ├── accounts.py ├── cluster │ ├── __init__.py │ ├── cluster.py │ ├── cluster_config.py │ ├── filter.py │ ├── guardian.py │ ├── jsonrpc.py │ ├── master.py │ ├── miner.py │ ├── monitoring.py │ ├── multi_cluster.py │ ├── neighbor.py │ ├── p2p_commands.py │ ├── protocol.py │ ├── root_state.py │ ├── rpc.py │ ├── shard.py │ ├── shard_db_operator.py │ ├── shard_state.py │ ├── simple_network.py │ ├── slave.py │ ├── tests │ │ ├── __init__.py │ │ ├── test_cluster.py │ │ ├── test_cluster_config.py │ │ ├── test_filter.py │ │ ├── test_jsonrpc.py │ │ ├── test_miner.py │ │ ├── test_monitoring.py │ │ ├── test_neighbor.py │ │ ├── test_protocol.py │ │ ├── test_root_state.py │ │ ├── test_shard_db_operator.py │ │ ├── test_shard_state.py │ │ └── test_utils.py │ └── tx_generator.py ├── config.py ├── core.py ├── db.py ├── diff.py ├── env.py ├── evm │ ├── __init__.py │ ├── bloom.py │ ├── common.py │ ├── config.py │ ├── exceptions.py │ ├── fast_rlp.py │ ├── messages.py │ ├── opcodes.py │ ├── securetrie.py │ ├── slogging.py │ ├── solidity_abi_utils.py │ ├── specials.py │ ├── state.py │ ├── tests │ │ ├── __init__.py │ │ ├── conftest.py │ │ ├── new_statetest_utils.py │ │ ├── test_solidity_abi.py │ │ ├── test_state.py │ │ ├── test_transaction_queue.py │ │ ├── test_trie.py │ │ └── testutils.py │ ├── transaction_queue.py │ ├── transactions.py │ ├── trie.py │ ├── utils.py │ └── vm.py ├── experimental │ ├── __init__.py │ ├── diff.py │ ├── ethash.py │ ├── event_driven_simulator.py │ ├── future.py │ ├── heap.py │ ├── latency_demo.py │ ├── photon_pos_simulator.py │ ├── proof_of_work.py │ ├── quark_eb_simulator.py │ ├── sha3_perf.py │ ├── simulator.py │ ├── test_heap.py │ ├── tests │ │ ├── __init__.py │ │ └── test_diff.py │ ├── tx_perf.py │ └── whitelist.py ├── genesis.py ├── genesis_data │ ├── alloc.json │ └── loadtest.json ├── p2p │ ├── DEVELOPMENT.md │ ├── auth.py │ ├── cancel_token │ │ ├── README.md │ │ ├── exceptions.py │ │ ├── tests │ │ │ └── test_cancel_token.py │ │ └── token.py │ ├── cancellable.py │ ├── constants.py │ ├── discovery.py │ ├── ecies.py │ ├── events.py │ ├── exceptions.py │ ├── kademlia.py │ ├── nat.py │ ├── p2p_manager.py │ ├── p2p_proto.py │ ├── p2p_server.py │ ├── peer.py │ ├── poc │ │ ├── paragon_node.py │ │ ├── paragon_node_network.py │ │ ├── trinity_disc_network.py │ │ ├── trinity_discovery.py │ │ └── udp_nat.py │ ├── protocol.py │ ├── service.py │ ├── tests │ │ ├── __init__.py │ │ ├── auth_constants.py │ │ ├── test_auth.py │ │ ├── test_discovery.py │ │ ├── test_ecies.py │ │ ├── test_kademlia.py │ │ ├── test_peer_collect_sub_proto_msgs.py │ │ ├── test_peer_subscriber.py │ │ ├── test_server.py │ │ └── test_service.py │ ├── tools │ │ ├── __init__.py │ │ └── paragon │ │ │ ├── __init__.py │ │ │ ├── commands.py │ │ │ ├── helpers.py │ │ │ ├── peer.py │ │ │ └── proto.py │ └── utils.py ├── protocol.py ├── reward.py ├── rlp │ └── utils.py ├── testnet │ ├── __init__.py │ └── addresses_to_fund.json ├── tests │ ├── __init__.py │ ├── test_accounts.py │ ├── test_config.py │ ├── test_core.py │ └── test_utils.py ├── tools │ ├── __init__.py │ ├── accounts │ ├── adjust_difficulty.py │ ├── batch_deploy_contract.py │ ├── block_owners.py │ ├── check_syncing_state.py │ ├── config_slave.py │ ├── external_miner.py │ ├── external_miner_manager.sh │ ├── fund_testnet.py │ ├── miner_address.py │ ├── monitoring.py │ ├── newkey.py │ ├── pypy-fix-cython-warning.pth │ ├── quick_miner_stopper.sh │ ├── quick_miner_tool.sh │ ├── stats │ ├── tests │ │ └── test_monitoring.py │ └── utils.py └── utils.py ├── requirements.txt ├── setup.py └── testnet └── 2 ├── Dockerfile ├── cluster_config_bootnodes.json └── cluster_config_template.json /.circleci/Dockerfile: -------------------------------------------------------------------------------- 1 | # docker pull qcgg/circleci-pypy3-rocksdb 2 | FROM ubuntu:xenial 3 | 4 | MAINTAINER qcgg 5 | 6 | WORKDIR /opt 7 | 8 | # set up basic system packages 9 | RUN apt-get update 10 | # for libxml2 and libxslt1: https://stackoverflow.com/questions/5178416/libxml-install-error-using-pip 11 | RUN apt-get install -y git build-essential wget pkg-config libgmp-dev libssl-dev ca-certificates python3-dev libxml2-dev libxslt1-dev 12 | 13 | # install rocksdb 14 | RUN apt-get install -y libsnappy-dev zlib1g-dev libbz2-dev libgflags-dev liblz4-dev libzstd-dev 15 | RUN git clone https://github.com/facebook/rocksdb.git 16 | RUN cd rocksdb && DEBUG_LEVEL=0 make shared_lib install-shared 17 | RUN ln -fs /opt/rocksdb/librocksdb.so* /usr/lib/ 18 | 19 | # intall pypy3 20 | RUN wget https://bitbucket.org/pypy/pypy/downloads/pypy3-v6.0.0-linux64.tar.bz2 21 | RUN tar fxv pypy3-v6.0.0-linux64.tar.bz2 22 | ENV PATH="${PATH}:/opt/pypy3-v6.0.0-linux64/bin/" 23 | RUN pypy3 -m ensurepip 24 | 25 | WORKDIR / 26 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | # Python CircleCI 2.0 configuration file 2 | # 3 | # Check https://circleci.com/docs/2.0/language-python/ for more details 4 | # 5 | version: 2 6 | jobs: 7 | build: 8 | docker: 9 | - image: qcdll/circleci-pypy3-rocksdb 10 | parallelism: 2 11 | 12 | working_directory: ~/repo 13 | 14 | steps: 15 | - checkout 16 | 17 | # The librocksdb* that comes with the image does not work on circle ci :( 18 | # Let's rebuild 19 | - run: 20 | name: Cleanup Prebuilt RocksDB 21 | command: | 22 | cd /opt/rocksdb 23 | make clean 24 | rm /usr/lib/librocksdb* /usr/local/lib/librocksdb* 25 | 26 | # Build, install and cache librocksdb 27 | - restore_cache: 28 | keys: 29 | - rocksdb-v1 30 | 31 | - run: 32 | name: Install RocksDB 33 | command: | 34 | cd /opt/rocksdb && DEBUG_LEVEL=0 make shared_lib install-shared 35 | ln -fs /opt/rocksdb/librocksdb.so* /usr/lib/ 36 | 37 | - save_cache: 38 | paths: 39 | - /opt/rocksdb 40 | key: rocksdb-v1 41 | 42 | # Download and cache python modules 43 | - restore_cache: 44 | keys: 45 | - pip-v2-{{ checksum "requirements.txt" }} 46 | 47 | - run: 48 | name: Install Project Dependencies 49 | command: | 50 | pip3 install -e . 51 | 52 | - save_cache: 53 | paths: 54 | - /opt/pypy3-v6.0.0-linux64 55 | key: pip-v2-{{ checksum "requirements.txt" }} 56 | 57 | # Run tests! 58 | - run: 59 | name: Run unittest/py.test Tests 60 | command: | 61 | if [[ $CIRCLE_NODE_INDEX = 0 ]]; then pypy3 -m pytest ; fi 62 | 63 | - run: 64 | name: Run EVM Tests 65 | command: | 66 | if [[ $CIRCLE_NODE_INDEX = 1 ]]; then git apply fixtures/0001-Necessary-changes-to-let-evm-tests-pass.patch && pypy3 quarkchain/evm/tests/test_state.py fixtures/GeneralStateTests/; fi 67 | 68 | - store_artifacts: 69 | path: test-reports 70 | destination: test-reports 71 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Database dirs 2 | *.db 3 | 4 | # Byte-compiled / optimized / DLL files 5 | __pycache__/ 6 | *.py[cod] 7 | *$py.class 8 | 9 | # C extensions 10 | *.so 11 | 12 | # qkchash binaries 13 | qkchash/qkchash 14 | qkchash/qkchash_llrb 15 | 16 | # Distribution / packaging 17 | .Python 18 | build/ 19 | develop-eggs/ 20 | dist/ 21 | downloads/ 22 | eggs/ 23 | .eggs/ 24 | lib/ 25 | lib64/ 26 | parts/ 27 | sdist/ 28 | var/ 29 | wheels/ 30 | *.egg-info/ 31 | .installed.cfg 32 | *.egg 33 | MANIFEST 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *.cover 54 | .hypothesis/ 55 | .pytest_cache/ 56 | 57 | # Translations 58 | *.mo 59 | *.pot 60 | 61 | # Django stuff 62 | *.log 63 | .static_storage/ 64 | .media/ 65 | local_settings.py 66 | 67 | # Flask stuff 68 | instance/ 69 | .webassets-cache 70 | 71 | # Scrapy stuff 72 | .scrapy 73 | 74 | # Sphinx documentation 75 | docs/_build/ 76 | 77 | # PyBuilder 78 | target/ 79 | 80 | # Jupyter Notebook 81 | .ipynb_checkpoints 82 | 83 | # pyenv 84 | .python-version 85 | 86 | # celery beat schedule file 87 | celerybeat-schedule 88 | 89 | # SageMath parsed files 90 | *.sage.py 91 | 92 | # Environments 93 | .env 94 | .venv 95 | env/ 96 | venv/ 97 | pypy-env/ 98 | py3-env/ 99 | ENV/ 100 | env.bak/ 101 | venv.bak/ 102 | 103 | # Spyder project settings 104 | .spyderproject 105 | .spyproject 106 | 107 | # Rope project settings 108 | .ropeproject 109 | 110 | # mkdocs documentation 111 | /site 112 | 113 | # mypy 114 | .mypy_cache/ 115 | 116 | *~ 117 | 118 | # IDE 119 | .idea/ 120 | .vscode/ 121 | 122 | # IPython notebook 123 | *.ipynb 124 | 125 | # Local config 126 | /cluster-config.json 127 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: git://github.com/pre-commit/pre-commit-hooks 3 | rev: v1.4.0 4 | hooks: 5 | - id: end-of-file-fixer 6 | - repo: https://github.com/ambv/black 7 | rev: stable 8 | hooks: 9 | - id: black 10 | language_version: python3.7 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 QuarkChain 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /STYLE: -------------------------------------------------------------------------------- 1 | Coding Style for pyquarkchain Project 2 | 3 | ============= 4 | General Rules 5 | 6 | Follow PEP8 https://www.python.org/dev/peps/pep-0008/ 7 | For sublime, we suggest to use Anaconda package. 8 | 9 | ====== 10 | Naming 11 | 12 | - Package name: lower_case_with_underscore 13 | - Class name: UpperCamelCase 14 | - Method name: lower_case_with_underscore 15 | - Constant: UPPER_CASE_WITH_UNDERSCORE 16 | - Global function: lower_case_with_underscore 17 | - Local variable: lower_case_with_underscore 18 | 19 | ============== 20 | Code Formatter 21 | 22 | All py files should be formatted using the Black code formatter. 23 | https://github.com/ambv/black 24 | -------------------------------------------------------------------------------- /TPS.md: -------------------------------------------------------------------------------- 1 | ### TPS Competition Questionnaire 2 | 3 | *Please replace the square brackets and the text in it with your answers* 4 | 5 | **Number of CPUs** 6 | 7 | [How many logical CPUs does the machine have for running one cluster?] 8 | 9 | **Memory (GB)** 10 | 11 | [How much memory does the machine have for running one cluster? For example, 16G.] 12 | 13 | **Storage (GB)** 14 | 15 | [Note down both the type and capacity of the storage on one machine. For example, SSD 1024G.] 16 | 17 | **Network** 18 | 19 | [Comment on the network connecting clusters. For example, 1 Gbps LAN] 20 | 21 | **Machine Type (Optional)** 22 | 23 | [If you are using public cloud service, note down the name of the provider and the machine type. For example, AWS EC2 m5.2xlarge.] 24 | 25 | **Command Lines for Running Cluster** 26 | ``` 27 | [Copy the command line here] 28 | ``` 29 | 30 | **Peak TPS** 31 | 32 | [Note down the highest TPS observed.] 33 | 34 | **Video URL** 35 | 36 | [URL for the video showing how you produced the above TPS.] 37 | 38 | **Output From `stats` Tool** 39 | ``` 40 | [Copy the complete output from `stats` here. It should capture the cluster configuration and at least 10 minute continuous samples (60 rows) with at least one sample showing the TPS claimed above.] 41 | ``` 42 | 43 | **Additional Comment** 44 | 45 | [If you have special setup, e.g., running a single cluster over multiple machines, the above questionnaire might not fit. Note down 46 | whatever you want us to know here to help evaluate the result.] 47 | -------------------------------------------------------------------------------- /ethereum/pow/ethash.py: -------------------------------------------------------------------------------- 1 | import copy 2 | from functools import lru_cache 3 | from typing import Callable, Dict, List 4 | 5 | from ethereum.pow.ethash_utils import * 6 | 7 | cache_seeds = [b"\x00" * 32] # type: List[bytes] 8 | 9 | 10 | def mkcache(cache_size: int, block_number) -> List[List[int]]: 11 | while len(cache_seeds) <= block_number // EPOCH_LENGTH: 12 | new_seed = serialize_hash(ethash_sha3_256(cache_seeds[-1])) 13 | cache_seeds.append(new_seed) 14 | 15 | seed = cache_seeds[block_number // EPOCH_LENGTH] 16 | return _get_cache(seed, cache_size // HASH_BYTES) 17 | 18 | 19 | @lru_cache(10) 20 | def _get_cache(seed, n) -> List[List[int]]: 21 | # Sequentially produce the initial dataset 22 | o = [ethash_sha3_512(seed)] 23 | for i in range(1, n): 24 | o.append(ethash_sha3_512(o[-1])) 25 | 26 | # Use a low-round version of randmemohash 27 | for _ in range(CACHE_ROUNDS): 28 | for i in range(n): 29 | v = o[i][0] % n 30 | o[i] = ethash_sha3_512(list(map(xor, o[(i - 1 + n) % n], o[v]))) 31 | 32 | return o 33 | 34 | 35 | def calc_dataset_item(cache: List[List[int]], i: int) -> List[int]: 36 | n = len(cache) 37 | r = HASH_BYTES // WORD_BYTES 38 | # initialize the mix 39 | mix = copy.copy(cache[i % n]) # type: List[int] 40 | mix[0] ^= i 41 | mix = ethash_sha3_512(mix) 42 | # fnv it with a lot of random cache nodes based on i 43 | for j in range(DATASET_PARENTS): 44 | cache_index = fnv(i ^ j, mix[j % r]) 45 | mix = list(map(fnv, mix, cache[cache_index % n])) 46 | return ethash_sha3_512(mix) 47 | 48 | 49 | def calc_dataset(full_size, cache) -> List[List[int]]: 50 | o = [] 51 | for i in range(full_size // HASH_BYTES): 52 | o.append(calc_dataset_item(cache, i)) 53 | return o 54 | 55 | 56 | def hashimoto( 57 | header: bytes, 58 | nonce: bytes, 59 | full_size: int, 60 | dataset_lookup: Callable[[int], List[int]], 61 | ) -> Dict: 62 | n = full_size // HASH_BYTES 63 | w = MIX_BYTES // WORD_BYTES 64 | mixhashes = MIX_BYTES // HASH_BYTES 65 | # combine header+nonce into a 64 byte seed 66 | s = ethash_sha3_512(header + nonce[::-1]) 67 | mix = [] 68 | for _ in range(MIX_BYTES // HASH_BYTES): 69 | mix.extend(s) 70 | # mix in random dataset nodes 71 | for i in range(ACCESSES): 72 | p = fnv(i ^ s[0], mix[i % w]) % (n // mixhashes) * mixhashes 73 | newdata = [] 74 | for j in range(mixhashes): 75 | newdata.extend(dataset_lookup(p + j)) 76 | mix = list(map(fnv, mix, newdata)) 77 | # compress mix 78 | cmix = [] 79 | for i in range(0, len(mix), 4): 80 | cmix.append(fnv(fnv(fnv(mix[i], mix[i + 1]), mix[i + 2]), mix[i + 3])) 81 | return { 82 | b"mix digest": serialize_hash(cmix), 83 | b"result": serialize_hash(ethash_sha3_256(s + cmix)), 84 | } 85 | 86 | 87 | def hashimoto_light( 88 | full_size: int, cache: List[List[int]], header: bytes, nonce: bytes 89 | ) -> Dict: 90 | return hashimoto(header, nonce, full_size, lambda x: calc_dataset_item(cache, x)) 91 | 92 | 93 | def hashimoto_full(dataset: List[List[int]], header: bytes, nonce: bytes) -> Dict: 94 | return hashimoto(header, nonce, len(dataset) * HASH_BYTES, lambda x: dataset[x]) 95 | -------------------------------------------------------------------------------- /ethereum/pow/ethash_utils.py: -------------------------------------------------------------------------------- 1 | from typing import List, Union 2 | 3 | from eth_utils import encode_hex, decode_hex 4 | 5 | try: 6 | from Crypto.Hash import keccak 7 | 8 | def _sha3_256(x): 9 | return keccak.new(digest_bits=256, data=x).digest() 10 | 11 | def _sha3_512(x): 12 | return keccak.new(digest_bits=512, data=x).digest() 13 | 14 | 15 | except Exception: 16 | import sha3 as _sha3 17 | 18 | def _sha3_256(x): 19 | return _sha3.sha3_256(x).digest() 20 | 21 | def _sha3_512(x): 22 | return _sha3.sha3_512(x).digest() 23 | 24 | 25 | import sys 26 | 27 | WORD_BYTES = 4 # bytes in word 28 | DATASET_BYTES_INIT = 2 ** 30 # bytes in dataset at genesis 29 | DATASET_BYTES_GROWTH = 2 ** 23 # growth per epoch (~7 GB per year) 30 | CACHE_BYTES_INIT = 2 ** 24 # Size of the dataset relative to the cache 31 | CACHE_BYTES_GROWTH = 2 ** 17 # Size of the dataset relative to the cache 32 | EPOCH_LENGTH = 30000 # blocks per epoch 33 | MIX_BYTES = 128 # width of mix 34 | HASH_BYTES = 64 # hash length in bytes 35 | DATASET_PARENTS = 256 # number of parents of each dataset element 36 | CACHE_ROUNDS = 3 # number of rounds in cache production 37 | ACCESSES = 64 # number of accesses in hashimoto loop 38 | 39 | FNV_PRIME = 0x01000193 40 | 41 | 42 | def fnv(v1, v2): 43 | return (v1 * FNV_PRIME ^ v2) % 2 ** 32 44 | 45 | 46 | # Assumes little endian bit ordering (same as Intel architectures) 47 | def decode_int(s): 48 | return int(encode_hex(s[::-1]), 16) if s else 0 49 | 50 | 51 | def encode_int(s): 52 | a = "%x" % s 53 | return b"" if s == 0 else decode_hex("0" * (len(a) % 2) + a)[::-1] 54 | 55 | 56 | def zpad(s, length): 57 | return s + b"\x00" * max(0, length - len(s)) 58 | 59 | 60 | def serialize_hash(h: List[int]) -> bytes: 61 | return b"".join([zpad(encode_int(x), 4) for x in h]) 62 | 63 | 64 | def deserialize_hash(h: bytes) -> List[int]: 65 | return [decode_int(h[i : i + WORD_BYTES]) for i in range(0, len(h), WORD_BYTES)] 66 | 67 | 68 | def hash_words(h, sz, x) -> List[int]: 69 | if isinstance(x, list): 70 | x = serialize_hash(x) 71 | y = h(x) 72 | return deserialize_hash(y) 73 | 74 | 75 | def to_bytes(x): 76 | if sys.version_info.major > 2 and isinstance(x, str): 77 | x = bytes(x, "utf-8") 78 | return x 79 | 80 | 81 | def xor(a, b): 82 | return a ^ b 83 | 84 | 85 | # sha3 hash function, outputs 64 bytes 86 | def ethash_sha3_512(x: Union[bytes, List[int]]) -> List[int]: 87 | return hash_words(lambda v: _sha3_512(to_bytes(v)), 64, x) 88 | 89 | 90 | def ethash_sha3_256(x: Union[bytes, List[int]]) -> List[int]: 91 | return hash_words(lambda v: _sha3_256(to_bytes(v)), 32, x) 92 | 93 | 94 | # Works for dataset and cache 95 | def serialize_cache(ds): 96 | return b"".join([serialize_hash(h) for h in ds]) 97 | 98 | 99 | serialize_dataset = serialize_cache 100 | 101 | 102 | def deserialize_cache(ds): 103 | return [ 104 | deserialize_hash(ds[i : i + HASH_BYTES]) for i in range(0, len(ds), HASH_BYTES) 105 | ] 106 | 107 | 108 | deserialize_dataset = deserialize_cache 109 | 110 | 111 | def isprime(x): 112 | for i in range(2, int(x ** 0.5)): 113 | if not x % i: 114 | return False 115 | return True 116 | 117 | 118 | def get_cache_size(block_number): 119 | sz = CACHE_BYTES_INIT + CACHE_BYTES_GROWTH * (block_number // EPOCH_LENGTH) 120 | sz -= HASH_BYTES 121 | while not isprime(sz // HASH_BYTES): 122 | sz -= 2 * HASH_BYTES 123 | return sz 124 | 125 | 126 | def get_full_size(block_number): 127 | sz = DATASET_BYTES_INIT + DATASET_BYTES_GROWTH * (block_number // EPOCH_LENGTH) 128 | sz -= MIX_BYTES 129 | while not isprime(sz // MIX_BYTES): 130 | sz -= 2 * MIX_BYTES 131 | return sz 132 | -------------------------------------------------------------------------------- /fixtures/GeneralStateTests/stAttackTest/CrashingTransaction.json: -------------------------------------------------------------------------------- 1 | { 2 | "CrashingTransaction" : { 3 | "_info" : { 4 | "comment" : "", 5 | "filledwith" : "cpp-1.3.0+commit.0f676bd1.Linux.g++", 6 | "source" : "src/GeneralStateTestsFiller/stAttackTest/CrashingTransactionFiller.json" 7 | }, 8 | "env" : { 9 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 10 | "currentDifficulty" : "0x20000", 11 | "currentGasLimit" : "0x47e7c4", 12 | "currentNumber" : "0x01", 13 | "currentTimestamp" : "0x03e8", 14 | "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" 15 | }, 16 | "post" : { 17 | "Byzantium" : [ 18 | { 19 | "hash" : "0xff08a9495550652210911b3534aa418c6fa298c7622f8e61a10ecf2c543115c9", 20 | "indexes" : { 21 | "data" : 0, 22 | "gas" : 0, 23 | "value" : 0 24 | }, 25 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 26 | } 27 | ], 28 | "EIP150" : [ 29 | { 30 | "hash" : "0x6e498faaa2edfe2e824e37c272cdd81d39350ef564cc58d150eeda8566c64908", 31 | "indexes" : { 32 | "data" : 0, 33 | "gas" : 0, 34 | "value" : 0 35 | }, 36 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 37 | } 38 | ], 39 | "EIP158" : [ 40 | { 41 | "hash" : "0xff08a9495550652210911b3534aa418c6fa298c7622f8e61a10ecf2c543115c9", 42 | "indexes" : { 43 | "data" : 0, 44 | "gas" : 0, 45 | "value" : 0 46 | }, 47 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 48 | } 49 | ], 50 | "Frontier" : [ 51 | { 52 | "hash" : "0xfea6da844256a3168856bef275b44759a14bcc363a3b10bc9053542047039e02", 53 | "indexes" : { 54 | "data" : 0, 55 | "gas" : 0, 56 | "value" : 0 57 | }, 58 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 59 | } 60 | ], 61 | "Homestead" : [ 62 | { 63 | "hash" : "0xf20f36cd0318c573d233d3c2977c5a93c7674e884f6e50d8d29ace15860ba59b", 64 | "indexes" : { 65 | "data" : 0, 66 | "gas" : 0, 67 | "value" : 0 68 | }, 69 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 70 | } 71 | ] 72 | }, 73 | "pre" : { 74 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 75 | "balance" : "0x0de0b6b3a7640000", 76 | "code" : "", 77 | "nonce" : "0x0cc6", 78 | "storage" : { 79 | } 80 | } 81 | }, 82 | "transaction" : { 83 | "data" : [ 84 | "0x60606040525b5b61c3505a1115602c576040516034806039833901809050604051809103906000f0506006565b5b600a80606d6000396000f360606040525b3373ffffffffffffffffffffffffffffffffffffffff16ff5b600a80602a6000396000f360606040526008565b0060606040526008565b00" 85 | ], 86 | "gasLimit" : [ 87 | "0x47127a" 88 | ], 89 | "gasPrice" : "0x02", 90 | "nonce" : "0x0cc6", 91 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 92 | "to" : "", 93 | "value" : [ 94 | "0x01" 95 | ] 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /fixtures/GeneralStateTests/stExample/add11.json: -------------------------------------------------------------------------------- 1 | { 2 | "add11" : { 3 | "_info" : { 4 | "comment" : "", 5 | "filledwith" : "cpp-1.3.0+commit.0f676bd1.Linux.g++", 6 | "source" : "src/GeneralStateTestsFiller/stExample/add11Filler.json" 7 | }, 8 | "env" : { 9 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 10 | "currentDifficulty" : "0x20000", 11 | "currentGasLimit" : "0x0f4240", 12 | "currentNumber" : "0x01", 13 | "currentTimestamp" : "0x03e8", 14 | "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" 15 | }, 16 | "post" : { 17 | "Byzantium" : [ 18 | { 19 | "hash" : "0x17454a767e5f04461256f3812ffca930443c04a47d05ce3f38940c4a14b8c479", 20 | "indexes" : { 21 | "data" : 0, 22 | "gas" : 0, 23 | "value" : 0 24 | }, 25 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 26 | } 27 | ], 28 | "EIP150" : [ 29 | { 30 | "hash" : "0x17454a767e5f04461256f3812ffca930443c04a47d05ce3f38940c4a14b8c479", 31 | "indexes" : { 32 | "data" : 0, 33 | "gas" : 0, 34 | "value" : 0 35 | }, 36 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 37 | } 38 | ], 39 | "EIP158" : [ 40 | { 41 | "hash" : "0x17454a767e5f04461256f3812ffca930443c04a47d05ce3f38940c4a14b8c479", 42 | "indexes" : { 43 | "data" : 0, 44 | "gas" : 0, 45 | "value" : 0 46 | }, 47 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 48 | } 49 | ], 50 | "Frontier" : [ 51 | { 52 | "hash" : "0x17454a767e5f04461256f3812ffca930443c04a47d05ce3f38940c4a14b8c479", 53 | "indexes" : { 54 | "data" : 0, 55 | "gas" : 0, 56 | "value" : 0 57 | }, 58 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 59 | } 60 | ], 61 | "Homestead" : [ 62 | { 63 | "hash" : "0x17454a767e5f04461256f3812ffca930443c04a47d05ce3f38940c4a14b8c479", 64 | "indexes" : { 65 | "data" : 0, 66 | "gas" : 0, 67 | "value" : 0 68 | }, 69 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 70 | } 71 | ] 72 | }, 73 | "pre" : { 74 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 75 | "balance" : "0x0de0b6b3a7640000", 76 | "code" : "0x6001600101600055", 77 | "nonce" : "0x00", 78 | "storage" : { 79 | } 80 | }, 81 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 82 | "balance" : "0x0de0b6b3a7640000", 83 | "code" : "", 84 | "nonce" : "0x00", 85 | "storage" : { 86 | } 87 | } 88 | }, 89 | "transaction" : { 90 | "data" : [ 91 | "" 92 | ], 93 | "gasLimit" : [ 94 | "0x061a80" 95 | ], 96 | "gasPrice" : "0x01", 97 | "nonce" : "0x00", 98 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 99 | "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", 100 | "value" : [ 101 | "0x0186a0" 102 | ] 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /fixtures/GeneralStateTests/stPreCompiledContracts/CALLCODESha256_0.json: -------------------------------------------------------------------------------- 1 | { 2 | "CALLCODESha256_0" : { 3 | "_info" : { 4 | "comment" : "", 5 | "filledwith" : "cpp-1.3.0+commit.4e336c9e.Linux.g++", 6 | "source" : "src/GeneralStateTestsFiller/stPreCompiledContracts/CALLCODESha256_0Filler.json" 7 | }, 8 | "env" : { 9 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 10 | "currentDifficulty" : "0x20000", 11 | "currentGasLimit" : "0x989680", 12 | "currentNumber" : "0x01", 13 | "currentTimestamp" : "0x03e8", 14 | "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" 15 | }, 16 | "post" : { 17 | "Byzantium" : [ 18 | { 19 | "hash" : "0x670a98631f06ae54db67f0cd501879d06ed88c14f5452a8ea1f9134c899c80d3", 20 | "indexes" : { 21 | "data" : 0, 22 | "gas" : 0, 23 | "value" : 0 24 | }, 25 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 26 | } 27 | ], 28 | "EIP150" : [ 29 | { 30 | "hash" : "0x670a98631f06ae54db67f0cd501879d06ed88c14f5452a8ea1f9134c899c80d3", 31 | "indexes" : { 32 | "data" : 0, 33 | "gas" : 0, 34 | "value" : 0 35 | }, 36 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 37 | } 38 | ], 39 | "EIP158" : [ 40 | { 41 | "hash" : "0x670a98631f06ae54db67f0cd501879d06ed88c14f5452a8ea1f9134c899c80d3", 42 | "indexes" : { 43 | "data" : 0, 44 | "gas" : 0, 45 | "value" : 0 46 | }, 47 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 48 | } 49 | ], 50 | "Frontier" : [ 51 | { 52 | "hash" : "0x1529c257c369c7802b4a9814d6fa4006f0be11238fe35cd9c8d8c1b8391c12be", 53 | "indexes" : { 54 | "data" : 0, 55 | "gas" : 0, 56 | "value" : 0 57 | }, 58 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 59 | } 60 | ], 61 | "Homestead" : [ 62 | { 63 | "hash" : "0x1529c257c369c7802b4a9814d6fa4006f0be11238fe35cd9c8d8c1b8391c12be", 64 | "indexes" : { 65 | "data" : 0, 66 | "gas" : 0, 67 | "value" : 0 68 | }, 69 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 70 | } 71 | ] 72 | }, 73 | "pre" : { 74 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 75 | "balance" : "0x01312d00", 76 | "code" : "0x600160005260206000602060006000600260fff2600051600055", 77 | "nonce" : "0x00", 78 | "storage" : { 79 | } 80 | }, 81 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 82 | "balance" : "0x0de0b6b3a7640000", 83 | "code" : "", 84 | "nonce" : "0x00", 85 | "storage" : { 86 | } 87 | } 88 | }, 89 | "transaction" : { 90 | "data" : [ 91 | "" 92 | ], 93 | "gasLimit" : [ 94 | "0x0592a8" 95 | ], 96 | "gasPrice" : "0x01", 97 | "nonce" : "0x00", 98 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 99 | "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", 100 | "value" : [ 101 | "0x0186a0" 102 | ] 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /fixtures/GeneralStateTests/stPreCompiledContracts/CALLCODESha256_1.json: -------------------------------------------------------------------------------- 1 | { 2 | "CALLCODESha256_1" : { 3 | "_info" : { 4 | "comment" : "", 5 | "filledwith" : "cpp-1.3.0+commit.4e336c9e.Linux.g++", 6 | "source" : "src/GeneralStateTestsFiller/stPreCompiledContracts/CALLCODESha256_1Filler.json" 7 | }, 8 | "env" : { 9 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 10 | "currentDifficulty" : "0x20000", 11 | "currentGasLimit" : "0x989680", 12 | "currentNumber" : "0x01", 13 | "currentTimestamp" : "0x03e8", 14 | "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" 15 | }, 16 | "post" : { 17 | "Byzantium" : [ 18 | { 19 | "hash" : "0x7d542c7d4109350d7cd0d349c12ce05e8681403b1bd186b56cdeb09e729bb19c", 20 | "indexes" : { 21 | "data" : 0, 22 | "gas" : 0, 23 | "value" : 0 24 | }, 25 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 26 | } 27 | ], 28 | "EIP150" : [ 29 | { 30 | "hash" : "0x7d542c7d4109350d7cd0d349c12ce05e8681403b1bd186b56cdeb09e729bb19c", 31 | "indexes" : { 32 | "data" : 0, 33 | "gas" : 0, 34 | "value" : 0 35 | }, 36 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 37 | } 38 | ], 39 | "EIP158" : [ 40 | { 41 | "hash" : "0x7d542c7d4109350d7cd0d349c12ce05e8681403b1bd186b56cdeb09e729bb19c", 42 | "indexes" : { 43 | "data" : 0, 44 | "gas" : 0, 45 | "value" : 0 46 | }, 47 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 48 | } 49 | ], 50 | "Frontier" : [ 51 | { 52 | "hash" : "0x4833302bd51ace328a4e36d14916842f10f430b1e7a4a91ae17ade32eac8909c", 53 | "indexes" : { 54 | "data" : 0, 55 | "gas" : 0, 56 | "value" : 0 57 | }, 58 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 59 | } 60 | ], 61 | "Homestead" : [ 62 | { 63 | "hash" : "0x4833302bd51ace328a4e36d14916842f10f430b1e7a4a91ae17ade32eac8909c", 64 | "indexes" : { 65 | "data" : 0, 66 | "gas" : 0, 67 | "value" : 0 68 | }, 69 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 70 | } 71 | ] 72 | }, 73 | "pre" : { 74 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 75 | "balance" : "0x01312d00", 76 | "code" : "0x6020600060006000600060026101f4f2600255600051600055", 77 | "nonce" : "0x00", 78 | "storage" : { 79 | } 80 | }, 81 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 82 | "balance" : "0x0de0b6b3a7640000", 83 | "code" : "", 84 | "nonce" : "0x00", 85 | "storage" : { 86 | } 87 | } 88 | }, 89 | "transaction" : { 90 | "data" : [ 91 | "" 92 | ], 93 | "gasLimit" : [ 94 | "0x0592a8" 95 | ], 96 | "gasPrice" : "0x01", 97 | "nonce" : "0x00", 98 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 99 | "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", 100 | "value" : [ 101 | "0x0186a0" 102 | ] 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /fixtures/GeneralStateTests/stPreCompiledContracts/CallIdentitiy_0.json: -------------------------------------------------------------------------------- 1 | { 2 | "CallIdentitiy_0" : { 3 | "_info" : { 4 | "comment" : "", 5 | "filledwith" : "cpp-1.3.0+commit.4e336c9e.Linux.g++", 6 | "source" : "src/GeneralStateTestsFiller/stPreCompiledContracts/CallIdentitiy_0Filler.json" 7 | }, 8 | "env" : { 9 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 10 | "currentDifficulty" : "0x20000", 11 | "currentGasLimit" : "0x989680", 12 | "currentNumber" : "0x01", 13 | "currentTimestamp" : "0x03e8", 14 | "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" 15 | }, 16 | "post" : { 17 | "Byzantium" : [ 18 | { 19 | "hash" : "0x15b122e1f8eff78043fb6fb23c5d011026cea7741586cb2bd0e9a2af074ce180", 20 | "indexes" : { 21 | "data" : 0, 22 | "gas" : 0, 23 | "value" : 0 24 | }, 25 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 26 | } 27 | ], 28 | "EIP150" : [ 29 | { 30 | "hash" : "0x2a2fe3cbecb8a0a5dcb6b1eec781f2c5bd4afbea81f5b77f97519c7218a7322b", 31 | "indexes" : { 32 | "data" : 0, 33 | "gas" : 0, 34 | "value" : 0 35 | }, 36 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 37 | } 38 | ], 39 | "EIP158" : [ 40 | { 41 | "hash" : "0x15b122e1f8eff78043fb6fb23c5d011026cea7741586cb2bd0e9a2af074ce180", 42 | "indexes" : { 43 | "data" : 0, 44 | "gas" : 0, 45 | "value" : 0 46 | }, 47 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 48 | } 49 | ], 50 | "Frontier" : [ 51 | { 52 | "hash" : "0xc0597a2a5a4719ac83e0ef87fe6ecc2cff6542f240815b94178d66501319befc", 53 | "indexes" : { 54 | "data" : 0, 55 | "gas" : 0, 56 | "value" : 0 57 | }, 58 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 59 | } 60 | ], 61 | "Homestead" : [ 62 | { 63 | "hash" : "0xc0597a2a5a4719ac83e0ef87fe6ecc2cff6542f240815b94178d66501319befc", 64 | "indexes" : { 65 | "data" : 0, 66 | "gas" : 0, 67 | "value" : 0 68 | }, 69 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 70 | } 71 | ] 72 | }, 73 | "pre" : { 74 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 75 | "balance" : "0x01312d00", 76 | "code" : "0x600160005260206000602060006000600460fff1600051600055", 77 | "nonce" : "0x00", 78 | "storage" : { 79 | } 80 | }, 81 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 82 | "balance" : "0x0de0b6b3a7640000", 83 | "code" : "", 84 | "nonce" : "0x00", 85 | "storage" : { 86 | } 87 | } 88 | }, 89 | "transaction" : { 90 | "data" : [ 91 | "" 92 | ], 93 | "gasLimit" : [ 94 | "0x0592a8" 95 | ], 96 | "gasPrice" : "0x01", 97 | "nonce" : "0x00", 98 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 99 | "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", 100 | "value" : [ 101 | "0x0186a0" 102 | ] 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /fixtures/GeneralStateTests/stPreCompiledContracts/CallIdentitiy_1.json: -------------------------------------------------------------------------------- 1 | { 2 | "CallIdentitiy_1" : { 3 | "_info" : { 4 | "comment" : "", 5 | "filledwith" : "cpp-1.3.0+commit.4e336c9e.Linux.g++", 6 | "source" : "src/GeneralStateTestsFiller/stPreCompiledContracts/CallIdentitiy_1Filler.json" 7 | }, 8 | "env" : { 9 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 10 | "currentDifficulty" : "0x20000", 11 | "currentGasLimit" : "0x989680", 12 | "currentNumber" : "0x01", 13 | "currentTimestamp" : "0x03e8", 14 | "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" 15 | }, 16 | "post" : { 17 | "Byzantium" : [ 18 | { 19 | "hash" : "0xab6b59df16a6036de5cbe6a121af7c01a6851d91ec2f04ecc227c33218af6171", 20 | "indexes" : { 21 | "data" : 0, 22 | "gas" : 0, 23 | "value" : 0 24 | }, 25 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 26 | } 27 | ], 28 | "EIP150" : [ 29 | { 30 | "hash" : "0x12941dbdbb5e71f565c3edb1abb5202ee31054a23497085e8331ee9d73df94f0", 31 | "indexes" : { 32 | "data" : 0, 33 | "gas" : 0, 34 | "value" : 0 35 | }, 36 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 37 | } 38 | ], 39 | "EIP158" : [ 40 | { 41 | "hash" : "0xab6b59df16a6036de5cbe6a121af7c01a6851d91ec2f04ecc227c33218af6171", 42 | "indexes" : { 43 | "data" : 0, 44 | "gas" : 0, 45 | "value" : 0 46 | }, 47 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 48 | } 49 | ], 50 | "Frontier" : [ 51 | { 52 | "hash" : "0xc3421551fe70fd96f23787dccbad42678560a10d563eed5798a4a4072ef0a84d", 53 | "indexes" : { 54 | "data" : 0, 55 | "gas" : 0, 56 | "value" : 0 57 | }, 58 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 59 | } 60 | ], 61 | "Homestead" : [ 62 | { 63 | "hash" : "0xc3421551fe70fd96f23787dccbad42678560a10d563eed5798a4a4072ef0a84d", 64 | "indexes" : { 65 | "data" : 0, 66 | "gas" : 0, 67 | "value" : 0 68 | }, 69 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 70 | } 71 | ] 72 | }, 73 | "pre" : { 74 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 75 | "balance" : "0x01312d00", 76 | "code" : "0x6020600060006000600060046101f4f1600255600051600055", 77 | "nonce" : "0x00", 78 | "storage" : { 79 | } 80 | }, 81 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 82 | "balance" : "0x0de0b6b3a7640000", 83 | "code" : "", 84 | "nonce" : "0x00", 85 | "storage" : { 86 | } 87 | } 88 | }, 89 | "transaction" : { 90 | "data" : [ 91 | "" 92 | ], 93 | "gasLimit" : [ 94 | "0x0592a8" 95 | ], 96 | "gasPrice" : "0x01", 97 | "nonce" : "0x00", 98 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 99 | "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", 100 | "value" : [ 101 | "0x0186a0" 102 | ] 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /fixtures/GeneralStateTests/stPreCompiledContracts/CallRipemd160_0.json: -------------------------------------------------------------------------------- 1 | { 2 | "CallRipemd160_0" : { 3 | "_info" : { 4 | "comment" : "", 5 | "filledwith" : "cpp-1.3.0+commit.4e336c9e.Linux.g++", 6 | "source" : "src/GeneralStateTestsFiller/stPreCompiledContracts/CallRipemd160_0Filler.json" 7 | }, 8 | "env" : { 9 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 10 | "currentDifficulty" : "0x20000", 11 | "currentGasLimit" : "0x989680", 12 | "currentNumber" : "0x01", 13 | "currentTimestamp" : "0x03e8", 14 | "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" 15 | }, 16 | "post" : { 17 | "Byzantium" : [ 18 | { 19 | "hash" : "0x435aedb8d3ae05243d181c5eb50880e30ac527b87163a86ee7cfd255ce79b94c", 20 | "indexes" : { 21 | "data" : 0, 22 | "gas" : 0, 23 | "value" : 0 24 | }, 25 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 26 | } 27 | ], 28 | "EIP150" : [ 29 | { 30 | "hash" : "0x686c6f0235678010e68839c7ba72cd39ed5b7de6475ebf2f1a42ed3056c445d6", 31 | "indexes" : { 32 | "data" : 0, 33 | "gas" : 0, 34 | "value" : 0 35 | }, 36 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 37 | } 38 | ], 39 | "EIP158" : [ 40 | { 41 | "hash" : "0x435aedb8d3ae05243d181c5eb50880e30ac527b87163a86ee7cfd255ce79b94c", 42 | "indexes" : { 43 | "data" : 0, 44 | "gas" : 0, 45 | "value" : 0 46 | }, 47 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 48 | } 49 | ], 50 | "Frontier" : [ 51 | { 52 | "hash" : "0xb418cef120df01a9cef80804c2f883527c0b550df6664166857a7c998a869b65", 53 | "indexes" : { 54 | "data" : 0, 55 | "gas" : 0, 56 | "value" : 0 57 | }, 58 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 59 | } 60 | ], 61 | "Homestead" : [ 62 | { 63 | "hash" : "0xb418cef120df01a9cef80804c2f883527c0b550df6664166857a7c998a869b65", 64 | "indexes" : { 65 | "data" : 0, 66 | "gas" : 0, 67 | "value" : 0 68 | }, 69 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 70 | } 71 | ] 72 | }, 73 | "pre" : { 74 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 75 | "balance" : "0x01312d00", 76 | "code" : "0x600160005260206000602060006000600360fff1600051600055", 77 | "nonce" : "0x00", 78 | "storage" : { 79 | } 80 | }, 81 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 82 | "balance" : "0x0de0b6b3a7640000", 83 | "code" : "", 84 | "nonce" : "0x00", 85 | "storage" : { 86 | } 87 | } 88 | }, 89 | "transaction" : { 90 | "data" : [ 91 | "" 92 | ], 93 | "gasLimit" : [ 94 | "0x0592a8" 95 | ], 96 | "gasPrice" : "0x01", 97 | "nonce" : "0x00", 98 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 99 | "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", 100 | "value" : [ 101 | "0x0186a0" 102 | ] 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /fixtures/GeneralStateTests/stPreCompiledContracts/CallRipemd160_1.json: -------------------------------------------------------------------------------- 1 | { 2 | "CallRipemd160_1" : { 3 | "_info" : { 4 | "comment" : "", 5 | "filledwith" : "cpp-1.3.0+commit.4e336c9e.Linux.g++", 6 | "source" : "src/GeneralStateTestsFiller/stPreCompiledContracts/CallRipemd160_1Filler.json" 7 | }, 8 | "env" : { 9 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 10 | "currentDifficulty" : "0x20000", 11 | "currentGasLimit" : "0x989680", 12 | "currentNumber" : "0x01", 13 | "currentTimestamp" : "0x03e8", 14 | "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" 15 | }, 16 | "post" : { 17 | "Byzantium" : [ 18 | { 19 | "hash" : "0x37bf4936518d1bdbd00c4d6085a1dda0c8c17d80fea19ac7c7a7212e40ca41db", 20 | "indexes" : { 21 | "data" : 0, 22 | "gas" : 0, 23 | "value" : 0 24 | }, 25 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 26 | } 27 | ], 28 | "EIP150" : [ 29 | { 30 | "hash" : "0x34f4f4a52d69fed606412853b95650be8dc1a3f35ef8da8b3a81a6da1c8b7135", 31 | "indexes" : { 32 | "data" : 0, 33 | "gas" : 0, 34 | "value" : 0 35 | }, 36 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 37 | } 38 | ], 39 | "EIP158" : [ 40 | { 41 | "hash" : "0x37bf4936518d1bdbd00c4d6085a1dda0c8c17d80fea19ac7c7a7212e40ca41db", 42 | "indexes" : { 43 | "data" : 0, 44 | "gas" : 0, 45 | "value" : 0 46 | }, 47 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 48 | } 49 | ], 50 | "Frontier" : [ 51 | { 52 | "hash" : "0x1d22c83f58f74145b7afad4f5a57244540f901969d5d2a7ec4aa519ed0787930", 53 | "indexes" : { 54 | "data" : 0, 55 | "gas" : 0, 56 | "value" : 0 57 | }, 58 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 59 | } 60 | ], 61 | "Homestead" : [ 62 | { 63 | "hash" : "0x1d22c83f58f74145b7afad4f5a57244540f901969d5d2a7ec4aa519ed0787930", 64 | "indexes" : { 65 | "data" : 0, 66 | "gas" : 0, 67 | "value" : 0 68 | }, 69 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 70 | } 71 | ] 72 | }, 73 | "pre" : { 74 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 75 | "balance" : "0x01312d00", 76 | "code" : "0x602060006000600060006003610258f1600255600051600055", 77 | "nonce" : "0x00", 78 | "storage" : { 79 | } 80 | }, 81 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 82 | "balance" : "0x0de0b6b3a7640000", 83 | "code" : "", 84 | "nonce" : "0x00", 85 | "storage" : { 86 | } 87 | } 88 | }, 89 | "transaction" : { 90 | "data" : [ 91 | "" 92 | ], 93 | "gasLimit" : [ 94 | "0x0592a8" 95 | ], 96 | "gasPrice" : "0x01", 97 | "nonce" : "0x00", 98 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 99 | "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", 100 | "value" : [ 101 | "0x0186a0" 102 | ] 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /fixtures/GeneralStateTests/stPreCompiledContracts/CallSha256_0.json: -------------------------------------------------------------------------------- 1 | { 2 | "CallSha256_0" : { 3 | "_info" : { 4 | "comment" : "", 5 | "filledwith" : "cpp-1.3.0+commit.4e336c9e.Linux.g++", 6 | "source" : "src/GeneralStateTestsFiller/stPreCompiledContracts/CallSha256_0Filler.json" 7 | }, 8 | "env" : { 9 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 10 | "currentDifficulty" : "0x20000", 11 | "currentGasLimit" : "0x989680", 12 | "currentNumber" : "0x01", 13 | "currentTimestamp" : "0x03e8", 14 | "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" 15 | }, 16 | "post" : { 17 | "Byzantium" : [ 18 | { 19 | "hash" : "0xaf78af682890ed52f547478bf1a105a5c8e2627f5eff5f951f38140fd8745152", 20 | "indexes" : { 21 | "data" : 0, 22 | "gas" : 0, 23 | "value" : 0 24 | }, 25 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 26 | } 27 | ], 28 | "EIP150" : [ 29 | { 30 | "hash" : "0xe5d6c470d46618ad3d1298c9575d622ff01035ab4e2717df0cb37ebb18b53b86", 31 | "indexes" : { 32 | "data" : 0, 33 | "gas" : 0, 34 | "value" : 0 35 | }, 36 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 37 | } 38 | ], 39 | "EIP158" : [ 40 | { 41 | "hash" : "0xaf78af682890ed52f547478bf1a105a5c8e2627f5eff5f951f38140fd8745152", 42 | "indexes" : { 43 | "data" : 0, 44 | "gas" : 0, 45 | "value" : 0 46 | }, 47 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 48 | } 49 | ], 50 | "Frontier" : [ 51 | { 52 | "hash" : "0x86b9a816d69dc08083a5266bcf788491fabc3986bfb4cbcef78bd9e9d5f30e50", 53 | "indexes" : { 54 | "data" : 0, 55 | "gas" : 0, 56 | "value" : 0 57 | }, 58 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 59 | } 60 | ], 61 | "Homestead" : [ 62 | { 63 | "hash" : "0x86b9a816d69dc08083a5266bcf788491fabc3986bfb4cbcef78bd9e9d5f30e50", 64 | "indexes" : { 65 | "data" : 0, 66 | "gas" : 0, 67 | "value" : 0 68 | }, 69 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 70 | } 71 | ] 72 | }, 73 | "pre" : { 74 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 75 | "balance" : "0x01312d00", 76 | "code" : "0x600160005260206000602060006000600260fff1600051600055", 77 | "nonce" : "0x00", 78 | "storage" : { 79 | } 80 | }, 81 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 82 | "balance" : "0x0de0b6b3a7640000", 83 | "code" : "", 84 | "nonce" : "0x00", 85 | "storage" : { 86 | } 87 | } 88 | }, 89 | "transaction" : { 90 | "data" : [ 91 | "" 92 | ], 93 | "gasLimit" : [ 94 | "0x0592a8" 95 | ], 96 | "gasPrice" : "0x01", 97 | "nonce" : "0x00", 98 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 99 | "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", 100 | "value" : [ 101 | "0x0186a0" 102 | ] 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /fixtures/GeneralStateTests/stPreCompiledContracts/CallSha256_1.json: -------------------------------------------------------------------------------- 1 | { 2 | "CallSha256_1" : { 3 | "_info" : { 4 | "comment" : "", 5 | "filledwith" : "cpp-1.3.0+commit.4e336c9e.Linux.g++", 6 | "source" : "src/GeneralStateTestsFiller/stPreCompiledContracts/CallSha256_1Filler.json" 7 | }, 8 | "env" : { 9 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 10 | "currentDifficulty" : "0x20000", 11 | "currentGasLimit" : "0x989680", 12 | "currentNumber" : "0x01", 13 | "currentTimestamp" : "0x03e8", 14 | "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" 15 | }, 16 | "post" : { 17 | "Byzantium" : [ 18 | { 19 | "hash" : "0x1bab374f8e446a5ba07b8e46f51211c46ef9688e93b5970c28eb971511ff5de9", 20 | "indexes" : { 21 | "data" : 0, 22 | "gas" : 0, 23 | "value" : 0 24 | }, 25 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 26 | } 27 | ], 28 | "EIP150" : [ 29 | { 30 | "hash" : "0x6de5c8f3f170953bc212092db9030852c7b36ea9c4a804b9cd5e967b5fdfb484", 31 | "indexes" : { 32 | "data" : 0, 33 | "gas" : 0, 34 | "value" : 0 35 | }, 36 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 37 | } 38 | ], 39 | "EIP158" : [ 40 | { 41 | "hash" : "0x1bab374f8e446a5ba07b8e46f51211c46ef9688e93b5970c28eb971511ff5de9", 42 | "indexes" : { 43 | "data" : 0, 44 | "gas" : 0, 45 | "value" : 0 46 | }, 47 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 48 | } 49 | ], 50 | "Frontier" : [ 51 | { 52 | "hash" : "0x308d9368ff3343b3dfe257199d9ff3ae8fbec5810c63e74e669a343fa658f4a8", 53 | "indexes" : { 54 | "data" : 0, 55 | "gas" : 0, 56 | "value" : 0 57 | }, 58 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 59 | } 60 | ], 61 | "Homestead" : [ 62 | { 63 | "hash" : "0x308d9368ff3343b3dfe257199d9ff3ae8fbec5810c63e74e669a343fa658f4a8", 64 | "indexes" : { 65 | "data" : 0, 66 | "gas" : 0, 67 | "value" : 0 68 | }, 69 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 70 | } 71 | ] 72 | }, 73 | "pre" : { 74 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 75 | "balance" : "0x01312d00", 76 | "code" : "0x6020600060006000600060026101f4f1600255600051600055", 77 | "nonce" : "0x00", 78 | "storage" : { 79 | } 80 | }, 81 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 82 | "balance" : "0x0de0b6b3a7640000", 83 | "code" : "", 84 | "nonce" : "0x00", 85 | "storage" : { 86 | } 87 | } 88 | }, 89 | "transaction" : { 90 | "data" : [ 91 | "" 92 | ], 93 | "gasLimit" : [ 94 | "0x0592a8" 95 | ], 96 | "gasPrice" : "0x01", 97 | "nonce" : "0x00", 98 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 99 | "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", 100 | "value" : [ 101 | "0x0186a0" 102 | ] 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /fixtures/GeneralStateTests/stPreCompiledContracts/CallSha256_2.json: -------------------------------------------------------------------------------- 1 | { 2 | "CallSha256_2" : { 3 | "_info" : { 4 | "comment" : "", 5 | "filledwith" : "cpp-1.3.0+commit.4e336c9e.Linux.g++", 6 | "source" : "src/GeneralStateTestsFiller/stPreCompiledContracts/CallSha256_2Filler.json" 7 | }, 8 | "env" : { 9 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 10 | "currentDifficulty" : "0x20000", 11 | "currentGasLimit" : "0x989680", 12 | "currentNumber" : "0x01", 13 | "currentTimestamp" : "0x03e8", 14 | "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" 15 | }, 16 | "post" : { 17 | "Byzantium" : [ 18 | { 19 | "hash" : "0xa8cca12173a969472c8e27402ac36b2089680e8d4926a2f8cce4a4a2769e60b8", 20 | "indexes" : { 21 | "data" : 0, 22 | "gas" : 0, 23 | "value" : 0 24 | }, 25 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 26 | } 27 | ], 28 | "EIP150" : [ 29 | { 30 | "hash" : "0x5f16214512791aa2ff58ed1dfb91dd03abf992eaa2459bd93eede7475dccfbe0", 31 | "indexes" : { 32 | "data" : 0, 33 | "gas" : 0, 34 | "value" : 0 35 | }, 36 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 37 | } 38 | ], 39 | "EIP158" : [ 40 | { 41 | "hash" : "0xa8cca12173a969472c8e27402ac36b2089680e8d4926a2f8cce4a4a2769e60b8", 42 | "indexes" : { 43 | "data" : 0, 44 | "gas" : 0, 45 | "value" : 0 46 | }, 47 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 48 | } 49 | ], 50 | "Frontier" : [ 51 | { 52 | "hash" : "0x4486c2ed72e7eb999134286eb0cdd193cd5a25fcf74b2f0ec41743fc2b0a993a", 53 | "indexes" : { 54 | "data" : 0, 55 | "gas" : 0, 56 | "value" : 0 57 | }, 58 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 59 | } 60 | ], 61 | "Homestead" : [ 62 | { 63 | "hash" : "0x4486c2ed72e7eb999134286eb0cdd193cd5a25fcf74b2f0ec41743fc2b0a993a", 64 | "indexes" : { 65 | "data" : 0, 66 | "gas" : 0, 67 | "value" : 0 68 | }, 69 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 70 | } 71 | ] 72 | }, 73 | "pre" : { 74 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 75 | "balance" : "0x01312d00", 76 | "code" : "0x64f34578907f6005526020600060256000600060026101f4f1600255600051600055", 77 | "nonce" : "0x00", 78 | "storage" : { 79 | } 80 | }, 81 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 82 | "balance" : "0x0de0b6b3a7640000", 83 | "code" : "", 84 | "nonce" : "0x00", 85 | "storage" : { 86 | } 87 | } 88 | }, 89 | "transaction" : { 90 | "data" : [ 91 | "" 92 | ], 93 | "gasLimit" : [ 94 | "0x0592a8" 95 | ], 96 | "gasPrice" : "0x01", 97 | "nonce" : "0x00", 98 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 99 | "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", 100 | "value" : [ 101 | "0x0186a0" 102 | ] 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /fixtures/GeneralStateTests/stPreCompiledContracts/CallSha256_3.json: -------------------------------------------------------------------------------- 1 | { 2 | "CallSha256_3" : { 3 | "_info" : { 4 | "comment" : "", 5 | "filledwith" : "cpp-1.3.0+commit.4e336c9e.Linux.g++", 6 | "source" : "src/GeneralStateTestsFiller/stPreCompiledContracts/CallSha256_3Filler.json" 7 | }, 8 | "env" : { 9 | "currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", 10 | "currentDifficulty" : "0x20000", 11 | "currentGasLimit" : "0x989680", 12 | "currentNumber" : "0x01", 13 | "currentTimestamp" : "0x03e8", 14 | "previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" 15 | }, 16 | "post" : { 17 | "Byzantium" : [ 18 | { 19 | "hash" : "0x52e69963b10d07e1181b4666ee8eb8c8a674b04a2d181ef63980711afe2fb451", 20 | "indexes" : { 21 | "data" : 0, 22 | "gas" : 0, 23 | "value" : 0 24 | }, 25 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 26 | } 27 | ], 28 | "EIP150" : [ 29 | { 30 | "hash" : "0x629bd433840e4cf0ff15d9f156c89b64b7db3d834ea2583694195997978fbe41", 31 | "indexes" : { 32 | "data" : 0, 33 | "gas" : 0, 34 | "value" : 0 35 | }, 36 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 37 | } 38 | ], 39 | "EIP158" : [ 40 | { 41 | "hash" : "0x52e69963b10d07e1181b4666ee8eb8c8a674b04a2d181ef63980711afe2fb451", 42 | "indexes" : { 43 | "data" : 0, 44 | "gas" : 0, 45 | "value" : 0 46 | }, 47 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 48 | } 49 | ], 50 | "Frontier" : [ 51 | { 52 | "hash" : "0x2b4bd681b739a73b8c2c150718789783ed83a01bc9e6aece404755418b5c18a7", 53 | "indexes" : { 54 | "data" : 0, 55 | "gas" : 0, 56 | "value" : 0 57 | }, 58 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 59 | } 60 | ], 61 | "Homestead" : [ 62 | { 63 | "hash" : "0x2b4bd681b739a73b8c2c150718789783ed83a01bc9e6aece404755418b5c18a7", 64 | "indexes" : { 65 | "data" : 0, 66 | "gas" : 0, 67 | "value" : 0 68 | }, 69 | "logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" 70 | } 71 | ] 72 | }, 73 | "pre" : { 74 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : { 75 | "balance" : "0x01312d00", 76 | "code" : "0x64f34578907f6000526020600060256000600060026101f4f1600255600051600055", 77 | "nonce" : "0x00", 78 | "storage" : { 79 | } 80 | }, 81 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { 82 | "balance" : "0x0de0b6b3a7640000", 83 | "code" : "", 84 | "nonce" : "0x00", 85 | "storage" : { 86 | } 87 | } 88 | }, 89 | "transaction" : { 90 | "data" : [ 91 | "" 92 | ], 93 | "gasLimit" : [ 94 | "0x0592a8" 95 | ], 96 | "gasPrice" : "0x01", 97 | "nonce" : "0x00", 98 | "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", 99 | "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", 100 | "value" : [ 101 | "0x0186a0" 102 | ] 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /fixtures/TrieTests/hex_encoded_securetrie_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "test1": { 3 | "in": { 4 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": 5 | "0xf848018405f446a7a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", 6 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87": 7 | "0xf8440101a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a004bccc5d94f4d1f99aab44369a910179931772f2a5c001c3229f57831c102769", 8 | "0xd2571607e241ecf590ed94b12d87c94babe36db6": 9 | "0xf8440180a0ba4b47865c55a341a4a78759bb913cd15c3ee8eaf30a62fa8d1c8863113d84e8a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", 10 | "0x62c01474f089b07dae603491675dc5b5748f7049": 11 | "0xf8448080a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", 12 | "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": 13 | "0xf8478083019a59a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" 14 | }, 15 | "root": "0x730a444e08ab4b8dee147c9b232fc52d34a223d600031c1e9d25bfc985cbd797", 16 | "hexEncoded": true 17 | }, 18 | "test2": { 19 | "in": { 20 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": 21 | "0xf84c01880de0b6b3a7622746a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", 22 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87": 23 | "0xf84780830186b7a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0501653f02840675b1aab0328c6634762af5d51764e78f9641cccd9b27b90db4f", 24 | "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": 25 | "0xf8468082521aa056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" 26 | }, 27 | "root": "0xa7c787bf470808896308c215e22c7a580a0087bb6db6e8695fb4759537283a83", 28 | "hexEncoded": true 29 | }, 30 | "test3": { 31 | "in": { 32 | "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": 33 | "0xf84c01880de0b6b3a7614bc3a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", 34 | "0x095e7baea6a6c7c4c2dfeb977efac326af552d87": 35 | "0xf84880840132b3a0a065fee2fffd7a68488cf7ef79f35f7979133172ac5727b5e0cf322953d13de492a06e5d8fec8b6b9bf41c3fb9b61696d5c87b66f6daa98d5f02ba9361b0c6916467", 36 | "0x0000000000000000000000000000000000000001": 37 | "0xf8448080a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", 38 | "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": 39 | "0xf8478083012d9da056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" 40 | }, 41 | "root": "0x40b37be88a49e2c08b8d33fcb03a0676ffd0481df54dfebd3512b8ec54f40cad", 42 | "hexEncoded": true 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /fixtures/TrieTests/trieanyorder.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleItem": { 3 | "in": { 4 | "A": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 5 | }, 6 | "root": "0xd23786fb4a010da3ce639d66d5e904a11dbc02746d1ce25029e53290cabf28ab" 7 | }, 8 | "dogs": { 9 | "in": { 10 | "doe": "reindeer", 11 | "dog": "puppy", 12 | "dogglesworth": "cat" 13 | }, 14 | "root": "0x8aad789dff2f538bca5d8ea56e8abe10f4c7ba3a5dea95fea4cd6e7c3a1168d3" 15 | }, 16 | "puppy": { 17 | "in": { 18 | "do": "verb", 19 | "horse": "stallion", 20 | "doge": "coin", 21 | "dog": "puppy" 22 | }, 23 | "root": "0x5991bb8c6514148a29db676a14ac506cd2cd5775ace63c30a4fe457715e9ac84" 24 | }, 25 | "foo": { 26 | "in": { 27 | "foo": "bar", 28 | "food": "bass" 29 | }, 30 | "root": "0x17beaa1648bafa633cda809c90c04af50fc8aed3cb40d16efbddee6fdf63c4c3" 31 | }, 32 | "smallValues": { 33 | "in": { 34 | "be": "e", 35 | "dog": "puppy", 36 | "bed": "d" 37 | }, 38 | "root": "0x3f67c7a47520f79faa29255d2d3c084a7a6df0453116ed7232ff10277a8be68b" 39 | }, 40 | "testy": { 41 | "in": { 42 | "test": "test", 43 | "te": "testy" 44 | }, 45 | "root": "0x8452568af70d8d140f58d941338542f645fcca50094b20f3c3d8c3df49337928" 46 | }, 47 | "hex": { 48 | "in": { 49 | "0x0045": "0x0123456789", 50 | "0x4500": "0x9876543210" 51 | }, 52 | "root": "0x285505fcabe84badc8aa310e2aae17eddc7d120aabec8a476902c8184b3a3503" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /fixtures/TrieTests/trieanyorder_secureTrie.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleItem": { 3 | "in": { 4 | "A": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 5 | }, 6 | "root": "0xe9e2935138352776cad724d31c9fa5266a5c593bb97726dd2a908fe6d53284df" 7 | }, 8 | "dogs": { 9 | "in": { 10 | "doe": "reindeer", 11 | "dog": "puppy", 12 | "dogglesworth": "cat" 13 | }, 14 | "root": "0xd4cd937e4a4368d7931a9cf51686b7e10abb3dce38a39000fd7902a092b64585" 15 | }, 16 | "puppy": { 17 | "in": { 18 | "do": "verb", 19 | "horse": "stallion", 20 | "doge": "coin", 21 | "dog": "puppy" 22 | }, 23 | "root": "0x29b235a58c3c25ab83010c327d5932bcf05324b7d6b1185e650798034783ca9d" 24 | }, 25 | "foo": { 26 | "in": { 27 | "foo": "bar", 28 | "food": "bass" 29 | }, 30 | "root": "0x1385f23a33021025d9e87cca5c66c00de06178807b96a9acc92b7d651ccde842" 31 | }, 32 | "smallValues": { 33 | "in": { 34 | "be": "e", 35 | "dog": "puppy", 36 | "bed": "d" 37 | }, 38 | "root": "0x826a4f9f9054a3e980e54b20da992c24fa20467f1ca635115ef4917be66e746f" 39 | }, 40 | "testy": { 41 | "in": { 42 | "test": "test", 43 | "te": "testy" 44 | }, 45 | "root": "0xaea54fb6c80499674248a462864c420c9d9f3b3d38c879c12425bade1ad76552" 46 | }, 47 | "hex": { 48 | "in": { 49 | "0x0045": "0x0123456789", 50 | "0x4500": "0x9876543210" 51 | }, 52 | "root": "0xbc11c02c8ab456db0c4d2728b6a2a6210d06f26a2ace4f7d8bdfc72ddf2630ab" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /fixtures/TrieTests/trietestnextprev.json: -------------------------------------------------------------------------------- 1 | { 2 | "basic": { 3 | "in": [ "cat", "doge", "wallace" ], 4 | "tests": [ 5 | [ "", "", "cat" ], 6 | [ "bobo", "", "cat" ], 7 | [ "c", "", "cat" ], 8 | [ "car", "", "cat" ], 9 | [ "cat", "", "doge" ], 10 | [ "catering", "cat", "doge" ], 11 | [ "d", "cat", "doge" ], 12 | [ "doge", "cat", "wallace" ], 13 | [ "dogerton", "doge", "wallace" ], 14 | [ "w", "doge", "wallace" ], 15 | [ "wallace", "doge", "" ], 16 | [ "wallace123", "wallace", ""] 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /qkchash/Makefile: -------------------------------------------------------------------------------- 1 | CC=g++ 2 | CFLAGS=-Wall -O3 -std=c++17 3 | 4 | all: qkchash libqkchash.so 5 | 6 | qkchash: qkchash.cpp 7 | $(CC) $(CFLAGS) -o qkchash qkchash.cpp 8 | 9 | libqkchash.so: qkchash.cpp 10 | $(CC) $(CFLAGS) -o libqkchash.so -shared -fPIC qkchash.cpp 11 | 12 | clean: 13 | rm -f qkchash libqkchash.so 14 | -------------------------------------------------------------------------------- /qkchash/README.md: -------------------------------------------------------------------------------- 1 | To build `qkchash` executable and `libqkchash.so` run 2 | ```bash 3 | make 4 | ``` 5 | By default it uses `g++` to compile the C++ code. 6 | You may use a different binary by overriding the `CC` variable. For example to use `g++-7` run 7 | ```bash 8 | make CC=g++-7 9 | ``` 10 | Read `Makefile ` for more details. 11 | 12 | To test the python wrapper run 13 | ``` 14 | LD_LIBRARY_PATH=. python3 qkchash.py 15 | ``` 16 | 17 | The output is: 18 | ``` 19 | make_cache time: 0.09 20 | Python version, time used: 0.46, hashes per sec: 21.54 21 | Native version, time used: 6.16, hashes per sec: 162.23 22 | Equal: True 23 | ``` 24 | -------------------------------------------------------------------------------- /qkchash/qkcpow.py: -------------------------------------------------------------------------------- 1 | import os 2 | from functools import lru_cache 3 | from typing import Optional, Tuple 4 | 5 | from qkchash.qkchash import CACHE_ENTRIES, make_cache, qkchash, QkcHashNative 6 | 7 | CACHE_SEED = b"" 8 | 9 | 10 | def get_qkchashlib_path(): 11 | """Assuming libqkchash.so is in the same dir as this file""" 12 | return os.path.join(os.path.dirname(__file__), "libqkchash.so") 13 | 14 | 15 | def init_qkc_hash_native(): 16 | try: 17 | return QkcHashNative(get_qkchashlib_path()) 18 | except Exception: 19 | return None 20 | 21 | 22 | QKC_HASH_NATIVE = init_qkc_hash_native() 23 | QKC_HASH_CACHE = ( 24 | QKC_HASH_NATIVE.make_cache(CACHE_ENTRIES, CACHE_SEED) 25 | if QKC_HASH_NATIVE 26 | else make_cache(CACHE_ENTRIES, CACHE_SEED) 27 | ) 28 | 29 | 30 | @lru_cache(maxsize=32) 31 | def check_pow( 32 | header_hash: bytes, mixhash: bytes, nonce: bytes, difficulty: int 33 | ) -> bool: 34 | """Check if the proof-of-work of the block is valid.""" 35 | if len(mixhash) != 32 or len(header_hash) != 32 or len(nonce) != 8: 36 | return False 37 | 38 | if QKC_HASH_NATIVE is None: 39 | mining_output = qkchash(header_hash, nonce, QKC_HASH_CACHE) 40 | else: 41 | dup_cache = QKC_HASH_NATIVE.dup_cache(QKC_HASH_CACHE) 42 | mining_output = QKC_HASH_NATIVE.calculate_hash(header_hash, nonce, dup_cache) 43 | 44 | if mining_output["mix digest"] != mixhash: 45 | return False 46 | result = int.from_bytes(mining_output["result"], byteorder="big") 47 | return result <= 2 ** 256 // (difficulty or 1) 48 | 49 | 50 | class QkchashMiner: 51 | def __init__(self, difficulty: int, header_hash: bytes): 52 | self.difficulty = difficulty 53 | self.header_hash = header_hash 54 | 55 | def mine( 56 | self, rounds=1000, start_nonce=0 57 | ) -> Tuple[Optional[bytes], Optional[bytes]]: 58 | bin_nonce, mixhash = mine( 59 | self.difficulty, self.header_hash, start_nonce=start_nonce, rounds=rounds 60 | ) 61 | if bin_nonce is not None: 62 | return bin_nonce, mixhash 63 | 64 | return None, None 65 | 66 | 67 | def mine( 68 | difficulty: int, header_hash: bytes, start_nonce: int = 0, rounds: int = 1000 69 | ) -> Tuple[Optional[bytes], Optional[bytes]]: 70 | nonce = start_nonce 71 | target = 2 ** 256 // (difficulty or 1) 72 | for i in range(1, rounds + 1): 73 | # hashimoto expected big-indian byte representation 74 | bin_nonce = (nonce + i).to_bytes(8, byteorder="big") 75 | if QKC_HASH_NATIVE is None: 76 | mining_output = qkchash(header_hash, bin_nonce, QKC_HASH_CACHE) 77 | else: 78 | dup_cache = QKC_HASH_NATIVE.dup_cache(QKC_HASH_CACHE) 79 | mining_output = QKC_HASH_NATIVE.calculate_hash( 80 | header_hash, bin_nonce, dup_cache 81 | ) 82 | result = int.from_bytes(mining_output["result"], byteorder="big") 83 | if result <= target: 84 | assert len(bin_nonce) == 8 85 | assert len(mining_output["mix digest"]) == 32 86 | return bin_nonce, mining_output["mix digest"] 87 | return None, None 88 | -------------------------------------------------------------------------------- /qkchash/set_benchmark.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define ELEMENT_TYPE uint64_t 12 | 13 | int main() { 14 | 15 | std::set oset; 16 | 17 | uint32_t key_size = 64 * 1024; 18 | 19 | std::uniform_int_distribution 20 | dist(0, std::numeric_limits::max()); 21 | std::uniform_int_distribution 22 | dist64(0, std::numeric_limits::max()); 23 | std::default_random_engine generator(475); 24 | 25 | // Prepare a search tree 26 | std::cout << "Inserting to set ..." << std::endl; 27 | auto t_start = std::chrono::steady_clock::now(); 28 | std::vector inserted; 29 | for (uint32_t i = 0; i < key_size; i++) { 30 | ELEMENT_TYPE v = dist(generator); 31 | inserted.push_back(v); 32 | oset.insert(v); 33 | } 34 | auto used_time = std::chrono::steady_clock::now() - t_start; 35 | std::cout << "Insert time: " 36 | << std::chrono::duration(used_time).count() 37 | << std::endl; 38 | 39 | // Performance random delete and insert 40 | uint32_t count = 1 * 1024 * 1024; 41 | t_start = std::chrono::steady_clock::now(); 42 | uint64_t total_count = 0; 43 | while (1) { 44 | for (uint32_t i = 0; i < count; i++) { 45 | uint64_t p = dist64(generator) % oset.size(); 46 | oset.erase(inserted[p]); 47 | inserted[p] = dist(generator); 48 | oset.insert(inserted[p]); 49 | } 50 | 51 | total_count += count; 52 | used_time = std::chrono::steady_clock::now() - t_start; 53 | auto used_time_count = 54 | (uint64_t)std::chrono::duration( 55 | used_time).count(); 56 | std::cout << total_count * 1000 / used_time_count << std::endl; 57 | } 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /qkchash/tests/test_qkcpow.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from qkchash.qkcpow import QkchashMiner, check_pow 4 | 5 | 6 | class TestQkcpow(unittest.TestCase): 7 | def test_pow(self): 8 | header = (2 ** 256 - 1234567890).to_bytes(32, "big") 9 | diff = 10 10 | miner = QkchashMiner(diff, header) 11 | nonce, mixhash = miner.mine() 12 | self.assertIsNotNone(nonce) 13 | self.assertIsNotNone(mixhash) 14 | 15 | # wrong nonce, mixhash order 16 | self.assertFalse(check_pow(header, nonce, mixhash, diff)) 17 | 18 | self.assertTrue(check_pow(header, mixhash, nonce, diff)) 19 | -------------------------------------------------------------------------------- /quarkchain/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llSourcell/pyquarkchain/d1c97674af8e0002ac136f7a7aef81deef16dfbd/quarkchain/__init__.py -------------------------------------------------------------------------------- /quarkchain/cluster/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llSourcell/pyquarkchain/d1c97674af8e0002ac136f7a7aef81deef16dfbd/quarkchain/cluster/__init__.py -------------------------------------------------------------------------------- /quarkchain/cluster/cluster.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import asyncio 3 | import os 4 | import platform 5 | import signal 6 | from asyncio import subprocess 7 | 8 | import psutil 9 | 10 | from quarkchain.cluster.cluster_config import ClusterConfig 11 | 12 | 13 | PYTHON = "pypy3" if platform.python_implementation() == "PyPy" else "python3" 14 | 15 | 16 | def kill_child_processes(parent_pid, sig=signal.SIGTERM): 17 | """ Kill all the subprocesses recursively """ 18 | try: 19 | parent = psutil.Process(parent_pid) 20 | except psutil.NoSuchProcess: 21 | return 22 | children = parent.children(recursive=True) 23 | print( 24 | "================================ SHUTTING DOWN CLUSTER ================================" 25 | ) 26 | for process in children: 27 | try: 28 | print("SIGTERM >>> " + " ".join(process.cmdline()[1:])) 29 | except Exception: 30 | pass 31 | process.send_signal(sig) 32 | 33 | 34 | async def run_master(config_file): 35 | cmd = "{} -u master.py --cluster_config={}".format(PYTHON, config_file) 36 | return await asyncio.create_subprocess_exec( 37 | *cmd.split(" "), stdout=subprocess.PIPE, stderr=subprocess.STDOUT 38 | ) 39 | 40 | 41 | async def run_slave(config_file, id): 42 | cmd = "{} -u slave.py --cluster_config={} --node_id={}".format( 43 | PYTHON, config_file, id 44 | ) 45 | return await asyncio.create_subprocess_exec( 46 | *cmd.split(" "), stdout=subprocess.PIPE, stderr=subprocess.STDOUT 47 | ) 48 | 49 | 50 | async def print_output(prefix, stream): 51 | while True: 52 | line = await stream.readline() 53 | if not line: 54 | break 55 | print("{}: {}".format(prefix, line.decode("ascii").strip())) 56 | 57 | 58 | class Cluster: 59 | def __init__(self, config, cluster_id=""): 60 | self.config = config 61 | self.procs = [] 62 | self.shutdown_called = False 63 | self.cluster_id = cluster_id 64 | 65 | async def wait_and_shutdown(self, prefix, proc): 66 | """ If one process terminates shutdown the entire cluster """ 67 | await proc.wait() 68 | if self.shutdown_called: 69 | return 70 | 71 | print("{} is dead. Shutting down the cluster...".format(prefix)) 72 | await self.shutdown() 73 | 74 | async def run_master(self): 75 | master = await run_master(self.config.json_filepath) 76 | prefix = "{}MASTER".format(self.cluster_id) 77 | asyncio.ensure_future(print_output(prefix, master.stdout)) 78 | self.procs.append((prefix, master)) 79 | 80 | async def run_slaves(self): 81 | for slave in self.config.SLAVE_LIST: 82 | s = await run_slave(self.config.json_filepath, slave.ID) 83 | prefix = "{}SLAVE_{}".format(self.cluster_id, slave.ID) 84 | asyncio.ensure_future(print_output(prefix, s.stdout)) 85 | self.procs.append((prefix, s)) 86 | 87 | async def run(self): 88 | await self.run_master() 89 | await self.run_slaves() 90 | 91 | await asyncio.gather( 92 | *[self.wait_and_shutdown(prefix, proc) for prefix, proc in self.procs] 93 | ) 94 | 95 | async def shutdown(self): 96 | self.shutdown_called = True 97 | kill_child_processes(os.getpid()) 98 | 99 | def start_and_loop(self): 100 | try: 101 | asyncio.get_event_loop().run_until_complete(self.run()) 102 | except KeyboardInterrupt: 103 | try: 104 | asyncio.get_event_loop().run_until_complete(self.shutdown()) 105 | except Exception: 106 | pass 107 | 108 | 109 | def main(): 110 | parser = argparse.ArgumentParser() 111 | ClusterConfig.attach_arguments(parser) 112 | args = parser.parse_args() 113 | 114 | config = ClusterConfig.create_from_args(args) 115 | print("Cluster config file: {}".format(config.json_filepath)) 116 | print(config.to_json()) 117 | 118 | os.chdir(os.path.dirname(os.path.abspath(__file__))) 119 | 120 | cluster = Cluster(config) 121 | 122 | cluster.start_and_loop() 123 | 124 | 125 | if __name__ == "__main__": 126 | main() 127 | -------------------------------------------------------------------------------- /quarkchain/cluster/guardian.py: -------------------------------------------------------------------------------- 1 | class Guardian: 2 | @staticmethod 3 | def adjust_difficulty(original_difficulty: int, block_height: int): 4 | return original_difficulty // 1000 5 | # TODO: decide on the parameters for mainnet 6 | # if block_height < 1000: 7 | # return original_difficulty // 1000 8 | # if block_height < 10000: 9 | # return original_difficulty // 100 10 | # if block_height < 100000: 11 | # return original_difficulty // 10 12 | # return original_difficulty 13 | -------------------------------------------------------------------------------- /quarkchain/cluster/monitoring.py: -------------------------------------------------------------------------------- 1 | import json 2 | import requests 3 | import aiohttp 4 | from quarkchain.utils import Logger 5 | 6 | 7 | class KafkaSampleLogger: 8 | def __init__(self, cluster_config): 9 | self.cluster_config = cluster_config 10 | 11 | def log_kafka_sample(self, topic: str, sample: dict): 12 | """This is for testing/debugging only, use async version for production""" 13 | if self.cluster_config.MONITORING.KAFKA_REST_ADDRESS == "": 14 | return 15 | url = "http://{}/topics/{}".format( 16 | self.cluster_config.MONITORING.KAFKA_REST_ADDRESS, topic 17 | ) 18 | try: 19 | record_data = json.dumps({"records": [{"value": sample}]}) 20 | headers = { 21 | "Content-Type": "application/vnd.kafka.json.v2+json", 22 | "Accept": "application/vnd.kafka.v2+json", 23 | } 24 | response = requests.post(url, data=record_data, headers=headers) 25 | if response.status_code != 200: 26 | raise Exception( 27 | "non-OK response status code: {}".format(response.status_code) 28 | ) 29 | except Exception as ex: 30 | Logger.error_only("Failed to log sample to Kafka: {}".format(ex)) 31 | 32 | async def log_kafka_sample_async(self, topic: str, sample: dict): 33 | """logs sample to Kafka topic asynchronously 34 | Sample for monitoring purpose: 35 | Supports logging samples to Kafka via REST API (Confluent) 36 | 37 | Column guidelines: 38 | time: epoch in seconds 39 | sample_rate: pre-sampled record shall set this to sample rate, e.g., 100 means one sample is logged out of 100 40 | column type shall be log int, str, or vector of str 41 | """ 42 | if not self.cluster_config.MONITORING.KAFKA_REST_ADDRESS or not topic: 43 | return 44 | url = "http://{}/topics/{}".format( 45 | self.cluster_config.MONITORING.KAFKA_REST_ADDRESS, topic 46 | ) 47 | try: 48 | record_data = json.dumps({"records": [{"value": sample}]}) 49 | headers = { 50 | "Content-Type": "application/vnd.kafka.json.v2+json", 51 | "Accept": "application/vnd.kafka.v2+json", 52 | } 53 | session = aiohttp.ClientSession() 54 | response = await session.post(url, data=record_data, headers=headers) 55 | if response.status != 200: 56 | raise Exception( 57 | "non-OK response status code: {}".format(response.status_code) 58 | ) 59 | except Exception as ex: 60 | Logger.error_only_every_n( 61 | "Failed to log sample to Kafka: {}".format(ex), 100 62 | ) 63 | finally: 64 | await session.close() 65 | -------------------------------------------------------------------------------- /quarkchain/cluster/multi_cluster.py: -------------------------------------------------------------------------------- 1 | """ 2 | multi_cluster.py - starts multiple clusters on localhost, and have them inter-connect using either simple network or real p2p 3 | Usage: 4 | multi_cluster.py accepts the same arguments as cluster.py 5 | additional arguments: 6 | --num_clusters 7 | also note that p2p bootstrap key is fixed to a test value 8 | 9 | Examples: 10 | 1. simple network, with one (random) cluster mining 11 | python multi_cluster.py --start_simulated_mining 12 | 2. p2p module, with one (random) cluster mining 13 | python multi_cluster.py --p2p --start_simulated_mining 14 | """ 15 | 16 | 17 | import argparse 18 | import asyncio 19 | import os 20 | import random 21 | 22 | from quarkchain.p2p.utils import colors, COLOR_END 23 | from quarkchain.cluster import cluster as cl 24 | from quarkchain.cluster.cluster_config import ClusterConfig 25 | 26 | 27 | async def main(): 28 | parser = argparse.ArgumentParser() 29 | ClusterConfig.attach_arguments(parser) 30 | parser.add_argument("--num_clusters", default=2, type=int) 31 | args = parser.parse_args() 32 | clusters = [] 33 | mine_i = random.randint(0, args.num_clusters - 1) 34 | mine = args.start_simulated_mining 35 | if mine: 36 | print("cluster {} will be mining".format(mine_i)) 37 | else: 38 | print("No one will be mining") 39 | 40 | db_path_root = args.db_path_root 41 | p2p_port = args.p2p_port 42 | for i in range(args.num_clusters): 43 | args.start_simulated_mining = mine and i == mine_i 44 | args.db_path_root = "{}_C{}".format(db_path_root, i) 45 | 46 | # set up p2p bootstrapping, with fixed bootstrap key for now 47 | if args.p2p: 48 | if i == 0: 49 | args.privkey = ( 50 | "31552f186bf90908ce386fb547dd0410bf443309125cc43fd0ffd642959bf6d9" 51 | ) 52 | else: 53 | args.privkey = "" 54 | 55 | args.bootnodes = "enode://c571e0db93d17cc405cb57640826b70588a6a28785f38b21be471c609ca12fcb06cb306ac44872908f5bed99046031a5af82072d484e3ef9029560c1707193a0@127.0.0.1:{}".format( 56 | p2p_port 57 | ) 58 | 59 | config = ClusterConfig.create_from_args(args) 60 | print("Cluster {} config file: {}".format(i, config.json_filepath)) 61 | print(config.to_json()) 62 | 63 | clusters.append( 64 | cl.Cluster(config, "{}C{}{}_".format(colors[i % len(colors)], i, COLOR_END)) 65 | ) 66 | 67 | args.p2p_port += 1 68 | args.port_start += 100 69 | args.json_rpc_port += 1 70 | args.json_rpc_private_port += 1 71 | 72 | tasks = list() 73 | tasks.append(asyncio.ensure_future(clusters[0].run())) 74 | await asyncio.sleep(3) 75 | for cluster in clusters[1:]: 76 | tasks.append(asyncio.ensure_future(cluster.run())) 77 | try: 78 | await asyncio.gather(*tasks) 79 | except KeyboardInterrupt: 80 | try: 81 | for cluster in clusters: 82 | asyncio.get_event_loop().run_until_complete(cluster.shutdown()) 83 | except Exception: 84 | pass 85 | 86 | 87 | if __name__ == "__main__": 88 | os.chdir(os.path.dirname(os.path.abspath(__file__))) 89 | 90 | loop = asyncio.get_event_loop() 91 | try: 92 | loop.run_until_complete(main()) 93 | except KeyboardInterrupt: 94 | try: 95 | cl.kill_child_processes(os.getpid()) 96 | except Exception: 97 | pass 98 | finally: 99 | loop.close() 100 | -------------------------------------------------------------------------------- /quarkchain/cluster/neighbor.py: -------------------------------------------------------------------------------- 1 | from quarkchain.core import Branch 2 | from quarkchain.utils import is_p2, check 3 | 4 | 5 | def is_neighbor(b1: Branch, b2: Branch): 6 | """A naive algorithm to decide neighbor relationship 7 | Two shards are neighbor iff there is only 1 bit difference in their shard ids. 8 | This only applies if there are more than 32 shards in the network. 9 | Otherwise all shards are neighbor to each other. 10 | TODO: a better algorithm 11 | """ 12 | check(b1.get_shard_size() == b2.get_shard_size()) 13 | check(b1.get_shard_id() != b2.get_shard_id()) 14 | 15 | if b1.get_shard_size() <= 32: 16 | return True 17 | 18 | return is_p2(abs(b1.get_shard_id() - b2.get_shard_id())) 19 | -------------------------------------------------------------------------------- /quarkchain/cluster/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llSourcell/pyquarkchain/d1c97674af8e0002ac136f7a7aef81deef16dfbd/quarkchain/cluster/tests/__init__.py -------------------------------------------------------------------------------- /quarkchain/cluster/tests/test_cluster_config.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import os 3 | import unittest 4 | 5 | from quarkchain.cluster.cluster_config import ClusterConfig 6 | 7 | 8 | class TestClusterConfig(unittest.TestCase): 9 | def test_cluster_dict_wloadtest(self): 10 | """convert to dict and back to check if the content changed, requires `__eq__` 11 | removing --loadtest will make the test faster 12 | passing more num_shards will increase runtime linearly 13 | """ 14 | parser = argparse.ArgumentParser() 15 | ClusterConfig.attach_arguments(parser) 16 | pwd = os.path.dirname(os.path.abspath(__file__)) 17 | default_genesis_dir = os.path.join(pwd, "../../genesis_data") 18 | args = parser.parse_args( 19 | ["--num_shards=4", "--genesis_dir=" + default_genesis_dir] 20 | ) 21 | cluster_config = ClusterConfig.create_from_args(args) 22 | 23 | args = parser.parse_args(["--cluster_config=" + cluster_config.json_filepath]) 24 | deserialized = ClusterConfig.create_from_args(args) 25 | 26 | self.assertTrue(cluster_config == deserialized) 27 | self.assertTrue( 28 | len(cluster_config.QUARKCHAIN.SHARD_LIST[0].GENESIS.ALLOC) > 12000 29 | ) 30 | 31 | def test_cluster_dict(self): 32 | parser = argparse.ArgumentParser() 33 | ClusterConfig.attach_arguments(parser) 34 | args = parser.parse_args(["--num_shards=4", "--genesis_dir="]) 35 | cluster_config = ClusterConfig.create_from_args(args) 36 | 37 | args = parser.parse_args(["--cluster_config=" + cluster_config.json_filepath]) 38 | deserialized = ClusterConfig.create_from_args(args) 39 | 40 | self.assertTrue(cluster_config == deserialized) 41 | -------------------------------------------------------------------------------- /quarkchain/cluster/tests/test_monitoring.py: -------------------------------------------------------------------------------- 1 | import json 2 | import unittest 3 | import argparse 4 | from quarkchain.cluster.cluster_config import ClusterConfig 5 | 6 | 7 | class MonitoringTest(unittest.TestCase): 8 | def test_toJSON(self): 9 | sample = dict(a=1, b=2, c=["x", "y"]) 10 | self.assertEqual(json.dumps(sample), '{"a": 1, "b": 2, "c": ["x", "y"]}') 11 | 12 | def test_unknown_structure(self): 13 | parser = argparse.ArgumentParser() 14 | ClusterConfig.attach_arguments(parser) 15 | args = parser.parse_args(["--monitoring_kafka_rest_address=x"]) 16 | cluster_config = ClusterConfig.create_from_args(args) 17 | sample = dict(a=1, b=2, c={"x", "y"}) 18 | cluster_config.kafka_logger.log_kafka_sample( 19 | "topic", sample 20 | ) # should trigger warning log 21 | 22 | def test_kafka_log(self): 23 | parser = argparse.ArgumentParser() 24 | ClusterConfig.attach_arguments(parser) 25 | args = parser.parse_args( 26 | [] 27 | ) # set --kafka_rest_address correctly to see real actions 28 | cluster_config = ClusterConfig.create_from_args(args) 29 | sample = dict(a=1, b=2, c=["x", "y"]) 30 | cluster_config.kafka_logger.log_kafka_sample("dlltest", sample) 31 | -------------------------------------------------------------------------------- /quarkchain/cluster/tests/test_neighbor.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from quarkchain.core import Branch 4 | from quarkchain.cluster.neighbor import is_neighbor 5 | 6 | 7 | class TestNeighbor(unittest.TestCase): 8 | 9 | def test_is_neighbor_small_shard_size(self): 10 | b1 = Branch.create(32, 0) 11 | b2 = Branch.create(32, 7) 12 | self.assertTrue(is_neighbor(b1, b2)) 13 | 14 | def test_is_neighbor_one_bit_difference(self): 15 | b1 = Branch.create(64, 5) 16 | b2 = Branch.create(64, 7) 17 | self.assertTrue(is_neighbor(b1, b2)) 18 | 19 | def test_not_neighbor_two_bit_difference(self): 20 | b1 = Branch.create(64, 4) 21 | b2 = Branch.create(64, 7) 22 | self.assertFalse(is_neighbor(b1, b2)) 23 | 24 | def test_raise_different_shard_size(self): 25 | b1 = Branch.create(64, 4) 26 | b2 = Branch.create(32, 5) 27 | with self.assertRaises(AssertionError): 28 | is_neighbor(b1, b2) 29 | 30 | def test_raise_same_shard_id(self): 31 | b1 = Branch.create(64, 5) 32 | b2 = Branch.create(64, 5) 33 | with self.assertRaises(AssertionError): 34 | is_neighbor(b1, b2) -------------------------------------------------------------------------------- /quarkchain/cluster/tests/test_shard_db_operator.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from quarkchain.cluster.shard_db_operator import ShardDbOperator 4 | from quarkchain.core import Branch, MinorBlockHeader, MinorBlock, MinorBlockMeta 5 | from quarkchain.db import InMemoryDb 6 | from quarkchain.env import DEFAULT_ENV 7 | 8 | 9 | class TestShardDbOperator(unittest.TestCase): 10 | def test_get_minor_block_by_hash(self): 11 | db = ShardDbOperator(InMemoryDb(), DEFAULT_ENV, Branch(2)) 12 | block = MinorBlock(MinorBlockHeader(), MinorBlockMeta()) 13 | block_hash = block.header.get_hash() 14 | db.put_minor_block(block, []) 15 | self.assertEqual(db.get_minor_block_by_hash(block_hash), block) 16 | self.assertIsNone(db.get_minor_block_by_hash(b"")) 17 | 18 | self.assertEqual(db.get_minor_block_header_by_hash(block_hash), block.header) 19 | self.assertIsNone(db.get_minor_block_header_by_hash(b"")) 20 | -------------------------------------------------------------------------------- /quarkchain/diff.py: -------------------------------------------------------------------------------- 1 | from quarkchain.utils import check 2 | 3 | 4 | class EthDifficultyCalculator: 5 | """ Using metropolis or homestead algorithm (check_uncle=True or False)""" 6 | 7 | def __init__(self, cutoff, diff_factor, minimum_diff=1): 8 | self.cutoff = cutoff 9 | self.diff_factor = diff_factor 10 | self.minimum_diff = minimum_diff 11 | 12 | def calculate_diff(self, chain, create_time=None): 13 | raise NotImplementedError() 14 | 15 | def calculate_diff_with_parent(self, parent, create_time): 16 | check(parent.create_time < create_time) 17 | sign = max(1 - (create_time - parent.create_time) // self.cutoff, -99) 18 | offset = parent.difficulty // self.diff_factor 19 | return int(max(parent.difficulty + offset * sign, self.minimum_diff)) 20 | -------------------------------------------------------------------------------- /quarkchain/env.py: -------------------------------------------------------------------------------- 1 | import copy 2 | from quarkchain.config import get_default_evm_config, QuarkChainConfig 3 | from quarkchain.evm.config import Env as EvmEnv 4 | from quarkchain.db import InMemoryDb 5 | from quarkchain.cluster.cluster_config import ClusterConfig 6 | 7 | 8 | class Env: 9 | def __init__(self, db=None, evm_config=None, cluster_config=None): 10 | self.db = db or InMemoryDb() 11 | self.cluster_config = cluster_config if cluster_config else ClusterConfig() 12 | 13 | self.evm_config = evm_config or get_default_evm_config() 14 | self.evm_config["NETWORK_ID"] = self.quark_chain_config.NETWORK_ID 15 | self.evm_env = EvmEnv(db=self.db, config=self.evm_config) 16 | 17 | def set_network_id(self, network_id): 18 | self.quark_chain_config.NETWORK_ID = network_id 19 | self.evm_config["NETWORK_ID"] = network_id 20 | 21 | @property 22 | def quark_chain_config(self): 23 | return self.cluster_config.QUARKCHAIN 24 | 25 | def copy(self): 26 | return Env( 27 | self.db, 28 | dict(self.evm_config), 29 | copy.copy(self.cluster_config) if self.cluster_config else None, 30 | ) 31 | 32 | 33 | DEFAULT_ENV = Env() 34 | -------------------------------------------------------------------------------- /quarkchain/evm/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llSourcell/pyquarkchain/d1c97674af8e0002ac136f7a7aef81deef16dfbd/quarkchain/evm/__init__.py -------------------------------------------------------------------------------- /quarkchain/evm/bloom.py: -------------------------------------------------------------------------------- 1 | from quarkchain.utils import sha3_256 2 | from quarkchain.evm import utils 3 | 4 | """ 5 | Blooms are the 3-point, 2048-bit (11-bits/point) Bloom filter of each 6 | component (except data) of each log entry of each transaction. 7 | 8 | We set the bits of a 2048-bit value whose indices are given by 9 | the low order 11-bits 10 | of the first three double-bytes 11 | of the SHA3 12 | of each value. 13 | 14 | bloom(0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6) 15 | sha3: bd2b01afcd27800b54d2179edc49e2bffde5078bb6d0b204694169b1643fb108 16 | first double-bytes: bd2b, 01af, cd27 -- which leads to bits in bloom --> 1323, 431, 1319 17 | 18 | blooms in this module are of type 'int' 19 | """ 20 | 21 | BUCKETS_PER_VAL = 3 22 | 23 | 24 | def safe_ord(value): 25 | if isinstance(value, int): 26 | return value 27 | else: 28 | return ord(value) 29 | 30 | 31 | def bloom(val: bytes): 32 | return bloom_insert(0, val) 33 | 34 | 35 | def bloom_insert(bloom: int, val: bytes): 36 | h = sha3_256(val) 37 | for i in range(0, BUCKETS_PER_VAL * 2, 2): 38 | bloom |= 1 << ((safe_ord(h[i + 1]) + (safe_ord(h[i]) << 8)) & 2047) 39 | return bloom 40 | 41 | 42 | def bloom_bits(val: bytes): 43 | h = sha3_256(val) 44 | return [ 45 | bits_in_number(1 << ((safe_ord(h[i + 1]) + (safe_ord(h[i]) << 8)) & 2047)) 46 | for i in range(0, BUCKETS_PER_VAL * 2, 2) 47 | ] 48 | 49 | 50 | def bits_in_number(val: int): 51 | assert isinstance(val, int) 52 | return [n for n in range(2048) if (1 << n) & val] 53 | 54 | 55 | def bloom_query(bloom: int, val: bytes): 56 | bloom2 = bloom_insert(0, val) 57 | return (bloom & bloom2) == bloom2 58 | 59 | 60 | def bloom_combine(*args): 61 | bloom = 0 62 | for arg in args: 63 | bloom |= arg 64 | return bloom 65 | 66 | 67 | def bloom_from_list(args): 68 | return bloom_combine(*[bloom_insert(0, arg) for arg in args]) 69 | 70 | 71 | def b64(int_bloom): 72 | "returns b256" 73 | return utils.zpad(utils.int_to_big_endian(int_bloom), 256) 74 | -------------------------------------------------------------------------------- /quarkchain/evm/common.py: -------------------------------------------------------------------------------- 1 | import rlp 2 | from quarkchain.utils import sha3_256 3 | 4 | 5 | class FakeHeader(): 6 | """ A Fake Minor Block Header 7 | TODO: Move non-root-chain 8 | """ 9 | 10 | def __init__(self, hash=b'\x00' * 32, number=0, timestamp=0, difficulty=1, 11 | gas_limit=3141592, gas_used=0, uncles_hash=sha3_256(rlp.encode([]))): 12 | self.hash = hash 13 | self.number = number 14 | self.timestamp = timestamp 15 | self.difficulty = difficulty 16 | self.gas_limit = gas_limit 17 | self.gas_used = gas_used 18 | self.uncles_hash = uncles_hash 19 | 20 | def get_hash(self): 21 | return self.hash 22 | -------------------------------------------------------------------------------- /quarkchain/evm/exceptions.py: -------------------------------------------------------------------------------- 1 | class UnknownParentException(Exception): 2 | pass 3 | 4 | 5 | class VerificationFailed(Exception): 6 | pass 7 | 8 | 9 | class InvalidTransaction(Exception): 10 | pass 11 | 12 | 13 | class UnsignedTransaction(InvalidTransaction): 14 | pass 15 | 16 | 17 | class InvalidNonce(InvalidTransaction): 18 | pass 19 | 20 | 21 | class InsufficientBalance(InvalidTransaction): 22 | pass 23 | 24 | 25 | class InsufficientStartGas(InvalidTransaction): 26 | pass 27 | 28 | 29 | class BlockGasLimitReached(InvalidTransaction): 30 | pass 31 | 32 | 33 | class GasPriceTooLow(InvalidTransaction): 34 | pass 35 | -------------------------------------------------------------------------------- /quarkchain/evm/fast_rlp.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import rlp 3 | from quarkchain.evm.utils import ( 4 | int_to_big_endian, 5 | big_endian_to_int, 6 | safe_ord, 7 | ) 8 | 9 | 10 | def _encode_optimized(item): 11 | """RLP encode (a nested sequence of) bytes""" 12 | if isinstance(item, bytes): 13 | if len(item) == 1 and ord(item) < 128: 14 | return item 15 | prefix = length_prefix(len(item), 128) 16 | else: 17 | item = b''.join([_encode_optimized(x) for x in item]) 18 | prefix = length_prefix(len(item), 192) 19 | return prefix + item 20 | 21 | 22 | def length_prefix(length, offset): 23 | """Construct the prefix to lists or strings denoting their length. 24 | 25 | :param length: the length of the item in bytes 26 | :param offset: ``0x80`` when encoding raw bytes, ``0xc0`` when encoding a 27 | list 28 | """ 29 | if length < 56: 30 | return chr(offset + length) 31 | else: 32 | length_string = int_to_big_endian(length) 33 | return chr(offset + 56 - 1 + len(length_string)) + length_string 34 | 35 | 36 | def _decode_optimized(rlp): 37 | o = [] 38 | pos = 0 39 | _typ, _len, pos = consume_length_prefix(rlp, pos) 40 | if _typ != list: 41 | return rlp[pos: pos + _len] 42 | while pos < len(rlp): 43 | _, _l, _p = consume_length_prefix(rlp, pos) 44 | o.append(_decode_optimized(rlp[pos: _l + _p])) 45 | pos = _l + _p 46 | return o 47 | 48 | 49 | def consume_length_prefix(rlp, start): 50 | """Read a length prefix from an RLP string. 51 | 52 | :param rlp: the rlp string to read from 53 | :param start: the position at which to start reading 54 | :returns: a tuple ``(type, length, end)``, where ``type`` is either ``str`` 55 | or ``list`` depending on the type of the following payload, 56 | ``length`` is the length of the payload in bytes, and ``end`` is 57 | the position of the first payload byte in the rlp string 58 | """ 59 | b0 = safe_ord(rlp[start]) 60 | if b0 < 128: # single byte 61 | return (str, 1, start) 62 | elif b0 < 128 + 56: # short string 63 | return (str, b0 - 128, start + 1) 64 | elif b0 < 192: # long string 65 | ll = b0 - 128 - 56 + 1 66 | l = big_endian_to_int(rlp[start + 1:start + 1 + ll]) 67 | return (str, l, start + 1 + ll) 68 | elif b0 < 192 + 56: # short list 69 | return (list, b0 - 192, start + 1) 70 | else: # long list 71 | ll = b0 - 192 - 56 + 1 72 | l = big_endian_to_int(rlp[start + 1:start + 1 + ll]) 73 | return (list, l, start + 1 + ll) 74 | 75 | 76 | def optimized_decode_single(x, pos): 77 | z = safe_ord(x[pos]) 78 | if z < 128: 79 | return x[pos: pos + 1], 1 80 | elif z < 184: 81 | return x[pos + 1: pos + z - 127], z - 127 82 | else: 83 | ll = big_endian_to_int(x[pos + 1: pos + z - 182]) 84 | return x[pos + z - 182: pos + z - 182 + ll], z - 182 + ll 85 | 86 | 87 | def optimized_decode_list(rlp): 88 | o, pos = [], 0 89 | _typ, _len, pos = consume_length_prefix(rlp, pos) 90 | while pos < len(rlp): 91 | x, inc = optimized_decode_single(rlp, pos) 92 | pos += inc 93 | o.append(x) 94 | return o 95 | 96 | 97 | # 98 | if sys.version_info.major == 2: 99 | encode_optimized = _encode_optimized 100 | decode_optimized = _decode_optimized 101 | else: 102 | encode_optimized = rlp.codec.encode_raw 103 | # rlp does not implement a decode_raw function. 104 | # decode_optimized = rlp.codec.decode_raw 105 | decode_optimized = _decode_optimized -------------------------------------------------------------------------------- /quarkchain/evm/securetrie.py: -------------------------------------------------------------------------------- 1 | from quarkchain import utils 2 | 3 | 4 | class SecureTrie(object): 5 | 6 | def __init__(self, t): 7 | self.trie = t 8 | self.db = t.db 9 | 10 | def update(self, k, v): 11 | h = utils.sha3_256(k) 12 | self.db.put(h, k) 13 | self.trie.update(h, v) 14 | 15 | def get(self, k): 16 | return self.trie.get(utils.sha3_256(k)) 17 | 18 | def delete(self, k): 19 | self.trie.delete(utils.sha3_256(k)) 20 | 21 | def to_dict(self): 22 | o = {} 23 | for h, v in list(self.trie.to_dict().items()): 24 | k = self.db.get(h) 25 | o[k] = v 26 | return o 27 | 28 | def iter_branch(self): 29 | for h, v in self.trie.iter_branch(): 30 | k = self.db.get(h) 31 | yield (k, v) 32 | 33 | def root_hash_valid(self): 34 | return self.trie.root_hash_valid() 35 | 36 | @property 37 | def root_hash(self): 38 | return self.trie.root_hash 39 | 40 | @root_hash.setter 41 | def root_hash(self, value): 42 | self.trie.root_hash = value 43 | 44 | @property 45 | def deletes(self): 46 | return self.trie.deletes 47 | 48 | @deletes.setter 49 | def deletes(self, value): 50 | self.trie.deletes = value 51 | 52 | def process_epoch(self, epoch): 53 | self.trie.process_epoch(epoch) 54 | 55 | def commit_death_row(self, epoch): 56 | self.trie.commit_death_row(epoch) 57 | 58 | def revert_epoch(self, epoch): 59 | self.trie.revert_epoch(epoch) 60 | -------------------------------------------------------------------------------- /quarkchain/evm/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llSourcell/pyquarkchain/d1c97674af8e0002ac136f7a7aef81deef16dfbd/quarkchain/evm/tests/__init__.py -------------------------------------------------------------------------------- /quarkchain/evm/tests/conftest.py: -------------------------------------------------------------------------------- 1 | collect_ignore = ["test_state.py"] 2 | -------------------------------------------------------------------------------- /quarkchain/evm/tests/test_solidity_abi.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from quarkchain.evm.solidity_abi_utils import tx_to_typed_data, solidity_pack, typed_signature_hash 3 | from quarkchain.evm.transactions import Transaction 4 | 5 | 6 | class TestTypedSignature(unittest.TestCase): 7 | 8 | 9 | raw_tx = Transaction(nonce=0x0d, 10 | gasprice=0x02540be400, 11 | startgas=0x7530, 12 | to=bytes.fromhex('314b2cd22c6d26618ce051a58c65af1253aecbb8'), 13 | value=0x056bc75e2d63100000, 14 | data=b'', 15 | from_full_shard_id=0xc47decfd, 16 | to_full_shard_id=0xc49c1950, 17 | network_id=0x03) 18 | 19 | 20 | tx = [ 21 | { 22 | "type": "uint256", 23 | "name": "nonce", 24 | "value": "0x0d" 25 | }, 26 | { 27 | "type": "uint256", 28 | "name": "gasPrice", 29 | "value": "0x02540be400" 30 | }, 31 | { 32 | "type": "uint256", 33 | "name": "gasLimit", 34 | "value": "0x7530" 35 | }, 36 | { 37 | "type": "uint160", 38 | "name": "to", 39 | "value": "0x314b2cd22c6d26618ce051a58c65af1253aecbb8" 40 | }, 41 | { 42 | "type": "uint256", 43 | "name": "value", 44 | "value": "0x056bc75e2d63100000" 45 | }, 46 | { 47 | "type": "bytes", 48 | "name": "data", 49 | "value": "0x" 50 | }, 51 | { 52 | "type": "uint32", 53 | "name": "fromFullShardId", 54 | "value": "0xc47decfd" 55 | }, 56 | { 57 | "type": "uint32", 58 | "name": "toFullShardId", 59 | "value": "0xc49c1950" 60 | }, 61 | { 62 | "type": "uint256", 63 | "name": "networkId", 64 | "value": "0x03" 65 | }, 66 | { 67 | "type": "string", 68 | "name": "qkcDomain", 69 | "value": "bottom-quark" 70 | } 71 | ] 72 | 73 | 74 | def test_typed(self): 75 | assert tx_to_typed_data(self.raw_tx) == self.tx 76 | 77 | 78 | def test_solidity_pack(self): 79 | schema = list(map(lambda x: "{} {}".format(x["type"], x["name"]), self.tx)) 80 | types = list(map(lambda x: x["type"], self.tx)) 81 | data = list(map(lambda x: bytes.fromhex(x['value'][2:]) if x['type'] == "bytes" else x['value'], self.tx)) 82 | h1 = solidity_pack(['string'] * len(self.tx), schema) 83 | h2 = solidity_pack(types, data) 84 | assert h1.hex() == "75696e74323536206e6f6e636575696e7432353620676173507269636575696e74323536206761734c696d697475696e7431363020746f75696e743235362076616c75656279746573206461746175696e7433322066726f6d46756c6c5368617264496475696e74333220746f46756c6c5368617264496475696e74323536206e6574776f726b4964737472696e6720716b63446f6d61696e" 85 | assert h2.hex() == "000000000000000000000000000000000000000000000000000000000000000d00000000000000000000000000000000000000000000000000000002540be4000000000000000000000000000000000000000000000000000000000000007530314b2cd22c6d26618ce051a58c65af1253aecbb80000000000000000000000000000000000000000000000056bc75e2d63100000c47decfdc49c19500000000000000000000000000000000000000000000000000000000000000003626f74746f6d2d717561726b" 86 | 87 | 88 | def test_typed_signature_hash(self): 89 | h = typed_signature_hash(self.tx) 90 | assert h == "0x57dfcc7be8e4249fb6e75a45dc5ecdfed0309ed951b6adc69b8a659c7eca33bf" 91 | 92 | 93 | def test_recover(self): 94 | """ 95 | """ 96 | self.raw_tx._in_mutable_context = True 97 | self.raw_tx.version = 1 98 | self.raw_tx.r = 0xb5145678e43df2b7ea8e0e969e51dbf72c956dd52e234c95393ad68744394855 99 | self.raw_tx.s = 0x44515b465dbbf746a484239c11adb98f967e35347e17e71b84d850d8e5c38a6a 100 | self.raw_tx.v = 0x1b 101 | self.raw_tx._in_mutable_context = False 102 | assert self.raw_tx.sender == bytes.fromhex('8b74a79290a437aa9589be3227d9bb81b22beff1') 103 | -------------------------------------------------------------------------------- /quarkchain/evm/tests/test_state.py: -------------------------------------------------------------------------------- 1 | import json 2 | import sys 3 | from quarkchain.evm.tests import new_statetest_utils, testutils 4 | 5 | from quarkchain.evm.slogging import get_logger, configure_logging 6 | logger = get_logger() 7 | # customize VM log output to your needs 8 | # hint: use 'py.test' with the '-s' option to dump logs to the console 9 | if '--trace' in sys.argv: # not default 10 | configure_logging(':trace') 11 | sys.argv.remove('--trace') 12 | 13 | checker = new_statetest_utils.verify_state_test 14 | place_to_check = 'GeneralStateTests' 15 | 16 | 17 | def test_state(filename, testname, testdata): 18 | logger.debug('running test:%r in %r' % (testname, filename)) 19 | try: 20 | checker(testdata) 21 | except new_statetest_utils.EnvNotFoundException: 22 | pass 23 | 24 | 25 | def exclude_func(filename, _, __): 26 | return ( 27 | 'stQuadraticComplexityTest' in filename or # Takes too long 28 | 'stMemoryStressTest' in filename or # We run out of memory 29 | 'MLOAD_Bounds.json' in filename or # We run out of memory 30 | # we know how to pass: force address 3 to get deleted. TODO confer 31 | # with c++ best path foward. 32 | 'failed_tx_xcf416c53' in filename or 33 | # we know how to pass: delete contract's code. Looks like c++ 34 | # issue. 35 | 'RevertDepthCreateAddressCollision.json' in filename or 36 | 'pairingTest.json' in filename or # definitely a c++ issue 37 | 'createJS_ExampleContract' in filename or # definitely a c++ issue 38 | # Existing failed tests in pyeth test (commit 69f55e86081) 39 | 'static_CallEcrecoverR_prefixed0.json' in filename or 40 | 'CallEcrecoverR_prefixed0.json' in filename or 41 | 'CALLCODEEcrecoverR_prefixed0.json' in filename or 42 | 'static_CallEcrecover80.json' in filename or 43 | 'CallEcrecover80.json' in filename or 44 | 'CALLCODEEcrecover80.json' in filename 45 | ) 46 | 47 | 48 | def pytest_generate_tests(metafunc): 49 | testutils.generate_test_params( 50 | place_to_check, 51 | metafunc, 52 | exclude_func=exclude_func 53 | ) 54 | 55 | 56 | def main(): 57 | global fixtures, filename, tests, testname, testdata 58 | if len(sys.argv) == 1: 59 | # read fixture from stdin 60 | fixtures = {'stdin': json.load(sys.stdin)} 61 | else: 62 | # load fixtures from specified file or dir 63 | try: 64 | fixtures = testutils.get_tests_from_file_or_dir(sys.argv[1]) 65 | except BaseException: 66 | fixtures = {'stdin': json.loads(sys.argv[1])} 67 | for filename, tests in list(fixtures.items()): 68 | for testname, testdata in list(tests.items()): 69 | if len(sys.argv) < 3 or testname == sys.argv[2]: 70 | if exclude_func(filename, None, None): 71 | print("Skipping: %s %s" % (filename, testname)) 72 | continue 73 | print("Testing: %s %s" % (filename, testname)) 74 | checker(testdata) 75 | 76 | 77 | if __name__ == '__main__': 78 | main() 79 | -------------------------------------------------------------------------------- /quarkchain/evm/tests/test_transaction_queue.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from quarkchain.evm.transactions import Transaction 4 | from quarkchain.evm.transaction_queue import OrderableTx, TransactionQueue 5 | 6 | 7 | def make_test_tx(s=100000, g=50, data=b'', nonce=0): 8 | return Transaction(nonce=nonce, startgas=s, gasprice=g, 9 | value=0, data=data, to=b'\x35' * 20) 10 | 11 | 12 | class TestTransactionQueue(unittest.TestCase): 13 | 14 | def test(self): 15 | q = TransactionQueue() 16 | # (startgas, gasprice) pairs 17 | params = [(100000, 81), (50000, 74), (40000, 65), 18 | (60000, 39), (30000, 50), (30000, 50), 19 | (30000, 80)] 20 | # (maxgas, expected_startgas, expected_gasprice) triplets 21 | operations = [(999999, 100000, 81), 22 | (999999, 30000, 80), 23 | (30000, 30000, 50), 24 | (29000, None, None), 25 | (30000, 30000, 50), 26 | (30000, None, None), 27 | (999999, 50000, 74)] 28 | # Add transactions to queue 29 | for param in params: 30 | q.add_transaction(make_test_tx(s=param[0], g=param[1])) 31 | # Attempt pops from queue 32 | for (maxgas, expected_s, expected_g) in operations: 33 | tx = q.pop_transaction(max_gas=maxgas) 34 | if tx: 35 | assert (tx.startgas, tx.gasprice) == (expected_s, expected_g) 36 | else: 37 | assert expected_s is expected_g is None 38 | print('Test successful') 39 | 40 | def test_diff(self): 41 | tx1 = make_test_tx(data=b'foo') 42 | tx2 = make_test_tx(data=b'bar') 43 | tx3 = make_test_tx(data=b'baz') 44 | tx4 = make_test_tx(data=b'foobar') 45 | q1 = TransactionQueue() 46 | for tx in [tx1, tx2, tx3, tx4]: 47 | q1.add_transaction(tx) 48 | q2 = q1.diff([tx2]) 49 | assert len(q2) == 3 50 | assert tx1 in [item.tx for item in q2.txs] 51 | assert tx3 in [item.tx for item in q2.txs] 52 | assert tx4 in [item.tx for item in q2.txs] 53 | 54 | q3 = q2.diff([tx4]) 55 | assert len(q3) == 2 56 | assert tx1 in [item.tx for item in q3.txs] 57 | assert tx3 in [item.tx for item in q3.txs] 58 | 59 | def test_orderable_tx(self): 60 | assert OrderableTx(-1, 0, None) < OrderableTx(0, 0, None) 61 | assert OrderableTx(-1, 0, None) < OrderableTx(-1, 1, None) 62 | assert not OrderableTx(1, 0, None) < OrderableTx(-1, 0, None) 63 | assert not OrderableTx(1, 1, None) < OrderableTx(-1, 0, None) 64 | 65 | def test_ordering_for_same_prio(self): 66 | q = TransactionQueue() 67 | count = 10 68 | # Add transactions to the queue, all with the same 69 | # startgas/gasprice but with sequential nonces. 70 | for i in range(count): 71 | q.add_transaction(make_test_tx(nonce=i)) 72 | 73 | expected_nonce_order = [i for i in range(count)] 74 | nonces = [] 75 | for i in range(count): 76 | tx = q.pop_transaction() 77 | nonces.append(tx.nonce) 78 | # Since they have the same gasprice they should have the same priority and 79 | # thus be popped in the order they were inserted. 80 | assert nonces == expected_nonce_order 81 | -------------------------------------------------------------------------------- /quarkchain/evm/tests/test_trie.py: -------------------------------------------------------------------------------- 1 | import os 2 | import json 3 | import quarkchain.evm.trie as trie 4 | from quarkchain.db import InMemoryDb 5 | import itertools 6 | from quarkchain.utils import Logger 7 | import unittest 8 | 9 | # customize VM log output to your needs 10 | # hint: use 'py.test' with the '-s' option to dump logs to the console 11 | # configure_logging(':trace') 12 | 13 | 14 | def check_testdata(data_keys, expected_keys): 15 | assert set(data_keys) == set(expected_keys), \ 16 | "test data changed, please adjust tests" 17 | 18 | 19 | fixture_path = os.path.join(os.path.dirname(__file__), '..', '..', '..', 'fixtures') 20 | 21 | 22 | def load_tests_dict(): 23 | fixture = {} 24 | testdir = os.path.join(fixture_path, 'TrieTests') 25 | for f in os.listdir(testdir): 26 | if f != 'trietest.json': 27 | continue 28 | sub_fixture = json.load(open(os.path.join(testdir, f))) 29 | for k, v in sub_fixture.items(): 30 | fixture[f + "_" + k] = v 31 | return fixture 32 | 33 | 34 | def load_tests(loader, tests, pattern): 35 | # python3 unittest interface 36 | suite = unittest.TestSuite() 37 | for key, pairs in load_tests_dict().items(): 38 | test = unittest.FunctionTestCase((lambda key, pairs: lambda: run_test(key, pairs))(key, pairs), description=key) 39 | suite.addTests([test]) 40 | return suite 41 | 42 | 43 | def run_test(name, pairs): 44 | Logger.debug('testing %s' % name) 45 | 46 | def _dec(x): 47 | if isinstance(x, str) and x.startswith('0x'): 48 | return bytes.fromhex(str(x[2:])) 49 | if isinstance(x, str): 50 | return bytes(x, "ascii") 51 | return x 52 | 53 | pairs['in'] = [(_dec(k), _dec(v)) for k, v in pairs['in']] 54 | deletes = [(k, v) for k, v in pairs['in'] if v is None] 55 | 56 | N_PERMUTATIONS = 100 57 | for i, permut in enumerate(itertools.permutations(pairs['in'])): 58 | if i > N_PERMUTATIONS: 59 | break 60 | if pairs.get('nopermute', None) is not None and pairs['nopermute']: 61 | permut = pairs['in'] 62 | N_PERMUTATIONS = 1 63 | t = trie.Trie(InMemoryDb()) 64 | for k, v in permut: 65 | # logger.debug('updating with (%s, %s)' %(k, v)) 66 | if v is not None: 67 | t.update(k, v) 68 | else: 69 | t.delete(k) 70 | # make sure we have deletes at the end 71 | for k, v in deletes: 72 | t.delete(k) 73 | if pairs['root'] != '0x' + t.root_hash.hex(): 74 | raise Exception("Mismatch: %r %r %r %r" % ( 75 | name, pairs['root'], '0x' + t.root_hash.hex(), (i, list(permut) + deletes))) 76 | 77 | 78 | if __name__ == '__main__': 79 | for name, pairs in load_tests_dict().items(): 80 | run_test(name, pairs) 81 | -------------------------------------------------------------------------------- /quarkchain/evm/tests/testutils.py: -------------------------------------------------------------------------------- 1 | import os 2 | import json 3 | 4 | 5 | fixture_path = os.path.join(os.path.dirname(__file__), '../..', 'fixtures') 6 | 7 | 8 | def generate_test_params(testsource, metafunc, 9 | skip_func=None, exclude_func=None): 10 | import pytest 11 | if ['filename', 'testname', 'testdata'] != metafunc.fixturenames: 12 | return 13 | 14 | fixtures = get_tests_from_file_or_dir( 15 | os.path.join(fixture_path, testsource)) 16 | 17 | base_dir = os.path.dirname(os.path.dirname(__file__)) 18 | params = [] 19 | for filename, tests in fixtures.items(): 20 | if isinstance(tests, dict): 21 | filename = os.path.relpath(filename, base_dir) 22 | for testname, testdata in tests.items(): 23 | if exclude_func and exclude_func(filename, testname, testdata): 24 | continue 25 | if skip_func: 26 | skipif = pytest.mark.skipif( 27 | skip_func(filename, testname, testdata), 28 | reason="Excluded" 29 | ) 30 | params.append(skipif((filename, testname, testdata))) 31 | else: 32 | params.append((filename, testname, testdata)) 33 | 34 | metafunc.parametrize( 35 | ('filename', 'testname', 'testdata'), 36 | params 37 | ) 38 | return params[::-1] 39 | 40 | 41 | def get_tests_from_file_or_dir(dname, json_only=False): 42 | if os.path.isfile(dname): 43 | if dname[-5:] == '.json' or not json_only: 44 | with open(dname) as f: 45 | return {dname: json.load(f)} 46 | else: 47 | return {} 48 | else: 49 | o = {} 50 | for f in os.listdir(dname): 51 | fullpath = os.path.join(dname, f) 52 | for k, v in list(get_tests_from_file_or_dir( 53 | fullpath, True).items()): 54 | o[k] = v 55 | return o 56 | -------------------------------------------------------------------------------- /quarkchain/evm/transaction_queue.py: -------------------------------------------------------------------------------- 1 | import heapq 2 | heapq.heaptop = lambda x: x[0] 3 | PRIO_INFINITY = -2**100 4 | 5 | 6 | class OrderableTx(object): 7 | 8 | def __init__(self, prio, counter, tx): 9 | self.prio = prio 10 | self.counter = counter 11 | self.tx = tx 12 | 13 | def __lt__(self, other): 14 | if self.prio < other.prio: 15 | return True 16 | elif self.prio == other.prio: 17 | return self.counter < other.counter 18 | else: 19 | return False 20 | 21 | 22 | class TransactionQueue(): 23 | 24 | def __init__(self): 25 | self.counter = 0 26 | self.txs = [] 27 | self.aside = [] 28 | 29 | def __len__(self): 30 | return len(self.txs) 31 | 32 | def add_transaction(self, tx, force=False): 33 | prio = PRIO_INFINITY if force else -tx.gasprice 34 | heapq.heappush(self.txs, OrderableTx(prio, self.counter, tx)) 35 | self.counter += 1 36 | 37 | def pop_transaction(self, max_gas=9999999999, 38 | max_seek_depth=16, min_gasprice=0): 39 | while len(self.aside) and max_gas >= heapq.heaptop(self.aside).prio: 40 | item = heapq.heappop(self.aside) 41 | item.prio = -item.tx.gasprice 42 | heapq.heappush(self.txs, item) 43 | for i in range(min(len(self.txs), max_seek_depth)): 44 | item = heapq.heaptop(self.txs) 45 | if item.tx.startgas > max_gas: 46 | heapq.heappop(self.txs) 47 | item.prio = item.tx.startgas 48 | heapq.heappush(self.aside, item) 49 | elif item.tx.gasprice >= min_gasprice or item.prio == PRIO_INFINITY: 50 | heapq.heappop(self.txs) 51 | return item.tx 52 | else: 53 | return None 54 | return None 55 | 56 | def peek(self, num=None): 57 | if num: 58 | return self.txs[0:num] 59 | else: 60 | return self.txs 61 | 62 | def diff(self, txs): 63 | remove_hashes = [tx.hash for tx in txs] 64 | keep_txs = [item for item in self.txs if item.tx.hash not in remove_hashes] 65 | keep_aside = [item for item in self.aside if item.tx.hash not in remove_hashes] 66 | q = TransactionQueue() 67 | q.txs = keep_txs 68 | q.aside = keep_aside 69 | heapq.heapify(q.txs) 70 | heapq.heapify(q.aside) 71 | return q 72 | -------------------------------------------------------------------------------- /quarkchain/experimental/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llSourcell/pyquarkchain/d1c97674af8e0002ac136f7a7aef81deef16dfbd/quarkchain/experimental/__init__.py -------------------------------------------------------------------------------- /quarkchain/experimental/diff.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | # Simple moving average difficulty 4 | 5 | 6 | class MADifficultyCalculator: 7 | def __init__( 8 | self, ma_samples=16, target_interval_sec=1, bootstrap_samples=0, slide_size=1 9 | ): 10 | self.ma_samples = ma_samples 11 | self.target_interval_sec = target_interval_sec 12 | self.bootstrap_samples = bootstrap_samples 13 | self.slide_size = slide_size 14 | 15 | # Obtain the difficulty required for the next block 16 | def calculate_diff(self, chain): 17 | assert len(chain) >= 1 18 | gensis_diff = chain[0].get_required_diff() 19 | chain = chain[: len(chain) // self.slide_size * self.slide_size] 20 | if len(chain) <= self.bootstrap_samples + 1: 21 | return gensis_diff 22 | 23 | samples = self.ma_samples 24 | if len(chain) < samples + 1: 25 | samples = len(chain) - 1 26 | 27 | work_done = 0 28 | for block in chain[-samples:]: 29 | work_done = work_done + 1 / block.get_required_diff() 30 | 31 | time_used_sec = ( 32 | chain[-1].get_create_time_sec() - chain[-1 - samples].get_create_time_sec() 33 | ) 34 | 35 | return time_used_sec / self.target_interval_sec / work_done 36 | 37 | 38 | class FixedDifficultyCalculator: 39 | def __init__(self, diff): 40 | self.diff = diff 41 | 42 | def calculate_diff(self, chain): 43 | return self.diff 44 | -------------------------------------------------------------------------------- /quarkchain/experimental/event_driven_simulator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import enum 4 | import heap 5 | 6 | 7 | class Task: 8 | class State(enum.Enum): 9 | SCHEDULED = 0 10 | FINISHED = 1 11 | CANCELLED = 2 12 | 13 | def __init__(self, scheduler, ts, callback, data): 14 | self.heap_index = 0 15 | self.scheduler = scheduler 16 | self.ts = ts 17 | self.callback = callback 18 | self.data = data 19 | self.state = Task.State.SCHEDULED 20 | 21 | def cancel(self): 22 | assert self.state == Task.State.SCHEDULED 23 | self.scheduler.cancel(self) 24 | 25 | def run(self): 26 | assert self.state == Task.State.SCHEDULED 27 | self.callback(self.ts, self.data) 28 | self.state = Task.State.FINISHED 29 | 30 | 31 | class Scheduler: 32 | def __init__(self): 33 | self.ts = 0 34 | self.pq = heap.Heap(lambda task1, task2: task1.ts - task2.ts) 35 | self.terminated = False 36 | self.stopped = False 37 | 38 | def schedule_after(self, duration, callback, data): 39 | if self.stopped: 40 | return None 41 | task = Task(self, self.ts + duration, callback, data) 42 | self.pq.push(task) 43 | return task 44 | 45 | def cancel(self, task): 46 | self.pq.pop(task) 47 | 48 | def terminate(self): 49 | """ Terminate the scheduler immediately 50 | """ 51 | self.terminated = True 52 | 53 | def stop(self): 54 | """ Stop the scheduler. schedule_after() will return None thereafter. 55 | """ 56 | self.stopped = True 57 | 58 | def loop_until_no_task(self): 59 | while not self.pq.is_empty() and not self.terminated: 60 | task = self.pq.pop_top() 61 | assert task.ts >= self.ts 62 | self.ts = task.ts 63 | task.run() 64 | -------------------------------------------------------------------------------- /quarkchain/experimental/future.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import asyncio 4 | 5 | 6 | async def slow_operation(future): 7 | await asyncio.sleep(1) 8 | future.set_result("Future is done") 9 | 10 | 11 | async def int_operation(future): 12 | await asyncio.sleep(0.5) 13 | future.cancel() 14 | 15 | 16 | async def next_operation(): 17 | future = asyncio.Future() 18 | asyncio.run_coroutine_threadsafe(slow_operation(future), asyncio.get_event_loop()) 19 | asyncio.run_coroutine_threadsafe(int_operation(future), asyncio.get_event_loop()) 20 | await future 21 | print("Done") 22 | 23 | 24 | loop = asyncio.get_event_loop() 25 | 26 | loop.run_until_complete(next_operation()) 27 | -------------------------------------------------------------------------------- /quarkchain/experimental/heap.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | 4 | # An implementation of heap that is able to quickly remove any item in 5 | # O(1) by assuming an item has an heap_index field. 6 | 7 | 8 | class Heap: 9 | def __init__(self, cmp): 10 | self.heap = [] 11 | self.heap_size = 0 12 | self.cmp = cmp 13 | 14 | def __assert_item(self, item): 15 | assert self.heap[item.heap_index] == item 16 | 17 | def __swap(self, item1, item2): 18 | self.__assert_item(item1) 19 | self.__assert_item(item2) 20 | self.heap[item1.heap_index] = item2 21 | self.heap[item2.heap_index] = item1 22 | tmp = item1.heap_index 23 | item1.heap_index = item2.heap_index 24 | item2.heap_index = tmp 25 | 26 | def __get_parent(self, item): 27 | assert item.heap_index != 0 28 | return self.heap[(item.heap_index - 1) // 2] 29 | 30 | def __get_left_child(self, item): 31 | index = item.heap_index * 2 + 1 32 | if index >= self.heap_size: 33 | return None 34 | return self.heap[index] 35 | 36 | def __get_right_child(self, item): 37 | index = item.heap_index * 2 + 2 38 | if index >= self.heap_size: 39 | return None 40 | return self.heap[index] 41 | 42 | def __sift_up(self, item): 43 | assert self.heap[item.heap_index] == item 44 | while item.heap_index != 0: 45 | parent = self.__get_parent(item) 46 | if self.cmp(parent, item) <= 0: 47 | return 48 | self.__swap(parent, item) 49 | 50 | def __sift_down(self, item): 51 | while True: 52 | left_child = self.__get_left_child(item) 53 | if left_child is None: 54 | return 55 | 56 | right_child = self.__get_right_child(item) 57 | min_child = left_child 58 | if right_child is not None and self.cmp(right_child, left_child) < 0: 59 | min_child = right_child 60 | 61 | if self.cmp(min_child, item) < 0: 62 | self.__swap(item, min_child) 63 | else: 64 | break 65 | 66 | def push(self, item): 67 | if self.heap_size == len(self.heap): 68 | self.heap.append(item) 69 | else: 70 | self.heap[self.heap_size] = item 71 | item.heap_index = self.heap_size 72 | self.heap_size += 1 73 | self.__sift_up(item) 74 | 75 | def pop(self, item): 76 | last_item = self.heap[self.heap_size - 1] 77 | self.__swap(item, last_item) 78 | self.heap_size -= 1 79 | self.heap[self.heap_size] = None 80 | if last_item != item: 81 | # TODO: Optimize 82 | self.__sift_down(last_item) 83 | self.__sift_up(last_item) 84 | return item 85 | 86 | def pop_top(self): 87 | return self.pop(self.heap[0]) 88 | 89 | def size(self): 90 | return self.heap_size 91 | 92 | def is_empty(self): 93 | return self.heap_size == 0 94 | 95 | def __str__(self): 96 | return str(self.heap[: self.heap_size]) 97 | 98 | # self check, used for testing only 99 | def check_integrity(self): 100 | for i in range(self.heap_size): 101 | item = self.heap[i] 102 | if i != 0: 103 | parent = self.__get_parent(item) 104 | if self.cmp(item, parent) < 0: 105 | return False 106 | left_child = self.__get_left_child(item) 107 | if left_child is not None and self.cmp(left_child, item) < 0: 108 | return False 109 | right_child = self.__get_right_child(item) 110 | if right_child is not None and self.cmp(right_child, item) < 0: 111 | return False 112 | return True 113 | -------------------------------------------------------------------------------- /quarkchain/experimental/proof_of_work.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import asyncio 4 | import numpy.random 5 | import time 6 | 7 | 8 | class PoW: 9 | # hash_power, number of hashs per second 10 | def __init__(self, hash_power): 11 | self.hash_power = hash_power 12 | 13 | # Return a realization of mining time in sec 14 | def mine(self, diff): 15 | return numpy.random.exponential(1 / diff / self.hash_power) 16 | 17 | 18 | async def test_po_w(): 19 | hash_power = 100 20 | diff = 0.01 21 | # Target block rate is 1sec 22 | p = PoW(hash_power) 23 | for i in range(10): 24 | start_time = time.time() 25 | await asyncio.sleep(p.mine(diff)) 26 | used_time = time.time() - start_time 27 | print(used_time) 28 | 29 | 30 | def main(): 31 | loop = asyncio.get_event_loop() 32 | loop.run_until_complete(test_po_w()) 33 | 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /quarkchain/experimental/sha3_perf.py: -------------------------------------------------------------------------------- 1 | 2 | # Performance of verification of transactions 3 | # 4 | # Some numbers on my machine (i7 7700K 4.2 GHZ): 5 | # SHA3 80000 shas/sec 6 | # One i7 4700K 3.5 GHZ): 7 | # SHA3 69000 shas/sec with pycryptodome. 8 | # SHA3 134000 shas/sec with pysha3. 9 | 10 | from quarkchain.core import MinorBlockHeader 11 | import argparse 12 | import time 13 | import profile 14 | 15 | 16 | def test_perf(): 17 | N = 20000 18 | start_time = time.time() 19 | m_header = MinorBlockHeader() 20 | for i in range(N): 21 | m_header.nonce = i 22 | m_header.get_hash() 23 | duration = time.time() - start_time 24 | print("TPS: %.2f" % (N / duration)) 25 | 26 | 27 | def main(): 28 | parser = argparse.ArgumentParser() 29 | parser.add_argument("--profile", default=False) 30 | args = parser.parse_args() 31 | 32 | if args.profile: 33 | profile.run("test_perf()") 34 | else: 35 | test_perf() 36 | 37 | 38 | if __name__ == "__main__": 39 | main() 40 | -------------------------------------------------------------------------------- /quarkchain/experimental/test_heap.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | from quarkchain.experimental import heap 4 | import random 5 | import unittest 6 | 7 | 8 | class HeapTestItem: 9 | def __init__(self, value): 10 | self.value = value 11 | self.heap_index = 0 12 | 13 | def __str__(self): 14 | return str(self.value) 15 | 16 | def __repr__(self): 17 | return self.__str__() 18 | 19 | 20 | class TestHeap(unittest.TestCase): 21 | def test_heap_sort(self): 22 | N = 100 23 | data = [HeapTestItem(i) for i in range(N)] 24 | random.shuffle(data) 25 | h = heap.Heap(lambda x, y: x.value - y.value) 26 | for d in data: 27 | h.push(d) 28 | self.assertTrue(h.check_integrity()) 29 | for i in range(N): 30 | self.assertEqual(h.pop_top().value, i) 31 | self.assertTrue(h.check_integrity()) 32 | self.assertTrue(h.is_empty()) 33 | 34 | def test_heap_random_pop(self): 35 | N = 100 36 | data = [HeapTestItem(i) for i in range(N)] 37 | random.shuffle(data) 38 | h = heap.Heap(lambda x, y: x.value - y.value) 39 | for d in data: 40 | h.push(d) 41 | self.assertTrue(h.check_integrity()) 42 | random.shuffle(data) 43 | for d in data: 44 | h.pop(d) 45 | self.assertTrue(h.check_integrity()) 46 | self.assertTrue(h.is_empty()) 47 | -------------------------------------------------------------------------------- /quarkchain/experimental/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llSourcell/pyquarkchain/d1c97674af8e0002ac136f7a7aef81deef16dfbd/quarkchain/experimental/tests/__init__.py -------------------------------------------------------------------------------- /quarkchain/experimental/tests/test_diff.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import quarkchain.experimental.diff as diff 3 | import quarkchain.experimental.proof_of_work as proof_of_work 4 | import statistics as stat 5 | 6 | 7 | class Block: 8 | def __init__(self, n_time=0.0, required_diff=0.1): 9 | self.n_time = n_time 10 | self.required_diff = required_diff 11 | 12 | def get_required_diff(self): 13 | return self.required_diff 14 | 15 | def get_create_time_sec(self): 16 | return self.n_time 17 | 18 | 19 | class TestMADifficulty(unittest.TestCase): 20 | def test_none_sample(self): 21 | chain = [Block(0, 0.1)] 22 | diff_calc = diff.MADifficultyCalculator(ma_samples=2, target_interval_sec=5.0) 23 | self.assertEqual(diff_calc.calculate_diff(chain), 0.1) 24 | 25 | def test_one_sample(self): 26 | chain = [Block(0, 0.1), Block(4.0, 0.1)] 27 | diff_calc = diff.MADifficultyCalculator(ma_samples=2, target_interval_sec=5.0) 28 | self.assertEqual(diff_calc.calculate_diff(chain), 0.08) 29 | 30 | def test_two_sample(self): 31 | chain = [Block(0, 0.1), Block(4.0, 0.1), Block(10, 0.08)] 32 | diff_calc = diff.MADifficultyCalculator(ma_samples=2, target_interval_sec=5.0) 33 | self.assertEqual(diff_calc.calculate_diff(chain), 1 / 11.25) 34 | 35 | 36 | def main(): 37 | target_interval_sec = 5 38 | diff_calc = diff.MADifficultyCalculator( 39 | ma_samples=32, target_interval_sec=target_interval_sec 40 | ) 41 | hash_power = 100 42 | 43 | cTime = 0.0 44 | chain = [Block(0, 0.002)] 45 | usedTimeList = [] 46 | p = proof_of_work.PoW(hash_power) 47 | 48 | for i in range(1000): 49 | required_diff = diff_calc.calculate_diff(chain) 50 | cTime = cTime + p.mine(required_diff) 51 | block = Block(cTime, required_diff) 52 | used_time = block.n_time - chain[-1].n_time 53 | chain.append(block) 54 | usedTimeList.append(used_time) 55 | print( 56 | "Time %.2f, block %d, requiredWork %.2f, used_time %.2f" 57 | % (block.n_time, i + 1, 1 / block.required_diff, used_time) 58 | ) 59 | 60 | print( 61 | "Max: %.2f, min: %.2f, avg: %.2f, std: %.2f" 62 | % ( 63 | max(usedTimeList), 64 | min(usedTimeList), 65 | stat.mean(usedTimeList), 66 | stat.stdev(usedTimeList), 67 | ) 68 | ) 69 | 70 | 71 | if __name__ == "__main__": 72 | main() 73 | -------------------------------------------------------------------------------- /quarkchain/experimental/tx_perf.py: -------------------------------------------------------------------------------- 1 | 2 | # Performance of verification of transactions 3 | # 4 | # Some numbers on my machine (i7 7700K 4.2 GHZ): 5 | # Verifications per second: 170.16 (using slow ecdsa_raw_recover) 6 | # Verifications per second: 9549.38 (using coincurve) 7 | # 8 | # The number of openssl: openssl speed ecdsap256 9 | # Verificatoins per second: 19088.5 10 | 11 | from quarkchain.tests.test_utils import create_random_test_transaction 12 | from quarkchain.core import Identity, Address 13 | from quarkchain.evm.transactions import Transaction as EvmTransaction 14 | import argparse 15 | import random 16 | import time 17 | import profile 18 | 19 | 20 | def test_perf(): 21 | N = 5000 22 | IDN = 10 23 | print("Creating %d identities" % IDN) 24 | id_list = [] 25 | for i in range(IDN): 26 | id_list.append(Identity.create_random_identity()) 27 | 28 | acc_list = [] 29 | for i in range(IDN): 30 | acc_list.append(Address.create_from_identity(id_list[i])) 31 | 32 | print("Creating %d transactions..." % N) 33 | start_time = time.time() 34 | tx_list = [] 35 | rec_list = [] 36 | for i in range(N): 37 | from_id = id_list[random.randint(0, IDN - 1)] 38 | to_addr = acc_list[random.randint(0, IDN - 1)] 39 | tx_list.append(create_random_test_transaction(from_id, to_addr)) 40 | rec_list.append(from_id.get_recipient()) 41 | duration = time.time() - start_time 42 | print("Creations PS: %.2f" % (N / duration)) 43 | 44 | print("Verifying transactions") 45 | start_time = time.time() 46 | for i in range(N): 47 | assert tx_list[i].verify_signature([rec_list[i]]) 48 | duration = time.time() - start_time 49 | print("Verifications PS: %.2f" % (N / duration)) 50 | 51 | 52 | def test_perf_evm(): 53 | N = 5000 54 | IDN = 10 55 | print("Creating %d identities" % IDN) 56 | id_list = [] 57 | for i in range(IDN): 58 | id_list.append(Identity.create_random_identity()) 59 | 60 | acc_list = [] 61 | for i in range(IDN): 62 | acc_list.append(Address.create_from_identity(id_list[i])) 63 | 64 | print("Creating %d transactions..." % N) 65 | start_time = time.time() 66 | tx_list = [] 67 | from_list = [] 68 | for i in range(N): 69 | from_id = id_list[random.randint(0, IDN - 1)] 70 | to_addr = acc_list[random.randint(0, IDN - 1)] 71 | evm_tx = EvmTransaction( 72 | nonce=0, 73 | gasprice=1, 74 | startgas=2, 75 | to=to_addr.recipient, 76 | value=3, 77 | data=b"", 78 | from_full_shard_id=0, 79 | to_full_shard_id=0, 80 | network_id=1, 81 | ) 82 | evm_tx.sign(key=from_id.get_key()) 83 | tx_list.append(evm_tx) 84 | from_list.append(from_id.get_recipient()) 85 | duration = time.time() - start_time 86 | print("Creations PS: %.2f" % (N / duration)) 87 | 88 | print("Verifying transactions") 89 | start_time = time.time() 90 | for i in range(N): 91 | tx_list[i]._sender = None 92 | assert tx_list[i].sender == from_list[i] 93 | duration = time.time() - start_time 94 | print("Verifications PS: %.2f" % (N / duration)) 95 | 96 | 97 | def main(): 98 | parser = argparse.ArgumentParser() 99 | parser.add_argument("--profile", default=False) 100 | parser.add_argument("--evm", default=False) 101 | args = parser.parse_args() 102 | 103 | if args.profile: 104 | profile.run("test_perf()") 105 | else: 106 | if args.evm: 107 | test_perf_evm() 108 | else: 109 | test_perf() 110 | 111 | 112 | if __name__ == "__main__": 113 | main() 114 | -------------------------------------------------------------------------------- /quarkchain/experimental/whitelist.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | 4 | class Candidate: 5 | def __init__(self, key, score): 6 | self.key = key 7 | self.score = score 8 | 9 | 10 | def get_whitelist(candidate_list, n, seed): 11 | random.seed(seed) 12 | white_list = [] 13 | candidate_list.sort(key=lambda p: p.key) 14 | for i in range(n): 15 | total_score = sum([p.score for p in candidate_list]) 16 | chosen = random.randint(0, total_score - 1) 17 | for idx, p in enumerate(candidate_list): 18 | if chosen <= p.score: 19 | white_list.append(p) 20 | candidate_list.pop(idx) 21 | break 22 | chosen -= p.score 23 | return white_list 24 | 25 | 26 | def generate_person_list(n, seed): 27 | random.seed(seed) 28 | return [ 29 | Candidate(key=random.random(), score=random.randint(1, 100)) for i in range(n) 30 | ] 31 | 32 | 33 | candidate_list = generate_person_list(100, 123) 34 | white_list = get_whitelist(candidate_list, 50, 321) 35 | for p in white_list: 36 | print(p.key, p.score) 37 | -------------------------------------------------------------------------------- /quarkchain/genesis.py: -------------------------------------------------------------------------------- 1 | from fractions import Fraction 2 | 3 | from quarkchain.config import QuarkChainConfig 4 | from quarkchain.core import ( 5 | Address, 6 | MinorBlockMeta, 7 | MinorBlockHeader, 8 | MinorBlock, 9 | Branch, 10 | ShardInfo, 11 | RootBlockHeader, 12 | RootBlock, 13 | ) 14 | from quarkchain.evm.state import State as EvmState 15 | from quarkchain.utils import sha3_256, check 16 | 17 | 18 | class GenesisManager: 19 | """ Manage the creation of genesis blocks based on the genesis configs from env""" 20 | 21 | def __init__(self, qkc_config: QuarkChainConfig): 22 | self._qkc_config = qkc_config 23 | 24 | def create_root_block(self) -> RootBlock: 25 | """ Create the genesis root block """ 26 | genesis = self._qkc_config.ROOT.GENESIS 27 | header = RootBlockHeader( 28 | version=genesis.VERSION, 29 | height=genesis.HEIGHT, 30 | shard_info=ShardInfo.create(genesis.SHARD_SIZE), 31 | hash_prev_block=bytes.fromhex(genesis.HASH_PREV_BLOCK), 32 | hash_merkle_root=bytes.fromhex(genesis.HASH_MERKLE_ROOT), 33 | create_time=genesis.TIMESTAMP, 34 | difficulty=genesis.DIFFICULTY, 35 | ) 36 | return RootBlock(header=header, minor_block_header_list=[]) 37 | 38 | def create_minor_block( 39 | self, root_block: RootBlock, shard_id: int, evm_state: EvmState 40 | ) -> MinorBlock: 41 | """ Create genesis block for shard. 42 | Genesis block's hash_prev_root_block is set to the genesis root block. 43 | Genesis state will be committed to the given evm_state. 44 | """ 45 | branch = Branch.create(self._qkc_config.SHARD_SIZE, shard_id) 46 | shard_config = self._qkc_config.SHARD_LIST[shard_id] 47 | genesis = shard_config.GENESIS 48 | 49 | for address_hex, amount_in_wei in genesis.ALLOC.items(): 50 | address = Address.create_from(bytes.fromhex(address_hex)) 51 | check(address.get_shard_id(self._qkc_config.SHARD_SIZE) == shard_id) 52 | evm_state.full_shard_id = address.full_shard_id 53 | evm_state.delta_balance(address.recipient, amount_in_wei) 54 | 55 | evm_state.commit() 56 | 57 | meta = MinorBlockMeta( 58 | hash_merkle_root=bytes.fromhex(genesis.HASH_MERKLE_ROOT), 59 | hash_evm_state_root=evm_state.trie.root_hash, 60 | ) 61 | 62 | local_fee_rate = 1 - self._qkc_config.reward_tax_rate # type: Fraction 63 | coinbase_amount = ( 64 | shard_config.COINBASE_AMOUNT 65 | * local_fee_rate.numerator 66 | // local_fee_rate.denominator 67 | ) 68 | coinbase_address = Address.create_empty_account(shard_id) 69 | 70 | header = MinorBlockHeader( 71 | version=genesis.VERSION, 72 | height=genesis.HEIGHT, 73 | branch=branch, 74 | hash_prev_minor_block=bytes.fromhex(genesis.HASH_PREV_MINOR_BLOCK), 75 | hash_prev_root_block=root_block.header.get_hash(), 76 | evm_gas_limit=genesis.GAS_LIMIT, 77 | hash_meta=sha3_256(meta.serialize()), 78 | coinbase_amount=coinbase_amount, 79 | coinbase_address=coinbase_address, 80 | create_time=genesis.TIMESTAMP, 81 | difficulty=genesis.DIFFICULTY, 82 | extra_data=bytes.fromhex(genesis.EXTRA_DATA), 83 | ) 84 | return MinorBlock(header=header, meta=meta, tx_list=[]) 85 | -------------------------------------------------------------------------------- /quarkchain/p2p/DEVELOPMENT.md: -------------------------------------------------------------------------------- 1 | # QuarkChain p2p module 2 | 3 | ## Status 4 | QuarkChain Testnet 2.0 is presented with the new p2p module 5 | - Kademlia 6 | - Discovery 7 | - P2P server and peer manager 8 | - Peer secure communication protocol 9 | 10 | ## Guidelines 11 | - loosely based on [py-evm (Trinity)'s implementation of devp2p](https://github.com/ethereum/py-evm/tree/master/p2p) 12 | - loosely follow [devp2p specifications](https://github.com/ethereum/devp2p) 13 | - adopt [discv5](https://github.com/fjl/p2p-drafts) 14 | 15 | ## Motivation 16 | First version of QuarkChain testnet used simple_network which connects all peers with a fully connected topology, and it soon became unrealistic to run a testnet with 100 nodes with fully connection (each node maintains 99 peers). We used pydevp2p that was part of pyethereum for QuarkChain testnet 1.0 which worked fine. However, pydevp2p is no longer in the list of [devp2p official implementations](https://github.com/ethereum/devp2p), albeit there is no real protocol changes of devp2p since 2014. And we need the new features brought by discv5. Discarding gevent and adopting asyncio is a bonus. 17 | 18 | We need a better p2p library for QuarkChain mainnet. 19 | 20 | We now propose our own implementation of devp2p-like specifications, learning from the implementations of ethereum (py-evm and go-ethereum) and adding our own features (treating shards as topics for discv5) 21 | -------------------------------------------------------------------------------- /quarkchain/p2p/cancel_token/README.md: -------------------------------------------------------------------------------- 1 | # cancel-token for QuarkChain services 2 | ported from https://github.com/ethereum/asyncio-cancel-token to work with python3.5 (pypy) 3 | 4 | ## What is CancelToken? 5 | see https://vorpus.org/blog/timeouts-and-cancellation-for-humans/ 6 | 7 | Essentially, it allows your async operations to "give up after ". Its chaining feature allows cancelling complex service/tasks altogether. 8 | -------------------------------------------------------------------------------- /quarkchain/p2p/cancel_token/exceptions.py: -------------------------------------------------------------------------------- 1 | class BaseCancelTokenException(Exception): 2 | """ 3 | Base exception class for the `asyncio-cancel-token` library. 4 | """ 5 | 6 | pass 7 | 8 | 9 | class EventLoopMismatch(BaseCancelTokenException): 10 | """ 11 | Raised when two different asyncio event loops are referenced, but must be equal 12 | """ 13 | 14 | pass 15 | 16 | 17 | class OperationCancelled(BaseCancelTokenException): 18 | """ 19 | Raised when an operation was cancelled. 20 | """ 21 | 22 | pass 23 | -------------------------------------------------------------------------------- /quarkchain/p2p/cancellable.py: -------------------------------------------------------------------------------- 1 | from typing import Awaitable, TypeVar 2 | 3 | from quarkchain.p2p.cancel_token.token import CancelToken 4 | 5 | 6 | class CancellableMixin: 7 | cancel_token = None # : CancelToken 8 | 9 | _TReturn = TypeVar("_TReturn") 10 | 11 | async def wait( 12 | self, 13 | awaitable: Awaitable[_TReturn], 14 | token: CancelToken = None, 15 | timeout: float = None, 16 | ) -> _TReturn: 17 | """See wait_first()""" 18 | return await self.wait_first(awaitable, token=token, timeout=timeout) 19 | 20 | async def wait_first( 21 | self, 22 | *awaitables: Awaitable[_TReturn], 23 | token: CancelToken = None, 24 | timeout: float = None 25 | ) -> _TReturn: 26 | """ 27 | Wait for the first awaitable to complete, unless we timeout or the token chain is triggered. 28 | 29 | The given token is chained with this service's token, so triggering either will cancel 30 | this. 31 | 32 | Returns the result of the first one to complete. 33 | 34 | Raises TimeoutError if we timeout or OperationCancelled if the token chain is triggered. 35 | 36 | All pending futures are cancelled before returning. 37 | """ 38 | if token is None: 39 | token_chain = self.cancel_token 40 | else: 41 | token_chain = token.chain(self.cancel_token) 42 | return await token_chain.cancellable_wait(*awaitables, timeout=timeout) 43 | -------------------------------------------------------------------------------- /quarkchain/p2p/events.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Type, 3 | ) 4 | 5 | from lahja import ( 6 | BaseEvent, 7 | BaseRequestResponseEvent, 8 | ) 9 | 10 | 11 | class PeerCountResponse(BaseEvent): 12 | 13 | def __init__(self, peer_count: int) -> None: 14 | self.peer_count = peer_count 15 | 16 | 17 | class PeerCountRequest(BaseRequestResponseEvent[PeerCountResponse]): 18 | 19 | @staticmethod 20 | def expected_response_type() -> Type[PeerCountResponse]: 21 | return PeerCountResponse 22 | -------------------------------------------------------------------------------- /quarkchain/p2p/exceptions.py: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Any 3 | ) 4 | 5 | 6 | class BaseP2PError(Exception): 7 | """ 8 | The base class for all p2p errors. 9 | """ 10 | pass 11 | 12 | 13 | class DecryptionError(BaseP2PError): 14 | """ 15 | Raised when a message could not be decrypted. 16 | """ 17 | pass 18 | 19 | 20 | class PeerConnectionLost(BaseP2PError): 21 | """ 22 | Raised when the connection to a peer was lost. 23 | """ 24 | pass 25 | 26 | 27 | class HandshakeFailure(BaseP2PError): 28 | """ 29 | Raised when the protocol handshake was unsuccessful. 30 | """ 31 | pass 32 | 33 | 34 | class MalformedMessage(BaseP2PError): 35 | """ 36 | Raised when a p2p command is received with a malformed message 37 | """ 38 | pass 39 | 40 | 41 | class UnknownProtocolCommand(BaseP2PError): 42 | """ 43 | Raised when the received protocal command isn't known. 44 | """ 45 | pass 46 | 47 | 48 | class UnexpectedMessage(BaseP2PError): 49 | """ 50 | Raised when the received message was unexpected. 51 | """ 52 | pass 53 | 54 | 55 | class UnreachablePeer(BaseP2PError): 56 | """ 57 | Raised when a peer was unreachable. 58 | """ 59 | pass 60 | 61 | 62 | class EmptyGetBlockHeadersReply(BaseP2PError): 63 | """ 64 | Raised when the received block headers were empty. 65 | """ 66 | pass 67 | 68 | 69 | class LESAnnouncementProcessingError(BaseP2PError): 70 | """ 71 | Raised when an LES announcement could not be processed. 72 | """ 73 | pass 74 | 75 | 76 | class TooManyTimeouts(BaseP2PError): 77 | """ 78 | Raised when too many timeouts occurred. 79 | """ 80 | pass 81 | 82 | 83 | class NoMatchingPeerCapabilities(BaseP2PError): 84 | """ 85 | Raised when no matching protocol between peers was found. 86 | """ 87 | pass 88 | 89 | 90 | class RemoteDisconnected(BaseP2PError): 91 | """ 92 | Raised when a remote disconnected. 93 | """ 94 | pass 95 | 96 | 97 | class NoConnectedPeers(BaseP2PError): 98 | """ 99 | Raised when we are not connected to any peers. 100 | """ 101 | pass 102 | 103 | 104 | class NoEligiblePeers(BaseP2PError): 105 | """ 106 | Raised when none of our peers have the data we want. 107 | """ 108 | pass 109 | 110 | 111 | class NoIdlePeers(BaseP2PError): 112 | """ 113 | Raised when none of our peers is idle and can be used for data requests. 114 | """ 115 | pass 116 | 117 | 118 | class EventLoopMismatch(BaseP2PError): 119 | """ 120 | Raised when two different asyncio event loops are referenced, but must be equal 121 | """ 122 | pass 123 | 124 | 125 | class NoEligibleNodes(BaseP2PError): 126 | """ 127 | Raised when there are no nodes which meet some filter criteria 128 | """ 129 | pass 130 | 131 | 132 | class BadAckMessage(BaseP2PError): 133 | """ 134 | Raised when the ack message during a peer handshake is malformed 135 | """ 136 | pass 137 | 138 | 139 | class BadLESResponse(BaseP2PError): 140 | """ 141 | Raised when the response to a LES request doesn't contain the data we asked for. 142 | 143 | The peer can be treated as violating protocol. Often, the repurcussion should be 144 | disconnection and blacklisting. 145 | """ 146 | pass 147 | 148 | 149 | class NoInternalAddressMatchesDevice(BaseP2PError): 150 | """ 151 | Raised when no internal IP address matches the UPnP device that is being configured. 152 | """ 153 | def __init__(self, *args: Any, device_hostname: str=None, **kwargs: Any) -> None: 154 | super().__init__(*args, **kwargs) 155 | self.device_hostname = device_hostname 156 | 157 | 158 | class AlreadyWaitingDiscoveryResponse(BaseP2PError): 159 | """ 160 | Raised when we are already waiting for a discovery response from a given remote. 161 | """ 162 | pass 163 | 164 | 165 | class UnableToGetDiscV5Ticket(BaseP2PError): 166 | """ 167 | Raised when we're unable to get a discv5 ticket from a remote peer. 168 | """ 169 | pass 170 | -------------------------------------------------------------------------------- /quarkchain/p2p/p2p_proto.py: -------------------------------------------------------------------------------- 1 | import enum 2 | import sys 3 | from typing import cast, Dict 4 | 5 | from toolz import assoc 6 | 7 | import rlp 8 | from rlp import sedes 9 | 10 | from quarkchain.p2p.exceptions import MalformedMessage 11 | from quarkchain.p2p.protocol import Command, Protocol, _DecodedMsgType 12 | 13 | 14 | class Hello(Command): 15 | _cmd_id = 0 16 | decode_strict = False 17 | structure = [ 18 | ("version", sedes.big_endian_int), 19 | ("client_version_string", sedes.text), 20 | ( 21 | "capabilities", 22 | sedes.CountableList(sedes.List([sedes.text, sedes.big_endian_int])), 23 | ), 24 | ("listen_port", sedes.big_endian_int), 25 | ("remote_pubkey", sedes.binary), 26 | ] 27 | 28 | 29 | @enum.unique 30 | class DisconnectReason(enum.Enum): 31 | """More details at https://github.com/ethereum/wiki/wiki/%C3%90%CE%9EVp2p-Wire-Protocol#p2p""" 32 | 33 | disconnect_requested = 0 34 | tcp_sub_system_error = 1 35 | bad_protocol = 2 36 | useless_peer = 3 37 | too_many_peers = 4 38 | already_connected = 5 39 | incompatible_p2p_version = 6 40 | null_node_identity_received = 7 41 | client_quitting = 8 42 | unexpected_identity = 9 43 | connected_to_self = 10 44 | timeout = 11 45 | subprotocol_error = 16 46 | 47 | 48 | class Disconnect(Command): 49 | _cmd_id = 1 50 | structure = [("reason", sedes.big_endian_int)] 51 | 52 | def get_reason_name(self, reason_id: int) -> str: 53 | try: 54 | return DisconnectReason(reason_id).name 55 | except ValueError: 56 | return "unknown reason" 57 | 58 | def decode(self, data: bytes) -> _DecodedMsgType: 59 | try: 60 | raw_decoded = cast(Dict[str, int], super().decode(data)) 61 | except rlp.exceptions.ListDeserializationError: 62 | self.logger.warning("Malformed Disconnect message: %s", data) 63 | raise MalformedMessage("Malformed Disconnect message: {}".format(data)) 64 | return assoc( 65 | raw_decoded, "reason_name", self.get_reason_name(raw_decoded["reason"]) 66 | ) 67 | 68 | 69 | class Ping(Command): 70 | _cmd_id = 2 71 | 72 | 73 | class Pong(Command): 74 | _cmd_id = 3 75 | 76 | 77 | def construct_quark_chain_client_identifier() -> str: 78 | __version__ = 2.0 79 | """ 80 | Constructs the client identifier string 81 | 82 | e.g. 'QuarkChain/v1.2.3/darwin-amd64/python3.6.5' 83 | """ 84 | return "pyquarkchain/{0}/{platform}/{imp.name}{v.major}.{v.minor}.{v.micro}".format( 85 | __version__, 86 | platform=sys.platform, 87 | v=sys.version_info, 88 | # mypy Doesn't recognize the `sys` module as having an `implementation` attribute. 89 | imp=sys.implementation, # type: ignore 90 | ) 91 | 92 | 93 | class P2PProtocol(Protocol): 94 | name = "p2p" 95 | version = 4 96 | _commands = [Hello, Ping, Pong, Disconnect] 97 | cmd_length = 16 98 | 99 | def __init__(self, peer) -> None: 100 | # For the base protocol the cmd_id_offset is always 0. 101 | super().__init__(peer, cmd_id_offset=0) 102 | 103 | def send_handshake(self) -> None: 104 | data = dict( 105 | version=self.version, 106 | client_version_string=construct_quark_chain_client_identifier(), 107 | capabilities=self.peer.capabilities, 108 | listen_port=self.peer.listen_port, 109 | remote_pubkey=self.peer.privkey.public_key.to_bytes(), 110 | ) 111 | header, body = Hello(self.cmd_id_offset).encode(data) 112 | self.send(header, body) 113 | 114 | def send_disconnect(self, reason: DisconnectReason) -> None: 115 | header, body = Disconnect(self.cmd_id_offset).encode(dict(reason=reason)) 116 | self.send(header, body) 117 | 118 | def send_pong(self) -> None: 119 | header, body = Pong(self.cmd_id_offset).encode({}) 120 | self.send(header, body) 121 | -------------------------------------------------------------------------------- /quarkchain/p2p/poc/paragon_node.py: -------------------------------------------------------------------------------- 1 | """ 2 | paragon_node.py - runs a p2p server that discovers through bootnodes and connects to peers 3 | Example runs: 4 | 5 | # run bootnode, this will fire up both UDP(discovery) and TCP(P2P) server 6 | # note the default private key is correct key for bootnode 7 | python paragon_node.py --logging_level=debug 8 | 9 | # run a different node on a new port, note we need to leave private key empty to automatically generate a new one 10 | python paragon_node.py --privkey="" --listen_port=29001 --logging_level=debug 11 | """ 12 | import argparse 13 | import asyncio 14 | from eth_keys import keys 15 | import signal 16 | 17 | from quarkchain.p2p import ecies 18 | from quarkchain.p2p import kademlia 19 | from quarkchain.p2p.cancel_token.token import CancelToken 20 | from quarkchain.p2p.p2p_server import BaseServer 21 | from quarkchain.p2p.tools.paragon import ParagonContext, ParagonPeer, ParagonPeerPool 22 | 23 | from quarkchain.utils import Logger 24 | 25 | NETWORK_ID = 999 26 | 27 | 28 | class ParagonServer(BaseServer): 29 | """ 30 | a server using ParagonPeerPool (that creates paragon peers for demonstration purposes) 31 | """ 32 | 33 | def _make_peer_pool(self): 34 | return ParagonPeerPool( 35 | privkey=self.privkey, 36 | context=ParagonContext(), 37 | listen_port=self.port, 38 | token=self.cancel_token, 39 | ) 40 | 41 | def _make_syncer(self): 42 | return 43 | 44 | 45 | def main(): 46 | parser = argparse.ArgumentParser() 47 | parser.add_argument( 48 | "--bootnodes", 49 | default="enode://c571e0db93d17cc405cb57640826b70588a6a28785f38b21be471c609ca12fcb06cb306ac44872908f5bed99046031a5af82072d484e3ef9029560c1707193a0@127.0.0.1:29000", 50 | type=str, 51 | ) 52 | parser.add_argument( 53 | "--privkey", 54 | default="31552f186bf90908ce386fb547dd0410bf443309125cc43fd0ffd642959bf6d9", 55 | help="hex string of private key; if empty, will be auto-generated", 56 | type=str, 57 | ) 58 | parser.add_argument( 59 | "--listen_port", 60 | default=29000, 61 | help="port for discovery UDP and P2P TCP connection", 62 | type=int, 63 | ) 64 | parser.add_argument("--max_peers", default=10, type=int) 65 | parser.add_argument("--logging_level", default="info", type=str) 66 | parser.add_argument( 67 | "--upnp", 68 | default=False, 69 | action="store_true", 70 | help="if set, will automatically set up port-fowarding if upnp devices that support port forwarding can be found", 71 | ) 72 | args = parser.parse_args() 73 | 74 | Logger.set_logging_level(args.logging_level) 75 | 76 | if args.privkey: 77 | privkey = keys.PrivateKey(bytes.fromhex(args.privkey)) 78 | else: 79 | privkey = ecies.generate_privkey() 80 | 81 | cancel_token = CancelToken("server") 82 | if args.bootnodes: 83 | bootstrap_nodes = args.bootnodes.split(",") 84 | else: 85 | bootstrap_nodes = [] 86 | server = ParagonServer( 87 | privkey=privkey, 88 | port=args.listen_port, 89 | network_id=NETWORK_ID, 90 | bootstrap_nodes=tuple( 91 | [kademlia.Node.from_uri(enode) for enode in bootstrap_nodes] 92 | ), 93 | token=cancel_token, 94 | upnp=args.upnp, 95 | ) 96 | 97 | loop = asyncio.get_event_loop() 98 | # loop.set_debug(True) 99 | 100 | for sig in [signal.SIGINT, signal.SIGTERM]: 101 | loop.add_signal_handler(sig, cancel_token.trigger) 102 | 103 | loop.run_until_complete(server.run()) 104 | loop.run_until_complete(server.cancel()) 105 | loop.close() 106 | 107 | 108 | if __name__ == "__main__": 109 | main() 110 | -------------------------------------------------------------------------------- /quarkchain/p2p/poc/trinity_discovery.py: -------------------------------------------------------------------------------- 1 | """ 2 | trinity_discovery.py - runs a single discover service that connects to the specified bootnode on startup 3 | Example runs: 4 | # this is the correct private key for the default bootnode, discovery will figure out that it is bootnode itself and won't bond at all ("Failed to bond with bootstrap nodes" message is expected) 5 | python p2p/poc/p2p_app.py --privkey=31552f186bf90908ce386fb547dd0410bf443309125cc43fd0ffd642959bf6d9 6 | # after bootnode is up, running a new node will populate discovery table of both nodes 7 | python trinity_discovery.py --listen_port=29001 8 | """ 9 | import argparse 10 | import asyncio 11 | import signal 12 | 13 | from eth_keys import keys 14 | 15 | from quarkchain.utils import Logger 16 | from quarkchain.p2p import ecies 17 | from quarkchain.p2p import kademlia 18 | from quarkchain.p2p.cancel_token.token import CancelToken, OperationCancelled 19 | from quarkchain.p2p.discovery import DiscoveryProtocol 20 | 21 | 22 | def main(): 23 | Logger.set_logging_level("debug") 24 | loop = asyncio.get_event_loop() 25 | loop.set_debug(True) 26 | 27 | parser = argparse.ArgumentParser() 28 | parser.add_argument( 29 | "--bootnode", 30 | default="enode://c571e0db93d17cc405cb57640826b70588a6a28785f38b21be471c609ca12fcb06cb306ac44872908f5bed99046031a5af82072d484e3ef9029560c1707193a0@127.0.0.1:29000", 31 | type=str, 32 | ) 33 | parser.add_argument("--listen_host", default="127.0.0.1", type=str) 34 | parser.add_argument( 35 | "--listen_port", 36 | default=29000, 37 | help="port for discovery UDP and P2P TCP connection", 38 | type=int, 39 | ) 40 | parser.add_argument("--max_peers", default=10, type=int) 41 | # private key of the bootnode above is 31552f186bf90908ce386fb547dd0410bf443309125cc43fd0ffd642959bf6d9 42 | parser.add_argument( 43 | "--privkey", 44 | default="", 45 | help="hex string of private key; if empty, will be auto-generated", 46 | type=str, 47 | ) 48 | 49 | args = parser.parse_args() 50 | 51 | if args.privkey: 52 | privkey = keys.PrivateKey(bytes.fromhex(args.privkey)) 53 | else: 54 | privkey = ecies.generate_privkey() 55 | addr = kademlia.Address(args.listen_host, args.listen_port, args.listen_port) 56 | bootstrap_nodes = tuple([kademlia.Node.from_uri(args.bootnode)]) 57 | 58 | cancel_token = CancelToken("discovery") 59 | discovery = DiscoveryProtocol(privkey, addr, bootstrap_nodes, cancel_token) 60 | 61 | async def run() -> None: 62 | await loop.create_datagram_endpoint( 63 | lambda: discovery, local_addr=("0.0.0.0", args.listen_port) 64 | ) 65 | try: 66 | await discovery.bootstrap() 67 | while True: 68 | Logger.info("Routing table size={}".format(len(discovery.routing))) 69 | await cancel_token.cancellable_wait(asyncio.sleep(5)) 70 | except OperationCancelled: 71 | pass 72 | finally: 73 | await discovery.stop() 74 | 75 | for sig in [signal.SIGINT, signal.SIGTERM]: 76 | loop.add_signal_handler(sig, cancel_token.trigger) 77 | 78 | loop.run_until_complete(run()) 79 | loop.close() 80 | 81 | 82 | if __name__ == "__main__": 83 | main() 84 | -------------------------------------------------------------------------------- /quarkchain/p2p/poc/udp_nat.py: -------------------------------------------------------------------------------- 1 | """ 2 | This is an exploratory piece of code to understand how UDP works with NAT. 3 | 4 | Tested with an Apple AirPort Extreme Router: 5 | 1. run this file on a computer (ALICE) behind router 6 | 2. find a machine (BOB) with public IP (eg. AWS), run the following code snippet, ALICE would not be able to receive the UDP packets: 7 | import socket 8 | import time 9 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 10 | sock.bind(('0.0.0.0', 60999)) 11 | while True: 12 | sock.sendto(b"hello there", ("$PUBLIC_IP_OF_ALICE", 9999)) 13 | time.sleep(0.2) 14 | 3. uncomment the part `transport.sendto(b"hello world", ("$PUBLIC_IP_OF_BOB", 60999))`, and run this file again 15 | 16 | It looks our router determined that ALICE:9999 is communicating with BOB:60999, and setup NAT traversal automatically so that packets that come from BOB:60999 (note we set up sock.bind so that packets are marked from 60999 although nobody is listening on BOB) are automatically forwarded to ALICE:9999. 17 | 18 | This demonstrates how NAT traversal is automatically handled in certain cases. 19 | 20 | In real world usage, if you want a reliable way for your application to be connected from outside your private network, setup port forwarding on your router, as there is no guarantee that this will work in all cases. 21 | """ 22 | 23 | import asyncio 24 | 25 | 26 | class EchoServerProtocol: 27 | def connection_made(self, transport): 28 | self.transport = transport 29 | 30 | def datagram_received(self, data, addr): 31 | message = data.decode() 32 | print("Received %r from %s" % (message, addr)) 33 | # print('Send %r to %s' % (message, addr)) 34 | # self.transport.sendto(data, addr) 35 | 36 | 37 | if __name__ == "__main__": 38 | loop = asyncio.get_event_loop() 39 | port = 9999 40 | print("Starting UDP server on port {}".format(port)) 41 | # One protocol instance will be created to serve all client requests 42 | listen = loop.create_datagram_endpoint( 43 | EchoServerProtocol, local_addr=("0.0.0.0", port) 44 | ) 45 | transport, protocol = loop.run_until_complete(listen) 46 | 47 | # transport.sendto(b"hello world", ("$PUBLIC_IP_OF_BOB", 60999)) 48 | 49 | try: 50 | loop.run_forever() 51 | except KeyboardInterrupt: 52 | pass 53 | 54 | transport.close() 55 | loop.close() 56 | -------------------------------------------------------------------------------- /quarkchain/p2p/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llSourcell/pyquarkchain/d1c97674af8e0002ac136f7a7aef81deef16dfbd/quarkchain/p2p/tests/__init__.py -------------------------------------------------------------------------------- /quarkchain/p2p/tests/test_peer_collect_sub_proto_msgs.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import logging 3 | 4 | import pytest 5 | 6 | from quarkchain.p2p.tools.paragon import BroadcastData, GetSum 7 | from quarkchain.p2p.tools.paragon.helpers import get_directly_linked_peers 8 | 9 | @pytest.mark.asyncio 10 | async def test_peer_subscriber_filters_messages(request, event_loop): 11 | peer, remote = await get_directly_linked_peers(request, event_loop) 12 | 13 | with peer.collect_sub_proto_messages() as collector: 14 | assert collector in peer._subscribers 15 | remote.sub_proto.send_broadcast_data(b"broadcast-a") 16 | remote.sub_proto.send_broadcast_data(b"broadcast-b") 17 | remote.sub_proto.send_get_sum(7, 8) 18 | remote.sub_proto.send_broadcast_data(b"broadcast-c") 19 | await asyncio.sleep(0.1) 20 | 21 | assert collector not in peer._subscribers 22 | 23 | # yield to let remote and peer transmit. 24 | 25 | all_messages = collector.get_messages() 26 | assert len(all_messages) == 4 27 | 28 | assert isinstance(all_messages[0][1], BroadcastData) 29 | assert isinstance(all_messages[1][1], BroadcastData) 30 | assert isinstance(all_messages[2][1], GetSum) 31 | assert isinstance(all_messages[3][1], BroadcastData) 32 | 33 | # make sure it isn't still collecting 34 | remote.sub_proto.send_broadcast_data(b"broadcast-d") 35 | 36 | await asyncio.sleep(0.01) 37 | 38 | assert len(collector.get_messages()) == 0 39 | -------------------------------------------------------------------------------- /quarkchain/p2p/tests/test_peer_subscriber.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import logging 3 | 4 | import pytest 5 | 6 | from quarkchain.utils import Logger 7 | 8 | from quarkchain.p2p.peer import PeerSubscriber 9 | from quarkchain.p2p.protocol import Command 10 | 11 | from quarkchain.p2p.tools.paragon import GetSum 12 | from quarkchain.p2p.tools.paragon.helpers import get_directly_linked_peers 13 | 14 | 15 | class GetSumSubscriber(PeerSubscriber): 16 | logger = Logger 17 | msg_queue_maxsize = 10 18 | subscription_msg_types = {GetSum} 19 | 20 | 21 | class AllSubscriber(PeerSubscriber): 22 | logger = Logger 23 | msg_queue_maxsize = 10 24 | subscription_msg_types = {Command} 25 | 26 | 27 | @pytest.mark.asyncio 28 | async def test_peer_subscriber_filters_messages(request, event_loop): 29 | peer, remote = await get_directly_linked_peers(request, event_loop) 30 | 31 | get_sum_subscriber = GetSumSubscriber() 32 | all_subscriber = AllSubscriber() 33 | 34 | peer.add_subscriber(get_sum_subscriber) 35 | peer.add_subscriber(all_subscriber) 36 | 37 | remote.sub_proto.send_broadcast_data(b"value-a") 38 | remote.sub_proto.send_broadcast_data(b"value-b") 39 | remote.sub_proto.send_get_sum(7, 8) 40 | remote.sub_proto.send_get_sum(1234, 4321) 41 | remote.sub_proto.send_broadcast_data(b"value-b") 42 | 43 | # yeild to let remote and peer transmit. 44 | await asyncio.sleep(0.2) 45 | 46 | assert get_sum_subscriber.queue_size == 2 47 | assert all_subscriber.queue_size == 5 48 | -------------------------------------------------------------------------------- /quarkchain/p2p/tests/test_server.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from quarkchain.p2p.p2p_manager import encode_bytes 4 | 5 | 6 | @pytest.mark.parametrize( 7 | "data, output", 8 | ( 9 | ( 10 | b"hello", 11 | ( 12 | b"\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 13 | b"hello", 14 | ), 15 | ), 16 | ( 17 | b"hello world", 18 | ( 19 | b"\x00\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 20 | b"hello world", 21 | ), 22 | ), 23 | ( 24 | b"It was the best of times, it was the worst of times, it was the age of wisdom", 25 | ( 26 | b"\x00\x00\x00M\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 27 | b"It was the best of times, it was the worst of times, it was the age of wisdom", 28 | ), 29 | ), 30 | ), 31 | ) 32 | def test_encode_bytes(data, output): 33 | assert encode_bytes(data) == output 34 | -------------------------------------------------------------------------------- /quarkchain/p2p/tests/test_service.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import gc 3 | import pytest 4 | 5 | from quarkchain.p2p.service import BaseService 6 | 7 | 8 | class ParentService(BaseService): 9 | """A Service which just runs WaitService with run_daemon() and waits for its cancel token to 10 | be triggered. 11 | """ 12 | 13 | async def _run(self): 14 | self.daemon = WaitService(token=self.cancel_token) 15 | self.run_daemon(self.daemon) 16 | await self.cancel_token.wait() 17 | 18 | 19 | class WaitService(BaseService): 20 | async def _run(self): 21 | await self.cancel_token.wait() 22 | 23 | 24 | @pytest.mark.asyncio 25 | async def test_daemon_exit_causes_parent_cancellation(): 26 | service = ParentService() 27 | asyncio.ensure_future(service.run()) 28 | 29 | await asyncio.sleep(0.01) 30 | 31 | assert service.daemon.is_operational 32 | assert service.daemon.is_running 33 | 34 | await service.daemon.cancel() 35 | await asyncio.sleep(0.01) 36 | 37 | assert not service.is_operational 38 | assert not service.is_running 39 | 40 | await asyncio.wait_for(service.events.cleaned_up.wait(), timeout=1) 41 | 42 | 43 | @pytest.mark.asyncio 44 | async def test_service_tasks_do_not_leak_memory(): 45 | service = WaitService() 46 | asyncio.ensure_future(service.run()) 47 | 48 | end = asyncio.Event() 49 | 50 | async def run_until_end(): 51 | await end.wait() 52 | 53 | service.run_task(run_until_end()) 54 | 55 | # inspect internals to determine if memory is leaking 56 | 57 | # confirm that task is tracked: 58 | assert len(service._tasks) == 1 59 | 60 | end.set() 61 | # allow the coro to exit 62 | await asyncio.sleep(0) 63 | 64 | # due to pypy, either use gc.collect or call service.gc() 65 | # gc.collect() # https://bitbucket.org/pypy/pypy/issues/1269/weakrefweakset-does-not-work-correctly 66 | service.gc() 67 | 68 | # confirm that task is no longer tracked: 69 | assert len(service._tasks) == 0 70 | 71 | # test cleanup 72 | await service.cancel() 73 | 74 | 75 | @pytest.mark.asyncio 76 | async def test_service_children_do_not_leak_memory(): 77 | parent = WaitService() 78 | child = WaitService() 79 | asyncio.ensure_future(parent.run()) 80 | 81 | parent.run_child_service(child) 82 | 83 | # inspect internals to determine if memory is leaking 84 | 85 | # confirm that child service is tracked: 86 | assert len(parent._child_services) == 1 87 | 88 | # give child a chance to start 89 | await asyncio.sleep(0) 90 | 91 | # ... and then end it 92 | await child.cancel() 93 | 94 | # remove the final reference to the child service 95 | del child 96 | 97 | # gc.collect() DOES NOT work here... have to use parent.gc() 98 | parent.gc() 99 | 100 | # confirm that child service is no longer tracked: 101 | assert len(parent._child_services) == 0 102 | 103 | # test cleanup 104 | await parent.cancel() 105 | -------------------------------------------------------------------------------- /quarkchain/p2p/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llSourcell/pyquarkchain/d1c97674af8e0002ac136f7a7aef81deef16dfbd/quarkchain/p2p/tools/__init__.py -------------------------------------------------------------------------------- /quarkchain/p2p/tools/paragon/__init__.py: -------------------------------------------------------------------------------- 1 | from .commands import ( # noqa: F401 2 | BroadcastData, 3 | GetSum, 4 | Sum, 5 | ) 6 | from .proto import ( # noqa: F401 7 | ParagonProtocol, 8 | ) 9 | from .peer import ( # noqa: F401 10 | ParagonContext, 11 | ParagonPeer, 12 | ParagonPeerFactory, 13 | ParagonPeerPool, 14 | ) 15 | from .helpers import ( # noqa: F401 16 | get_directly_connected_streams, 17 | get_directly_linked_peers, 18 | get_directly_linked_peers_without_handshake, 19 | ) 20 | -------------------------------------------------------------------------------- /quarkchain/p2p/tools/paragon/commands.py: -------------------------------------------------------------------------------- 1 | from rlp import sedes 2 | 3 | from quarkchain.p2p.protocol import Command 4 | 5 | 6 | class BroadcastData(Command): 7 | _cmd_id = 0 8 | structure = [("data", sedes.binary)] 9 | 10 | 11 | class GetSum(Command): 12 | _cmd_id = 2 13 | structure = [("a", sedes.big_endian_int), ("b", sedes.big_endian_int)] 14 | 15 | 16 | class Sum(Command): 17 | _cmd_id = 3 18 | structure = [("result", sedes.big_endian_int)] 19 | -------------------------------------------------------------------------------- /quarkchain/p2p/tools/paragon/peer.py: -------------------------------------------------------------------------------- 1 | from quarkchain.p2p.peer import BasePeer, BasePeerContext, BasePeerPool, BasePeerFactory 2 | from quarkchain.p2p.protocol import Command, _DecodedMsgType 3 | 4 | from .proto import ParagonProtocol 5 | 6 | 7 | class ParagonPeer(BasePeer): 8 | _supported_sub_protocols = [ParagonProtocol] 9 | sub_proto = None # : ParagonProtocol 10 | peer_idle_timeout = None # do not timeout for connected paragon peers 11 | 12 | async def send_sub_proto_handshake(self) -> None: 13 | pass 14 | 15 | async def process_sub_proto_handshake( 16 | self, cmd: Command, msg: _DecodedMsgType 17 | ) -> None: 18 | pass 19 | 20 | async def do_sub_proto_handshake(self) -> None: 21 | pass 22 | 23 | 24 | class ParagonContext(BasePeerContext): 25 | # nothing magic here. Simply an example of how the context class can be 26 | # used to store data specific to a certain peer class. 27 | paragon = "paragon" # : str 28 | 29 | 30 | class ParagonPeerFactory(BasePeerFactory): 31 | peer_class = ParagonPeer 32 | context = None # : ParagonContext 33 | 34 | 35 | class ParagonPeerPool(BasePeerPool): 36 | peer_factory_class = ParagonPeerFactory 37 | context = None # : ParagonContext 38 | -------------------------------------------------------------------------------- /quarkchain/p2p/tools/paragon/proto.py: -------------------------------------------------------------------------------- 1 | from quarkchain.utils import Logger 2 | from quarkchain.p2p.protocol import Protocol 3 | 4 | from .commands import BroadcastData, GetSum, Sum 5 | 6 | 7 | class ParagonProtocol(Protocol): 8 | name = "paragon" 9 | version = 1 10 | _commands = [BroadcastData, GetSum, Sum] 11 | cmd_length = 3 12 | logger = Logger 13 | 14 | # 15 | # Broadcast 16 | # 17 | def send_broadcast_data(self, data: bytes) -> None: 18 | cmd = BroadcastData(self.cmd_id_offset) 19 | header, body = cmd.encode({"data": data}) 20 | self.send(header, body) 21 | 22 | # 23 | # Sum 24 | # 25 | def send_get_sum(self, value_a: int, value_b: int) -> None: 26 | cmd = GetSum(self.cmd_id_offset) 27 | header, body = cmd.encode({"a": value_a, "b": value_b}) 28 | self.send(header, body) 29 | 30 | def send_sum(self, result: int) -> None: 31 | cmd = GetSum(self.cmd_id_offset) 32 | header, body = cmd.encode({"result": result}) 33 | self.send(header, body) 34 | -------------------------------------------------------------------------------- /quarkchain/p2p/utils.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | from typing import Tuple 3 | 4 | import rlp 5 | 6 | 7 | def sxor(s1: bytes, s2: bytes) -> bytes: 8 | if len(s1) != len(s2): 9 | raise ValueError("Cannot sxor strings of different length") 10 | return bytes(x ^ y for x, y in zip(s1, s2)) 11 | 12 | 13 | def roundup_16(x: int) -> int: 14 | """Rounds up the given value to the next multiple of 16.""" 15 | remainder = x % 16 16 | if remainder != 0: 17 | x += 16 - remainder 18 | return x 19 | 20 | 21 | def get_devp2p_cmd_id(msg: bytes) -> int: 22 | """Return the cmd_id for the given devp2p msg. 23 | 24 | The cmd_id, also known as the payload type, is always the first entry of the RLP, interpreted 25 | as an integer. 26 | """ 27 | return rlp.decode(msg[:1], sedes=rlp.sedes.big_endian_int) 28 | 29 | 30 | def time_since(start_time: datetime.datetime) -> Tuple[int, int, int, int]: 31 | delta = datetime.datetime.now() - start_time 32 | hours, remainder = divmod(delta.seconds, 3600) 33 | minutes, seconds = divmod(remainder, 60) 34 | return delta.days, hours, minutes, seconds 35 | 36 | 37 | # colors from devp2p/utils.py 38 | # ###### colors ############### 39 | 40 | COLOR_FAIL = "\033[91m" 41 | COLOR_BOLD = "\033[1m" 42 | COLOR_UNDERLINE = "\033[4m" 43 | COLOR_END = "\033[0m" 44 | 45 | colors = ["\033[9%dm" % i for i in range(0, 7)] 46 | colors += ["\033[4%dm" % i for i in range(1, 8)] 47 | 48 | 49 | def cstr(num, txt): 50 | return "%s%s%s" % (colors[num % len(colors)], txt, COLOR_END) 51 | 52 | 53 | def cprint(num, txt): 54 | print(cstr(num, txt)) 55 | 56 | 57 | if __name__ == "__main__": 58 | for i in range(len(colors)): 59 | cprint(i, "test") 60 | -------------------------------------------------------------------------------- /quarkchain/reward.py: -------------------------------------------------------------------------------- 1 | class ConstMinorBlockRewardCalcultor: 2 | def __init__(self, env): 3 | self.env = env 4 | 5 | def get_block_reward(self): 6 | return 100000000000000000000 7 | -------------------------------------------------------------------------------- /quarkchain/rlp/utils.py: -------------------------------------------------------------------------------- 1 | import abc 2 | import binascii 3 | from math import ceil 4 | 5 | 6 | class Atomic(type.__new__(abc.ABCMeta, "metaclass", (), {})): 7 | """ABC for objects that can be RLP encoded as is.""" 8 | 9 | pass 10 | 11 | 12 | Atomic.register(str) 13 | Atomic.register(bytes) 14 | 15 | 16 | """ 17 | from pyrlp<1.0.0 18 | """ 19 | 20 | 21 | def str_to_bytes(value): 22 | if isinstance(value, bytearray): 23 | value = bytes(value) 24 | if isinstance(value, bytes): 25 | return value 26 | return bytes(value, "utf-8") 27 | 28 | 29 | def bytes_to_str(value): 30 | if isinstance(value, str): 31 | return value 32 | return value.decode("utf-8") 33 | 34 | 35 | def ascii_chr(value): 36 | return bytes([value]) 37 | 38 | 39 | def int_to_big_endian(value): 40 | byte_length = max(ceil(value.bit_length() / 8), 1) 41 | return (value).to_bytes(byte_length, byteorder="big") 42 | 43 | 44 | def big_endian_to_int(value): 45 | return int.from_bytes(value, byteorder="big") 46 | 47 | 48 | def is_integer(value): 49 | return isinstance(value, int) 50 | 51 | 52 | def decode_hex(s): 53 | if isinstance(s, str): 54 | return bytes.fromhex(s) 55 | if isinstance(s, (bytes, bytearray)): 56 | return binascii.unhexlify(s) 57 | raise TypeError("Value must be an instance of str or bytes") 58 | 59 | 60 | def encode_hex(b): 61 | if isinstance(b, str): 62 | b = bytes(b, "utf-8") 63 | if isinstance(b, (bytes, bytearray)): 64 | return str(binascii.hexlify(b), "utf-8") 65 | raise TypeError("Value must be an instance of str or bytes") 66 | 67 | 68 | def safe_ord(c): 69 | try: 70 | return ord(c) 71 | except TypeError: 72 | assert isinstance(c, int) 73 | return c 74 | -------------------------------------------------------------------------------- /quarkchain/testnet/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llSourcell/pyquarkchain/d1c97674af8e0002ac136f7a7aef81deef16dfbd/quarkchain/testnet/__init__.py -------------------------------------------------------------------------------- /quarkchain/testnet/addresses_to_fund.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "address": "000000000000000000000000000000000000000000000000", 4 | "value": 1000 5 | }, 6 | { 7 | "address": "111111111111111111111111111111111111111111111111", 8 | "value": 1000 9 | }, 10 | { 11 | "address": "222222222222222222222222222222222222222222222222", 12 | "value": 1000 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /quarkchain/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llSourcell/pyquarkchain/d1c97674af8e0002ac136f7a7aef81deef16dfbd/quarkchain/tests/__init__.py -------------------------------------------------------------------------------- /quarkchain/tests/test_accounts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import os 4 | import unittest 5 | 6 | from quarkchain.accounts import Account 7 | from quarkchain.core import Address, Identity 8 | 9 | PRIVATE_KEY = "7a28b5ba57c53603b0b07b56bba752f7784bf506fa95edc395f5cf6c7514fe9d" 10 | ADDRESS = "008aeeda4d805471df9b2a5b0f38a0c3bcba786b00802ac3" 11 | 12 | 13 | class TestAccount(unittest.TestCase): 14 | 15 | def test_create_account_with_key(self): 16 | account = Account.new(key=PRIVATE_KEY) 17 | assert account.privkey == PRIVATE_KEY 18 | assert account.address == ADDRESS 19 | # check integer version of full shard id matches 20 | assert account.qkc_address.full_shard_id == int(ADDRESS[40:], 16) 21 | 22 | def test_create_random_account(self): 23 | account = Account.new() 24 | assert len(account.privkey) == 64 25 | assert len(account.qkc_address.recipient.hex()) == 40 26 | assert len(account.address) == 48 27 | identity = Identity.create_from_key(account.identity.key) 28 | assert account.address == Address.create_from_identity(identity).to_hex() 29 | 30 | def test_write_and_load_keystore(self): 31 | tmp_dir = "/tmp" 32 | account = Account.new() 33 | account.dump("a-super-secure-password", write=True, directory=tmp_dir) 34 | 35 | file_path = "{0}/{1}.json".format(tmp_dir, account.uuid) 36 | loaded = Account.load(file_path, password="a-super-secure-password") 37 | assert account.privkey == loaded.privkey 38 | assert account.address == loaded.address 39 | 40 | # cleanup 41 | os.remove(file_path) 42 | -------------------------------------------------------------------------------- /quarkchain/tests/test_utils.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import random 3 | 4 | from quarkchain.core import ( 5 | Address, 6 | Transaction, 7 | TransactionInput, 8 | TransactionOutput, 9 | Code, 10 | random_bytes, 11 | ) 12 | 13 | from quarkchain.utils import token_id_encode, token_id_decode, ZZZZZZZZZZZZ 14 | 15 | 16 | def create_test_transaction( 17 | from_id, 18 | from_tx_id, 19 | to_address, 20 | amount=100, 21 | remaining=100, 22 | shard_id=0, 23 | output_index=0, 24 | code=Code.get_transfer_code(), 25 | ): 26 | acc1 = Address.create_from_identity(from_id, shard_id) 27 | tx = Transaction( 28 | in_list=[TransactionInput(from_tx_id, output_index)], 29 | code=code, 30 | out_list=[ 31 | TransactionOutput(acc1, remaining), 32 | TransactionOutput(to_address, amount), 33 | ], 34 | ) 35 | tx.sign([from_id.get_key()]) 36 | return tx 37 | 38 | 39 | def create_random_test_transaction(from_id, to_address, amount=100, remaining=100): 40 | return create_test_transaction( 41 | from_id, 42 | random_bytes(32), 43 | to_address, 44 | random.randint(0, 100), 45 | random.randint(0, 100), 46 | ) 47 | 48 | 49 | ENCODED_VALUES = [ 50 | ("0", 0), 51 | ("Z", 35), 52 | ("00", 36), 53 | ("0Z", 71), 54 | ("1Z", 107), 55 | ("20", 108), 56 | ("ZZ", 1331), 57 | ("QKC", 35760), 58 | ("ZZZZZZZZZZZZ", ZZZZZZZZZZZZ), 59 | # ("2V4D00153RFRF", 2**64-1), 60 | ] 61 | 62 | 63 | @pytest.mark.parametrize("name, id", ENCODED_VALUES) 64 | def test_token_id_encode(name, id): 65 | assert token_id_encode(name) == id 66 | assert name == token_id_decode(id) 67 | 68 | 69 | def test_random_token(): 70 | COUNT = 100000 71 | random.seed(2) 72 | for i in range(COUNT): 73 | id = random.randint(0, ZZZZZZZZZZZZ) 74 | assert id == token_id_encode(token_id_decode(id)) 75 | 76 | 77 | def test_token_id_exceptions(): 78 | with pytest.raises(AssertionError): 79 | token_id_encode("qkc") 80 | with pytest.raises(AssertionError): 81 | token_id_encode(" ") 82 | with pytest.raises(AssertionError): 83 | token_id_encode("btc") 84 | with pytest.raises(AssertionError): 85 | token_id_encode("ZZZZZZZZZZZZZ") 86 | with pytest.raises(AssertionError): 87 | token_id_decode(2 ** 64 - 1) 88 | with pytest.raises(AssertionError): 89 | token_id_decode(-1) 90 | with pytest.raises(AssertionError): 91 | token_id_decode(ZZZZZZZZZZZZ + 1) 92 | -------------------------------------------------------------------------------- /quarkchain/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llSourcell/pyquarkchain/d1c97674af8e0002ac136f7a7aef81deef16dfbd/quarkchain/tools/__init__.py -------------------------------------------------------------------------------- /quarkchain/tools/accounts: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | 3 | import argparse 4 | import pprint 5 | from utils import colorify 6 | 7 | from quarkchain.accounts import Account 8 | 9 | 10 | def print_account(a): 11 | print("Address: {0}".format(colorify("0x" + str(a.address), "blue"))) 12 | print( 13 | "Shard ID (uint32): {0}".format( 14 | colorify(str(a.qkc_address.full_shard_id), "green") 15 | ) 16 | ) 17 | print("Private Key: {0}".format(colorify(str(a.privkey), "red"))) 18 | print("UUID: {0}".format(colorify(str(a.uuid), "grey"))) 19 | 20 | 21 | def main(): 22 | parser = argparse.ArgumentParser() 23 | 24 | subparsers = parser.add_subparsers( 25 | title="quarkchain account management", description="commands to run", dest="cmd" 26 | ) 27 | 28 | parser_new = subparsers.add_parser( 29 | "new", description="create a new account", help="create a new account" 30 | ) 31 | parser_new.add_argument( 32 | "pw", type=str, help="passwd for encrypting your private key" 33 | ) 34 | parser_new.add_argument( 35 | "--key", 36 | default=None, 37 | type=str, 38 | help="private key you want to use if you already have one", 39 | ) 40 | parser_new.add_argument( 41 | "--dir", 42 | default=None, 43 | type=str, 44 | help="path of the directory for storing the keystore file", 45 | ) 46 | 47 | parser_load = subparsers.add_parser( 48 | "load", description="reads the keystore file specified and dumps the JSON" 49 | ) 50 | parser_load.add_argument("path", type=str, help="path to the keystore file") 51 | parser_load.add_argument( 52 | "pw", type=str, help="password for decrypting your private key" 53 | ) 54 | 55 | args = parser.parse_args() 56 | 57 | if args.cmd == "new": 58 | a = Account.new(key=args.key) 59 | print("Generated a new account: ") 60 | print_account(a) 61 | 62 | if args.dir: 63 | print("Writing keystore file (Version 3) to {0}".format(args.dir)) 64 | a.dump(args.pw, write=True, directory=args.dir) 65 | print("Success.") 66 | else: 67 | print("Raw keystore file (Version 3):") 68 | print(a.dump(args.pw, write=False)) 69 | elif args.cmd == "load": 70 | a = Account.load(args.path, args.pw) 71 | print("Loaded account: ") 72 | print_account(a) 73 | 74 | 75 | if __name__ == "__main__": 76 | main() 77 | -------------------------------------------------------------------------------- /quarkchain/tools/block_owners.py: -------------------------------------------------------------------------------- 1 | # Count minor blocks from db by mining algorithm and coinbase address 2 | 3 | import argparse 4 | import operator 5 | from pprint import pprint 6 | 7 | from quarkchain.db import PersistentDb 8 | from quarkchain.cluster.root_state import RootDb 9 | 10 | 11 | def parse_args(): 12 | parser = argparse.ArgumentParser() 13 | parser.add_argument("--db", default="data/master.db", type=str) 14 | parser.add_argument("--root_height", default=0, type=int) 15 | args = parser.parse_args() 16 | return args 17 | 18 | 19 | def shard_id_to_algorithm(shard_id: int) -> str: 20 | if shard_id < 4: 21 | return "ETHASH" 22 | if shard_id < 6: 23 | return "SHA2SHA2" 24 | return "QKCHASH" 25 | 26 | 27 | def main(): 28 | args = parse_args() 29 | db = RootDb(PersistentDb(args.db), 0) 30 | header = db.get_tip_header() 31 | if not header: 32 | raise RuntimeError("Not a valid RootDb") 33 | from_height = header.height if args.root_height <= 0 else args.root_height 34 | tip_header = None 35 | block = db.get_root_block_by_hash(header.get_hash(), False) 36 | shard_to_address_count = dict() # shard -> (recipient -> count) 37 | while block.header.height > 0: 38 | if block.header.height > from_height: 39 | block = db.get_root_block_by_hash(block.header.hash_prev_block, False) 40 | continue 41 | if block.header.height == from_height: 42 | tip_header = block.header 43 | for minor_header in block.minor_block_header_list: 44 | shard = minor_header.branch.get_shard_id() 45 | address_hex = minor_header.coinbase_address.recipient.hex() 46 | address_to_count = shard_to_address_count.setdefault(shard, dict()) 47 | current = address_to_count.setdefault(address_hex, 0) 48 | address_to_count[address_hex] = current + 1 49 | block = db.get_root_block_by_hash(block.header.hash_prev_block, False) 50 | 51 | algo_to_address_count = dict() # algorithm -> (recipient -> count) 52 | for shard_id, address_to_count in shard_to_address_count.items(): 53 | algo = shard_id_to_algorithm(shard_id) 54 | addr_to_count = algo_to_address_count.setdefault(algo, dict()) 55 | for address, count in address_to_count.items(): 56 | current = addr_to_count.setdefault(address, 0) 57 | addr_to_count[address] = current + count 58 | 59 | print( 60 | "Counting shard blocks from root block {} {}".format( 61 | tip_header.height, tip_header.get_hash().hex() 62 | ) 63 | ) 64 | 65 | for algo, address_count in algo_to_address_count.items(): 66 | total = sum(address_count.values()) 67 | 68 | print() 69 | print("{} has {} blocks".format(algo, total)) 70 | sorted_by_count = sorted( 71 | address_count.items(), key=operator.itemgetter(1), reverse=True 72 | ) 73 | for address, count in sorted_by_count: 74 | print("{} {} {:.2f}%".format(address, count, count / total * 100)) 75 | 76 | 77 | if __name__ == "__main__": 78 | main() 79 | -------------------------------------------------------------------------------- /quarkchain/tools/check_syncing_state.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env pypy3 2 | 3 | import argparse 4 | import logging 5 | import time 6 | from datetime import datetime 7 | import jsonrpcclient 8 | import psutil 9 | import numpy 10 | from decimal import Decimal 11 | 12 | TIMEOUT=10 13 | 14 | # disable jsonrpcclient verbose logging 15 | logging.getLogger("jsonrpcclient.client.request").setLevel(logging.WARNING) 16 | logging.getLogger("jsonrpcclient.client.response").setLevel(logging.WARNING) 17 | 18 | 19 | def now(): 20 | return datetime.now().strftime("%Y-%m-%d %H:%M:%S") 21 | 22 | def checkHeight(private_client, public_client, timeout=TIMEOUT): 23 | result_private = private_client.send( 24 | jsonrpcclient.Request("getRootBlockByHeight"), 25 | timeout=timeout,) 26 | result_public = public_client.send( 27 | jsonrpcclient.Request("getRootBlockByHeight"), 28 | timeout=timeout,) 29 | return { 30 | "height": int(result_private["height"], 16), 31 | "currentHeight": int(result_public["height"], 16), 32 | } 33 | 34 | 35 | 36 | def query_height(private_client, public_client, args): 37 | format = "{time:20} {syncing:>15}{height:>30}{currentHeight:>30}" 38 | print( 39 | format.format( 40 | time="Timestamp", 41 | syncing="Syncing", 42 | height="LocalRootHeight", 43 | currentHeight="CurrentRootHeight", 44 | ) 45 | ) 46 | while True: 47 | while True: 48 | try: 49 | data = checkHeight(private_client, public_client) 50 | break 51 | except Exception as e: 52 | print("Failed to get the current root height", e) 53 | time.sleep(2) 54 | 55 | syncing_state = (False if data["height"] >= data["currentHeight"] else True) 56 | 57 | print(format.format(time=now(), syncing=str(syncing_state), height=data["height"], currentHeight=data["currentHeight"])) 58 | 59 | if syncing_state is False: 60 | break 61 | time.sleep(args.interval) 62 | 63 | 64 | def main(): 65 | parser = argparse.ArgumentParser() 66 | parser.add_argument("--ip", default="localhost", type=str, help="Cluster IP") 67 | 68 | 69 | parser.add_argument("--bootstrapip", default="jrpc.testnet2.quarkchain.io", type=str, help="Bootstrap Cluster IP") 70 | 71 | parser.add_argument( 72 | "-i", "--interval", default=10, type=int, help="Query interval in second" 73 | ) 74 | 75 | args = parser.parse_args() 76 | 77 | private_endpoint = "http://{}:38391".format(args.ip) 78 | private_client = jsonrpcclient.HTTPClient(private_endpoint) 79 | 80 | public_endpoint = "http://{}:38391".format(args.bootstrapip) 81 | public_client = jsonrpcclient.HTTPClient(public_endpoint) 82 | 83 | 84 | 85 | 86 | query_height(private_client, public_client, args) 87 | 88 | 89 | if __name__ == "__main__": 90 | # query syncing state 91 | main() 92 | -------------------------------------------------------------------------------- /quarkchain/tools/config_slave.py: -------------------------------------------------------------------------------- 1 | """ 2 | python config_slave.py 127.0.0.1 38000 38006 127.0.0.2 18999 18002 3 | 4 | will generate 4 slave server configs accordingly. will be used in deployment automation to configure a cluster. 5 | usage: python config_slave.py ... 6 | """ 7 | import argparse 8 | import collections 9 | import json 10 | import os 11 | 12 | FILE = "../../testnet/2/cluster_config_template.json" 13 | 14 | 15 | def main(): 16 | parser = argparse.ArgumentParser() 17 | parser.add_argument( 18 | "hostports", 19 | nargs="+", 20 | metavar="hostports", 21 | help="Host and ports for slave config", 22 | ) 23 | args = parser.parse_args() 24 | 25 | abspath = os.path.abspath(__file__) 26 | dname = os.path.dirname(abspath) 27 | os.chdir(dname) 28 | 29 | ############### 30 | # parse hosts and ports to form a slave list 31 | ############### 32 | 33 | host_port_mapping = collections.defaultdict(list) 34 | last_host = None 35 | for host_or_port in args.hostports: # type: str 36 | if not host_or_port.isdigit(): # host 37 | last_host = host_or_port 38 | else: # port 39 | host_port_mapping[last_host].append(host_or_port) 40 | 41 | assert None not in host_port_mapping 42 | slave_num = sum(len(port_list) for port_list in host_port_mapping.values()) 43 | # make sure number of slaves is power of 2 44 | assert slave_num > 0 and (slave_num & (slave_num - 1) == 0) 45 | 46 | slave_servers, i = [], 0 47 | for host, port_list in host_port_mapping.items(): 48 | for port in port_list: 49 | s = { 50 | "HOST": host, 51 | "PORT": int(port), 52 | "ID": "S%d" % i, 53 | "SHARD_MASK_LIST": [i | slave_num], 54 | } 55 | slave_servers.append(s) 56 | i += 1 57 | 58 | ############### 59 | # read config file and substitute with updated slave config 60 | ############### 61 | 62 | with open(FILE, "r+") as f: 63 | parsed_config = json.load(f) 64 | parsed_config["SLAVE_LIST"] = slave_servers 65 | f.seek(0) 66 | f.truncate() 67 | f.write(json.dumps(parsed_config, indent=4)) 68 | 69 | 70 | if __name__ == "__main__": 71 | main() 72 | -------------------------------------------------------------------------------- /quarkchain/tools/external_miner_manager.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -u; set -e 4 | 5 | type jq >/dev/null 2>&1 || { echo >&2 "Please install jq."; exit 1; } 6 | 7 | # c -> config, p -> process number, t -> threads per miner process 8 | # eg: external_miner_manager.sh -c ~/Documents/config.json -p 8 -h localhost 9 | while getopts ":c:p:t:h:" opt; do 10 | case ${opt} in 11 | c ) 12 | config=$OPTARG 13 | ;; 14 | p ) 15 | process=$OPTARG 16 | ;; 17 | h ) 18 | host=$OPTARG 19 | ;; 20 | \? ) 21 | echo "Invalid option: $OPTARG" 1>&2 22 | exit 1 23 | ;; 24 | : ) 25 | echo "Invalid option: $OPTARG requires an argument" 1>&2 26 | exit 1 27 | ;; 28 | esac 29 | done 30 | shift $((OPTIND -1)) 31 | 32 | shards=() 33 | shard_cnt=$(jq '.QUARKCHAIN.SHARD_LIST | length' < $config) 34 | end_shard=$(( $shard_cnt - 1)) 35 | for i in $(seq 0 $end_shard); do 36 | shards+=("$i") 37 | done 38 | 39 | shards_by_process=() 40 | i=0 41 | for shard in "${shards[@]}"; do 42 | shards_by_process[$(( i % $process ))]+=" $shard" 43 | i=$(( $i + 1 )) 44 | done 45 | 46 | miner_py_path="$( cd "$(dirname "$0")" ; pwd -P )/external_miner.py" 47 | for shards_per_process in "${shards_by_process[@]}"; do 48 | python3 $miner_py_path \ 49 | --host $host \ 50 | --config $config \ 51 | --worker 1 \ 52 | --shards $shards_per_process & 53 | done 54 | 55 | wait 56 | -------------------------------------------------------------------------------- /quarkchain/tools/miner_address.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import re 3 | import os 4 | import sys 5 | 6 | import ecdsa 7 | from utils import underline, colorify 8 | from quarkchain.utils import sha3_256 9 | 10 | FILE = "../../testnet/2/cluster_config_template.json" 11 | 12 | 13 | def gen_address(): 14 | sk = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1) 15 | print( 16 | colorify( 17 | "A new address has been generated for you, your private key is: ", "grey" 18 | ) 19 | ) 20 | print(sk.to_string().hex()) 21 | address = sha3_256(sk.verifying_key.to_string())[-20:].hex() 22 | print(colorify("Address is:", "grey") + " 0x{}".format(address)) 23 | return address 24 | 25 | 26 | def touch_file(address: str): 27 | # sanitize the input address first 28 | with open(FILE, "r+") as f: 29 | content = f.read() 30 | content = re.sub( 31 | r"\"COINBASE_ADDRESS\": \"[0-9a-fA-F]{40}", 32 | '"COINBASE_ADDRESS": "{}'.format(address), 33 | content, 34 | ) 35 | f.seek(0) 36 | f.truncate() 37 | f.write(content) 38 | 39 | print( 40 | colorify( 41 | "{} has been updated with {}, run `git diff` to double check".format( 42 | FILE, address 43 | ), 44 | "green", 45 | ) 46 | ) 47 | 48 | 49 | def main(): 50 | parser = argparse.ArgumentParser() 51 | parser.add_argument( 52 | "address", 53 | nargs="?", 54 | metavar="addr", 55 | type=str, 56 | help="Address to put into config", 57 | ) 58 | args = parser.parse_args() 59 | 60 | abspath = os.path.abspath(__file__) 61 | dname = os.path.dirname(abspath) 62 | os.chdir(dname) 63 | 64 | # interactive mode 65 | if not args.address: 66 | print( 67 | "This tool will edit {} with your address; if you don't have one, one will be generated for you".format( 68 | FILE 69 | ) 70 | ) 71 | print(colorify("--------------", "green")) 72 | address = input( 73 | underline( 74 | "Please paste your QKC address (make sure you have the private key for it)" 75 | ) 76 | + ": " 77 | ) 78 | if not address: 79 | print( 80 | "your input is empty, so we will generate one for you; " 81 | + underline("be sure to keep the private key in a safe place") 82 | ) 83 | address = gen_address() 84 | touch_file(address) 85 | return 86 | else: 87 | address = args.address 88 | 89 | if address.startswith("0x"): 90 | address = address[2:] 91 | if len(address) == 40: 92 | print( 93 | "your input is ETH address, but it's OK, we actually just need the 20-byte address" 94 | ) 95 | touch_file(address) 96 | elif len(address) == 48: 97 | touch_file(address[:40]) 98 | else: 99 | print( 100 | colorify( 101 | "Wrong address length, please provide either 20-byte ETH address or 24-byte QKC address", 102 | "red", 103 | ) 104 | ) 105 | sys.exit(1) 106 | 107 | 108 | if __name__ == "__main__": 109 | main() 110 | -------------------------------------------------------------------------------- /quarkchain/tools/newkey.py: -------------------------------------------------------------------------------- 1 | """ 2 | This is a command line tool for generating private key used in QuarkChain Network 3 | """ 4 | from quarkchain.p2p import ecies 5 | 6 | 7 | def main(): 8 | privkey = ecies.generate_privkey() 9 | print("Here is a new SECP256K1 private key, please keep it in a safe place:") 10 | print("*" * 50) 11 | print(privkey.to_bytes().hex()) 12 | print("*" * 50) 13 | print("You can pass it to --privkey when running cluster.py") 14 | print( 15 | "If you want to use the key for bootnode, here is what you want others to use (replace IP/PORT):" 16 | ) 17 | print("*" * 50) 18 | print("enode://{}@IP:PORT".format(privkey.public_key.to_bytes().hex())) 19 | print("*" * 50) 20 | 21 | 22 | if __name__ == "__main__": 23 | main() 24 | -------------------------------------------------------------------------------- /quarkchain/tools/pypy-fix-cython-warning.pth: -------------------------------------------------------------------------------- 1 | import warnings; warnings.filterwarnings("ignore", "builtins.type size changed, may indicate binary incompatibility. Expected .*, got .*") 2 | -------------------------------------------------------------------------------- /quarkchain/tools/quick_miner_stopper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pkill -f master.py 4 | 5 | pkill -f slave.py 6 | 7 | pkill -f external_miner.py 8 | 9 | pkill -f check_syncing_state.py 10 | 11 | screen -ls | grep -i detached | cut -d. -f1 | tr -d [:blank:] | xargs kill 12 | 13 | wait -------------------------------------------------------------------------------- /quarkchain/tools/quick_miner_tool.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | screen -dmS jobs 4 | 5 | clear 6 | echo "Step 1: Enter or generate your coinbase address!" 7 | 8 | miner_tools_path="$(pwd -P)/quarkchain/tools/miner_address.py" 9 | pypy3 $miner_tools_path 10 | 11 | echo "Step 2: Download a snapshot of the database. Your cluster only need to sync 12 | the blocks mined in the past 12 hours or less." 13 | 14 | 15 | curl https://s3-us-west-2.amazonaws.com/testnet2/data/23/`curl https://s3-us-west-2.amazonaws.com/testnet2/data/23/LATEST`.tar.gz --output data.tar.gz 16 | 17 | tar xvfz data.tar.gz 18 | 19 | miner_data_path="$(pwd -P)/quarkchain/cluster/data" 20 | 21 | rm -rf $miner_data_path 22 | 23 | mv data $miner_data_path 24 | 25 | 26 | screen -S jobs -X screen bash 27 | 28 | screen -S jobs -p bash -X title cluster 29 | 30 | screen -S jobs -p cluster -X stuff $'pypy3 quarkchain/cluster/cluster.py --cluster_config "$(pwd -P)/testnet/2/cluster_config_template.json" 31 | ' 32 | 33 | 34 | seconds_left=20 35 | 36 | echo "Step 3: Initiate the cluster and start synchorizing blocks in the past 12 hours or less. Please wait for time: ${seconds_left} seconds……" 37 | while [ $seconds_left -gt 0 ];do 38 | echo -n "${seconds_left} seconds left" 39 | sleep 1 40 | seconds_left=$(($seconds_left - 1)) 41 | echo -ne "\r \r" 42 | done 43 | 44 | echo "Step 4: Start synchorizing blocks in the past 12 hours or less. It takes about five minutes. Be patient!" 45 | pypy3 quarkchain/tools/check_syncing_state.py 46 | 47 | 48 | while true; do 49 | read -p "Step 4: Do you wish to start mining now?(Y or N)" yn 50 | case $yn in 51 | [Yy]* ) bash quarkchain/tools/external_miner_manager.sh -c "$(pwd -P)/testnet/2/cluster_config_template.json" -p 8 -h localhost; 52 | break;; 53 | [Nn]* ) bash quarkchain/tools/quick_miner_stopper.sh 54 | exit;; 55 | * ) echo "Please answer Y or N.";; 56 | esac 57 | done 58 | 59 | wait 60 | -------------------------------------------------------------------------------- /quarkchain/tools/tests/test_monitoring.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from quarkchain.tools.monitoring import crawl_recursive, crawl_bfs 3 | 4 | 5 | class TestCrawl(unittest.TestCase): 6 | def test_crawl(self): 7 | cache = {} 8 | res = {} 9 | # crawl_recursive(cache, "54.152.237.112", 38291, 38291 + 200, ip_lookup={}) 10 | # res = crawl_bfs("54.152.237.112", 38291, 38291 + 200) 11 | dfs = {k: set(v) for k, v in cache.items()} 12 | bfs = {k: set(v) for k, v in res.items()} 13 | self.assertEqual(dfs, bfs) 14 | -------------------------------------------------------------------------------- /quarkchain/tools/utils.py: -------------------------------------------------------------------------------- 1 | def colorify(s, color): 2 | color_map = { 3 | "grey": "\033[90m", 4 | "red": "\033[91m", 5 | "green": "\033[92m", 6 | "yellow": "\033[93m", 7 | "purple": "\033[94m", 8 | "pink": "\033[95m", 9 | "blue": "\033[96m", 10 | } 11 | 12 | return color_map[color] + s + "\033[0m" 13 | 14 | 15 | def underline(s): 16 | return "\033[4m" + s + "\033[0m" 17 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | aiohttp==3.1.3 2 | aioprocessing==1.0.1 3 | async_armor==0.0.2 4 | coincurve==7.1.0 5 | decorator==4.2.1 6 | ecdsa==0.13 7 | jsonrpcclient==2.5.2 8 | jsonrpcserver==3.5.4 9 | jsonrpc-async==0.6 10 | numpy==1.15.1 11 | psutil==5.4.5 12 | python-rocksdb==0.6.9 13 | requests==2.20.0 14 | aiohttp_cors==0.7.0 15 | eth-utils==1.2.0 16 | eth-keys==0.2.0b3 17 | eth-bloom==1.0.0 18 | pyethash>=0.1.27,<1.0.0 19 | py_ecc==1.4.3 20 | eth-hash[pycryptodome]==0.1.4 21 | 22 | # p2p 23 | pytest>=3.6,<3.7 24 | pytest-asyncio==0.9.0 25 | cryptography==2.3.1 26 | upnpclient==0.0.8 27 | netifaces==0.10.7 28 | rlp>=1.0.0,<2.0.0 29 | 30 | # pyethapp/accounts.py dependency 31 | pbkdf2 32 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from setuptools import setup 4 | from setuptools.command.develop import develop 5 | 6 | install_requires = set(x.strip() for x in open("requirements.txt")) 7 | install_requires_replacements = {} 8 | install_requires = [install_requires_replacements.get(r, r) for r in install_requires] 9 | PTH = "pypy-fix-cython-warning.pth" 10 | 11 | # Utility function to read the README file. 12 | # Used for the long_description. It's nice, because now 1) we have a top level 13 | # README file and 2) it's easier to type in the README file than to put a raw 14 | # string in below ... 15 | 16 | 17 | class custom_develop(develop): 18 | @property 19 | def target(self): 20 | return os.path.join(self.install_dir, PTH) 21 | 22 | def run(self): 23 | print(self.install_dir) 24 | with open("quarkchain/tools/" + PTH) as infp: 25 | with open(self.target, "w") as outfp: 26 | outfp.write(infp.read()) 27 | develop.run(self) 28 | 29 | 30 | def read(fname): 31 | return open(os.path.join(os.path.dirname(__file__), fname)).read() 32 | 33 | 34 | setup( 35 | name="quarkchain", 36 | version="0.0", 37 | author="QuarkChain", 38 | author_email="", 39 | description=("QuarkChain"), 40 | license="MIT", 41 | keywords="QuarkChain,blockchain", 42 | url="", 43 | packages=["quarkchain"], 44 | long_description=read("README.md"), 45 | classifiers=["Development Status :: 0 - Development", "License :: MIT License"], 46 | install_requires=install_requires, 47 | python_requires=">=3.5", 48 | cmdclass={"develop": custom_develop}, 49 | ) 50 | -------------------------------------------------------------------------------- /testnet/2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:bionic 2 | 3 | MAINTAINER quarkchain 4 | 5 | ### set up basic system packages 6 | RUN apt-get update && \ 7 | DEBIAN_FRONTEND=noninteractive apt-get install -y libpq-dev libxml2-dev libxslt1-dev nginx openssh-client openssh-server openssl rsyslog rsyslog-gnutls liblcms2-dev libwebp-dev python-tk libfreetype6-dev vim-nox imagemagick libffi-dev libgmp-dev build-essential libssl-dev software-properties-common pkg-config libtool python3-dev && \ 8 | apt-get clean 9 | 10 | # install git and misc dep 11 | RUN apt-get update && apt-get install -y git-core jq screen curl && apt-get clean 12 | 13 | # install rocksdb 14 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y libsnappy-dev zlib1g-dev libbz2-dev libgflags-dev liblz4-dev libzstd-dev librocksdb-dev 15 | 16 | # install python development tools, setuptools and pip 17 | WORKDIR /opt 18 | RUN wget https://bitbucket.org/pypy/pypy/downloads/pypy3-v6.0.0-linux64.tar.bz2 19 | RUN tar fxv pypy3-v6.0.0-linux64.tar.bz2 20 | RUN ln -s /opt/pypy3-v6.0.0-linux64/bin/pypy3 /usr/bin/pypy3 21 | RUN pypy3 -m ensurepip 22 | RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py 23 | RUN python3 get-pip.py 24 | 25 | # configure locale 26 | RUN apt-get update && apt-get install -y locales 27 | RUN locale-gen en_US.UTF-8 && dpkg-reconfigure --frontend noninteractive locales 28 | ENV LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" 29 | 30 | EXPOSE 22 80 443 38291 38391 38491 8000 29000 31 | 32 | ### set up code 33 | RUN mkdir /code 34 | WORKDIR /code 35 | 36 | # docker build --build-arg CACHEBUST=$(date +%s) . 37 | ARG CACHEBUST=1 38 | RUN git clone https://github.com/QuarkChain/pyquarkchain.git 39 | 40 | # py dep 41 | RUN pypy3 -m pip install -r pyquarkchain/requirements.txt 42 | RUN python3 -m pip install -r pyquarkchain/requirements.txt 43 | 44 | # build qkchash c++ lib 45 | WORKDIR /code/pyquarkchain/qkchash 46 | RUN make 47 | 48 | ENV PYTHONPATH /code/pyquarkchain 49 | ENV QKCHASHLIB /code/pyquarkchain/qkchash/libqkchash.so 50 | 51 | WORKDIR /code/pyquarkchain 52 | --------------------------------------------------------------------------------