Skip to content

Commit

Permalink
Release 2.5.0. (#460)
Browse files Browse the repository at this point in the history
* Engine: Upgrade to latest SputnikVM changes (#455)
* Engine: further caching optimizations (#456)
* Use EthTransactionKind reference to serialize into bytes (#457)
* Test: Reproduce GdASJ3KESs8VegpFECTveCwLQp8fxw8yvsauNEmGb6pZ gas failure (#454)
* Fix typo: promise_create (#452)
* Fix(Engine): Transactions to the zero address are not the same as transactions with empty to field (#458)

Co-authored-by: Marcelo Fornet <[email protected]>
Co-authored-by: Michael Birch <[email protected]>
  • Loading branch information
birchmd and Marcelo Fornet authored Mar 9, 2022
1 parent d2d3073 commit 0c8db05
Show file tree
Hide file tree
Showing 29 changed files with 1,235 additions and 65 deletions.
18 changes: 17 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.5.0] - 2022-03-09

### Changes

- Performance improvement by [@birchmd] and [@olonho]: ([#455]) ([#456])

### Fixes

- Bug fix for the behaviour of transactions to the zero address by [@birchmd]. ([#458])

[#455]: https://github.com/aurora-is-near/aurora-engine/pull/455
[#456]: https://github.com/aurora-is-near/aurora-engine/pull/456
[#458]: https://github.com/aurora-is-near/aurora-engine/pull/458

## [2.4.0] - 2022-02-16

### Changes
Expand Down Expand Up @@ -205,7 +219,8 @@ struct SubmitResult {

## [1.0.0] - 2021-05-12

[Unreleased]: https://github.com/aurora-is-near/aurora-engine/compare/2.4.0...master
[Unreleased]: https://github.com/aurora-is-near/aurora-engine/compare/2.5.0...develop
[2.5.0]: https://github.com/aurora-is-near/aurora-engine/compare/2.4.0...2.5.0
[2.4.0]: https://github.com/aurora-is-near/aurora-engine/compare/2.3.0...2.4.0
[2.3.0]: https://github.com/aurora-is-near/aurora-engine/compare/2.2.0...2.3.0
[2.2.0]: https://github.com/aurora-is-near/aurora-engine/compare/2.1.0...2.2.0
Expand Down Expand Up @@ -236,3 +251,4 @@ struct SubmitResult {
[@mrLSD]: https://github.com/mrLSD
[@sept-en]: https://github.com/sept-en
[@matklad]: https://github.com/matklad
[@olonho]: https://github.com/olonho
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ documentation.

Network | Contract ID | Chain ID | Version
------- | ------------------- | ---------- | ------
Mainnet | [`aurora`][Mainnet] | 1313161554 | 2.3.0
Testnet | [`aurora`][Testnet] | 1313161555 | 2.4.0
Local | `aurora.test.near` | 1313161556 | 2.4.0
Mainnet | [`aurora`][Mainnet] | 1313161554 | 2.4.0
Testnet | [`aurora`][Testnet] | 1313161555 | 2.5.0
Local | `aurora.test.near` | 1313161556 | 2.5.0

[Mainnet]: https://explorer.near.org/accounts/aurora
[Testnet]: https://explorer.testnet.near.org/accounts/aurora
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.0
2.5.0
4 changes: 2 additions & 2 deletions engine-precompiles/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ base64 = { version = "0.13.0", default-features = false, features = ["alloc"] }
near-blake2 = { git = "https://github.com/near/near-blake2.git", version = "0.9.1", default-features = false }
borsh = { version = "0.8.2", default-features = false }
bn = { package = "aurora-bn", git = "https://github.com/aurora-is-near/aurora-bn.git", default-features = false }
evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "f4ee520254856898d451c7225851520a35c97cea", default-features = false }
evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "f4ee520254856898d451c7225851520a35c97cea", default-features = false }
evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "37448b6cacd98b06282cff5a559684505c29bd2b", default-features = false }
evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "37448b6cacd98b06282cff5a559684505c29bd2b", default-features = false }
libsecp256k1 = { version = "0.3.5", default-features = false }
num = { version = "0.4.0", default-features = false, features = ["alloc"] }
primitive-types = { version = "0.10.0", default-features = false, features = ["rlp"] }
Expand Down
2 changes: 1 addition & 1 deletion engine-sdk/src/promise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub trait PromiseHandler {
fn promise_create_batch(&mut self, args: &PromiseBatchAction) -> PromiseId;
fn promise_return(&mut self, promise: PromiseId);

fn promise_crate_with_callback(&mut self, args: &PromiseWithCallbackArgs) -> PromiseId {
fn promise_create_with_callback(&mut self, args: &PromiseWithCallbackArgs) -> PromiseId {
let base = self.promise_create_call(&args.base);
self.promise_attach_callback(base, &args.callback)
}
Expand Down
2 changes: 1 addition & 1 deletion engine-standalone-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ aurora-engine-types = { path = "../engine-types", default-features = false, feat
aurora-engine-sdk = { path = "../engine-sdk", default-features = false, features = ["std"] }
aurora-engine-transactions = { path = "../engine-transactions", default-features = false, features = ["std"] }
borsh = { version = "0.8.2" }
evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "f4ee520254856898d451c7225851520a35c97cea", default-features = false }
evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "37448b6cacd98b06282cff5a559684505c29bd2b", default-features = false }
rocksdb = "0.16.0"
postgres = "0.19.2"
serde = "1.0.130"
Expand Down
8 changes: 4 additions & 4 deletions engine-standalone-storage/src/json_snapshot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ pub fn initialize_engine_state(
storage: &mut Storage,
snapshot: types::JsonSnapshot,
) -> Result<(), error::Error> {
// When we access engine storage, we are accessing the pre-state. The snapshot is giving
// us a post-state, which of course is the pre-state of the following block.
let block_height = snapshot.result.block_height + 1;
// The snapshot is giving us a post-state, so we insert it right at the end of its block height.
let block_height = snapshot.result.block_height;
let transaction_position = u16::MAX;

let mut batch = rocksdb::WriteBatch::default();
for entry in snapshot.result.values {
let key = base64::decode(entry.key)?;
let value = base64::decode(entry.value)?;
let storage_key = crate::construct_engine_key(&key, block_height, 0);
let storage_key = crate::construct_engine_key(&key, block_height, transaction_position);
let storage_value = crate::diff::DiffValue::Modified(value);
batch.put(storage_key, storage_value.try_to_bytes()?);
}
Expand Down
2 changes: 1 addition & 1 deletion engine-standalone-storage/src/relayer_db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ where
let block_hash = row.block_hash;
let block_metadata = storage.get_block_metadata(block_hash)?;
let tx: EthTransactionKind = row.into();
let transaction_bytes: Vec<u8> = tx.into();
let transaction_bytes: Vec<u8> = (&tx).into();
let tx_hash = aurora_engine_sdk::keccak(&transaction_bytes);

env.block_height = block_height;
Expand Down
2 changes: 1 addition & 1 deletion engine-standalone-storage/src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub fn consume_message(storage: &mut crate::Storage, message: Message) -> Result
// Only promises possible from `submit` are exit precompiles and we cannot act on those promises
let mut handler = crate::promise::Noop;
let engine_state = engine::get_state(&io)?;
let transaction_bytes: Vec<u8> = tx.into();
let transaction_bytes: Vec<u8> = (&tx).into();
let tx_hash = aurora_engine_sdk::keccak(&transaction_bytes);

let _result = engine::submit(
Expand Down
8 changes: 4 additions & 4 deletions engine-standalone-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ crate-type = ["lib"]
aurora-engine = { path = "../engine", default-features = false, features = ["std"] }
aurora-engine-types = { path = "../engine-types", default-features = false, features = ["std"] }
aurora-engine-sdk = { path = "../engine-sdk", default-features = false, features = ["std"] }
evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "f4ee520254856898d451c7225851520a35c97cea", default-features = false, features = ["std"] }
evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "f4ee520254856898d451c7225851520a35c97cea", default-features = false, features = ["std", "tracing"] }
evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "f4ee520254856898d451c7225851520a35c97cea", default-features = false, features = ["std", "tracing"] }
evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "f4ee520254856898d451c7225851520a35c97cea", default-features = false, features = ["std", "tracing"] }
evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "37448b6cacd98b06282cff5a559684505c29bd2b", default-features = false, features = ["std"] }
evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "37448b6cacd98b06282cff5a559684505c29bd2b", default-features = false, features = ["std", "tracing"] }
evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "37448b6cacd98b06282cff5a559684505c29bd2b", default-features = false, features = ["std", "tracing"] }
evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "37448b6cacd98b06282cff5a559684505c29bd2b", default-features = false, features = ["std", "tracing"] }

[features]
default = []
Expand Down
2 changes: 1 addition & 1 deletion engine-standalone-tracing/src/sputnik.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl evm_runtime::tracing::EventListener for TransactionTraceBuilder {
use evm_runtime::tracing::Event;
match event {
Event::Step {
context: _,
address: _,
opcode,
position,
stack,
Expand Down
6 changes: 3 additions & 3 deletions engine-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ engine-standalone-storage = { path = "../engine-standalone-storage", default-fea
engine-standalone-tracing = { path = "../engine-standalone-tracing", default-features = false }
borsh = { version = "0.8.2", default-features = false }
sha3 = { version = "0.9.1", default-features = false }
evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "f4ee520254856898d451c7225851520a35c97cea", default-features = false, features = ["std", "tracing"] }
evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "f4ee520254856898d451c7225851520a35c97cea", default-features = false, features = ["std", "tracing"] }
evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "f4ee520254856898d451c7225851520a35c97cea", default-features = false, features = ["std", "tracing"] }
evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "37448b6cacd98b06282cff5a559684505c29bd2b", default-features = false, features = ["std", "tracing"] }
evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "37448b6cacd98b06282cff5a559684505c29bd2b", default-features = false, features = ["std", "tracing"] }
evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "37448b6cacd98b06282cff5a559684505c29bd2b", default-features = false, features = ["std", "tracing"] }
rlp = { version = "0.5.0", default-features = false }

[dev-dependencies]
Expand Down
12 changes: 12 additions & 0 deletions engine-tests/src/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,18 @@ impl AuroraRunner {
(maybe_outcome, maybe_error)
}

pub fn consume_json_snapshot(
&mut self,
snapshot: engine_standalone_storage::json_snapshot::types::JsonSnapshot,
) {
let trie = &mut self.ext.underlying.fake_trie;
for entry in snapshot.result.values {
let key = base64::decode(entry.key).unwrap();
let value = base64::decode(entry.value).unwrap();
trie.insert(key, value);
}
}

pub fn create_address(
&mut self,
address: Address,
Expand Down
1 change: 1 addition & 0 deletions engine-tests/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod eth_connector;
mod meta_parsing;
mod one_inch;
mod random;
mod repro;
mod sanity;
mod self_destruct_state;
mod standalone;
Expand Down
8 changes: 4 additions & 4 deletions engine-tests/src/tests/one_inch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn test_1inch_liquidity_protocol() {
let (result, profile, pool) =
helper.create_pool(&pool_factory, token_a.0.address, token_b.0.address);
assert!(result.gas_used >= 4_500_000); // more than 4.5M EVM gas used
assert_gas_bound(profile.all_gas(), 34); // less than 34 NEAR Tgas used
assert_gas_bound(profile.all_gas(), 33); // less than 33 NEAR Tgas used

// Approve giving ERC-20 tokens to the pool
helper.approve_erc20_tokens(&token_a, pool.address());
Expand All @@ -58,7 +58,7 @@ fn test_1inch_liquidity_protocol() {
},
);
assert!(result.gas_used >= 302_000); // more than 302k EVM gas used
assert_gas_bound(profile.all_gas(), 45); // less than 45 NEAR Tgas used
assert_gas_bound(profile.all_gas(), 44); // less than 44 NEAR Tgas used

// Same here
helper.runner.context.block_timestamp += 10_000_000 * 1_000_000_000;
Expand All @@ -73,7 +73,7 @@ fn test_1inch_liquidity_protocol() {
},
);
assert!(result.gas_used >= 210_000); // more than 210k EVM gas used
assert_gas_bound(profile.all_gas(), 48); // less than 48 NEAR Tgas used
assert_gas_bound(profile.all_gas(), 46); // less than 46 NEAR Tgas used

let (result, profile) = helper.pool_withdraw(
&pool,
Expand All @@ -84,7 +84,7 @@ fn test_1inch_liquidity_protocol() {
},
);
assert!(result.gas_used >= 150_000); // more than 150k EVM gas used
assert_gas_bound(profile.all_gas(), 39); // less than 39 NEAR Tgas used
assert_gas_bound(profile.all_gas(), 38); // less than 38 NEAR Tgas used
}

#[test]
Expand Down
60 changes: 60 additions & 0 deletions engine-tests/src/tests/repro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//! A module containing tests which reproduce transactions sent to live networks.

use crate::test_utils::standalone;
use crate::test_utils::{AuroraRunner, ExecutionProfile};
use aurora_engine::parameters::SubmitResult;
use borsh::{BorshDeserialize, BorshSerialize};
use engine_standalone_storage::json_snapshot;

/// This test reproduces a transaction from testnet:
/// https://explorer.testnet.near.org/transactions/GdASJ3KESs8VegpFECTveCwLQp8fxw8yvsauNEmGb6pZ
/// It hit the NEAR gas limit even after the 2.4 engine release and limit increase to 300 Tgas.
/// The purpose of having it here is to be able to track it's performance as we continue to
/// optimize the Engine.
/// The test is somewhat inscrutable because the data was directly pulled from the Engine contract
/// on testnet, but according to the partner that submitted the transaction, the high level
/// description of what is happening is as follows:
/// "flashswap from uniswapv pool with call back to liquidate the user on compound and swap back the seized asset to payback the pool"
#[allow(non_snake_case)]
#[test]
fn repro_GdASJ3KESs() {
// Note: this snapshot is pruned from the full Engine state on testnet at that block height.
// The full snapshot is very large, and all that is necessary for this test are the keys used
// in the transaction. This pruned snapshot contains precisely those keys, and no others.
let snapshot = json_snapshot::types::JsonSnapshot::load_from_file(
"src/tests/res/aurora_state_GdASJ3KESs.json",
)
.unwrap();

let mut runner = AuroraRunner::default();
runner.wasm_config.limit_config.max_gas_burnt = 3_000_000_000_000_000;
runner.context.storage_usage = 1_000_000_000;
runner.consume_json_snapshot(snapshot.clone());
runner.context.block_index = 83596945;
runner.context.block_timestamp = 1645717564644206730;

let tx_hex = std::fs::read_to_string("src/tests/res/input_GdASJ3KESs.hex").unwrap();
let tx_bytes = hex::decode(tx_hex.trim()).unwrap();

let (outcome, error) = runner.call("submit", "relay.aurora", tx_bytes);
let outcome = outcome.unwrap();
let profile = ExecutionProfile::new(&outcome);
if let Some(error) = error {
panic!("{:?}", error);
}
let submit_result =
SubmitResult::try_from_slice(&outcome.return_data.as_value().unwrap()).unwrap();

assert_eq!(submit_result.gas_used, 706713);
assert_eq!(238, profile.all_gas() / 1_000_000_000_000);

// Also validate the SubmitResult in the standalone engine
let mut standalone = standalone::StandaloneRunner::default();
json_snapshot::initialize_engine_state(&mut standalone.storage, snapshot).unwrap();
let standalone_result = standalone.submit_raw("submit", &runner.context).unwrap();
assert_eq!(
submit_result.try_to_vec().unwrap(),
standalone_result.try_to_vec().unwrap()
);
standalone.close()
}
Loading

0 comments on commit 0c8db05

Please sign in to comment.