Generated Blockchain Tests

Location /BlockchainTests

Subfolders

GeneralStateTests Tests generated in blockchain form from GeneralStateTests
InvalidBlocks Tests containing blocks that are expected to fail on import
ValidBlocks Normal blockchain tests
TransitionTests BC tests with exotic network rules switching forks at block#5

Test Structure

Contains blocks that are to be imported on top of genesisRLP of network fork rules network using sealEngine NoProof (Ethash no longer supported) and having genesis state as pre.

The result of block import must be state postState or postStateHash if result state is too big. And the last block of chain with maxTotalDifficulty must be block with hash lastblockhash

Single blockchain test file might contain many tests as there are many test generations for each individual network fork rules from single test source.

{
   "testname": {
     "_info" : { ... },
     "sealEngine": [ "NoProof" | "Ethash" ]
     "network": "Byzantium",
     "pre": { ... },
     "genesisBlockHeader": { ... },
     "genesisRLP": " ... ",
     "blocks" : [ ... ],
     "postState": { ... },
     "lastblockhash": " ... "
   },
   "testname": {
     "_info" : { ... },
     "sealEngine": [ "NoProof" | "Ethash" ]
     "network": "Byzantium",
     "pre": { ... },
     "genesisBlockHeader": { ... },
     "genesisRLP": " ... ",
     "blocks" : [ ... ],
     "postStateHash": " ... ",
     "lastblockhash": " ... "
   }
   ...
}

Info Section

"_info" : {
         "comment" : "A test for (add 1 1) opcode result",
         "filling-rpc-server" : "Geth-1.9.14-unstable-8cf83419-20200512",
         "filling-tool-version" : "retesteth-0.0.3+commit.672a84dd.Linux.g++",
         "lllcversion" : "Version: 0.5.14-develop.2019.11.27+commit.8f259595.Linux.g++",
         "source" : "src/GeneralStateTestsFiller/stExample/add11Filler.json",
         "sourceHash" : "e474fc13b1ea4c60efe2ba925dd48d6f9c1b12317dcd631f5eeeb3722a790a37"
 },

Info section is generated with the test and contains information about test and it’s generators.

Fields

comment comment from the test source. (can be edited at source)
filling-rpc-server tool that has been used to generate the test (version)
filling-tool-version the test generator (retesteth) version
lllcversion lllc version that was used to compile LLL code in test fillers
source path to the source filler in the test repository
sourceHash hash of the json of source file (used to track that tests are updated)

Pre/preState Section

"pre" : {
    "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
        "balance" : "0x0de0b6b3a7640000",
        "code" : "0x600160010160005500",
        "nonce" : "0x00",
        "storage" : {
            "0x00" : "0x01"
        }
    },
    "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
        "balance" : "0x0de0b6b3a7640000",
        "code" : "0x",
        "nonce" : "0x00",
        "storage" : {
        }
    }
},

Pre section describes a full state of accounts used in test.

Its a map of <Account> => <AccountFields>

AccountFields are always complete (balance, code, nonce, storage must present) in this section and can not have a missing field.

  • All values are 0x prefixed hex.
  • Empty code defined as 0x.
  • Zero storage record defined as 0x00.

Fields

address hash HASH20 is 20 bytes ethereum address 0x prefixed
balance VALUE account balance in evm state
code BYTES account code in evm state
nonce VALUE account nonce in evm state
storage map map of storage records VALUE => VALUE
TYPE Empty Length Format description
VALUE 0x00 Any* 0x prefixed hex up to 32 bytes long with no leading zeros.
BYTES 0x Any* 0x prefixed bytes of any length
HASH8 0x00…00 Fixed 8 0x prefixed bytes of length 8
HASH20 0x00…00 Fixed 20 0x prefixed bytes of length 20
HASH32 0x00…00 Fixed 32 0x prefixed bytes of length 32
HASH256 0x00…00 Fixed 256 0x prefixed bytes of length 256
  • Size can be limited by the meaning of field in tests. (like gasLimit ceil, tx signature v - value)

GenesisBlockHeader Section

