Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 1ace3c7

Browse files
authored
Adria0/fix/tests (#11597)
* fix stRevertTests * add pending v7 tests * panic tests when chainspec is unimplemented * verify post_state in BlockchainTests * update to latest eth/test develop b9f5fe3 * EIP161 precompile balances precondition
1 parent b079d17 commit 1ace3c7

File tree

20 files changed

+708
-133
lines changed

20 files changed

+708
-133
lines changed

ethcore/machine/src/executive.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ const STACK_SIZE_ENTRY_OVERHEAD: usize = 100 * 1024;
6262
/// Entry stack overhead prior to execution.
6363
const STACK_SIZE_ENTRY_OVERHEAD: usize = 20 * 1024;
6464

65+
#[cfg(any(test, feature = "test-helpers"))]
66+
/// Precompile that can never be prunned from state trie (0x3, only in tests)
67+
const UNPRUNABLE_PRECOMPILE_ADDRESS: Option<Address> = Some(ethereum_types::H160([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3]));
68+
69+
#[cfg(not(any(test, feature = "test-helpers")))]
70+
/// Precompile that can never be prunned from state trie (none)
71+
const UNPRUNABLE_PRECOMPILE_ADDRESS: Option<Address> = None;
72+
6573
/// Returns new address created from address, nonce, and code hash
6674
pub fn contract_address(address_scheme: CreateContractAddress, sender: &Address, nonce: &U256, code: &[u8]) -> (Address, Option<H256>) {
6775
match address_scheme {
@@ -350,6 +358,11 @@ impl<'a> CallCreateExecutive<'a> {
350358
| Err(vm::Error::OutOfBounds)
351359
| Err(vm::Error::Reverted)
352360
| Ok(FinalizationResult { apply_state: false, .. }) => {
361+
if let Some(addr) = UNPRUNABLE_PRECOMPILE_ADDRESS {
362+
if un_substate.touched.contains(&addr) {
363+
substate.touched.insert(addr);
364+
}
365+
}
353366
state.revert_to_checkpoint();
354367
},
355368
Ok(_) | Err(vm::Error::Internal(_)) => {
@@ -407,6 +420,7 @@ impl<'a> CallCreateExecutive<'a> {
407420

408421
Self::check_static_flag(&params, self.static_flag, self.is_create)?;
409422
state.checkpoint();
423+
410424
Self::transfer_exec_balance(&params, self.schedule, state, substate)?;
411425

412426
let default = [];
@@ -435,9 +449,17 @@ impl<'a> CallCreateExecutive<'a> {
435449
})
436450
}
437451
} else {
452+
// Openethereum needs balance > 0 in precompiles to be EIP161 compliant, see PR#11597.
453+
// Since RIPEMD160 was removed in mainnet block #2686351, this is activated only in
454+
// tests to check this specific irregular state transition.
455+
if let Some(unprunable_addr) = UNPRUNABLE_PRECOMPILE_ADDRESS {
456+
if unprunable_addr != params.code_address
457+
&& state.balance(&params.code_address)?.is_zero() {
458+
substate.touched.remove(&params.code_address);
459+
}
460+
}
438461
// just drain the whole gas
439462
state.revert_to_checkpoint();
440-
441463
Err(vm::Error::OutOfGas)
442464
}
443465
};

ethcore/machine/src/test_helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub fn new_byzantium_test_machine() -> Machine { load_machine(include_bytes!("..
5050
pub fn new_constantinople_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/test-specs/constantinople_test.json")) }
5151

5252
/// Create a new Foundation St. Peter's (Contantinople Fix) era spec.
53-
pub fn new_constantinople_fix_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/test-specs/st_peters_test.json")) }
53+
pub fn new_constantinople_fix_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/test-specs/constantinople_fix_test.json")) }
5454

5555
/// Create a new Foundation Istanbul era spec.
5656
pub fn new_istanbul_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/test-specs/istanbul_test.json")) }
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{
2+
"name": "Byzantium to Constantinople (test)",
3+
"engine": {
4+
"Ethash": {
5+
"params": {
6+
"minimumDifficulty": "0x020000",
7+
"difficultyBoundDivisor": "0x0800",
8+
"durationLimit": "0x0d",
9+
"blockReward": {
10+
"0x0": "0x29A2241AF62C0000",
11+
"0x5": "0x1BC16D674EC80000"
12+
},
13+
"homesteadTransition": "0x0",
14+
"eip100bTransition": "0x0",
15+
"difficultyBombDelays": {
16+
"0": 3000000
17+
}
18+
}
19+
}
20+
},
21+
"params": {
22+
"gasLimitBoundDivisor": "0x0400",
23+
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
24+
"accountStartNonce": "0x00",
25+
"maximumExtraDataSize": "0x20",
26+
"minGasLimit": "0x1388",
27+
"networkID" : "0x1",
28+
"maxCodeSize": 24576,
29+
"maxCodeSizeTransition": "0x0",
30+
"eip150Transition": "0x0",
31+
"eip160Transition": "0x0",
32+
"eip161abcTransition": "0x0",
33+
"eip161dTransition": "0x0",
34+
"eip140Transition": "0x0",
35+
"eip211Transition": "0x0",
36+
"eip214Transition": "0x0",
37+
"eip155Transition": "0x0",
38+
"eip658Transition": "0x0",
39+
"eip145Transition": "0x5",
40+
"eip1014Transition": "0x5",
41+
"eip1052Transition": "0x5",
42+
"eip1283Transition": "0x5" ,
43+
"eip1283DisableTransition": "0x5"
44+
},
45+
"genesis": {
46+
"seal": {
47+
"ethereum": {
48+
"nonce": "0x0000000000000042",
49+
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
50+
}
51+
},
52+
"difficulty": "0x400000000",
53+
"author": "0x0000000000000000000000000000000000000000",
54+
"timestamp": "0x00",
55+
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
56+
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
57+
"gasLimit": "0x1388"
58+
},
59+
"accounts": {
60+
"0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
61+
"0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
62+
"0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
63+
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
64+
"0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x00", "pricing": { "modexp": { "divisor": 20 } } } },
65+
"0000000000000000000000000000000000000006": {
66+
"builtin": {
67+
"name": "alt_bn128_add",
68+
"pricing": {
69+
"0": {
70+
"price": { "alt_bn128_const_operations": { "price": 500 }}
71+
},
72+
"0x7fffffffffffff": {
73+
"info": "EIP 1108 transition",
74+
"price": { "alt_bn128_const_operations": { "price": 150 }}
75+
}
76+
}
77+
}
78+
},
79+
"0000000000000000000000000000000000000007": {
80+
"builtin": {
81+
"name": "alt_bn128_mul",
82+
"pricing": {
83+
"0": {
84+
"price": { "alt_bn128_const_operations": { "price": 40000 }}
85+
},
86+
"0x7fffffffffffff": {
87+
"info": "EIP 1108 transition",
88+
"price": { "alt_bn128_const_operations": { "price": 6000 }}
89+
}
90+
}
91+
}
92+
},
93+
"0000000000000000000000000000000000000008": {
94+
"builtin": {
95+
"name": "alt_bn128_pairing",
96+
"pricing": {
97+
"0": {
98+
"price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }}
99+
},
100+
"0x7fffffffffffff": {
101+
"info": "EIP 1108 transition",
102+
"price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }}
103+
}
104+
}
105+
}
106+
}
107+
}
108+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"name": "St. Peter's (test)",
3+
"engine": {
4+
"Ethash": {
5+
"params": {
6+
"minimumDifficulty": "0x020000",
7+
"difficultyBoundDivisor": "0x0800",
8+
"durationLimit": "0x0d",
9+
"blockReward": "0x1BC16D674EC80000",
10+
"homesteadTransition": "0x0",
11+
"eip100bTransition": "0x0",
12+
"difficultyBombDelays": {
13+
"0": 5000000
14+
}
15+
}
16+
}
17+
},
18+
"params": {
19+
"gasLimitBoundDivisor": "0x0400",
20+
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
21+
"accountStartNonce": "0x00",
22+
"maximumExtraDataSize": "0x20",
23+
"minGasLimit": "0x1388",
24+
"networkID" : "0x1",
25+
"maxCodeSize": 24576,
26+
"maxCodeSizeTransition": "0x0",
27+
"eip150Transition": "0x0",
28+
"eip160Transition": "0x0",
29+
"eip161abcTransition": "0x0",
30+
"eip161dTransition": "0x0",
31+
"eip140Transition": "0x0",
32+
"eip211Transition": "0x0",
33+
"eip214Transition": "0x0",
34+
"eip155Transition": "0x0",
35+
"eip658Transition": "0x0",
36+
"eip145Transition": "0x0",
37+
"eip1014Transition": "0x0",
38+
"eip1052Transition": "0x0",
39+
"eip1283Transition": "0x0",
40+
"eip1283DisableTransition": "0x0"
41+
},
42+
"genesis": {
43+
"seal": {
44+
"ethereum": {
45+
"nonce": "0x0000000000000042",
46+
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
47+
}
48+
},
49+
"difficulty": "0x400000000",
50+
"author": "0x0000000000000000000000000000000000000000",
51+
"timestamp": "0x00",
52+
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
53+
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
54+
"gasLimit": "0x1388"
55+
},
56+
"accounts": {
57+
"0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
58+
"0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
59+
"0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
60+
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
61+
"0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x00", "pricing": { "modexp": { "divisor": 20 } } } },
62+
"0000000000000000000000000000000000000006": {
63+
"builtin": {
64+
"name": "alt_bn128_add",
65+
"pricing": {
66+
"0": {
67+
"price": { "alt_bn128_const_operations": { "price": 500 }}
68+
},
69+
"0x7fffffffffffff": {
70+
"info": "EIP 1108 transition",
71+
"price": { "alt_bn128_const_operations": { "price": 150 }}
72+
}
73+
}
74+
}
75+
},
76+
"0000000000000000000000000000000000000007": {
77+
"builtin": {
78+
"name": "alt_bn128_mul",
79+
"pricing": {
80+
"0": {
81+
"price": { "alt_bn128_const_operations": { "price": 40000 }}
82+
},
83+
"0x7fffffffffffff": {
84+
"info": "EIP 1108 transition",
85+
"price": { "alt_bn128_const_operations": { "price": 6000 }}
86+
}
87+
}
88+
}
89+
},
90+
"0000000000000000000000000000000000000008": {
91+
"builtin": {
92+
"name": "alt_bn128_pairing",
93+
"pricing": {
94+
"0": {
95+
"price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }}
96+
},
97+
"0x7fffffffffffff": {
98+
"info": "EIP 1108 transition",
99+
"price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }}
100+
}
101+
}
102+
}
103+
}
104+
}
105+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"name": "EIP158 to byzantium (test)",
3+
"engine": {
4+
"Ethash": {
5+
"params": {
6+
"minimumDifficulty": "0x020000",
7+
"difficultyBoundDivisor": "0x0800",
8+
"durationLimit": "0x0d",
9+
"blockReward": {
10+
"0x0": "0x4563918244F40000",
11+
"0x5": "0x29A2241AF62C0000"
12+
},
13+
"homesteadTransition": "0",
14+
"eip100bTransition": "5",
15+
"difficultyBombDelays": {
16+
"5": 3000000
17+
}
18+
}
19+
}
20+
},
21+
"params": {
22+
"gasLimitBoundDivisor": "0x0400",
23+
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
24+
"accountStartNonce": "0x00",
25+
"maximumExtraDataSize": "0x20",
26+
"minGasLimit": "0x1388",
27+
"networkID" : "0x1",
28+
"maxCodeSize": 24576,
29+
"maxCodeSizeTransition": "0",
30+
"eip150Transition": "0",
31+
"eip155Transition": "0",
32+
"eip160Transition": "0",
33+
"eip161abcTransition": "0",
34+
"eip161dTransition": "0",
35+
"eip98Transition": "5",
36+
"eip140Transition": "5",
37+
"eip211Transition": "5",
38+
"eip214Transition": "5",
39+
"eip658Transition": "5"
40+
},
41+
"genesis": {
42+
"seal": {
43+
"ethereum": {
44+
"nonce": "0x0000000000000042",
45+
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
46+
}
47+
},
48+
"difficulty": "0x400000000",
49+
"author": "0x0000000000000000000000000000000000000000",
50+
"timestamp": "0x00",
51+
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
52+
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
53+
"gasLimit": "0x1388"
54+
},
55+
"accounts": {
56+
"0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
57+
"0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
58+
"0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
59+
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
60+
"0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x5", "pricing": { "modexp": { "divisor": 20 } } } },
61+
"0000000000000000000000000000000000000006": {
62+
"builtin": {
63+
"name": "alt_bn128_add",
64+
"pricing": {
65+
"5": {
66+
"price": { "alt_bn128_const_operations": { "price": 500 }}
67+
},
68+
"0x7fffffffffffff": {
69+
"info": "EIP 1108 transition",
70+
"price": { "alt_bn128_const_operations": { "price": 150 }}
71+
}
72+
}
73+
}
74+
},
75+
"0000000000000000000000000000000000000007": {
76+
"builtin": {
77+
"name": "alt_bn128_mul",
78+
"pricing": {
79+
"5": {
80+
"price": { "alt_bn128_const_operations": { "price": 40000 }}
81+
},
82+
"0x7fffffffffffff": {
83+
"info": "EIP 1108 transition",
84+
"price": { "alt_bn128_const_operations": { "price": 6000 }}
85+
}
86+
}
87+
}
88+
},
89+
"0000000000000000000000000000000000000008": {
90+
"builtin": {
91+
"name": "alt_bn128_pairing",
92+
"pricing": {
93+
"5": {
94+
"price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }}
95+
},
96+
"0x7fffffffffffff": {
97+
"info": "EIP 1108 transition",
98+
"price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }}
99+
}
100+
}
101+
}
102+
}
103+
}
104+
}

ethcore/res/ethereum/tests

Submodule tests updated 10353 files

0 commit comments

Comments
 (0)