Skip to content

Commit

Permalink
Merge branch 'develop' into feat/mrLSD/wasm-opt
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/tests.yml
#	engine-tests/src/tests/uniswap.rs
  • Loading branch information
aleksuss committed Oct 13, 2023
2 parents 0ffd4fb + d5b941f commit 48c6330
Show file tree
Hide file tree
Showing 19 changed files with 256 additions and 125 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/scheduled_lints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ jobs:
run: |
git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :
- name: Clone the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Test mainnet
run: cargo make --profile mainnet test
run: cargo make --profile mainnet test-flow
- name: Test testnet
run: cargo make --profile testnet test
run: cargo make --profile testnet test-flow
- name: Test mainnet silo
run: cargo make --profile mainnet-silo test-flow
- name: Test testnet silo
run: cargo make --profile testnet-silo test-flow

checks:
name: Run checks
runs-on: [self-hosted, heavy]
Expand All @@ -25,5 +30,5 @@ jobs:
run: |
git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :
- name: Clone the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- run: cargo make check
117 changes: 61 additions & 56 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,80 +9,85 @@ on:
name: Tests
jobs:
test:
name: Test suite (mainnet, testnet)
runs-on: [self-hosted, heavy]
name: Test suite ${{ matrix.profile }}
runs-on: github-hosted-heavy-runner
strategy:
fail-fast: false
matrix:
profile: [ mainnet, testnet, mainnet-silo, testnet-silo ]
steps:
- name: Potential broken submodules fix
run: |
git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :
- name: Clone the repository
uses: actions/checkout@v3
- name: Restore cache
run: cache-util restore cargo_git cargo_registry yarn_cache rocksdb:/root/rocksdb
- name: Preparing rocksdb library
run: scripts/ci/build_rocksdb.sh
uses: actions/checkout@v4
- name: Cargo Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.profile }}-cargo-test
- name: Setup Node and cache
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
cache-dependency-path: |
etc/eth-contracts
etc/tests/uniswap
- name: Install dependencies
run: cargo make -V || cargo install cargo-make
- name: Install wasm-opt
run: scripts/ci/install-wasm-opt.sh
- name: Test mainnet
run: cargo make --profile mainnet test-flow
- name: Test testnet
run: cargo make --profile testnet test-flow
- name: Save cache
run: cache-util save cargo_git cargo_registry yarn_cache

test_silo:
name: Test Silo suite (mainnet-silo, testnet-silo)
runs-on: [ self-hosted, heavy ]
steps:
- name: Potential broken submodules fix
- name: Build main contract
run: |
git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :
- name: Clone the repository
uses: actions/checkout@v3
- name: Restore cache
run: cache-util restore cargo_git cargo_registry yarn_cache rocksdb:/root/rocksdb
- name: Preparing rocksdb library
run: scripts/ci/build_rocksdb.sh
- name: Test mainnet
run: |
cargo make --profile mainnet build-test
cargo make --profile mainnet-silo test-flow
- name: Test testnet
run: |
cargo make --profile testnet build-test
cargo make --profile testnet-silo test-flow
- name: Save cache
run: cache-util save cargo_git cargo_registry yarn_cache
case ${{ matrix.profile }} in
mainnet-silo)
cargo make --profile mainnet build-test
;;
testnet-silo)
cargo make --profile testnet build-test
;;
*)
;;
esac
- name: Tests ${{ matrix.profile }}
run: cargo make --profile ${{ matrix.profile }} test-flow

