Skip to content

Commit

Permalink
chore: change wasm-opt settings
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksuss committed Mar 25, 2024
1 parent c846820 commit 1c73fc1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ dependencies = ["build-forwarder", "build-fees"]
dependencies = ["download-wasm-opt"]
script = '''
filesize_before=$(wc -c res/${FWD_WASM_FILE} | awk '{print $1}')
res/binaryen/bin/wasm-opt -O4 res/${FWD_WASM_FILE} -o res/${FWD_WASM_FILE} --strip-debug --vacuum
res/binaryen/bin/wasm-opt -Os res/${FWD_WASM_FILE} -o res/${FWD_WASM_FILE}
filesize_after=$(wc -c res/${FWD_WASM_FILE} | awk '{print $1}')
echo "File size before: [$filesize_before] and after: [$filesize_after]"
'''
Expand Down
3 changes: 2 additions & 1 deletion factory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ use near_sdk::{
};

const FORWARDER_WASM: &[u8] = include_bytes!("../../res/aurora-forwarder.wasm");
const INIT_BALANCE: NearToken = NearToken::from_millinear(445);
const STORAGE_BALANCE_BOUND: NearToken = NearToken::from_yoctonear(1_250_000_000_000_000_000_000);
const FORWARDER_NEW_GAS: Gas = Gas::from_tgas(5);
const MAX_NUM_CONTRACTS: usize = 8;

pub const INIT_BALANCE: NearToken = NearToken::from_millinear(440);

#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)]
#[borsh(crate = "near_sdk::borsh")]
Expand Down
2 changes: 1 addition & 1 deletion forwarder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod types;
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

const MINIMUM_BALANCE: u128 = 445_000_000_000_000_000_000_000;
const MINIMUM_BALANCE: u128 = 440_000_000_000_000_000_000_000;
const ZERO_YOCTO: u128 = 0;
const MAX_FEE_PERCENT: u128 = 10;

Expand Down
5 changes: 2 additions & 3 deletions tests/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::sandbox::{aurora::Aurora, fungible_token::FungibleToken, Sandbox};
use aurora_engine_types::types::Address;
use aurora_forwarder_factory::DeployParameters;
use aurora_forwarder_factory::{DeployParameters, INIT_BALANCE};
use near_workspaces::types::{AccessKeyPermission, NearToken, PublicKey};
use near_workspaces::AccountId;
use once_cell::sync::Lazy;
Expand All @@ -12,7 +12,6 @@ mod wrap;
const RECEIVER: &str = "0x17ffdf6becbbc34d5c7d3bf4a0ed4a680395d057";
const TOTAL_SUPPLY: u128 = 1_000_000_000_000_000;
const MAX_NUM_CONTRACTS: usize = 8;
const MIN_FWD_BALANCE: NearToken = NearToken::from_millinear(445);

static WNEAR: Lazy<AccountId> = Lazy::new(|| AccountId::from_str("wrap.test.near").unwrap());

Expand Down Expand Up @@ -226,7 +225,7 @@ async fn test_using_factory() {
assert_eq!(forwarder_ids.len(), MAX_NUM_CONTRACTS);

for (id, params) in forwarder_ids.iter().zip(parameters) {
assert!(sandbox.balance(id).await > MIN_FWD_BALANCE.as_yoctonear());
assert!(sandbox.balance(id).await > INIT_BALANCE.as_yoctonear());

let expected_id = format!(
"{}.{factory_id}",
Expand Down
11 changes: 5 additions & 6 deletions tests/src/tests/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use crate::sandbox::aurora::Aurora;
use crate::sandbox::factory::Factory;
use crate::sandbox::fungible_token::FungibleToken;
use crate::sandbox::Sandbox;
use crate::tests::MIN_FWD_BALANCE;
use aurora_forwarder_factory::DeployParameters;
use aurora_forwarder_factory::{DeployParameters, INIT_BALANCE};
use near_workspaces::types::NearToken;
use near_workspaces::AccountId;
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -45,7 +44,7 @@ async fn test_forward_native_tokens() {
assert_eq!(
fwd_balance / rounder,
transfer
.checked_add(MIN_FWD_BALANCE)
.checked_add(INIT_BALANCE)
.unwrap()
.as_yoctonear()
/ rounder
Expand All @@ -54,7 +53,7 @@ async fn test_forward_native_tokens() {
factory.forward(&forwarder, &NEAR).await.unwrap();

let fwd_balance = sandbox.balance(&forwarder).await;
assert_eq!(fwd_balance / rounder, MIN_FWD_BALANCE.as_millinear());
assert_eq!(fwd_balance / rounder, INIT_BALANCE.as_millinear());

let fee = transfer.as_yoctonear() * 5 / 100;
let deposit = transfer.as_yoctonear() - fee;
Expand Down Expand Up @@ -104,7 +103,7 @@ async fn test_forward_native_tokens_with_zero_fee() {
assert_eq!(
fwd_balance / rounder,
transfer
.checked_add(MIN_FWD_BALANCE)
.checked_add(INIT_BALANCE)
.unwrap()
.as_yoctonear()
/ rounder
Expand All @@ -113,7 +112,7 @@ async fn test_forward_native_tokens_with_zero_fee() {
factory.forward(&forwarder, &NEAR).await.unwrap();

let fwd_balance = sandbox.balance(&forwarder).await;
assert_eq!(fwd_balance / rounder, MIN_FWD_BALANCE.as_millinear());
assert_eq!(fwd_balance / rounder, INIT_BALANCE.as_millinear());

let deposit = transfer.as_yoctonear();

Expand Down

0 comments on commit 1c73fc1

Please sign in to comment.