Skip to content

Commit

Permalink
Merge pull request #2 from etclabscore/create2-patch
Browse files Browse the repository at this point in the history
Add CREATE2 patch entry
  • Loading branch information
Mike Lubinets authored Feb 15, 2019
2 parents 148540c + af1e365 commit 16ab820
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 2 deletions.
1 change: 0 additions & 1 deletion jsontests/benches/performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#[macro_use]
extern crate jsontests_derive;
extern crate jsontests;
extern crate sputnikvm;
#[macro_use]
extern crate criterion;
extern crate evm;
Expand Down
1 change: 1 addition & 0 deletions jsontests/tests/eiptests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ impl Patch for EIP1283Patch {
fn has_bitwise_shift() -> bool {
true
}
fn has_create2() -> bool { true }
fn has_extcodehash() -> bool {
true
}
Expand Down
6 changes: 6 additions & 0 deletions network/classic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl<A: AccountPatch> Patch for FrontierPatch<A> {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { true }
Expand Down Expand Up @@ -122,6 +123,7 @@ impl<A: AccountPatch> Patch for HomesteadPatch<A> {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { true }
Expand Down Expand Up @@ -154,6 +156,7 @@ impl<A: AccountPatch> Patch for EIP150Patch<A> {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { false }
Expand Down Expand Up @@ -186,6 +189,7 @@ impl<A: AccountPatch> Patch for EIP160Patch<A> {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { false }
Expand Down Expand Up @@ -218,6 +222,7 @@ impl<A: AccountPatch> Patch for ByzantiumPatch<A> {
fn has_revert() -> bool { true }
fn has_return_data() -> bool { true }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { false }
Expand Down Expand Up @@ -251,6 +256,7 @@ impl<A: AccountPatch> Patch for ConstantinoplePatch<A> {
fn has_revert() -> bool { true }
fn has_return_data() -> bool { true }
fn has_bitwise_shift() -> bool { true }
fn has_create2() -> bool { true }
fn has_extcodehash() -> bool { true }
fn has_reduced_sstore_gas_metering() -> bool { true }
fn err_on_call_with_more_gas() -> bool { false }
Expand Down
1 change: 1 addition & 0 deletions network/ellaism/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl<A: AccountPatch> Patch for EIP160Patch<A> {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { false }
Expand Down
4 changes: 4 additions & 0 deletions network/expanse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ impl Patch for FrontierPatch {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { true }
Expand Down Expand Up @@ -116,6 +117,7 @@ impl Patch for HomesteadPatch {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { true }
Expand Down Expand Up @@ -146,6 +148,7 @@ impl Patch for SpuriousDragonPatch {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { false }
Expand Down Expand Up @@ -176,6 +179,7 @@ impl Patch for ByzantiumPatch {
fn has_revert() -> bool { true }
fn has_return_data() -> bool { true }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { false }
Expand Down
5 changes: 5 additions & 0 deletions network/foundation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ impl Patch for FrontierPatch {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { true }
Expand Down Expand Up @@ -116,6 +117,7 @@ impl Patch for HomesteadPatch {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { true }
Expand Down Expand Up @@ -146,6 +148,7 @@ impl Patch for EIP150Patch {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { false }
Expand Down Expand Up @@ -176,6 +179,7 @@ impl Patch for SpuriousDragonPatch {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { false }
Expand Down Expand Up @@ -206,6 +210,7 @@ impl Patch for ByzantiumPatch {
fn has_revert() -> bool { true }
fn has_return_data() -> bool { true }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { false }
Expand Down
2 changes: 2 additions & 0 deletions network/musicoin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl<A: AccountPatch> Patch for FrontierPatch<A> {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { true }
Expand Down Expand Up @@ -82,6 +83,7 @@ impl<A: AccountPatch> Patch for HomesteadPatch<A> {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { true }
Expand Down
1 change: 1 addition & 0 deletions network/ubiq/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl Patch for SpuriousDragonPatch {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { false }
Expand Down
4 changes: 4 additions & 0 deletions src/patch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ pub trait Patch {
fn has_return_data() -> bool;
/// Whether the EVM has SHL, SHR and SAR
fn has_bitwise_shift() -> bool;
/// Whether the EVM has CREATE2
fn has_create2() -> bool;
/// Whether the EVM has EXTCODEHASH
fn has_extcodehash() -> bool;
/// Whether EVM should implement the EIP1283 gas metering scheme for SSTORE opcode
Expand Down Expand Up @@ -130,6 +132,7 @@ impl Patch for VMTestPatch {
fn has_revert() -> bool { true }
fn has_return_data() -> bool { true }
fn has_bitwise_shift() -> bool { true }
fn has_create2() -> bool { true }
fn has_extcodehash() -> bool { true }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { true }
Expand Down Expand Up @@ -160,6 +163,7 @@ impl Patch for EmbeddedPatch {
fn has_revert() -> bool { false }
fn has_return_data() -> bool { false }
fn has_bitwise_shift() -> bool { false }
fn has_create2() -> bool { false }
fn has_extcodehash() -> bool { false }
fn has_reduced_sstore_gas_metering() -> bool { false }
fn err_on_call_with_more_gas() -> bool { false }
Expand Down
8 changes: 7 additions & 1 deletion src/pc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,13 @@ macro_rules! impl_pc {
Opcode::LOG(v) => Instruction::LOG(v),

Opcode::CREATE => Instruction::CREATE,
Opcode::CREATE2 => Instruction::CREATE2,
Opcode::CREATE2 => {
if P::has_create2() {
Instruction::CREATE2
} else {
return Err(OnChainError::InvalidOpcode);
}
},
Opcode::CALL => Instruction::CALL,
Opcode::CALLCODE => Instruction::CALLCODE,
Opcode::RETURN => Instruction::RETURN,
Expand Down

0 comments on commit 16ab820

Please sign in to comment.