Skip to content

Commit

Permalink
VM: add retesteth support for transition-tool protocol (#2088)
Browse files Browse the repository at this point in the history
* vm: add transition-tool script

* vm: add yars devDependency [no ci]

* vm: first retesteth test passes (stExample/add11)

* vm: add README and add client config

* vm: add client configs [no ci]

* vm: create transition-tool cluster

* vm: retesteth cleanup

* retesteth: update cluster

* retesteth: remove unused files

* vm: update common config to work with retesteth

* retesteth: fix runner for typed txs

* retesteth: fix tx common loader for data fee

* retesteth: add support for tx rejects

* reteseteth: add errors

* retesteth: remove console.logs

* retesteth: ensure difficulty is set

* update pkglock

* retesteth: update configs

* add merge support

* update path to transition-child, clarify readme

* Add workaround for merge tests genesis block error

Co-authored-by: acolytec3 <[email protected]>
Co-authored-by: Holger Drewes <[email protected]>
  • Loading branch information
3 people authored Sep 15, 2022
1 parent cfa99af commit 8f48a1d
Show file tree
Hide file tree
Showing 42 changed files with 5,275 additions and 288 deletions.
4,829 changes: 4,583 additions & 246 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions packages/block/.c8rc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "../../config/.c8rc.json",
"include": [
"src/**/*.ts"
]
"include": ["src/**/*.ts"]
}
4 changes: 1 addition & 3 deletions packages/blockchain/.c8rc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "../../config/.c8rc.json",
"include": [
"src/**/*.ts"
]
"include": ["src/**/*.ts"]
}
4 changes: 1 addition & 3 deletions packages/client/.c8rc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "../../config/.c8rc.json",
"include": [
"lib/**/*.ts"
]
"include": ["lib/**/*.ts"]
}
4 changes: 1 addition & 3 deletions packages/common/.c8rc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "../../config/.c8rc.json",
"include": [
"src/**/*.ts"
]
"include": ["src/**/*.ts"]
}
4 changes: 1 addition & 3 deletions packages/devp2p/.c8rc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "../../config/.c8rc.json",
"include": [
"src/**/*.ts"
]
"include": ["src/**/*.ts"]
}
4 changes: 1 addition & 3 deletions packages/ethash/.c8rc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "../../config/.c8rc.json",
"include": [
"src/**/*.ts"
]
"include": ["src/**/*.ts"]
}
4 changes: 1 addition & 3 deletions packages/evm/.c8rc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "../../config/.c8rc.json",
"include": [
"src/**/*.ts"
]
"include": ["src/**/*.ts"]
}
4 changes: 1 addition & 3 deletions packages/rlp/.c8rc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "../../config/.c8rc.json",
"include": [
"src/**/*.ts"
]
"include": ["src/**/*.ts"]
}
4 changes: 1 addition & 3 deletions packages/statemanager/.c8rc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "../../config/.c8rc.json",
"include": [
"src/**/*.ts"
]
"include": ["src/**/*.ts"]
}
4 changes: 1 addition & 3 deletions packages/trie/.c8rc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "../../config/.c8rc.json",
"include": [
"src/**/*.ts"
]
"include": ["src/**/*.ts"]
}
4 changes: 1 addition & 3 deletions packages/tx/.c8rc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "../../config/.c8rc.json",
"include": [
"src/**/*.ts"
]
"include": ["src/**/*.ts"]
}
4 changes: 1 addition & 3 deletions packages/util/.c8rc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "../../config/.c8rc.json",
"include": [
"src/**/*.ts"
]
"include": ["src/**/*.ts"]
}
4 changes: 1 addition & 3 deletions packages/vm/.c8rc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "../../config/.c8rc.json",
"include": [
"src/**/*.ts"
]
"include": ["src/**/*.ts"]
}
7 changes: 7 additions & 0 deletions packages/vm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@
"memory-level": "^1.0.0",
"minimist": "^1.2.5",
"node-dir": "^0.1.17",
"nyc": "^15.1.0",
"prettier": "^2.0.5",
"standard": "^10.0.0",
"tape": "^5.3.1",
"ts-node": "^10.2.1",
"typedoc": "^0.22.4",
"typescript": "^4.4.2",
"solc": "^0.8.1"
},
"engines": {
Expand Down
6 changes: 3 additions & 3 deletions packages/vm/src/buildBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class BlockBuilder {
/**
* Calculates and returns the transactionsTrie for the block.
*/
private async transactionsTrie() {
public async transactionsTrie() {
const trie = new Trie()
for (const [i, tx] of this.transactions.entries()) {
await trie.put(Buffer.from(RLP.encode(i)), tx.serialize())
Expand All @@ -76,7 +76,7 @@ export class BlockBuilder {
/**
* Calculates and returns the logs bloom for the block.
*/
private logsBloom() {
public logsBloom() {
const bloom = new Bloom()
for (const txResult of this.transactionResults) {
// Combine blooms via bitwise OR
Expand All @@ -88,7 +88,7 @@ export class BlockBuilder {
/**
* Calculates and returns the receiptTrie for the block.
*/
private async receiptTrie() {
public async receiptTrie() {
const receiptTrie = new Trie()
for (const [i, txResult] of this.transactionResults.entries()) {
const tx = this.transactions[i]
Expand Down
23 changes: 23 additions & 0 deletions packages/vm/tests/retesteth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
This folder contains a script to run with `ts-node` together with `retesteth`.

# Instructions

Clone `ethereum/tests` (either in the `ethereumjs-monorepo` or elsewhere).

Configure and run `transition-tool`:

Note: All paths are relative paths to the `VM` package root.

1. If you change the port number in `transition-cluster.ts` to anything other than 3000 (or run `transition-cluster` on a separate machine or different IP address from retesteth), update `tests/vm/retesteth/clients/ethereumjs/start.sh` to reflect the right IP and port.

2. From VM package root directory, run `npx ts-node tests/retesteth/transition-cluster.ts`

Configure and run `retesteth`:

1. Follow the build instructions to build and install [`retesteth`](https://github.com/ethereum/retesteth)

2. Run `retesteth` from `[retesteth repository root]/build/retesteth` using the below command

`./retesteth -t GeneralStateTests -- --testpath $ETHEREUM_TESTPATH --datadir $RETESTETH_CLIENTS --clients "ethereumjs"`

Here `$ETHEREUM_TESTPATH` should be set to where `ethereum/tests` root folder is installed (so after cloning it). `$RETESTETH_CLIENTS` should be set to `[ethereumjs-monorepo root]/packages/vm/tests/retesteth/clients` (use the absolute path from root when running retesteth from another folder).
212 changes: 212 additions & 0 deletions packages/vm/tests/retesteth/clients/ethereumjs/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
{
"name":"EthereumJS Transition Tool",
"socketType":"tranition-tool",
"socketAddress":"start.sh",
"forks":[
"Frontier",
"Homestead",
"EIP150",
"EIP158",
"Byzantium",
"Constantinople",
"ConstantinopleFix",
"Istanbul",
"Berlin",
"London",
"Merge"
],
"additionalForks":[
"FrontierToHomesteadAt5",
"HomesteadToEIP150At5",
"EIP158ToByzantiumAt5",
"HomesteadToDaoAt5",
"ByzantiumToConstantinopleFixAt5",
"BerlinToLondonAt5",
"ArrowGlacier"
],
"exceptions":{
"AddressTooShort":"",
"AddressTooLong":"",
"NonceMax":"",
"NonceTooLong":"",
"InvalidVRS":"",
"InvalidV":"",
"InvalidR":"",
"InvalidS":"",
"InvalidChainID":"",
"ECRecoveryFail":"",
"InvalidStateRoot":"",
"ExtraDataTooBig":"",
"InvalidData":"",
"InvalidDifficulty":"",
"InvalidDifficulty2":"",
"InvalidDifficulty_TooLarge":"",
"InvalidGasLimit":"",
"InvalidGasLimit2":"",
"InvalidGasLimit3":"",
"InvalidGasLimit4":"",
"InvalidGasLimit5":"",
"InvalidValue":"",
"InvalidGasPrice":"",
"InvalidMaxPriorityFeePerGas":"",
"InvalidMaxFeePerGas":"",
"InvalidNonce":"",
"InvalidTo":"",
"GasLimitPriceProductOverflow":"",
"TooMuchGasUsed":"",
"TooMuchGasUsed2":"",
"LeadingZerosGasLimit":"",
"LeadingZerosGasPrice":"",
"LeadingZerosValue":"",
"LeadingZerosNonce":"",
"LeadingZerosR":"",
"LeadingZerosS":"",
"LeadingZerosV":"",
"LeadingZerosDataSize":"",
"LeadingZerosNonceSize":"",
"InvalidNumber":"",
"InvalidTimestampEqualParent":"",
"InvalidTimestampOlderParent":"",
"InvalidLogBloom":"",
"InvalidGasUsed":"",
"InvalidGasUsed2":"",
"InvalidBlockMixHash":"",
"InvalidBlockNonce":"",
"UnknownParent":"",
"UnknownParent2":"",
"InvalidReceiptsStateRoot":"",
"InvalidTransactionsRoot":"",
"InvalidUnclesHash":"",
"InvalidUncleParentHash":"",
"UncleInChain":"",
"UncleIsAncestor":"",
"UncleParentIsNotAncestor":"",
"TooManyUncles":"",
"UncleIsBrother":"",
"OutOfGas":"",
"SenderNotEOA":"",
"IntrinsicGas":"",
"ExtraDataIncorrectDAO":"",
"InvalidTransactionVRS":"",
"BLOCKHEADER_VALUE_TOOLARGE":"",
"TRANSACTION_VALUE_TOOLARGE":"",
"TRANSACTION_VALUE_TOOSHORT":"",
"TR_NonceHasMaxValue":"",
"OVERSIZE_RLP":"",
"RLP_TooFewElements":"",
"RLP_TooManyElements":"",
"RLP_InputContainsMoreThanOneValue":"",
"RLP_VALUESIZE_MORE_AVAILABLEINPUTLENGTH":"",
"RLP_ELEMENT_LARGER_CONTAININGLIST_UNDERSIZE":"",
"RLP_ELEMENT_LARGER_CONTAININGLIST_OVERSIZE":"",
"RLP_ExpectedInputList_EXTBLOCK":"",
"RLP_InvalidArg0_UNMARSHAL_BYTES":"",
"RLP_ExpectedInputList_HEADER_DECODEINTO_BLOCK_EXTBLOCK":"",
"RLP_InputList_TooManyElements_HEADER_DECODEINTO_BLOCK_EXTBLOCK_HEADER":"",
"RLP_InputList_TooManyElements_TXDATA_DECODEINTO_BLOCK_EXTBLOCK_TXS0":"",
"RLP_InputString_TooShort_ADDRESS_DECODEINTO_BLOCK_EXTBLOCK_HEADER_COINBASE":"",
"RLP_InputString_TooShort_ADDRESS_DECODEINTO_BLOCK_EXTBLOCK_HEADER_COINBASE2":"",
"RLP_InputString_TooShort_ADDRESS_DECODEINTO_BLOCK_EXTBLOCK_TXS0_RECIPIENT":"",
"RLP_InputString_TooLong_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_ROOT":"",
"RLP_InputString_TooLong_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_ROOT2":"",
"RLP_InputString_TooLong_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_MIXDIGEST":"",
"RLP_InputString_TooLong_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_MIXDIGEST2":"",
"RLP_InputString_TooLong_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_PARENTHASH":"",
"RLP_InputString_TooLong_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_PARENTHASH2":"",
"RLP_InputString_TooLong_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_RECEIPTHASH":"",
"RLP_InputString_TooLong_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_RECEIPTHASH2":"",
"RLP_InputString_TooLong_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_TXHASH":"",
"RLP_InputString_TooLong_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_UNCLEHASH":"",
"RLP_InputString_TooLong_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_UNCLEHASH2":"",
"RLP_InputString_TooLong_UINT64_DECODEINTO_BLOCK_EXTBLOCK_HEADER_GASLIMIT":"",
"RLP_InputString_TooLong_UINT64_DECODEINTO_BLOCK_EXTBLOCK_HEADER_GASUSED":"",
"RLP_InputString_TooLong_UINT64_DECODEINTO_BLOCK_EXTBLOCK_HEADER_TIME":"",
"RLP_InputString_TooLong_UINT64_DECODEINTO_BLOCK_EXTBLOCK_TXS0_GASLIMIT":"",
"RLP_InputString_TooShort_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_RECEIPTHASH":"",
"RLP_InputString_TooShort_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_RECEIPTHASH2":"",
"RLP_InputString_TooShort_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_ROOT":"",
"RLP_InputString_TooShort_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_MIXDIGEST":"",
"RLP_InputString_TooShort_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_MIXDIGEST2":"",
"RLP_InputString_TooShort_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_PARENTHASH":"",
"RLP_InputString_TooShort_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_PARENTHASH2":"",
"RLP_InputString_TooShort_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_UNCLEHASH":"",
"RLP_InputString_TooShort_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_UNCLEHASH2":"",
"RLP_InputString_TooShort_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_TXHASH":"",
"RLP_InputString_TooShort_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_TXHASH2":"",
"RLP_InputString_TooShort_BLOOM_DECODEINTO_BLOCK_EXTBLOCK_HEADER_BLOOM":"",
"RLP_NonCanonicalINT_LeadingZeros_BIGINT_DECODEINTO_BLOCK_EXTBLOCK_HEADER_DIFFICULTY":"",
"RLP_NonCanonicalINT_LeadingZeros_BIGINT_DECODEINTO_BLOCK_EXTBLOCK_HEADER_DIFFICULTY2":"",
"RLP_NonCanonicalINT_LeadingZeros_UINT64_DECODEINTO_BLOCK_EXTBLOCK_HEADER_GASLIMIT":"",
"RLP_NonCanonicalINT_LeadingZeros_UINT64_DECODEINTO_BLOCK_EXTBLOCK_HEADER_GASLIMIT2":"",
"RLP_NonCanonicalINT_LeadingZeros_UINT64_DECODEINTO_BLOCK_EXTBLOCK_HEADER_GASUSED":"",
"RLP_NonCanonicalINT_LeadingZeros_UINT64_DECODEINTO_BLOCK_EXTBLOCK_HEADER_GASUSED2":"",
"RLP_NonCanonicalINT_LeadingZeros_UINT64_DECODEINTO_BLOCK_EXTBLOCK_HEADER_TIME":"",
"RLP_NonCanonicalINT_LeadingZeros_UINT64_DECODEINTO_BLOCK_EXTBLOCK_HEADER_TIME2":"",
"RLP_NonCanonicalINT_LeadingZeros_UINT64_DECODEINTO_BLOCK_EXTBLOCK_TXS0_GASLIMIT":"",
"RLP_NonCanonicalINT_LeadingZeros_UINT64_DECODEINTO_BLOCK_EXTBLOCK_TXS0_GASLIMIT2":"",
"RLP_NonCanonicalINT_LeadingZeros_BIGINT_DECODEINTO_BLOCK_EXTBLOCK_HEADER_NUMBER":"",
"RLP_NonCanonicalINT_LeadingZeros_BIGINT_DECODEINTO_BLOCK_EXTBLOCK_HEADER_NUMBER2":"",
"RLP_NonCanonicalINT_LeadingZeros_BIGINT_DECODEINTO_BLOCK_EXTBLOCK_TXS0_TXDATA_PRICE":"",
"RLP_NonCanonicalINT_LeadingZeros_BIGINT_DECODEINTO_BLOCK_EXTBLOCK_TXS0_TXDATA_R":"",
"RLP_NonCanonicalINT_LeadingZeros_BIGINT_DECODEINTO_BLOCK_EXTBLOCK_TXS0_TXDATA_S":"",
"RLP_InputString_TooLong_BLOOM_DECODEINTO_BLOCK_EXTBLOCK_HEADER_BLOOM":"",
"RLP_ExpectedInputString_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_PARENTHASH":"",
"RLP_ExpectedInputString_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_RECEIPTHASH":"",
"RLP_ExpectedInputString_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_ROOT":"",
"RLP_ExpectedInputString_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_MIXDIGEST":"",
"RLP_ExpectedInputString_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_TXHASH":"",
"RLP_ExpectedInputString_HASH_DECODEINTO_BLOCK_EXTBLOCK_HEADER_UNCLEHASH":"",
"RLP_ExpectedInputString_ADDRESS_DECODEINTO_BLOCK_EXTBLOCK_HEADER_COINBASE":"",
"RLP_ExpectedInputString_ADDRESS_DECODEINTO_BLOCK_EXTBLOCK_TX0_RECIPIENT":"",
"RLP_InputString_TooLong_ADDRESS_DECODEINTO_BLOCK_EXTBLOCK_HEADER_COINBASE":"",
"RLP_InputString_TooLong_ADDRESS_DECODEINTO_BLOCK_EXTBLOCK_TXS0_RECIPIENT":"",
"RLP_ExpectedInputString_BIGINT_DECODEINTO_BLOCK_EXTBLOCK_HEADER_DIFFICULTY":"",
"RLP_ExpectedInputString_BIGINT_DECODEINTO_BLOCK_EXTBLOCK_TXS0_TXR":"",
"RLP_ExpectedInputString_BIGINT_DECODEINTO_BLOCK_EXTBLOCK_TXS0_TXS":"",
"RLP_ExpectedInputString_UINT64_DECODEINTO_BLOCK_EXTBLOCK_HEADER_GASLIMIT":"",
"RLP_ExpectedInputString_UINT64_DECODEINTO_BLOCK_EXTBLOCK_HEADER_GASUSED":"",
"RLP_ExpectedInputString_UINT64_DECODEINTO_BLOCK_EXTBLOCK_HEADER_TIME":"",
"RLP_ExpectedInputString_UINT64_DECODEINTO_BLOCK_EXTBLOCK_TXS0_GASLIMIT":"",
"RLP_ExpectedInputString_NONCE_DECODEINTO_BLOCK_EXTBLOCK_HEADER_NONCE":"",
"RLP_ExpectedInputString_UINT8_DECODEINTO_BLOCK_EXTBLOCK_TXS0_PAYLOAD":"",
"RLP_InputString_TooLong_BLOCKNONCE_DECODEINTO_BLOCK_EXTBLOCK_HEADER_NONCE":"",
"RLP_InputString_TooLong_BLOCKNONCE_DECODEINTO_BLOCK_EXTBLOCK_HEADER_NONCE2":"",
"RLP_NonCanonical_SizeInfo_EXTBLOCK":"",
"RLP_ExpectedInputList_TRANSACTION_DECODEINTO_BLOCK_EXTBLOCK_TXS":"",
"RLP_ExpectedInputList_HEADER_DECODEINTO_BLOCK_EXTBLOCK_UNCLES":"",
"RLP_ExpectedInputList_TXDATA_DECODEINTO_BLOCK_EXTBLOCK_TXS0":"",
"RLP_Error_EOF":"",
"RLP_Error_RLP_Size":"",
"RLP_Error_Size_Information":"",
"LegacyBlockImportImpossible":"",
"LegacyBlockImportImpossible2":"",
"LegacyBlockBaseFeeTransaction":"",
"1559BlockImportImpossible_HeaderIsLegacy":"",
"1559BlockImportImpossible_BaseFeeWrong":"",
"1559BlockImportImpossible_InitialBaseFeeWrong":"",
"1559BlockImportImpossible_TargetGasLow":"",
"1559BlockImportImpossible_TargetGasHigh":"",
"1559BlockImportImpossible_InitialGasLimitInvalid":"",
"TR_IntrinsicGas":"",
"TR_NoFunds":"",
"TR_NoFundsValue":"",
"TR_FeeCapLessThanBlocks":"",
"TR_GasLimitReached":"",
"TR_NonceTooHigh":"",
"TR_NonceTooLow":"",
"TR_TypeNotSupported":"",
"TR_TipGtFeeCap":"",
"TR_TooShort":"",
"1559BaseFeeTooLarge":"",
"1559PriorityFeeGreaterThanBaseFee":"",
"2930AccessListAddressTooLong":"",
"2930AccessListAddressTooShort":"",
"2930AccessListStorageHashTooLong":"",
"1559LeadingZerosBaseFee":"",
"1559LeadingZerosPriorityFee":"",
"2930AccessListStorageHashTooShort":"",
"3675PoWBlockRejected":"",
"3675PoSBlockRejected":"",
"3675PreMerge1559BlockRejected":""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"params" : {
"fork" : "ArrowGlacier",
"constantinopleForkBlock" : "0x00",
"byzantiumForkBlock" : "0x00",
"homesteadForkBlock" : "0x00"
},
"accounts" : {
}
}
Loading

0 comments on commit 8f48a1d

Please sign in to comment.