Skip to content
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
310 changes: 171 additions & 139 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ bstr = "0.2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
hex = { version = "0.4.3", default-features = false }
near-sdk = { git = "https://github.com/aurora-is-near/near-sdk-rs.git", rev = "1b9843fe5b652928582e33879fc92ba87a639450" }
near-sdk-sim = { git = "https://github.com/aurora-is-near/near-sdk-rs.git", rev = "1b9843fe5b652928582e33879fc92ba87a639450" }
near-crypto = { git = "https://github.com/near/nearcore.git", branch = "1.20.1"}
near-vm-runner = { git = "https://github.com/near/nearcore.git", branch = "1.20.1"}
near-vm-logic = { git = "https://github.com/near/nearcore.git", branch = "1.20.1"}
near-primitives-core = { git = "https://github.com/near/nearcore.git", branch = "1.20.1"}
near-sdk = { git = "https://github.com/aurora-is-near/near-sdk-rs.git", rev = "5e58722bd61d9d24ae6293326146c751f0a814fb" }
near-sdk-sim = { git = "https://github.com/aurora-is-near/near-sdk-rs.git", rev = "5e58722bd61d9d24ae6293326146c751f0a814fb" }
near-crypto = { git = "https://github.com/near/nearcore.git", rev = "8a377fda0b4ce319385c463f1ae46e4b0b29dcd9"}
near-vm-runner = { git = "https://github.com/near/nearcore.git", rev = "8a377fda0b4ce319385c463f1ae46e4b0b29dcd9"}
near-vm-logic = { git = "https://github.com/near/nearcore.git", rev = "8a377fda0b4ce319385c463f1ae46e4b0b29dcd9"}
near-primitives-core = { git = "https://github.com/near/nearcore.git", rev = "8a377fda0b4ce319385c463f1ae46e4b0b29dcd9"}
libsecp256k1 = "0.3.5"
rand = "0.7.3"
criterion = "0.3.4"
Expand Down
11 changes: 5 additions & 6 deletions src/benches/eth_deploy_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ pub(crate) fn eth_deploy_code_benchmark(c: &mut Criterion) {
rlp::encode(&transaction).to_vec()
})
.collect();
let calling_account_id = "some-account.near".to_string();
let calling_account_id = "some-account.near";

