Skip to content

Commit

Permalink
Feat: Update dependencies & toolchain (#936)
Browse files Browse the repository at this point in the history
Co-authored-by: Oleksandr Anyshchenko <oleksandr.anyshchenko@aurora.dev>
  • Loading branch information
mrLSD and aleksuss authored Aug 7, 2024
1 parent 372b92f commit 03083d7
Show file tree
Hide file tree
Showing 28 changed files with 2,334 additions and 783 deletions.
2,986 changes: 2,270 additions & 716 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ engine-standalone-storage = { path = "engine-standalone-storage" }
engine-standalone-tracing = { path = "engine-standalone-tracing", default-features = false, features = ["impl-serde"] }

anyhow = "1"
base64 = { version = "0.21", default-features = false, features = ["alloc"] }
base64 = { version = "0.22", default-features = false, features = ["alloc"] }
bitflags = { version = "1", default-features = false }
bn = { version = "0.5", package = "zeropool-bn", default-features = false }
borsh = { version = "1", default-features = false, features = ["derive"] }
Expand All @@ -37,7 +37,7 @@ evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag =
evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.42.0-aurora", default-features = false, features = ["std", "tracing"] }
fixed-hash = { version = "0.8", default-features = false }
function_name = "0.3"
git2 = "0.18"
git2 = "0.19"
hex = { version = "0.4", default-features = false, features = ["alloc"] }
ibig = { version = "0.3", default-features = false, features = ["num-traits"] }
impl-serde = { version = "0.4", default-features = false }
Expand All @@ -55,7 +55,7 @@ num = { version = "0.4", default-features = false, features = ["alloc"] }
postgres = "0.19"
primitive-types = { version = "0.12", default-features = false, features = ["rlp", "serde_no_std"] }
rand = "0.8"
reqwest = "0.11"
reqwest = "0.12"
ripemd = { version = "0.1", default-features = false }
rlp = { version = "0.5", default-features = false }
rocksdb = { version = "0.21", default-features = false }
Expand All @@ -67,7 +67,7 @@ strum = { version = "0.26", features = ["derive"] }
tempfile = "3"
tokio = { version = "1", default-features = false, features = ["macros"] }
test-case = "3.1"
walrus = "0.20"
walrus = "0.21"
wee_alloc = { version = "0.4", default-features = false }

[workspace]
Expand Down
7 changes: 5 additions & 2 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ script = '''
AURORA_ETH_CONNECTOR_DIR="engine-tests-connector/etc/aurora-eth-connector/"
AURORA_ETH_CONNECTOR_ETC="engine-tests-connector/etc/"
AURORA_ETH_CONNECTOR_REPO_NAME="aurora-eth-connector"
AURORA_ETH_CONNECTOR_REPO="https://github.com/aurora-is-near/"$AURORA_ETH_CONNECTOR_REPO_NAME
AURORA_ETH_CONNECTOR_REPO="https://github.com/Near-One/$AURORA_ETH_CONNECTOR_REPO_NAME"
if [ -d $AURORA_ETH_CONNECTOR_DIR ]; then
cd $AURORA_ETH_CONNECTOR_DIR
echo "Pull Aurora Eth-Connector repo"
Expand All @@ -387,7 +387,10 @@ else
git clone --depth 1 $AURORA_ETH_CONNECTOR_REPO
cd $AURORA_ETH_CONNECTOR_REPO_NAME
fi
cargo make --profile mainnet build-test
RUST_VERSION=$(cat rust-toolchain | grep channel | cut -d'"' -f 2)
rustup toolchain add $RUST_VERSION
rustup target add wasm32-unknown-unknown --toolchain $RUST_VERSION
cargo +$RUST_VERSION make --profile mainnet build-test
'''

[tasks.test-flow]
Expand Down
2 changes: 1 addition & 1 deletion engine-precompiles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub struct PrecompileOutput {

impl PrecompileOutput {
#[must_use]
pub fn without_logs(cost: EthGas, output: Vec<u8>) -> Self {
pub const fn without_logs(cost: EthGas, output: Vec<u8>) -> Self {
Self {
cost,
output,
Expand Down
4 changes: 2 additions & 2 deletions engine-standalone-storage/src/json_snapshot/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct JsonSnapshotResult {
/// Base 64 encoding of the block hash
pub block_hash: String,
pub block_height: u64,
/// See https://github.com/near/nearcore/blob/2bc63c60afe202e7c78a67176a4e267b8c0fb48f/core/primitives/src/views.rs#L201-L202.
/// See <https://github.com/near/nearcore/blob/2bc63c60afe202e7c78a67176a4e267b8c0fb48f/core/primitives/src/views.rs#L201-L202>.
pub proof: Vec<String>,
pub values: Vec<JsonSnapshotValue>,
}
Expand All @@ -31,7 +31,7 @@ pub struct JsonSnapshotResult {
pub struct JsonSnapshotValue {
/// Base 64 encoding of the key
pub key: String,
/// See https://github.com/near/nearcore/blob/2bc63c60afe202e7c78a67176a4e267b8c0fb48f/core/primitives/src/views.rs#L201-L202.
/// See <https://github.com/near/nearcore/blob/2bc63c60afe202e7c78a67176a4e267b8c0fb48f/core/primitives/src/views.rs#L201-L202>.
pub proof: Vec<String>,
/// Base 64 encoding of the value
pub value: String,
Expand Down
12 changes: 6 additions & 6 deletions engine-standalone-storage/src/sync/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ pub struct TransactionMessage {
/// This quantity is used together with the block random seed
/// to generate the random value available to the transaction.
/// nearcore references:
/// - https://github.com/near/nearcore/blob/00ca2f3f73e2a547ba881f76ecc59450dbbef6e2/core/primitives/src/utils.rs#L261
/// - https://github.com/near/nearcore/blob/00ca2f3f73e2a547ba881f76ecc59450dbbef6e2/core/primitives/src/utils.rs#L295
/// - <https://github.com/near/nearcore/blob/00ca2f3f73e2a547ba881f76ecc59450dbbef6e2/core/primitives/src/utils.rs#L261>
/// - <https://github.com/near/nearcore/blob/00ca2f3f73e2a547ba881f76ecc59450dbbef6e2/core/primitives/src/utils.rs#L295>
pub action_hash: H256,
}

Expand Down Expand Up @@ -108,13 +108,13 @@ pub enum TransactionKind {
/// Bytes here will be parsed into `aurora_engine::proof::Proof`
Deposit(Vec<u8>),
/// This can change balances on aurora in the case that `receiver_id == aurora`.
/// Example: https://explorer.mainnet.near.org/transactions/DH6iNvXCt5n5GZBZPV1A6sLmMf1EsKcxXE4uqk1cShzj
/// Example: <https://explorer.mainnet.near.org/transactions/DH6iNvXCt5n5GZBZPV1A6sLmMf1EsKcxXE4uqk1cShzj>
FtTransferCall(parameters::TransferCallCallArgs),
/// FinishDeposit-type receipts are created by calls to `deposit`
FinishDeposit(parameters::FinishDepositCallArgs),
/// ResolveTransfer-type receipts are created by calls to ft_on_transfer
/// ResolveTransfer-type receipts are created by calls to `ft_on_transfer`
ResolveTransfer(parameters::ResolveTransferCallArgs, types::PromiseResult),
/// ft_transfer (related to eth-connector)
/// `ft_transfer` (related to eth-connector)
FtTransfer(parameters::TransferCallArgs),
/// Function to take ETH out of Aurora
Withdraw(aurora_engine_types::parameters::WithdrawCallArgs),
Expand All @@ -132,7 +132,7 @@ pub enum TransactionKind {
SetPausedFlags(parameters::PauseEthConnectorCallArgs),
/// Ad entry mapping from address to relayer NEAR account
RegisterRelayer(Address),
/// Callback called by ExitToNear precompile, also can refund on fail
/// Callback called by `ExitToNear` precompile, also can refund on fail
ExitToNear(Option<aurora_engine_types::parameters::ExitToNearPrecompileCallbackCallArgs>),
/// Update eth-connector config
SetConnectorData(parameters::SetContractDataCallArgs),
Expand Down
2 changes: 1 addition & 1 deletion engine-standalone-tracing/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ pub struct TransactionTrace {
impl TransactionTrace {
/// Constructs a new `TransactionTrace` with a given gas, return, and logs.
#[must_use]
pub fn new(gas: EthGas, failed: bool, return_value: Vec<u8>, struct_logs: Logs) -> Self {
pub const fn new(gas: EthGas, failed: bool, return_value: Vec<u8>, struct_logs: Logs) -> Self {
Self {
gas,
failed,
Expand Down
8 changes: 4 additions & 4 deletions engine-tests-connector/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ async fn test_deposit_pausability_eth_connector() -> anyhow::Result<()> {
let res = contract
.engine_contract
.call("deposit")
.args_borsh(&contract.get_proof(PROOF_DATA_ETH))
.args_borsh(contract.get_proof(PROOF_DATA_ETH))
.max_gas()
.transact()
.await?;
Expand All @@ -803,7 +803,7 @@ async fn test_deposit_pausability_eth_connector() -> anyhow::Result<()> {

let res = user_acc
.call(contract.eth_connector_contract.id(), "deposit")
.args_borsh(&contract.get_proof(PROOF_DATA_NEAR))
.args_borsh(contract.get_proof(PROOF_DATA_NEAR))
.max_gas()
.transact()
.await?;
Expand Down Expand Up @@ -839,7 +839,7 @@ async fn test_deposit_pausability() -> anyhow::Result<()> {
let res = contract
.engine_contract
.call("deposit")
.args_borsh(&contract.get_proof(PROOF_DATA_ETH))
.args_borsh(contract.get_proof(PROOF_DATA_ETH))
.max_gas()
.transact()
.await?;
Expand All @@ -859,7 +859,7 @@ async fn test_deposit_pausability() -> anyhow::Result<()> {
let res = contract
.engine_contract
.call("deposit")
.args_borsh(&contract.get_proof(PROOF_DATA_ETH))
.args_borsh(contract.get_proof(PROOF_DATA_ETH))
.max_gas()
.transact()
.await?;
Expand Down
2 changes: 0 additions & 2 deletions engine-tests/src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
mod v0 {
#[cfg(feature = "meta-call")]
pub use aurora_engine::meta_parsing;
pub use aurora_engine::parameters;
pub use aurora_engine_sdk as sdk;
pub use aurora_engine_transactions as transactions;
Expand Down
2 changes: 0 additions & 2 deletions engine-tests/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ mod erc20_connector;
mod erc20_mirror;
mod ghsa_3p69_m8gg_fwmf;
mod hashchain;
#[cfg(feature = "meta-call")]
mod meta_parsing;
pub mod modexp;
mod multisender;
mod one_inch;
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/tests/promise_results_precompile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn test_promise_results_precompile() {
data: Vec::new(),
};

runner.promise_results = promise_results.clone();
runner.promise_results.clone_from(&promise_results);
let result = runner
.submit_transaction(&signer.secret_key, transaction)
.unwrap();
Expand Down
12 changes: 6 additions & 6 deletions engine-tests/src/tests/repro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn repro_GdASJ3KESs() {
block_timestamp: 1_645_717_564_644_206_730,
input_path: "src/tests/res/input_GdASJ3KESs.hex",
evm_gas_used: 706_713,
near_gas_used: 117,
near_gas_used: 114,
});
}

Expand All @@ -51,7 +51,7 @@ fn repro_8ru7VEA() {
block_timestamp: 1_648_829_935_343_349_589,
input_path: "src/tests/res/input_8ru7VEA.hex",
evm_gas_used: 1_732_181,
near_gas_used: 211,
near_gas_used: 204,
});
}

Expand All @@ -71,7 +71,7 @@ fn repro_FRcorNv() {
block_timestamp: 1_650_960_438_774_745_116,
input_path: "src/tests/res/input_FRcorNv.hex",
evm_gas_used: 1_239_721,
near_gas_used: 171,
near_gas_used: 166,
});
}

Expand All @@ -88,7 +88,7 @@ fn repro_5bEgfRQ() {
block_timestamp: 1_651_073_772_931_594_646,
input_path: "src/tests/res/input_5bEgfRQ.hex",
evm_gas_used: 6_414_105,
near_gas_used: 655,
near_gas_used: 646,
});
}

Expand All @@ -106,7 +106,7 @@ fn repro_D98vwmi() {
block_timestamp: 1_651_753_443_421_003_245,
input_path: "src/tests/res/input_D98vwmi.hex",
evm_gas_used: 1_035_348,
near_gas_used: 173,
near_gas_used: 167,
});
}

Expand All @@ -125,7 +125,7 @@ fn repro_Emufid2() {
block_timestamp: 1_662_118_048_636_713_538,
input_path: "src/tests/res/input_Emufid2.hex",
evm_gas_used: 1_156_364,
near_gas_used: 296,
near_gas_used: 292,
});
}

Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/tests/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ fn test_solidity_pure_bench() {
);
let near_gas = profile.all_gas();
assert!(
near_gas > 1500 * 1_000_000_000_000,
near_gas > 1400 * 1_000_000_000_000,
"Expected 1500 NEAR Tgas to be used, but only consumed {}",
near_gas / 1_000_000_000_000,
);
Expand Down
1 change: 1 addition & 0 deletions engine-tests/src/tests/standalone/tracing.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// For the future: #![allow(clippy::doc_lazy_continuation)]
use aurora_engine_sdk::env::Env;
use aurora_engine_types::types::{Address, Wei};
use aurora_engine_types::{H256, U256};
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/tests/uniswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn test_uniswap_input_multihop() {

let (_amount_out, _evm_gas, profile) = context.exact_input(&tokens, INPUT_AMOUNT.into());

assert_eq!(110, profile.all_gas() / 1_000_000_000_000);
assert_eq!(107, profile.all_gas() / 1_000_000_000_000);
}

#[test]
Expand Down
8 changes: 2 additions & 6 deletions engine-tests/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ pub struct AuroraRunner {
pub context: VMContext,
pub wasm_config: Config,
pub fees_config: RuntimeFeesConfig,
pub current_protocol_version: u32,
pub previous_logs: Vec<String>,
// Use the standalone in parallel if set. This allows checking both
// implementations give the same results.
Expand Down Expand Up @@ -233,7 +232,7 @@ impl AuroraRunner {
}

self.context.storage_usage = outcome.storage_usage;
self.previous_logs = outcome.logs.clone();
self.previous_logs.clone_from(&outcome.logs);

if let Some(standalone_runner) = &mut self.standalone_runner {
standalone_runner.submit_raw(
Expand Down Expand Up @@ -509,7 +508,7 @@ impl AuroraRunner {
self.getter_method_call("get_code", address)
}

pub fn get_fixed_gas(&mut self) -> Option<EthGas> {
pub fn get_fixed_gas(&self) -> Option<EthGas> {
let outcome = self
.one_shot()
.call("get_fixed_gas", "getter", vec![])
Expand Down Expand Up @@ -666,7 +665,6 @@ impl Default for AuroraRunner {
},
wasm_config,
fees_config: RuntimeFeesConfig::test(),
current_protocol_version: u32::MAX,
previous_logs: Vec::new(),
standalone_runner: Some(standalone::StandaloneRunner::default()),
promise_results: Vec::new(),
Expand All @@ -681,15 +679,13 @@ impl Default for AuroraRunner {
pub struct ExecutionProfile {
pub host_breakdown: ProfileDataV3,
total_gas_cost: u64,
pub logs: Vec<String>,
}

impl ExecutionProfile {
pub fn new(outcome: &VMOutcome) -> Self {
Self {
host_breakdown: outcome.profile.clone(),
total_gas_cost: outcome.burnt_gas,
logs: outcome.logs.clone(),
}
}

Expand Down
4 changes: 2 additions & 2 deletions engine-tests/src/utils/solidity/exit_precompile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Tester {
fn submit_result_to_success_or_revert(result: SubmitResult) -> Result<SubmitResult, Revert> {
match result.status {
aurora_engine::parameters::TransactionStatus::Succeed(_) => Ok(result),
aurora_engine::parameters::TransactionStatus::Revert(bytes) => Err(Revert(bytes)),
aurora_engine::parameters::TransactionStatus::Revert(_bytes) => Err(Revert),
other => panic!("Unexpected status {other:?}"),
}
}
Expand Down Expand Up @@ -222,4 +222,4 @@ impl Tester {
}

#[derive(Debug)]
pub struct Revert(Vec<u8>);
pub struct Revert;
15 changes: 6 additions & 9 deletions engine-tests/src/utils/solidity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,12 @@ impl ContractConstructor {
let bin_file = format!("{contract_name}.bin");
let abi_file = format!("{contract_name}.abi");
let hex_path = artifacts_base_path.as_ref().join(bin_file);
let hex_rep = fs::read_to_string(&hex_path).map_or_else(
|_| {
// An error occurred opening the file, maybe the contract hasn't been compiled?
compile(sources_root, contract_file, &artifacts_base_path);
// If another error occurs, then we can't handle it so we just unwrap.
fs::read_to_string(hex_path).unwrap()
},
|hex| hex,
);
let hex_rep = fs::read_to_string(&hex_path).unwrap_or_else(|_| {
// An error occurred opening the file, maybe the contract hasn't been compiled?
compile(sources_root, contract_file, &artifacts_base_path);
// If another error occurs, then we can't handle it so we just unwrap.
fs::read_to_string(hex_path).unwrap()
});
let code = hex::decode(hex_rep).unwrap();
let abi_path = artifacts_base_path.as_ref().join(abi_file);
let file = fs::File::open(abi_path).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/utils/solidity/uniswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ fn uniswap_root_path() -> PathBuf {
fn download_uniswap_artifacts() {
DOWNLOAD_ONCE.call_once(|| {
let output = Command::new("/usr/bin/env")
.current_dir(&uniswap_root_path())
.current_dir(uniswap_root_path())
.args(["yarn", "install"])
.output()
.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions engine-tests/src/utils/standalone/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,23 +276,23 @@ impl StandaloneRunner {
&self.cumulative_diff
}

pub fn get_balance(&mut self, address: &Address) -> Wei {
pub fn get_balance(&self, address: &Address) -> Wei {
self.storage
.with_engine_access(self.env.block_height + 1, 0, &[], |io| {
engine::get_balance(&io, address)
})
.result
}

pub fn get_nonce(&mut self, address: &Address) -> U256 {
pub fn get_nonce(&self, address: &Address) -> U256 {
self.storage
.with_engine_access(self.env.block_height + 1, 0, &[], |io| {
engine::get_nonce(&io, address)
})
.result
}

pub fn get_code(&mut self, address: &Address) -> Vec<u8> {
pub fn get_code(&self, address: &Address) -> Vec<u8> {
self.storage
.with_engine_access(self.env.block_height + 1, 0, &[], |io| {
engine::get_code(&io, address)
Expand Down
Loading

0 comments on commit 03083d7

Please sign in to comment.