Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CREATE2 patch entry #2

Merged
merged 1 commit into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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