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

Feat: Update dependencies & toolchain #936

Merged
merged 7 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2,622 changes: 1,971 additions & 651 deletions Cargo.lock

Large diffs are not rendered by default.

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
2 changes: 1 addition & 1 deletion engine-standalone-storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl Storage {
}

fn process_transaction<F: Fn(&mut rocksdb::WriteBatch, &[u8], &[u8])>(
&mut self,
&self,
aleksuss marked this conversation as resolved.
Show resolved Hide resolved
tx_hash: H256,
tx_msg: &TransactionMessage,
diff: &Diff,
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 @@ -813,7 +813,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 @@ -824,7 +824,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 @@ -860,7 +860,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 @@ -880,7 +880,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,
aleksuss marked this conversation as resolved.
Show resolved Hide resolved
});
}

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: 205,
});
}

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: 168,
});
}

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
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 @@
#![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
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
4 changes: 2 additions & 2 deletions engine-types/src/parameters/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ impl rlp::Encodable for LogEntry {
/// Borsh-encoded parameters for `mirror_erc20_token` function.
#[derive(BorshSerialize, BorshDeserialize, Debug, Eq, PartialEq, Clone)]
pub struct MirrorErc20TokenArgs {
/// AccountId of the main Aurora contract which has previously deployed ERC-20.
/// `AccountId` of the main Aurora contract which has previously deployed ERC-20.
pub contract_id: AccountId,
/// AccountId of the bridged NEP-141 token.
/// `AccountId` of the bridged NEP-141 token.
pub nep141: AccountId,
}

Expand Down
2 changes: 1 addition & 1 deletion engine-types/src/parameters/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl SubmitResult {
const VERSION: u8 = 7;

#[must_use]
pub fn new(status: TransactionStatus, gas_used: u64, logs: Vec<ResultLog>) -> Self {
pub const fn new(status: TransactionStatus, gas_used: u64, logs: Vec<ResultLog>) -> Self {
Self {
version: Self::VERSION,
status,
Expand Down
7 changes: 3 additions & 4 deletions engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl AsRef<[u8]> for BalanceOverflow {
pub enum GasPaymentError {
/// Overflow adding ETH to an account balance (should never happen)
BalanceOverflow(BalanceOverflow),
/// Overflow in gas * gas_price calculation
/// Overflow in `gas * gas_price` calculation
EthAmountOverflow,
/// Not enough balance for account to cover the gas cost
OutOfFund,
Expand Down Expand Up @@ -816,10 +816,9 @@ impl<'env, I: IO + Copy, E: Env, M: ModExpAlgorithm> Engine<'env, I, E, M> {
gas_used: submit_result.gas_used,
}),
})
.map_err(|e| {
sdk::log!("{:?}", e);
.inspect_err(|_e| {
sdk::log!("{:?}", _e);
aleksuss marked this conversation as resolved.
Show resolved Hide resolved
self.io.return_output(output_on_fail);
e
})?;

// Everything succeed so return "0"
Expand Down
Loading
Loading