test_modexp:
name: Test modexp suite (mainnet, testnet)
runs-on: [ self-hosted, heavy ]
name: Test modexp suite ${{ matrix.profile }}
runs-on: github-hosted-heavy-runner
strategy:
fail-fast: false
matrix:
profile: [ mainnet, testnet ]
steps:
- name: Potential broken submodules fix
run: |
git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :
- name: Clone the repository
uses: actions/checkout@v3
- name: Restore cache
run: |
cache-util restore cargo_git cargo_registry yarn_cache rocksdb:/root/rocksdb
cache-util restore aurora-engine-target@modexp@${{ hashFiles('**/Cargo.lock') }}:target
- name: Preparing rocksdb library
run: scripts/ci/build_rocksdb.sh
uses: actions/checkout@v4
- name: Cargo Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.profile }}-cargo-modexp-test
- name: Install dependencies
run: cargo make -V || cargo install cargo-make
- name: Install wasm-opt
run: scripts/ci/install-wasm-opt.sh
- name: Test mainnet bench-modexp
run: cargo make --profile mainnet bench-modexp
- name: Test testnet bench-modexp
run: cargo make --profile testnet bench-modexp
- name: Save cache
run: |
cache-util save cargo_git cargo_registry yarn_cache
cache-util msave aurora-engine-target@modexp@${{ hashFiles('**/Cargo.lock') }}:target
- name: Test ${{ matrix.profile }} bench-modexp
run: cargo make --profile ${{ matrix.profile }} bench-modexp

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
ROCKSDB_INCLUDE_DIR: /root/rocksdb/include
ROCKSDB_LIB_DIR: /root/rocksdb/lib
ROCKSDB_STATIC: 1
2 changes: 1 addition & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ category = "Build"
run_task = "build-engine-flow"