// measure gas usage
for input in inputs.iter() {
let input_size = input.len();
let (output, maybe_err) =
runner
.one_shot()
.call(SUBMIT, calling_account_id.clone(), input.clone());
let (output, maybe_err) = runner
.one_shot()
.call(SUBMIT, calling_account_id, input.clone());
assert!(maybe_err.is_none());
let output = output.unwrap();
let gas = output.burnt_gas;
Expand All @@ -59,7 +58,7 @@ pub(crate) fn eth_deploy_code_benchmark(c: &mut Criterion) {
group.throughput(Throughput::Bytes(input_size));
group.bench_function(id, |b| {
b.iter_batched(
|| (runner.one_shot(), calling_account_id.clone(), input.clone()),
|| (runner.one_shot(), calling_account_id, input.clone()),
|(r, c, i)| r.call(SUBMIT, c, i),
BatchSize::SmallInput,
)
Expand Down
24 changes: 8 additions & 16 deletions src/benches/eth_erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(crate) fn eth_erc20_benchmark(c: &mut Criterion) {
crate::types::Wei::new_u64(INITIAL_BALANCE),
INITIAL_NONCE.into(),
);
let calling_account_id = "some-account.near".to_string();
let calling_account_id = "some-account.near";

// deploy the erc20 contract
let constructor = ERC20Constructor::load();
Expand Down Expand Up @@ -54,22 +54,15 @@ pub(crate) fn eth_erc20_benchmark(c: &mut Criterion) {
// measure mint wall-clock time
group.bench_function(mint_id, |b| {
b.iter_batched(
|| {
(
runner.one_shot(),
calling_account_id.clone(),
mint_tx_bytes.clone(),
)
},
|| (runner.one_shot(), calling_account_id, mint_tx_bytes.clone()),
|(r, c, i)| r.call(SUBMIT, c, i),
BatchSize::SmallInput,
)
});

// Measure mint gas usage; don't use `one_shot` because we want to keep this state change for
// the next benchmark where we transfer some of the minted tokens.
let (output, maybe_error) =
runner.call(SUBMIT, calling_account_id.clone(), mint_tx_bytes.clone());
let (output, maybe_error) = runner.call(SUBMIT, calling_account_id, mint_tx_bytes.clone());
assert!(maybe_error.is_none());
let output = output.unwrap();
let gas = output.burnt_gas;
Expand All @@ -79,11 +72,10 @@ pub(crate) fn eth_erc20_benchmark(c: &mut Criterion) {
println!("ETH_ERC20_MINT ETH GAS: {:?}", eth_gas);

// Measure transfer gas usage
let (output, maybe_err) = runner.one_shot().call(
SUBMIT,
calling_account_id.clone(),
transfer_tx_bytes.clone(),
);
let (output, maybe_err) =
runner
.one_shot()
.call(SUBMIT, calling_account_id, transfer_tx_bytes.clone());
assert!(maybe_err.is_none());
let output = output.unwrap();
let gas = output.burnt_gas;
Expand All @@ -98,7 +90,7 @@ pub(crate) fn eth_erc20_benchmark(c: &mut Criterion) {
|| {
(
runner.one_shot(),
calling_account_id.clone(),
calling_account_id,
transfer_tx_bytes.clone(),
)
},
Expand Down
12 changes: 3 additions & 9 deletions src/benches/eth_standard_precompiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(crate) fn eth_standard_precompiles_benchmark(c: &mut Criterion) {
INITIAL_BALANCE,
INITIAL_NONCE.into(),
);
let calling_account_id = "some-account.near".to_string();
let calling_account_id = "some-account.near";

// deploy StandardPrecompiles contract
let constructor = PrecompilesConstructor::load();
Expand Down Expand Up @@ -46,7 +46,7 @@ pub(crate) fn eth_standard_precompiles_benchmark(c: &mut Criterion) {
let (output, maybe_err) =
runner
.one_shot()
.call(SUBMIT, calling_account_id.clone(), tx_bytes.clone());
.call(SUBMIT, calling_account_id, tx_bytes.clone());
assert!(maybe_err.is_none());
let output = output.unwrap();
let gas = output.burnt_gas;
Expand All @@ -62,13 +62,7 @@ pub(crate) fn eth_standard_precompiles_benchmark(c: &mut Criterion) {
for (tx_bytes, id) in transactions.iter().zip(bench_ids.into_iter()) {
group.bench_function(id, |b| {
b.iter_batched(
|| {
(
runner.one_shot(),
calling_account_id.clone(),
tx_bytes.clone(),
)
},
|| (runner.one_shot(), calling_account_id, tx_bytes.clone()),
|(r, c, i)| r.call(SUBMIT, c, i),
BatchSize::SmallInput,
)
Expand Down
11 changes: 5 additions & 6 deletions src/benches/eth_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ pub(crate) fn eth_transfer_benchmark(c: &mut Criterion) {
&source_account,
);
let input = rlp::encode(&transaction).to_vec();
let calling_account_id = "some-account.near".to_string();
let calling_account_id = "some-account.near";

// measure gas usage
let (output, maybe_err) =
runner
.one_shot()
.call(SUBMIT, calling_account_id.clone(), input.clone());
let (output, maybe_err) = runner
.one_shot()
.call(SUBMIT, calling_account_id, input.clone());
assert!(maybe_err.is_none());
let gas = output.unwrap().burnt_gas;
// TODO(#45): capture this in a file
Expand All @@ -42,7 +41,7 @@ pub(crate) fn eth_transfer_benchmark(c: &mut Criterion) {
// measure wall-clock time
c.bench_function("eth_transfer", |b| {
b.iter_batched(
|| (runner.one_shot(), calling_account_id.clone(), input.clone()),
|| (runner.one_shot(), calling_account_id, input.clone()),
|(r, c, i)| r.call(SUBMIT, c, i),
BatchSize::SmallInput,
)
Expand Down
Loading