"genesisRLP" : "0xf901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0cafd881ab193703b83816c49ff6c2bf6ba6f464a1be560c42106128c8dbc35e7a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080832fefd8808454c98c8142a00000000000000000000000000000000000000000000000000000000000000000880000000000000000c0c0",
"genesisBlockHeader" :
{
    "bloom" : "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "coinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
    "difficulty" : "0x020000",
    "extraData" : "0x42",
    "gasLimit" : "0x7fffffffffffffff",
    "gasUsed" : "0x00",
    "hash" : "0xd1b5003dbed66eb89c9b0062798a4fddf737157ef6550187d098d91ae2c3b853",
    "mixHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
    "nonce" : "0x0000000000000000",
    "number" : "0x00",
    "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
    "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
    "stateRoot" : "0x423c3994e5db8348336dd13c498b840988ea7f716a0b876af847c6b8a3446e43",
    "timestamp" : "0x03b6",
    "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
    "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
}

Genesis blockheader is basically the block header struct of the first block. It is constructed from test_setChainParams or config files and specify the genesis block header fields. Genesis block hash is later used in the tests. The key field here is genesisRLP, it contains the block information. genesisBlockHeader exist merely for humans to read the genesisRLP content. The content of genesisRLP MUST be equal to the one in genesisBlockHeader and is actually used in testers.

  • all fields are 0x prefixed HEX
  • 0 values are 0x00 rounded
  • empty extraData 0x

Fields

Fields are similar to the standard ethereum block header.

Valid Block Section

{
    "chainname" : "default",
    "blocknumber" : "1",
    "blockHeader" : {
        "bloom" : "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
        "coinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
        "difficulty" : "0x020000",
        "extraData" : "0x42",
        "gasLimit" : "0x7fffffffffffffff",
        "gasUsed" : "0x556d",
        "hash" : "0x46a8332db77844422d2550849594af5ae994a23274255fd369d3fbe964eb7cb1",
        "mixHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
        "nonce" : "0x0000000000000000",
        "number" : "0x01",
        "parentHash" : "0xd1b5003dbed66eb89c9b0062798a4fddf737157ef6550187d098d91ae2c3b853",
        "receiptTrie" : "0x5fa98a3ba1e25059bf41376c6f9a57b500a02c14c6a87afd1665a3906c4afd51",
        "stateRoot" : "0x6a117466ec6b8dbea3a613366a1b468bdeb6282e0156772c81cc2139caa7c88e",
        "timestamp" : "0x03e8",
        "transactionsTrie" : "0x76660905a74ef4a24b19295d8740a349b1170d3298118106201d43cd7886afbf",
        "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
    },
    "transactions" : [
        {
            "data" : "0x00000000000000000000000000000000000000000000000000000000000bc03712fac13c68425054e372b0861af05648614d69d32800fba9ad4522238d4b937a0000000000000000000000000000000000000000000000000000000000000000",
            "gasLimit" : "0x030d40",
            "gasPrice" : "0x01",
            "nonce" : "0x00",
            "r" : "0x3d55a2ac293c7ad82632b18705e67ad2a0e6177d44f601dca043934c8cd8c07a",
            "s" : "0x1c069ed47162b350a1f496e9a55f53685189e9c3076a4931334a43719b9a158e",
            "to" : "0x1baf27b88c48dd02b744999cf3522766929d2b2a",
            "v" : "0x1c",
            "value" : "0x00"
        }
    ],
    "uncleHeaders" : [
    ],
    "rlp" : "0xf902c5f901fca0d1b5003dbed66eb89c9b0062798a4fddf737157ef6550187d098d91ae2c3b853a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa06a117466ec6b8dbea3a613366a1b468bdeb6282e0156772c81cc2139caa7c88ea076660905a74ef4a24b19295d8740a349b1170d3298118106201d43cd7886afbfa05fa98a3ba1e25059bf41376c6f9a57b500a02c14c6a87afd1665a3906c4afd51b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001887fffffffffffffff82556d8203e842a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f8c3f8c1800183030d40941baf27b88c48dd02b744999cf3522766929d2b2a80b86000000000000000000000000000000000000000000000000000000000000bc03712fac13c68425054e372b0861af05648614d69d32800fba9ad4522238d4b937a00000000000000000000000000000000000000000000000000000000000000001ca03d55a2ac293c7ad82632b18705e67ad2a0e6177d44f601dca043934c8cd8c07aa01c069ed47162b350a1f496e9a55f53685189e9c3076a4931334a43719b9a158ec0"
}

Contains the block information that is going to be imported into test chain. The key field here is rlp. All testers take rlp field data and import it on top of genesis that was described in test by genesisRLP