[tasks.wasm-opt]
condition = { profiles = ["mainnet", "testnet", "custom"] }
condition = { profiles = ["mainnet", "testnet", "mainnet-silo", "testnet-silo", "custom"] }
category = "Build"
script = '''
filesize_before=$(wc -c bin/${WASM_FILE} | awk '{print $1}')
Expand Down
18 changes: 8 additions & 10 deletions engine-sdk/src/near_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,16 +409,14 @@ impl crate::promise::PromiseHandler for Runtime {
});
}
PromiseAction::AddFullAccessKey { public_key, nonce } => {
feature_gated!("all-promise-actions", {
let pk: RawPublicKey = public_key.into();
let pk_bytes = pk.as_bytes();
exports::promise_batch_action_add_key_with_full_access(
id,
pk_bytes.len() as _,
pk_bytes.as_ptr() as _,
*nonce,
);
});
let pk: RawPublicKey = public_key.into();
let pk_bytes = pk.as_bytes();
exports::promise_batch_action_add_key_with_full_access(
id,
pk_bytes.len() as _,
pk_bytes.as_ptr() as _,
*nonce,
);
}
PromiseAction::AddFunctionCallKey {
public_key,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::utils::workspace::deploy_engine;
use aurora_engine_types::parameters::engine::{RelayerKeyArgs, RelayerKeyManagerArgs};
use aurora_engine_types::parameters::engine::{
FullAccessKeyArgs, RelayerKeyArgs, RelayerKeyManagerArgs, SetUpgradeDelayBlocksArgs,
};
use aurora_engine_types::public_key::PublicKey;
use aurora_engine_types::types::Address;
use aurora_engine_workspace::parse_near;
Expand Down Expand Up @@ -275,6 +277,62 @@ async fn test_call_not_allowed_contract() {
assert_error_message(&err, "unable to broadcast the transaction to the network");
}

#[tokio::test]
async fn test_attach_full_access_key() {
let aurora = deploy_engine().await;
let secret_key = SecretKey::from_random(KeyType::ED25519);
let public_key = public_key(&secret_key);
let admin = aurora.create_account(&aurora.id(), secret_key);

let err = admin
.call(&aurora.id(), "set_upgrade_delay_blocks")
.args_borsh(SetUpgradeDelayBlocksArgs {
upgrade_delay_blocks: 5,
})
.max_gas()
.transact()
.await;
assert_error_message(&err, "Failed to query access key");

let result = aurora
.attach_full_access_key(FullAccessKeyArgs { public_key })
.max_gas()
.transact()
.await
.unwrap();
assert!(result.is_success());

let result = admin
.call(&aurora.id(), "set_upgrade_delay_blocks")
.args_borsh(SetUpgradeDelayBlocksArgs {
upgrade_delay_blocks: 5,
})
.max_gas()
.transact()
.await
.unwrap();
assert!(result.is_success()); // because owner_account_id == current_account_id

// Change the owner
let result = aurora
.set_owner(&"some_owner.root".parse().unwrap())
.max_gas()
.transact()
.await
.unwrap();
assert!(result.is_success());

let err = admin
.call(&aurora.id(), "set_upgrade_delay_blocks")
.args_borsh(SetUpgradeDelayBlocksArgs {
upgrade_delay_blocks: 5,
})
.max_gas()
.transact()
.await;
assert_error_message(&err, "ERR_NOT_ALLOWED");
}

fn public_key(sk: &SecretKey) -> PublicKey {
let pk_str = serde_json::to_string(&sk.public_key()).unwrap();
PublicKey::from_str(pk_str.trim_matches('"')).unwrap()
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod access_keys;
mod account_id_precompiles;
mod contract_call;
mod ecrecover;
Expand All @@ -16,7 +17,6 @@ mod pause_contract;
mod prepaid_gas_precompile;
mod promise_results_precompile;
mod random;
mod relayer_keys;
mod repro;
pub mod sanity;
mod self_destruct_state;
Expand Down
6 changes: 2 additions & 4 deletions engine-tests/src/tests/one_inch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use std::sync::Once;
const INITIAL_BALANCE: Wei = Wei::new_u64(1_000_000);
const INITIAL_NONCE: u64 = 0;

static DOWNLOAD_ONCE: Once = Once::new();
static COMPILE_ONCE: Once = Once::new();
static DOWNLOAD_COMPILE_ONCE: Once = Once::new();

#[test]
fn test_1inch_liquidity_protocol() {
Expand Down Expand Up @@ -116,8 +115,7 @@ fn deploy_1_inch_limit_order_contract(
) -> VMOutcome {
let artifacts_path = utils::one_inch::download_and_compile_solidity_sources(
"limit-order-protocol",
&DOWNLOAD_ONCE,
&COMPILE_ONCE,
&DOWNLOAD_COMPILE_ONCE,
);
let contract_path = artifacts_path.join("LimitOrderProtocol.sol/LimitOrderProtocol.json");
let constructor =
Expand Down
8 changes: 4 additions & 4 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: 116,
near_gas_used: 117,
});
}

Expand Down Expand Up @@ -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: 172,
near_gas_used: 171,
});
}

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: 605,
near_gas_used: 604,
});
}

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: 174,
near_gas_used: 173,
});
}

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 @@ -684,7 +684,7 @@ fn test_num_wasm_functions() {
let module = walrus::ModuleConfig::default()
.parse(runner.code.code())
.unwrap();
let expected_number = 1524;
let expected_number = 1550;
let actual_number = module.funcs.iter().count();

assert!(
Expand Down
13 changes: 4 additions & 9 deletions engine-tests/src/utils/one_inch/liquidity_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use aurora_engine_types::types::Wei;
use std::path::PathBuf;
use std::sync::Once;

static DOWNLOAD_ONCE: Once = Once::new();
static COMPILE_ONCE: Once = Once::new();
static DOWNLOAD_COMPILE_ONCE: Once = Once::new();

pub struct Helper<'a> {
pub runner: &'a mut utils::AuroraRunner,
Expand All @@ -19,7 +18,7 @@ impl<'a> Helper<'a> {
&mut self,
) -> (SubmitResult, ExecutionProfile, PoolDeployer) {
let artifacts_path = download_and_compile_solidity_sources();
let deployer_constructor = utils::solidity::ContractConstructor::compile_from_extended_json(
let deployer_constructor = solidity::ContractConstructor::compile_from_extended_json(
artifacts_path.join("MooniswapDeployer.sol/MooniswapDeployer.json"),
);
let data = deployer_constructor.code;
Expand Down Expand Up @@ -54,7 +53,7 @@ impl<'a> Helper<'a> {
pool_deployer: &PoolDeployer,
) -> (SubmitResult, ExecutionProfile, PoolFactory) {
let artifacts_path = download_and_compile_solidity_sources();
let constructor = utils::solidity::ContractConstructor::compile_from_extended_json(
let constructor = solidity::ContractConstructor::compile_from_extended_json(
artifacts_path.join("MooniswapFactory.sol/MooniswapFactory.json"),
);

Expand Down Expand Up @@ -251,9 +250,5 @@ impl Pool {
}

fn download_and_compile_solidity_sources() -> PathBuf {
super::download_and_compile_solidity_sources(
"liquidity-protocol",
&DOWNLOAD_ONCE,
&COMPILE_ONCE,
)
super::download_and_compile_solidity_sources("liquidity-protocol", &DOWNLOAD_COMPILE_ONCE)
}
Loading

0 comments on commit 48c6330

Please sign in to comment.