forked from ETCDEVTeam/sputnikvm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specify patches for supported networks
Summary: This moves Classic patches to a separate crate, and add additional patches for Foundation, Ellaism, Musicoin, Expanse, Ubiq. Reviewers: sorpaas Reviewed By: sorpaas Subscribers: jenkins Differential Revision: https://source.that.world/D46
- Loading branch information
Showing
25 changed files
with
840 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "sputnikvm-network-classic" | ||
version = "0.0.1" | ||
license = "Apache-2.0" | ||
authors = ["Wei Tang <[email protected]>"] | ||
repository = "https://github.com/ethereumproject/sputnikvm" | ||
|
||
[dependencies] | ||
sputnikvm = { version = "0.9", path = "../.." } | ||
etcommon-bigint = { version = "0.2", default-features = false } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
extern crate bigint; | ||
extern crate sputnikvm; | ||
|
||
use std::marker::PhantomData; | ||
use bigint::{Gas, U256, H160, Address}; | ||
use sputnikvm::{Precompiled, AccountPatch, Patch, | ||
ID_PRECOMPILED, ECREC_PRECOMPILED, SHA256_PRECOMPILED, RIP160_PRECOMPILED}; | ||
|
||
/// Mainnet account patch | ||
pub struct MainnetAccountPatch; | ||
impl AccountPatch for MainnetAccountPatch { | ||
fn initial_nonce() -> U256 { U256::zero() } | ||
fn initial_create_nonce() -> U256 { Self::initial_nonce() } | ||
fn empty_considered_exists() -> bool { true } | ||
} | ||
|
||
pub struct MordenAccountPatch; | ||
impl AccountPatch for MordenAccountPatch { | ||
fn initial_nonce() -> U256 { U256::from(1048576) } | ||
fn initial_create_nonce() -> U256 { Self::initial_nonce() } | ||
fn empty_considered_exists() -> bool { true } | ||
} | ||
|
||
pub static ETC_PRECOMPILEDS: [(Address, Option<&'static [u8]>, &'static Precompiled); 4] = [ | ||
(H160([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x01]), | ||
None, | ||
&ECREC_PRECOMPILED), | ||
(H160([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x02]), | ||
None, | ||
&SHA256_PRECOMPILED), | ||
(H160([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x03]), | ||
None, | ||
&RIP160_PRECOMPILED), | ||
(H160([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x04]), | ||
None, | ||
&ID_PRECOMPILED), | ||
]; | ||
|
||
/// Frontier patch. | ||
pub struct FrontierPatch<A: AccountPatch>(PhantomData<A>); | ||
pub type MainnetFrontierPatch = FrontierPatch<MainnetAccountPatch>; | ||
pub type MordenFrontierPatch = FrontierPatch<MordenAccountPatch>; | ||
impl<A: AccountPatch> Patch for FrontierPatch<A> { | ||
type Account = A; | ||
|
||
fn code_deposit_limit() -> Option<usize> { None } | ||
fn callstack_limit() -> usize { 1024 } | ||
fn gas_extcode() -> Gas { Gas::from(20usize) } | ||
fn gas_balance() -> Gas { Gas::from(20usize) } | ||
fn gas_sload() -> Gas { Gas::from(50usize) } | ||
fn gas_suicide() -> Gas { Gas::from(0usize) } | ||
fn gas_suicide_new_account() -> Gas { Gas::from(0usize) } | ||
fn gas_call() -> Gas { Gas::from(40usize) } | ||
fn gas_expbyte() -> Gas { Gas::from(10usize) } | ||
fn gas_transaction_create() -> Gas { Gas::from(0usize) } | ||
fn force_code_deposit() -> bool { true } | ||
fn has_delegate_call() -> bool { false } | ||
fn has_static_call() -> bool { false } | ||
fn has_revert() -> bool { false } | ||
fn has_return_data() -> bool { false } | ||
fn err_on_call_with_more_gas() -> bool { true } | ||
fn call_create_l64_after_gas() -> bool { false } | ||
fn memory_limit() -> usize { usize::max_value() } | ||
fn precompileds() -> &'static [(Address, Option<&'static [u8]>, &'static Precompiled)] { | ||
&ETC_PRECOMPILEDS } | ||
} | ||
|
||
/// Homestead patch. | ||
pub struct HomesteadPatch<A: AccountPatch>(PhantomData<A>); | ||
pub type MainnetHomesteadPatch = HomesteadPatch<MainnetAccountPatch>; | ||
pub type MordenHomesteadPatch = HomesteadPatch<MordenAccountPatch>; | ||
impl<A: AccountPatch> Patch for HomesteadPatch<A> { | ||
type Account = A; | ||
|
||
fn code_deposit_limit() -> Option<usize> { None } | ||
fn callstack_limit() -> usize { 1024 } | ||
fn gas_extcode() -> Gas { Gas::from(20usize) } | ||
fn gas_balance() -> Gas { Gas::from(20usize) } | ||
fn gas_sload() -> Gas { Gas::from(50usize) } | ||
fn gas_suicide() -> Gas { Gas::from(0usize) } | ||
fn gas_suicide_new_account() -> Gas { Gas::from(0usize) } | ||
fn gas_call() -> Gas { Gas::from(40usize) } | ||
fn gas_expbyte() -> Gas { Gas::from(10usize) } | ||
fn gas_transaction_create() -> Gas { Gas::from(32000usize) } | ||
fn force_code_deposit() -> bool { false } | ||
fn has_delegate_call() -> bool { true } | ||
fn has_static_call() -> bool { false } | ||
fn has_revert() -> bool { false } | ||
fn has_return_data() -> bool { false } | ||
fn err_on_call_with_more_gas() -> bool { true } | ||
fn call_create_l64_after_gas() -> bool { false } | ||
fn memory_limit() -> usize { usize::max_value() } | ||
fn precompileds() -> &'static [(Address, Option<&'static [u8]>, &'static Precompiled)] { | ||
&ETC_PRECOMPILEDS } | ||
} | ||
|
||
/// EIP150 patch. | ||
pub struct EIP150Patch<A: AccountPatch>(PhantomData<A>); | ||
pub type MainnetEIP150Patch = EIP150Patch<MainnetAccountPatch>; | ||
pub type MordenEIP150Patch = EIP150Patch<MordenAccountPatch>; | ||
impl<A: AccountPatch> Patch for EIP150Patch<A> { | ||
type Account = A; | ||
|
||
fn code_deposit_limit() -> Option<usize> { None } | ||
fn callstack_limit() -> usize { 1024 } | ||
fn gas_extcode() -> Gas { Gas::from(700usize) } | ||
fn gas_balance() -> Gas { Gas::from(400usize) } | ||
fn gas_sload() -> Gas { Gas::from(200usize) } | ||
fn gas_suicide() -> Gas { Gas::from(5000usize) } | ||
fn gas_suicide_new_account() -> Gas { Gas::from(25000usize) } | ||
fn gas_call() -> Gas { Gas::from(700usize) } | ||
fn gas_expbyte() -> Gas { Gas::from(10usize) } | ||
fn gas_transaction_create() -> Gas { Gas::from(32000usize) } | ||
fn force_code_deposit() -> bool { false } | ||
fn has_delegate_call() -> bool { true } | ||
fn has_static_call() -> bool { false } | ||
fn has_revert() -> bool { false } | ||
fn has_return_data() -> bool { false } | ||
fn err_on_call_with_more_gas() -> bool { false } | ||
fn call_create_l64_after_gas() -> bool { true } | ||
fn memory_limit() -> usize { usize::max_value() } | ||
fn precompileds() -> &'static [(Address, Option<&'static [u8]>, &'static Precompiled)] { | ||
&ETC_PRECOMPILEDS } | ||
} | ||
|
||
/// EIP160 patch. | ||
pub struct EIP160Patch<A: AccountPatch>(PhantomData<A>); | ||
pub type MainnetEIP160Patch = EIP160Patch<MainnetAccountPatch>; | ||
pub type MordenEIP160Patch = EIP160Patch<MordenAccountPatch>; | ||
impl<A: AccountPatch> Patch for EIP160Patch<A> { | ||
type Account = A; | ||
|
||
fn code_deposit_limit() -> Option<usize> { None } | ||
fn callstack_limit() -> usize { 1024 } | ||
fn gas_extcode() -> Gas { Gas::from(700usize) } | ||
fn gas_balance() -> Gas { Gas::from(400usize) } | ||
fn gas_sload() -> Gas { Gas::from(200usize) } | ||
fn gas_suicide() -> Gas { Gas::from(5000usize) } | ||
fn gas_suicide_new_account() -> Gas { Gas::from(25000usize) } | ||
fn gas_call() -> Gas { Gas::from(700usize) } | ||
fn gas_expbyte() -> Gas { Gas::from(50usize) } | ||
fn gas_transaction_create() -> Gas { Gas::from(32000usize) } | ||
fn force_code_deposit() -> bool { false } | ||
fn has_delegate_call() -> bool { true } | ||
fn has_static_call() -> bool { false } | ||
fn has_revert() -> bool { false } | ||
fn has_return_data() -> bool { false } | ||
fn err_on_call_with_more_gas() -> bool { false } | ||
fn call_create_l64_after_gas() -> bool { true } | ||
fn memory_limit() -> usize { usize::max_value() } | ||
fn precompileds() -> &'static [(Address, Option<&'static [u8]>, &'static Precompiled)] { | ||
&ETC_PRECOMPILEDS } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "sputnikvm-network-ellaism" | ||
version = "0.0.1" | ||
license = "Apache-2.0" | ||
authors = ["Wei Tang <[email protected]>"] | ||
repository = "https://github.com/ethereumproject/sputnikvm" | ||
|
||
[dependencies] | ||
sputnikvm = { version = "0.9", path = "../.." } | ||
etcommon-bigint = { version = "0.2", default-features = false } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
extern crate bigint; | ||
extern crate sputnikvm; | ||
|
||
use std::marker::PhantomData; | ||
use bigint::{Gas, U256, H160, Address}; | ||
use sputnikvm::{Precompiled, AccountPatch, Patch, | ||
ID_PRECOMPILED, ECREC_PRECOMPILED, SHA256_PRECOMPILED, RIP160_PRECOMPILED}; | ||
|
||
pub static ELLA_PRECOMPILEDS: [(Address, Option<&'static [u8]>, &'static Precompiled); 4] = [ | ||
(H160([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x01]), | ||
None, | ||
&ECREC_PRECOMPILED), | ||
(H160([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x02]), | ||
None, | ||
&SHA256_PRECOMPILED), | ||
(H160([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x03]), | ||
None, | ||
&RIP160_PRECOMPILED), | ||
(H160([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x04]), | ||
None, | ||
&ID_PRECOMPILED), | ||
]; | ||
|
||
/// Mainnet account patch | ||
pub struct MainnetAccountPatch; | ||
impl AccountPatch for MainnetAccountPatch { | ||
fn initial_nonce() -> U256 { U256::zero() } | ||
fn initial_create_nonce() -> U256 { Self::initial_nonce() } | ||
fn empty_considered_exists() -> bool { true } | ||
} | ||
|
||
/// EIP160 patch. | ||
pub struct EIP160Patch<A: AccountPatch>(PhantomData<A>); | ||
pub type MainnetEIP160Patch = EIP160Patch<MainnetAccountPatch>; | ||
impl<A: AccountPatch> Patch for EIP160Patch<A> { | ||
type Account = A; | ||
|
||
fn code_deposit_limit() -> Option<usize> { None } | ||
fn callstack_limit() -> usize { 1024 } | ||
fn gas_extcode() -> Gas { Gas::from(700usize) } | ||
fn gas_balance() -> Gas { Gas::from(400usize) } | ||
fn gas_sload() -> Gas { Gas::from(200usize) } | ||
fn gas_suicide() -> Gas { Gas::from(5000usize) } | ||
fn gas_suicide_new_account() -> Gas { Gas::from(25000usize) } | ||
fn gas_call() -> Gas { Gas::from(700usize) } | ||
fn gas_expbyte() -> Gas { Gas::from(50usize) } | ||
fn gas_transaction_create() -> Gas { Gas::from(32000usize) } | ||
fn force_code_deposit() -> bool { false } | ||
fn has_delegate_call() -> bool { true } | ||
fn has_static_call() -> bool { false } | ||
fn has_revert() -> bool { false } | ||
fn has_return_data() -> bool { false } | ||
fn err_on_call_with_more_gas() -> bool { false } | ||
fn call_create_l64_after_gas() -> bool { true } | ||
fn memory_limit() -> usize { usize::max_value() } | ||
fn precompileds() -> &'static [(Address, Option<&'static [u8]>, &'static Precompiled)] { | ||
&ELLA_PRECOMPILEDS } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "sputnikvm-network-expanse" | ||
version = "0.0.1" | ||
license = "Apache-2.0" | ||
authors = ["Wei Tang <[email protected]>"] | ||
repository = "https://github.com/ethereumproject/sputnikvm" | ||
|
||
[dependencies] | ||
sputnikvm = { version = "0.9", path = "../.." } | ||
sputnikvm-precompiled-bn128 = { path = "../../precompiled/bn128" } | ||
sputnikvm-precompiled-modexp = { path = "../../precompiled/modexp" } | ||
etcommon-bigint = { version = "0.2", default-features = false } |
Oops, something went wrong.