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

fix(revme): Burntpix bench #1937

Merged
merged 4 commits into from
Dec 20, 2024
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
3 changes: 1 addition & 2 deletions bins/revme/src/cmd/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ pub enum BenchName {
impl BenchName {
pub const ALL: &[BenchName] = &[
BenchName::Analysis,
// TODO: Fails with OutOfGas(InvalidOperand)
// BenchName::Burntpix,
BenchName::Burntpix,
BenchName::Snailtracer,
BenchName::Transfer,
];
Expand Down
24 changes: 7 additions & 17 deletions bins/revme/src/cmd/bench/burntpix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub fn run() {
tx.caller = address!("1000000000000000000000000000000000000000");
tx.transact_to = TxKind::Call(BURNTPIX_MAIN_ADDRESS);
tx.data = run_call_data.clone().into();
tx.gas_limit = u64::MAX;
});
let mut evm = MainEvm::new(context, EthHandler::default());

Expand Down Expand Up @@ -100,7 +101,8 @@ fn try_from_hex_to_u32(hex: &str) -> Result<u32, Box<dyn Error>> {
u32::from_str_radix(trimmed, 16).map_err(|e| format!("Failed to parse hex: {}", e).into())
}

fn insert_account_info(cache_db: &mut CacheDB<EmptyDB>, addr: Address, code: Bytes) {
fn insert_account_info(cache_db: &mut CacheDB<EmptyDB>, addr: Address, code: &str) {
let code = Bytes::from(hex::decode(code).unwrap());
let code_hash = hex::encode(keccak256(&code));
let account_info = AccountInfo::new(
U256::from(0),
Expand All @@ -114,25 +116,13 @@ fn insert_account_info(cache_db: &mut CacheDB<EmptyDB>, addr: Address, code: Byt
fn init_db() -> CacheDB<EmptyDB> {
let mut cache_db = CacheDB::new(EmptyDB::default());

insert_account_info(
&mut cache_db,
BURNTPIX_ADDRESS_ONE,
BURNTPIX_BYTECODE_ONE.clone(),
);
insert_account_info(
&mut cache_db,
BURNTPIX_MAIN_ADDRESS,
BURNTPIX_BYTECODE_TWO.clone(),
);
insert_account_info(
&mut cache_db,
BURNTPIX_ADDRESS_TWO,
BURNTPIX_BYTECODE_THREE.clone(),
);
insert_account_info(&mut cache_db, BURNTPIX_ADDRESS_ONE, BURNTPIX_BYTECODE_ONE);
insert_account_info(&mut cache_db, BURNTPIX_MAIN_ADDRESS, BURNTPIX_BYTECODE_TWO);
insert_account_info(&mut cache_db, BURNTPIX_ADDRESS_TWO, BURNTPIX_BYTECODE_THREE);
insert_account_info(
&mut cache_db,
BURNTPIX_ADDRESS_THREE,
BURNTPIX_BYTECODE_FOUR.clone(),
BURNTPIX_BYTECODE_FOUR,
);

cache_db
Expand Down
2 changes: 1 addition & 1 deletion bins/revme/src/cmd/bench/burntpix/bytecode_four.hex

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bins/revme/src/cmd/bench/burntpix/bytecode_one.hex
Original file line number Diff line number Diff line change
@@ -1 +1 @@
60806040526004361015610011575f80fd5b5f3560e01c63d85fe4b414610024575f80fd5b346100925760603660031901126100925767ffffffffffffffff60043581811161009257366023820112156100925780600401359182116100925736602483830101116100925761008e9161008291604435916024803592016103ee565b604051918291826100b7565b0390f35b5f80fd5b5f5b8381106100a75750505f910152565b8181015183820152602001610098565b604091602082526100d78151809281602086015260208686019101610096565b601f01601f1916010190565b634e487b7160e01b5f52604160045260245ffd5b6040810190811067ffffffffffffffff82111761011357604052565b6100e3565b90601f8019910116810190811067ffffffffffffffff82111761011357604052565b67ffffffffffffffff811161011357601f01601f191660200190565b60405190610163826100f7565b60208083523683820137565b906101798261013a565b6101866040519182610118565b8281528092610197601f199161013a565b0190602036910137565b604051906060820182811067ffffffffffffffff82111761011357604052603c82527f74683d22313522206865696768743d223135222072783d2232222f3e000000006040837f3c726563742069643d22702220783d222d31352220793d222d3135222077696460208201520152565b9061022460209282815194859201610096565b0190565b60206102699193929360405194816102498793518092868087019101610096565b820161025d82518093868085019101610096565b01038085520183610118565b565b60405190610278826100f7565b601082526f181899199a1a9b1b9c1cb0b131b232b360811b6020830152565b634e487b7160e01b5f52603260045260245ffd5b908210156102b7570190565b610297565b9081518110156102b7570160200190565b9693909897949195929560405199888b9951908160208c0191602001916102f392610096565b8901711e3ab9b290343932b31e9111b811103c1e9160711b60208201528151918260328301916020019161032692610096565b016411103c9e9160d91b603282015260370161034191610211565b68222066696c6c3d222360b81b8152956001600160f81b03191660098701526001600160f81b031916600a8601526001600160f81b031916600b8501526001600160f81b031916600c8401526001600160f81b031916600d8301526001600160f81b031916600e8201526211179f60e91b600f82015203600d19810183526012016102699083610118565b604051906103d9826100f7565b60068252651e17b9bb339f60d11b6020830152565b91909161040361011c6036868502020161016f565b9361042b61042261041483866105a2565b61041c6101a1565b90610228565b602087016106fd565b93909461043661026b565b5f94859160105b86881061047957505050505050505061047692916104606104669261041c6103cc565b906106fd565b90829003601f1901825290610228565b90565b5f60105b87821061049457505060106001910197019661043d565b949a90998b6104a48189886102ab565b3560f81c6104b6600183018a896102ab565b3560f81c916104c9906002018a896102ab565b3560f81c906104d78961079c565b926104e18761079c565b600492600f91826104f683871c82168d6102bc565b516001600160f81b031916921661050d908c6102bc565b516001600160f81b0319169280878d8261052b898b1c8216836102bc565b516001600160f81b0319169816610541916102bc565b516001600160f81b031916971c16610559908d6102bc565b516001600160f81b0319169616610570908c6102bc565b516001600160f81b03191696610585986102cd565b61058e916106fd565b99909a60030194601001906001019061047d565b601960016104769260041b01926106cb60016105bd8661079c565b9260041b01600a6106b66105e26105dc6105d68561079c565b9961079c565b9361079c565b92607f604051998a977f3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323060208a01527f30302f737667222076657273696f6e3d22312e31222076696577426f783d223060408a01526201018160ed1b60608a015261065781518092602060638d019101610096565b8801600160fd1b6063820152610677825180936020606485019101610096565b0161111f60f11b60648201526106af606682017f3c7265637420783d22302220793d2230222077696474683d22000000000000009052565b0190610211565b6911103432b4b3b43a1e9160b11b81526106af565b7f222072783d2233222066696c6c3d2223323032303230222f3e00000000000000815203600619810184520182610118565b91909160208084018451918260051c905f5b82811061076b5750505050601f1916808451039061072c8261016f565b945f5b83811061073e57505050509190565b6001906001600160f81b0319610756858301856102bc565b51165f1a610764828a6102bc565b530161072f565b83518652948101949281019260010161070f565b6040519061078c826100f7565b60018252600360fc1b6020830152565b8015610832576107aa610156565b90805f915b61080357506107bd8161016f565b915f5b8281106107cd5750505090565b6001906107f06107e28286035f1901856102bc565b516001600160f81b03191690565b5f1a6107fc82876102bc565b53016107c0565b90600a80830692048161082c6001839492019460ff60f81b9060300160f81b165f1a91866102bc565b536107af565b5061047661077f56fea26469706673582212202620cded94f0cf54cc3df219c4b7a2d33ca1cff9b87da504fdd707bc8b7d38e464736f6c63430008170033
60806040526004361015610011575f80fd5b5f3560e01c63d85fe4b414610024575f80fd5b346100925760603660031901126100925767ffffffffffffffff60043581811161009257366023820112156100925780600401359182116100925736602483830101116100925761008e9161008291604435916024803592016103ee565b604051918291826100b7565b0390f35b5f80fd5b5f5b8381106100a75750505f910152565b8181015183820152602001610098565b604091602082526100d78151809281602086015260208686019101610096565b601f01601f1916010190565b634e487b7160e01b5f52604160045260245ffd5b6040810190811067ffffffffffffffff82111761011357604052565b6100e3565b90601f8019910116810190811067ffffffffffffffff82111761011357604052565b67ffffffffffffffff811161011357601f01601f191660200190565b60405190610163826100f7565b60208083523683820137565b906101798261013a565b6101866040519182610118565b8281528092610197601f199161013a565b0190602036910137565b604051906060820182811067ffffffffffffffff82111761011357604052603c82527f74683d22313522206865696768743d223135222072783d2232222f3e000000006040837f3c726563742069643d22702220783d222d31352220793d222d3135222077696460208201520152565b9061022460209282815194859201610096565b0190565b60206102699193929360405194816102498793518092868087019101610096565b820161025d82518093868085019101610096565b01038085520183610118565b565b60405190610278826100f7565b601082526f181899199a1a9b1b9c1cb0b131b232b360811b6020830152565b634e487b7160e01b5f52603260045260245ffd5b908210156102b7570190565b610297565b9081518110156102b7570160200190565b9693909897949195929560405199888b9951908160208c0191602001916102f392610096565b8901711e3ab9b290343932b31e9111b811103c1e9160711b60208201528151918260328301916020019161032692610096565b016411103c9e9160d91b603282015260370161034191610211565b68222066696c6c3d222360b81b8152956001600160f81b03191660098701526001600160f81b031916600a8601526001600160f81b031916600b8501526001600160f81b031916600c8401526001600160f81b031916600d8301526001600160f81b031916600e8201526211179f60e91b600f82015203600d19810183526012016102699083610118565b604051906103d9826100f7565b60068252651e17b9bb339f60d11b6020830152565b91909161040361011c6036868502020161016f565b9361042b61042261041483866105a2565b61041c6101a1565b90610228565b602087016106fd565b93909461043661026b565b5f94859160105b86881061047957505050505050505061047692916104606104669261041c6103cc565b906106fd565b90829003601f1901825290610228565b90565b5f60105b87821061049457505060106001910197019661043d565b949a90998b6104a48189886102ab565b3560f81c6104b6600183018a896102ab565b3560f81c916104c9906002018a896102ab565b3560f81c906104d78961079c565b926104e18761079c565b600492600f91826104f683871c82168d6102bc565b516001600160f81b031916921661050d908c6102bc565b516001600160f81b0319169280878d8261052b898b1c8216836102bc565b516001600160f81b0319169816610541916102bc565b516001600160f81b031916971c16610559908d6102bc565b516001600160f81b0319169616610570908c6102bc565b516001600160f81b03191696610585986102cd565b61058e916106fd565b99909a60030194601001906001019061047d565b601960016104769260041b01926106cb60016105bd8661079c565b9260041b01600a6106b66105e26105dc6105d68561079c565b9961079c565b9361079c565b92607f604051998a977f3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323060208a01527f30302f737667222076657273696f6e3d22312e31222076696577426f783d223060408a01526201018160ed1b60608a015261065781518092602060638d019101610096565b8801600160fd1b6063820152610677825180936020606485019101610096565b0161111f60f11b60648201526106af606682017f3c7265637420783d22302220793d2230222077696474683d22000000000000009052565b0190610211565b6911103432b4b3b43a1e9160b11b81526106af565b7f222072783d2233222066696c6c3d2223323032303230222f3e00000000000000815203600619810184520182610118565b91909160208084018451918260051c905f5b82811061076b5750505050601f1916808451039061072c8261016f565b945f5b83811061073e57505050509190565b6001906001600160f81b0319610756858301856102bc565b51165f1a610764828a6102bc565b530161072f565b83518652948101949281019260010161070f565b6040519061078c826100f7565b60018252600360fc1b6020830152565b8015610832576107aa610156565b90805f915b61080357506107bd8161016f565b915f5b8281106107cd5750505090565b6001906107f06107e28286035f1901856102bc565b516001600160f81b03191690565b5f1a6107fc82876102bc565b53016107c0565b90600a80830692048161082c6001839492019460ff60f81b9060300160f81b165f1a91866102bc565b536107af565b5061047661077f56fea26469706673582212202620cded94f0cf54cc3df219c4b7a2d33ca1cff9b87da504fdd707bc8b7d38e464736f6c63430008170033
2 changes: 1 addition & 1 deletion bins/revme/src/cmd/bench/burntpix/bytecode_three.hex

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bins/revme/src/cmd/bench/burntpix/bytecode_two.hex

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions bins/revme/src/cmd/bench/burntpix/static_data.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use revm::primitives::{address, fixed_bytes, Address, Bytes, FixedBytes};
use revm::primitives::{address, fixed_bytes, Address, FixedBytes};

pub const BURNTPIX_MAIN_ADDRESS: Address = address!("49206861766520746f6f206d7563682074696d65");
pub const BURNTPIX_ADDRESS_ONE: Address = address!("0a743ba7304efcc9e384ece9be7631e2470e401e");
Expand All @@ -12,11 +12,7 @@ pub const STORAGE_ONE: FixedBytes<32> =
pub const STORAGE_TWO: FixedBytes<32> =
fixed_bytes!("000000000000000000000000c917e98213a05d271adc5d93d2fee6c1f1006f75");

pub const BURNTPIX_BYTECODE_ONE: Bytes =
Bytes::from_static(include_str!("bytecode_one.hex").as_bytes());
pub const BURNTPIX_BYTECODE_TWO: Bytes =
Bytes::from_static(include_str!("bytecode_two.hex").as_bytes());
pub const BURNTPIX_BYTECODE_THREE: Bytes =
Bytes::from_static(include_str!("bytecode_three.hex").as_bytes());
pub const BURNTPIX_BYTECODE_FOUR: Bytes =
Bytes::from_static(include_str!("bytecode_four.hex").as_bytes());
pub const BURNTPIX_BYTECODE_ONE: &str = include_str!("bytecode_one.hex");
pub const BURNTPIX_BYTECODE_TWO: &str = include_str!("bytecode_two.hex");
pub const BURNTPIX_BYTECODE_THREE: &str = include_str!("bytecode_three.hex");
pub const BURNTPIX_BYTECODE_FOUR: &str = include_str!("bytecode_four.hex");
Loading