Fields “blockHeader`, transactions, uncleHeaders describe the content of rlp for humans to read. it’s content MUST be equal to rlp field binary. All testers use rlp field data to import it into the test chain.

Fields chainname, blocknumber are irrelevant for the test client.

  • all fields are 0x prefixed HEX
  • 0 values are 0x00 rounded
  • empty extraData 0x
  • transaction creation to is “”

Invalid Block Section

{
    "chainname" : "default",
    "blocknumber" : "1",
    "expectException" : "InvalidDifficulty",
    "rlp" : "0xf902c5f901fca0d1b5003dbed66eb89c9b0062798a4fddf737157ef6550187d098d91ae2c3b853a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942adc25665018aa1fe0e6bc666dac8fc2697ff9baa06a117466ec6b8dbea3a613366a1b468bdeb6282e0156772c81cc2139caa7c88ea076660905a74ef4a24b19295d8740a349b1170d3298118106201d43cd7886afbfa05fa98a3ba1e25059bf41376c6f9a57b500a02c14c6a87afd1665a3906c4afd51b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001887fffffffffffffff82556d8203e842a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f8c3f8c1800183030d40941baf27b88c48dd02b744999cf3522766929d2b2a80b86000000000000000000000000000000000000000000000000000000000000bc03712fac13c68425054e372b0861af05648614d69d32800fba9ad4522238d4b937a00000000000000000000000000000000000000000000000000000000000000001ca03d55a2ac293c7ad82632b18705e67ad2a0e6177d44f601dca043934c8cd8c07aa01c069ed47162b350a1f496e9a55f53685189e9c3076a4931334a43719b9a158ec0"
}

The block rlp can represent invalid block that is expected to fail upon import. In this case there MUST BE NO blockHeader, transactions, uncleHeaders fields.

Fields chainname, blocknumber, expectException are irrelevant for the test client.

expectException is index in client’s exception string map defined in retesteth client configs.

Fields

Fields are similar to the standard ethereum block header / transaction

Transaction Section

{
    "transaction" : {
        "data" : "0x",
        "gasLimit" : "0x061a80",
        "gasPrice" : "0x01",
        "nonce" : "0x00",
        "secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
        "to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87",
        "value" : "0x0186a0"
    }
},
{
    "transaction" : {
        "data" : "0x",
        "gasLimit" : "0x061a80",
        "gasPrice" : "0x01",
        "nonce" : "0x00",
        "v" : "0x1c",
        "r" : "0x3d55a2ac293c7ad82632b18705e67ad2a0e6177d44f601dca043934c8cd8c07a",
        "s" : "0x1c069ed47162b350a1f496e9a55f53685189e9c3076a4931334a43719b9a158e",
        "to" : "",
        "value" : "0x0186a0"
    }
}

Transaction section defines single transaction to be executed in BlockchainTest’s block.

  • All fields are 0x prefixed HEX of even length (can be like 0x0122)
  • empty data is defined as 0x
  • transaction creation to defined as “”

Note

Fields r, s are u256 and can be less than 32 bytes!

Note

There is an EIP limiting s max value (source?). From a certain fork transactions with s value > sMaxValue are considered to be invalid.

Fields

data BYTES data/input code of the transaction
gasLimit VALUE gasLimit of transaction.
gasPrice VALUE Transaction’s gas price
nonce VALUE Transaction’s nonce
secretKey HASH32 SecretKey criptic value used to sign tx data by v,r,s
v VALUE Cryptic value 1 byte in length
r VALUE Values corresponding to the signature of the transaction and used to determine the sender of the transaction.
s VALUE Values corresponding to the signature of the transaction and used to determine the sender of the transaction.
to FH20 Transaction’s to destination address. set to "" if creation.
value VALUE Value of the transaction.
TYPE Empty Length Format description
VALUE 0x00 Any* 0x prefixed hex up to 32 bytes long with no leading zeros.
BYTES 0x Any* 0x prefixed bytes of any length
HASH8 0x00…00 Fixed 8 0x prefixed bytes of length 8
HASH20 0x00…00 Fixed 20 0x prefixed bytes of length 20
HASH32 0x00…00 Fixed 32 0x prefixed bytes of length 32
HASH256 0x00…00 Fixed 256 0x prefixed bytes of length 256
  • Size can be limited by the meaning of field in tests. (like gasLimit ceil, tx signature v - value)