diff --git a/Cargo.lock b/Cargo.lock index b50f9a55055..8522db14dc0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1151,6 +1151,17 @@ dependencies = [ "log", ] +[[package]] +name = "derivative" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f" +dependencies = [ + "proc-macro2 1.0.20", + "quote 1.0.3", + "syn 1.0.38", +] + [[package]] name = "derive_more" version = "0.99.9" @@ -2866,11 +2877,12 @@ dependencies = [ [[package]] name = "near-evm-runner" -version = "0.1.0" +version = "2.2.0" dependencies = [ "bn", "borsh", "byteorder", + "derivative", "enum-primitive-derive", "ethabi", "ethabi-contract", @@ -3187,6 +3199,7 @@ name = "near-vm-errors" version = "2.2.0" dependencies = [ "borsh", + "ethereum-types", "hex", "near-rpc-error-macro", "serde", @@ -3216,6 +3229,7 @@ dependencies = [ "assert_matches", "bencher", "cached", + "near-evm-runner", "near-runtime-fees", "near-vm-errors", "near-vm-logic", @@ -4410,11 +4424,18 @@ dependencies = [ "borsh", "clap 2.33.0", "csv", + "ethabi", + "ethabi-contract", + "ethabi-derive", + "ethereum-types", "glob 0.3.0", "gnuplot", + "hex", "indicatif 0.15.0", + "lazy-static-include", "near-chain-configs", "near-crypto", + "near-evm-runner", "near-primitives", "near-runtime-fees", "near-store", @@ -4423,11 +4444,14 @@ dependencies = [ "neard", "node-runtime", "num-rational 0.3.0", + "num-traits", "rand 0.7.3", "rand_xorshift 0.2.0", "rocksdb", "serde_json", + "state-viewer", "tempfile", + "testlib", "walrus", ] diff --git a/core/primitives/src/version.rs b/core/primitives/src/version.rs index c0f2aef157a..922fdee71ff 100644 --- a/core/primitives/src/version.rs +++ b/core/primitives/src/version.rs @@ -108,7 +108,9 @@ lazy_static! { let nightly_protocol_features_to_version_mapping: HashMap< ProtocolFeature, ProtocolVersion, - > = vec![(ProtocolFeature::ForwardChunkParts, 41)].into_iter().collect(); + > = vec![(ProtocolFeature::ForwardChunkParts, 41), (ProtocolFeature::EVM, 41)] + .into_iter() + .collect(); for (stable_protocol_feature, stable_protocol_version) in STABLE_PROTOCOL_FEATURES_TO_VERSION_MAPPING.iter() { diff --git a/neard/Cargo.toml b/neard/Cargo.toml index 427908647d8..aa2e65080f9 100644 --- a/neard/Cargo.toml +++ b/neard/Cargo.toml @@ -59,7 +59,7 @@ no_cache = ["node-runtime/no_cache", "near-store/no_cache", "near-chain/no_cache delay_detector = ["near-client/delay_detector"] rosetta_rpc = ["near-rosetta-rpc"] protocol_feature_forward_chunk_parts = ["near-client/protocol_feature_forward_chunk_parts"] -protocol_feature_evm = ["near-primitives/protocol_feature_evm"] +protocol_feature_evm = ["node-runtime/protocol_feature_evm", "near-primitives/protocol_feature_evm"] nightly_protocol_features = ["nightly_protocol", "protocol_feature_forward_chunk_parts", "near-client/nightly_protocol_features", "protocol_feature_evm"] nightly_protocol = ["near-primitives/nightly_protocol"] diff --git a/runtime/near-evm-runner/Cargo.toml b/runtime/near-evm-runner/Cargo.toml index c0599106e4b..3bb83461e6b 100644 --- a/runtime/near-evm-runner/Cargo.toml +++ b/runtime/near-evm-runner/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "near-evm-runner" -version = "0.1.0" +version = "2.2.0" authors = ["Near Inc "] edition = "2018" license = "Apache-2.0" @@ -35,6 +35,8 @@ near-vm-errors = { path = "../near-vm-errors" } near-runtime-utils = { path = "../near-runtime-utils" } near-runtime-fees = { path = "../near-runtime-fees" } +derivative = "2.1.1" + [dev-dependencies] ethabi = "8.0.0" ethabi-contract = "8.0.0" @@ -42,4 +44,8 @@ ethabi-derive = "8.0.0" lazy_static = "1.4" lazy-static-include = "2.2.2" -near-crypto = { path = "../../core/crypto" } \ No newline at end of file +near-crypto = { path = "../../core/crypto" } + +[features] +default = [] +costs_counting = [] \ No newline at end of file diff --git a/runtime/near-evm-runner/src/builtins.rs b/runtime/near-evm-runner/src/builtins.rs index fe6f039b973..a7f861ca3eb 100644 --- a/runtime/near-evm-runner/src/builtins.rs +++ b/runtime/near-evm-runner/src/builtins.rs @@ -4,9 +4,9 @@ use std::{ mem::size_of, }; -use bn::arith::U256; use byteorder::{BigEndian, ByteOrder, LittleEndian, ReadBytesExt}; -use ethereum_types::Address; +use ethereum_types::{Address, H256, U256}; +use near_runtime_fees::EvmCostConfig; use num_bigint::BigUint; use num_traits::{FromPrimitive, One, ToPrimitive, Zero}; use parity_bytes::BytesRef; @@ -48,13 +48,23 @@ pub fn precompile(id: u64) -> Result, String> { }) } -pub fn process_precompile(addr: &Address, input: &[u8]) -> MessageCallResult { +pub fn process_precompile( + addr: &Address, + input: &[u8], + gas: &U256, + evm_gas_config: &EvmCostConfig, +) -> MessageCallResult { let f = match precompile(addr.to_low_u64_be()) { Ok(f) => f, Err(_) => return MessageCallResult::Failed, }; let mut bytes = vec![]; let mut output = parity_bytes::BytesRef::Flexible(&mut bytes); + let cost = f.gas(input, evm_gas_config); + + if cost > *gas { + return MessageCallResult::Failed; + } // mutates bytes match f.execute(input, &mut output) { @@ -63,8 +73,7 @@ pub fn process_precompile(addr: &Address, input: &[u8]) -> MessageCallResult { }; let size = bytes.len(); - // TODO: add gas usage here. - MessageCallResult::Success(1_000_000_000.into(), ReturnData::new(bytes, 0, size)) + MessageCallResult::Success(*gas - cost, ReturnData::new(bytes, 0, size)) } /** the following is copied from ethcore/src/builtin.rs **/ @@ -131,6 +140,9 @@ pub struct Blake2FImpl; pub trait Impl: Send + Sync { /// execute this built-in on the given input, writing to the given output. fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), Error>; + fn gas(&self, _input: &[u8], _evm_gas_config: &EvmCostConfig) -> U256 { + 0.into() + } } impl Impl for Identity { @@ -138,6 +150,9 @@ impl Impl for Identity { output.write(0, input); Ok(()) } + fn gas(&self, _input: &[u8], evm_gas_config: &EvmCostConfig) -> U256 { + evm_gas_config.identity_cost.into() + } } impl Impl for EcRecover { @@ -157,6 +172,10 @@ impl Impl for EcRecover { Ok(()) } + + fn gas(&self, _input: &[u8], evm_gas_config: &EvmCostConfig) -> U256 { + evm_gas_config.ecrecover_cost.into() + } } impl Impl for Sha256 { @@ -166,6 +185,10 @@ impl Impl for Sha256 { output.write(0, &*d); Ok(()) } + + fn gas(&self, _input: &[u8], evm_gas_config: &EvmCostConfig) -> U256 { + evm_gas_config.sha256_cost.into() + } } impl Impl for Ripemd160 { @@ -175,6 +198,10 @@ impl Impl for Ripemd160 { output.write(12, &hash); Ok(()) } + + fn gas(&self, _input: &[u8], evm_gas_config: &EvmCostConfig) -> U256 { + evm_gas_config.ripemd160_cost.into() + } } // calculate modexp: left-to-right binary exponentiation to keep multiplicands lower @@ -283,6 +310,10 @@ impl Impl for ModexpImpl { Ok(()) } + + fn gas(&self, _input: &[u8], evm_gas_config: &EvmCostConfig) -> U256 { + evm_gas_config.modexp_cost.into() + } } fn read_fr(reader: &mut io::Chain<&[u8], io::Repeat>) -> Result<::bn::Fr, Error> { @@ -431,7 +462,7 @@ impl Bn128PairingImpl { }; let mut buf = [0u8; 32]; - ret_val.to_big_endian(&mut buf).expect("Can't fail"); + ret_val.to_big_endian(&mut buf); output.write(0, &buf); Ok(()) diff --git a/runtime/near-evm-runner/src/evm_state.rs b/runtime/near-evm-runner/src/evm_state.rs index a47d037e55a..28e2a92de63 100644 --- a/runtime/near-evm-runner/src/evm_state.rs +++ b/runtime/near-evm-runner/src/evm_state.rs @@ -325,6 +325,31 @@ impl EvmState for SubState<'_> { } } +#[derive(Debug)] +pub struct EvmGasCounter { + pub used_gas: U256, + pub max_gas: U256, +} + +impl EvmGasCounter { + pub fn new(used_gas: U256, max_gas: U256) -> EvmGasCounter { + Self { used_gas, max_gas } + } + + pub fn pay_gas(&mut self, amount: U256) { + debug_assert!(self.used_gas + amount <= self.max_gas); + self.used_gas += amount; + } + + pub fn set_gas_left(&mut self, left: U256) { + self.used_gas = self.max_gas.saturating_sub(left); + } + + pub fn gas_left(&self) -> U256 { + self.max_gas - self.used_gas + } +} + #[cfg(test)] mod test { use super::*; diff --git a/runtime/near-evm-runner/src/interpreter.rs b/runtime/near-evm-runner/src/interpreter.rs index aee86c9121d..f767cf85e55 100644 --- a/runtime/near-evm-runner/src/interpreter.rs +++ b/runtime/near-evm-runner/src/interpreter.rs @@ -2,9 +2,10 @@ use std::sync::Arc; use ethereum_types::{Address, U256}; use evm::{CreateContractAddress, Factory}; +use near_runtime_fees::EvmCostConfig; use vm::{ - ActionParams, ActionValue, CallType, ExecTrapResult, Ext, GasLeft, ParamsType, ReturnData, - Schedule, + ActionParams, ActionValue, CallType, ContractCreateResult, ExecTrapResult, Ext, GasLeft, + MessageCallResult, ParamsType, ReturnData, Schedule, }; use near_vm_errors::{EvmError, VMLogicError}; @@ -23,7 +24,9 @@ pub fn deploy_code( address_type: CreateContractAddress, recreate: bool, code: &[u8], -) -> Result
{ + gas: &U256, + evm_gas_config: &EvmCostConfig, +) -> Result { let mut nonce = U256::zero(); if address_type == CreateContractAddress::FromSenderAndNonce { nonce = state.next_nonce(&sender)?; @@ -36,15 +39,26 @@ pub fn deploy_code( return Err(VMLogicError::EvmError(EvmError::DuplicateContract(address.0.to_vec()))); } - let (result, state_updates) = - _create(state, origin, sender, value, call_stack_depth, &address, code)?; + let (result, state_updates) = _create( + state, + origin, + sender, + value, + call_stack_depth, + &address, + code, + gas, + evm_gas_config, + )?; // Apply known gas amount changes (all reverts are NeedsReturn) // Apply NeedsReturn changes if apply_state // Return the result unmodified - let (return_data, apply) = match result { - Ok(Ok(GasLeft::Known(_))) => (ReturnData::empty(), true), - Ok(Ok(GasLeft::NeedsReturn { gas_left: _, data, apply_state })) => (data, apply_state), + let (return_data, apply, gas_left) = match result { + Ok(Ok(GasLeft::Known(left))) => (ReturnData::empty(), true, left), + Ok(Ok(GasLeft::NeedsReturn { gas_left: left, data, apply_state })) => { + (data, apply_state, left) + } Ok(Err(err)) => return Err(convert_vm_error(err)), Err(_) => return Err(VMLogicError::EvmError(EvmError::Reverted)), }; @@ -52,10 +66,10 @@ pub fn deploy_code( if apply { state.commit_changes(&state_updates.unwrap())?; state.set_code(&address, &return_data.to_vec())?; + Ok(ContractCreateResult::Created(address, gas_left)) } else { - return Err(VMLogicError::EvmError(EvmError::DeployFail(return_data.to_vec()))); + Ok(ContractCreateResult::Reverted(gas_left, return_data)) } - Ok(address) } pub fn _create( @@ -66,6 +80,8 @@ pub fn _create( call_stack_depth: usize, address: &Address, code: &[u8], + gas: &U256, + evm_gas_config: &EvmCostConfig, ) -> Result<(ExecTrapResult, Option)> { let mut store = StateStore::default(); let mut sub_state = SubState::new(sender, &mut store, state); @@ -75,8 +91,7 @@ pub fn _create( address: *address, sender: *sender, origin: *origin, - // TODO: gas usage. - gas: 1_000_000_000.into(), + gas: *gas, gas_price: 1.into(), value: ActionValue::Transfer(value), code: Some(Arc::new(code.to_vec())), @@ -88,16 +103,21 @@ pub fn _create( sub_state.transfer_balance(sender, address, value)?; - let mut ext = NearExt::new(*address, *origin, &mut sub_state, call_stack_depth + 1, false); - // TODO: gas usage. - ext.info.gas_limit = U256::from(1_000_000_000); + let mut ext = NearExt::new( + *address, + *origin, + &mut sub_state, + call_stack_depth + 1, + false, + evm_gas_config, + ); + ext.info.gas_limit = U256::from(gas); ext.schedule = Schedule::new_constantinople(); let instance = Factory::default().create(params, ext.schedule(), ext.depth()); // Run the code let result = instance.exec(&mut ext); - Ok((result, Some(store))) } @@ -111,7 +131,9 @@ pub fn call( contract_address: &Address, input: &[u8], should_commit: bool, -) -> Result { + gas: &U256, + evm_gas_config: &EvmCostConfig, +) -> Result { run_and_commit_if_success( state, origin, @@ -124,6 +146,8 @@ pub fn call( input, false, should_commit, + gas, + evm_gas_config, ) } @@ -135,7 +159,9 @@ pub fn delegate_call( context: &Address, delegee: &Address, input: &[u8], -) -> Result { + gas: &U256, + evm_gas_config: &EvmCostConfig, +) -> Result { run_and_commit_if_success( state, origin, @@ -148,6 +174,8 @@ pub fn delegate_call( input, false, true, + gas, + evm_gas_config, ) } @@ -158,7 +186,9 @@ pub fn static_call( call_stack_depth: usize, contract_address: &Address, input: &[u8], -) -> Result { + gas: &U256, + evm_gas_config: &EvmCostConfig, +) -> Result { run_and_commit_if_success( state, origin, @@ -171,6 +201,8 @@ pub fn static_call( input, true, false, + gas, + evm_gas_config, ) } @@ -187,7 +219,9 @@ fn run_and_commit_if_success( input: &[u8], is_static: bool, should_commit: bool, -) -> Result { + gas: &U256, + evm_gas_config: &EvmCostConfig, +) -> Result { // run the interpreter and let (result, state_updates) = run_against_state( state, @@ -200,26 +234,33 @@ fn run_and_commit_if_success( code_address, input, is_static, + gas, + evm_gas_config, )?; // Apply known gas amount changes (all reverts are NeedsReturn) // Apply NeedsReturn changes if apply_state // Return the result unmodified + let mut should_apply_state = true; let return_data = match result { - Ok(Ok(GasLeft::Known(_))) => Ok(ReturnData::empty()), - Ok(Ok(GasLeft::NeedsReturn { gas_left: _, data, apply_state: true })) => Ok(data), - Ok(Ok(GasLeft::NeedsReturn { gas_left: _, data, apply_state: false })) => { - Err(VMLogicError::EvmError(EvmError::Revert(data.to_vec()))) + Ok(Ok(GasLeft::Known(gas_left))) => { + Ok(MessageCallResult::Success(gas_left, ReturnData::empty())) + } + Ok(Ok(GasLeft::NeedsReturn { gas_left, data, apply_state: true })) => { + Ok(MessageCallResult::Success(gas_left, data)) + } + Ok(Ok(GasLeft::NeedsReturn { gas_left, data, apply_state: false })) => { + should_apply_state = false; + Ok(MessageCallResult::Reverted(gas_left, data)) } Ok(Err(err)) => Err(convert_vm_error(err)), Err(_) => Err(VMLogicError::EvmError(EvmError::Reverted)), }; // Don't apply changes from a static context (these _should_ error in the ext) - if !is_static && return_data.is_ok() && should_commit { + if !is_static && return_data.is_ok() && should_apply_state && should_commit { state.commit_changes(&state_updates.unwrap())?; } - return_data } @@ -236,6 +277,8 @@ fn run_against_state( code_address: &Address, input: &[u8], is_static: bool, + gas: &U256, + evm_gas_config: &EvmCostConfig, ) -> Result<(ExecTrapResult, Option)> { let code = state.code_at(code_address)?.unwrap_or_else(Vec::new); @@ -254,8 +297,7 @@ fn run_against_state( address: *state_address, sender: *sender, origin: *origin, - // TODO: gas usage. - gas: 1_000_000_000.into(), + gas: *gas, gas_price: 1.into(), value: ActionValue::Apparent(0.into()), code: Some(Arc::new(code)), @@ -270,10 +312,16 @@ fn run_against_state( sub_state.transfer_balance(sender, state_address, val)?; } - let mut ext = - NearExt::new(*state_address, *origin, &mut sub_state, call_stack_depth + 1, is_static); - // TODO: gas usage. - ext.info.gas_limit = U256::from(1_000_000_000); + let mut ext = NearExt::new( + *state_address, + *origin, + &mut sub_state, + call_stack_depth + 1, + is_static, + evm_gas_config, + ); + // Gas limit is evm block gas limit, should at least prepaid gas. + ext.info.gas_limit = *gas; ext.schedule = Schedule::new_constantinople(); let instance = Factory::default().create(params, ext.schedule(), ext.depth()); diff --git a/runtime/near-evm-runner/src/lib.rs b/runtime/near-evm-runner/src/lib.rs index 96bd3ed325c..13b5ccd8296 100644 --- a/runtime/near-evm-runner/src/lib.rs +++ b/runtime/near-evm-runner/src/lib.rs @@ -4,15 +4,16 @@ extern crate enum_primitive_derive; use borsh::{BorshDeserialize, BorshSerialize}; use ethereum_types::{Address, H160, U256}; use evm::CreateContractAddress; +use vm::{ContractCreateResult, MessageCallResult}; -use near_runtime_fees::RuntimeFeesConfig; +use near_runtime_fees::{EvmCostConfig, RuntimeFeesConfig}; use near_runtime_utils::{is_account_id_64_len_hex, is_valid_sub_account_id}; use near_vm_errors::{EvmError, FunctionCallError, VMError}; use near_vm_logic::gas_counter::GasCounter; use near_vm_logic::types::{AccountId, Balance, Gas, ReturnData, StorageUsage}; use near_vm_logic::{ActionCosts, External, VMConfig, VMLogicError, VMOutcome}; -use crate::evm_state::{EvmAccount, EvmState, StateStore}; +use crate::evm_state::{EvmAccount, EvmGasCounter, EvmState, StateStore}; use crate::types::{ AddressArg, GetStorageAtArgs, RawU256, Result, TransferArgs, ViewCallArgs, WithdrawArgs, }; @@ -32,14 +33,23 @@ pub struct EvmContext<'a> { signer_id: AccountId, predecessor_id: AccountId, current_amount: Balance, - attached_deposit: Balance, + pub attached_deposit: Balance, storage_usage: StorageUsage, pub logs: Vec, gas_counter: GasCounter, + pub evm_gas_counter: EvmGasCounter, fees_config: &'a RuntimeFeesConfig, domain_separator: RawU256, } +// Different kind of evm operations that result in different gas calculation +pub enum EvmOpForGas { + // size of deployed evm contract after it's decoded from hex (0.5x) + Deploy(usize), + Funcall, + Other, +} + enum KeyPrefix { Account = 0, Contract = 1, @@ -144,6 +154,7 @@ impl<'a> EvmContext<'a> { storage_usage: StorageUsage, prepaid_gas: Gas, is_view: bool, + evm_gas: U256, ) -> Self { let max_gas_burnt = if is_view { config.limit_config.max_gas_burnt_view @@ -168,6 +179,7 @@ impl<'a> EvmContext<'a> { is_view, None, ), + evm_gas_counter: EvmGasCounter::new(0.into(), evm_gas), fees_config, domain_separator, } @@ -180,7 +192,7 @@ impl<'a> EvmContext<'a> { pub fn deploy_code(&mut self, bytecode: Vec) -> Result
{ let sender = utils::near_account_id_to_evm_address(&self.predecessor_id); self.add_balance(&sender, U256::from(self.attached_deposit))?; - interpreter::deploy_code( + match interpreter::deploy_code( self, &sender, &sender, @@ -189,7 +201,19 @@ impl<'a> EvmContext<'a> { CreateContractAddress::FromSenderAndNonce, false, &bytecode, - ) + &self.evm_gas_counter.gas_left(), + &self.fees_config.evm_config, + )? { + ContractCreateResult::Created(address, gas_left) => { + self.evm_gas_counter.set_gas_left(gas_left); + Ok(address) + } + ContractCreateResult::Reverted(gas_left, return_data) => { + self.evm_gas_counter.set_gas_left(gas_left); + Err(VMLogicError::EvmError(EvmError::DeployFail(return_data.to_vec()))) + } + _ => unreachable!(), + } } /// Make an EVM transaction. Calls `contract_address` with RLP encoded `input`. Execution @@ -206,8 +230,29 @@ impl<'a> EvmContext<'a> { self.add_balance(&sender, U256::from(self.attached_deposit))?; let value = if self.attached_deposit == 0 { None } else { Some(U256::from(self.attached_deposit)) }; - interpreter::call(self, &origin, &sender, value, 0, &contract_address, &input, true) - .map(|rd| rd.to_vec()) + let result = interpreter::call( + self, + &sender, + &sender, + value, + 0, + &contract_address, + &input, + true, + &self.evm_gas_counter.gas_left(), + &self.fees_config.evm_config, + )?; + match result { + MessageCallResult::Success(gas_left, data) => { + self.evm_gas_counter.set_gas_left(gas_left); + Ok(data.to_vec()) + } + MessageCallResult::Reverted(gas_left, data) => { + self.evm_gas_counter.set_gas_left(gas_left); + Err(VMLogicError::EvmError(EvmError::Revert(data.to_vec()))) + } + _ => unreachable!(), + } } /// Make an EVM call via a meta transaction pattern. @@ -221,7 +266,7 @@ impl<'a> EvmContext<'a> { self.add_balance(&meta_call_args.sender, U256::from(self.attached_deposit))?; let value = if self.attached_deposit == 0 { None } else { Some(U256::from(self.attached_deposit)) }; - interpreter::call( + let result = interpreter::call( self, &meta_call_args.sender, &meta_call_args.sender, @@ -230,8 +275,20 @@ impl<'a> EvmContext<'a> { &meta_call_args.contract_address, &meta_call_args.input, true, - ) - .map(|rd| rd.to_vec()) + &self.evm_gas_counter.gas_left(), + &self.fees_config.evm_config, + )?; + match result { + MessageCallResult::Success(gas_left, data) => { + self.evm_gas_counter.set_gas_left(gas_left); + Ok(data.to_vec()) + } + MessageCallResult::Reverted(gas_left, data) => { + self.evm_gas_counter.set_gas_left(gas_left); + Err(VMLogicError::EvmError(EvmError::Revert(data.to_vec()))) + } + _ => unreachable!(), + } } /// Make an EVM transaction. Calls `contract_address` with `encoded_input`. Execution @@ -254,8 +311,20 @@ impl<'a> EvmContext<'a> { &Address::from(&args.address), &args.args, false, - ) - .map(|rd| rd.to_vec()); + &self.evm_gas_counter.gas_left(), + &self.fees_config.evm_config, + )?; + let result = match result { + MessageCallResult::Success(gas_left, data) => { + self.evm_gas_counter.set_gas_left(gas_left); + Ok(data.to_vec()) + } + MessageCallResult::Reverted(gas_left, data) => { + self.evm_gas_counter.set_gas_left(gas_left); + Err(VMLogicError::EvmError(EvmError::Revert(data.to_vec()))) + } + _ => unreachable!(), + }; // Need to subtract amount back, because if view call is called inside the transaction state will be applied. // The interpreter call is not committing changes, but `add_balance` did, so need to revert that. self.sub_balance(&sender, attached_amount)?; @@ -400,6 +469,27 @@ impl<'a> EvmContext<'a> { self.gas_counter.pay_action_accumulated(burn_gas, use_gas, ActionCosts::new_receipt) } + fn pay_gas_from_evm_gas(&mut self, op: EvmOpForGas) -> Result<()> { + let fee_cfg = &self.fees_config.evm_config; + let evm_gas = self.evm_gas_counter.used_gas.as_u64(); + self.gas_counter.inc_evm_gas_counter(evm_gas); + let gas = match op { + EvmOpForGas::Deploy(decoded_len) => { + // gas per byte is counting hex encoded contract size (solc output, 2x of decoded len) + (decoded_len as u64 * 2) * fee_cfg.deploy_cost_per_byte + + evm_gas * fee_cfg.deploy_cost_per_evm_gas + + fee_cfg.bootstrap_cost + } + EvmOpForGas::Funcall => { + evm_gas * fee_cfg.funcall_cost_per_evm_gas + + fee_cfg.funcall_cost_base + + fee_cfg.bootstrap_cost + } + EvmOpForGas::Other => fee_cfg.bootstrap_cost, + }; + self.gas_counter.pay_evm_gas(gas) + } + fn pay_gas_for_transfer(&mut self, account_id: &AccountId) -> Result<()> { if is_account_id_64_len_hex(&account_id) { self.gas_counter.pay_action_base( @@ -421,6 +511,45 @@ impl<'a> EvmContext<'a> { } } +fn max_evm_gas_from_near_gas( + near_gas: Gas, + evm_gas_config: &EvmCostConfig, + method_name: &str, + decoded_code_size: Option, +) -> Option { + match method_name { + "deploy_code" => { + if near_gas < evm_gas_config.bootstrap_cost { + return None; + } + Some( + ((near_gas + - evm_gas_config.bootstrap_cost + - evm_gas_config.deploy_cost_per_byte + * (2 * decoded_code_size.unwrap() as u64)) + / evm_gas_config.deploy_cost_per_evm_gas) + .into(), + ) + } + "call_function" => { + if near_gas < evm_gas_config.bootstrap_cost + evm_gas_config.funcall_cost_base { + return None; + } + Some( + ((near_gas - evm_gas_config.bootstrap_cost - evm_gas_config.funcall_cost_base) + / evm_gas_config.funcall_cost_per_evm_gas) + .into(), + ) + } + _ => { + if near_gas < evm_gas_config.bootstrap_cost { + return None; + } + Some(evm_gas_config.bootstrap_cost.into()) + } + } +} + pub fn run_evm( ext: &mut dyn External, chain_id: u128, @@ -437,6 +566,22 @@ pub fn run_evm( prepaid_gas: Gas, is_view: bool, ) -> (Option, Option) { + let evm_gas_result = max_evm_gas_from_near_gas( + prepaid_gas, + &fees_config.evm_config, + &method_name, + if &method_name == "deploy_code" { Some(args.len()) } else { None }, + ); + + if evm_gas_result.is_none() { + return ( + None, + Some(VMError::FunctionCallError(FunctionCallError::EvmError(EvmError::Revert( + "Not enough to run EVM".as_bytes().to_vec(), + )))), + ); + } + let evm_gas = evm_gas_result.unwrap(); let mut context = EvmContext::new( ext, chain_id, @@ -452,30 +597,50 @@ pub fn run_evm( storage_usage, prepaid_gas, is_view, + evm_gas, ); + let result = match method_name.as_str() { // Change the state methods. - "deploy_code" => context.deploy_code(args).map(|address| utils::address_to_vec(&address)), + "deploy_code" => context.deploy_code(args.clone()).map(|address| { + context.pay_gas_from_evm_gas(EvmOpForGas::Deploy(args.len())).unwrap(); + utils::address_to_vec(&address) + }), // TODO: remove this function name if no one is using it. - "call_function" => context.call_function(args), - "call" => context.call_function(args), - "meta_call" => context.meta_call_function(args), - "deposit" => context.deposit(args).map(|balance| utils::u256_to_arr(&balance).to_vec()), - "withdraw" => context.withdraw(args).map(|_| vec![]), - "transfer" => context.transfer(args).map(|_| vec![]), - "create" => context.create_evm(args).map(|_| vec![]), + "call_function" | "call" => { + let r = context.call_function(args.clone()); + context.pay_gas_from_evm_gas(EvmOpForGas::Funcall).unwrap(); + r + } + "meta_call" => { + let r = context.meta_call_function(args.clone()); + context.pay_gas_from_evm_gas(EvmOpForGas::Other).unwrap(); + r + } + "deposit" => { + context.deposit(args.clone()).map(|balance| utils::u256_to_arr(&balance).to_vec()) + } + "withdraw" => context.withdraw(args.clone()).map(|_| vec![]), + "transfer" => context.transfer(args.clone()).map(|_| vec![]), + "create" => context.create_evm(args.clone()).map(|_| vec![]), // View methods. // TODO: remove this function name if no one is using it. - "view_function_call" => context.view_call_function(args), - "view" => context.view_call_function(args), - "get_code" => context.get_code(args), - "get_storage_at" => context.get_storage_at(args), - "get_nonce" => context.get_nonce(args).map(|nonce| utils::u256_to_arr(&nonce).to_vec()), + "view_function_call" | "view" => { + let r = context.view_call_function(args.clone()); + context.pay_gas_from_evm_gas(EvmOpForGas::Other).unwrap(); + r + } + "get_code" => context.get_code(args.clone()), + "get_storage_at" => context.get_storage_at(args.clone()), + "get_nonce" => { + context.get_nonce(args.clone()).map(|nonce| utils::u256_to_arr(&nonce).to_vec()) + } "get_balance" => { - context.get_balance(args).map(|balance| utils::u256_to_arr(&balance).to_vec()) + context.get_balance(args.clone()).map(|balance| utils::u256_to_arr(&balance).to_vec()) } _ => Err(VMLogicError::EvmError(EvmError::MethodNotFound)), }; + match result { Ok(value) => { let outcome = VMOutcome { @@ -531,6 +696,7 @@ mod tests { 0, 0, false, + 1_000_000_000.into(), ) } diff --git a/runtime/near-evm-runner/src/near_ext.rs b/runtime/near-evm-runner/src/near_ext.rs index bdcafb8db3d..499e7d18884 100644 --- a/runtime/near-evm-runner/src/near_ext.rs +++ b/runtime/near-evm-runner/src/near_ext.rs @@ -3,16 +3,16 @@ use std::sync::Arc; use ethereum_types::{Address, H256, U256}; use evm::ActionParams; use keccak_hash::keccak; +use near_runtime_fees::EvmCostConfig; use parity_bytes::Bytes; use vm::{ CallType, ContractCreateResult, CreateContractAddress, EnvInfo, Error as VmError, MessageCallResult, Result as EvmResult, ReturnData, Schedule, TrapKind, }; -use near_vm_errors::{EvmError, VMLogicError}; - use crate::evm_state::{EvmState, SubState}; use crate::interpreter; + use crate::utils::format_log; // https://github.com/paritytech/parity-ethereum/blob/77643c13e80ca09d9a6b10631034f5a1568ba6d3/ethcore/machine/src/externalities.rs @@ -25,6 +25,7 @@ pub struct NearExt<'a> { pub sub_state: &'a mut SubState<'a>, pub static_flag: bool, pub depth: usize, + pub evm_gas_config: &'a EvmCostConfig, } impl std::fmt::Debug for NearExt<'_> { @@ -46,6 +47,7 @@ impl<'a> NearExt<'a> { sub_state: &'a mut SubState<'a>, depth: usize, static_flag: bool, + evm_gas_config: &'a EvmCostConfig, ) -> Self { Self { info: Default::default(), @@ -56,6 +58,7 @@ impl<'a> NearExt<'a> { sub_state, static_flag, depth, + evm_gas_config, } } } @@ -125,7 +128,7 @@ impl<'a> vm::Ext for NearExt<'a> { fn create( &mut self, - _gas: &U256, + gas: &U256, value: &U256, code: &[u8], address_type: CreateContractAddress, @@ -136,7 +139,6 @@ impl<'a> vm::Ext for NearExt<'a> { } // TODO: better error propagation. - // TODO: gas metering. interpreter::deploy_code( self.sub_state, &self.origin, @@ -146,9 +148,9 @@ impl<'a> vm::Ext for NearExt<'a> { address_type, true, &code.to_vec(), + gas, + &self.evm_gas_config, ) - // TODO: gas usage. - .map(|result| ContractCreateResult::Created(result, 1_000_000_000.into())) .map_err(|_| TrapKind::Call(ActionParams::default())) } @@ -159,7 +161,7 @@ impl<'a> vm::Ext for NearExt<'a> { /// and true if subcall was successful. fn call( &mut self, - _gas: &U256, + gas: &U256, sender_address: &Address, receive_address: &Address, value: Option, @@ -174,7 +176,12 @@ impl<'a> vm::Ext for NearExt<'a> { // hijack builtins if crate::builtins::is_precompile(receive_address) { - return Ok(crate::builtins::process_precompile(receive_address, data)); + return Ok(crate::builtins::process_precompile( + receive_address, + data, + gas, + &self.evm_gas_config, + )); } let result = match call_type { @@ -191,6 +198,8 @@ impl<'a> vm::Ext for NearExt<'a> { receive_address, &data.to_vec(), true, // should_commit + gas, + &self.evm_gas_config, ), CallType::StaticCall => interpreter::static_call( self.sub_state, @@ -199,6 +208,8 @@ impl<'a> vm::Ext for NearExt<'a> { self.depth, receive_address, &data.to_vec(), + gas, + &self.evm_gas_config, ), CallType::CallCode => { // Call another contract using storage of the current contract. No longer used. @@ -212,29 +223,11 @@ impl<'a> vm::Ext for NearExt<'a> { receive_address, code_address, &data.to_vec(), + gas, + &self.evm_gas_config, ), }; - - let msg_call_result = match result { - // TODO: gas usage. - Ok(data) => MessageCallResult::Success(1_000_000_000.into(), data), - Err(err) => { - let message = match err { - VMLogicError::EvmError(EvmError::Revert(encoded_message)) => { - hex::decode(encoded_message).unwrap_or(vec![]) - } - // TODO(3455): Pass errors indirectly via state of the object. - _ => vec![], - }; - let message_len = message.len(); - // TODO: gas usage. - MessageCallResult::Reverted( - 1_000_000_000.into(), - ReturnData::new(message, 0, message_len), - ) - } - }; - Ok(msg_call_result) + result.map_err(|_| TrapKind::Call(ActionParams::default())) } /// Returns code at given address diff --git a/runtime/near-evm-runner/tests/build.sh b/runtime/near-evm-runner/tests/build.sh index 391db5242a6..f6245fa2712 100755 --- a/runtime/near-evm-runner/tests/build.sh +++ b/runtime/near-evm-runner/tests/build.sh @@ -6,6 +6,7 @@ contracts=( "Create2Factory" "SelfDestruct" "ConstructorRevert" + "PrecompiledFunction" ) truffle compile || exit 1 diff --git a/runtime/near-evm-runner/tests/build/BBronze.abi b/runtime/near-evm-runner/tests/build/BBronze.abi new file mode 100644 index 00000000000..ff6c870a05c --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BBronze.abi @@ -0,0 +1,17 @@ +[ + { + "constant": true, + "inputs": [], + "name": "getColor", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/BBronze.bin b/runtime/near-evm-runner/tests/build/BBronze.bin new file mode 100644 index 00000000000..9bbf2865e61 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BBronze.bin @@ -0,0 +1 @@ +6080604052348015600f57600080fd5b5060ba8061001e6000396000f3fe6080604052348015600f57600080fd5b50600436106044577c010000000000000000000000000000000000000000000000000000000060003504639a86139b81146049575b600080fd5b604f6061565b60408051918252519081900360200190f35b7f42524f4e5a4500000000000000000000000000000000000000000000000000009056fea265627a7a72315820d02b5140da771a0eb87c9231627fadfdca36c5c04f502cc3fe1163438b04bda664736f6c634300050c0032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/BColor.abi b/runtime/near-evm-runner/tests/build/BColor.abi new file mode 100644 index 00000000000..ff6c870a05c --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BColor.abi @@ -0,0 +1,17 @@ +[ + { + "constant": true, + "inputs": [], + "name": "getColor", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/BConst.abi b/runtime/near-evm-runner/tests/build/BConst.abi new file mode 100644 index 00000000000..42a7386d836 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BConst.abi @@ -0,0 +1,257 @@ +[ + { + "constant": true, + "inputs": [], + "name": "BONE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "BPOW_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "EXIT_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "INIT_POOL_SUPPLY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_IN_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_OUT_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_TOTAL_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BALANCE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getColor", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/BConst.bin b/runtime/near-evm-runner/tests/build/BConst.bin new file mode 100644 index 00000000000..df5ec05428b --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BConst.bin @@ -0,0 +1 @@ +608060405234801561001057600080fd5b5061029c806100206000396000f3fe608060405234801561001057600080fd5b5060043610610108576000357c010000000000000000000000000000000000000000000000000000000090048063b0e0d136116100af578063b0e0d1361461015f578063b7b800a414610167578063ba019dab1461016f578063bc063e1a14610177578063bc694ea21461017f578063c36596a61461012f578063c6580d1214610187578063e4a28a521461010d578063ec0930211461018f57610108565b806309a3bbe41461010d578063189d00ca14610127578063218b53821461012f57806376c7a3c714610137578063867378c51461013f5780639381cd2b14610147578063992e2a921461014f5780639a86139b14610157575b600080fd5b610115610197565b60408051918252519081900360200190f35b6101156101a4565b6101156101b8565b6101156101c4565b6101156101d6565b6101156101ea565b6101156101f7565b610115610203565b610115610227565b61011561022c565b610115610231565b610115610236565b610115610246565b610115610252565b610115610257565b6802b5e3af16b188000081565b6402540be400670de0b6b3a76400005b0481565b670de0b6b3a764000081565b620f4240670de0b6b3a76400006101b4565b64e8d4a51000670de0b6b3a76400006101b4565b68056bc75e2d6310000081565b6704a03ce68d21555681565b7f42524f4e5a45000000000000000000000000000000000000000000000000000090565b600881565b600281565b600181565b600a670de0b6b3a76400006101b4565b671bc16d674ec7ffff81565b600081565b6002670de0b6b3a76400006101b456fea265627a7a72315820a3ed3e544d5a2480a4ca8e33cf23ff0c96b482b4cef52e564e7ba36b9ce3855064736f6c634300050c0032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/BFactory.abi b/runtime/near-evm-runner/tests/build/BFactory.abi new file mode 100644 index 00000000000..2946beca8ae --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BFactory.abi @@ -0,0 +1,142 @@ +[ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "blabs", + "type": "address" + } + ], + "name": "LOG_BLABS", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "LOG_NEW_POOL", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "getColor", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "b", + "type": "address" + } + ], + "name": "isBPool", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "newBPool", + "outputs": [ + { + "internalType": "contract BPool", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getBLabs", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "b", + "type": "address" + } + ], + "name": "setBLabs", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract BPool", + "name": "pool", + "type": "address" + } + ], + "name": "collect", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/BFactory.bin b/runtime/near-evm-runner/tests/build/BFactory.bin new file mode 100644 index 00000000000..c025ffa35ec --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BFactory.bin @@ -0,0 +1 @@ +608060405234801561001057600080fd5b5060018054600160a060020a03191633179055615fb1806100326000396000f3fe608060405234801561001057600080fd5b506004361061007e577c0100000000000000000000000000000000000000000000000000000000600035046306ec16f8811461008357806336ffb167146100ab5780639a86139b146100cf578063c2bb6dc2146100e9578063c6ce34fb14610123578063d556c5dc14610149575b600080fd5b6100a96004803603602081101561009957600080fd5b5035600160a060020a0316610151565b005b6100b361033e565b60408051600160a060020a039092168252519081900360200190f35b6100d761034d565b60408051918252519081900360200190f35b61010f600480360360208110156100ff57600080fd5b5035600160a060020a0316610371565b604080519115158252519081900360200190f35b6100a96004803603602081101561013957600080fd5b5035600160a060020a031661038f565b6100b3610456565b600154600160a060020a031633146101b3576040805160e560020a62461bcd02815260206004820152600d60248201527f4552525f4e4f545f424c41425300000000000000000000000000000000000000604482015290519081900360640190fd5b604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600091600160a060020a038416916370a0823191602480820192602092909190829003018186803b15801561021657600080fd5b505afa15801561022a573d6000803e3d6000fd5b505050506040513d602081101561024057600080fd5b5051600154604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201526024810184905290519293506000929185169163a9059cbb9160448082019260209290919082900301818787803b1580156102b657600080fd5b505af11580156102ca573d6000803e3d6000fd5b505050506040513d60208110156102e057600080fd5b5051905080610339576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f45524332305f4641494c454400000000000000000000000000000000604482015290519081900360640190fd5b505050565b600154600160a060020a031690565b7f42524f4e5a45000000000000000000000000000000000000000000000000000090565b600160a060020a031660009081526020819052604090205460ff1690565b600154600160a060020a031633146103f1576040805160e560020a62461bcd02815260206004820152600d60248201527f4552525f4e4f545f424c41425300000000000000000000000000000000000000604482015290519081900360640190fd5b604051600160a060020a0382169033907ff586fa6ee1fc42f5b727f3b214ccbd0b6d7e698c45d49ba32f224fbb8670155d90600090a36001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000806040516104659061054f565b604051809103906000f080158015610481573d6000803e3d6000fd5b50600160a060020a038116600081815260208190526040808220805460ff1916600117905551929350909133917f8ccec77b0cb63ac2cafd0f5de8cdfadab91ce656d262240ba8a6343bccc5f94591a3604080517f92eefe9b0000000000000000000000000000000000000000000000000000000081523360048201529051600160a060020a038316916392eefe9b91602480830192600092919082900301818387803b15801561053157600080fd5b505af1158015610545573d6000803e3d6000fd5b5092935050505090565b615a208061055d8339019056fe60c0604052601360808190527f42616c616e63657220506f6f6c20546f6b656e0000000000000000000000000060a0908152620000409160039190620000f7565b506040805180820190915260038082527f425054000000000000000000000000000000000000000000000000000000000060209092019182526200008791600491620000f7565b506005805460ff19166012179055348015620000a257600080fd5b5060068054600580546201000060b060020a031916336201000081029190911790915564e8d4a51000600755600160a060020a03199091161760a060020a60ff02191690556008805460ff191690556200019c565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200013a57805160ff19168380011785556200016a565b828001600101855582156200016a579182015b828111156200016a5782518255916020019190600101906200014d565b50620001789291506200017c565b5090565b6200019991905b8082111562000178576000815560010162000183565b90565b61587480620001ac6000396000f3fe608060405234801561001057600080fd5b5060043610610378576000357c0100000000000000000000000000000000000000000000000000000000900480638d4e4083116101e7578063bc694ea211610122578063d73dd623116100c5578063d73dd62314610b7f578063dd62ed3e14610bab578063e4a28a521461047e578063e4e1e53814610bd9578063ec09302114610c0b578063f1b8a9b714610c13578063f8b2cb4f14610c39578063f8d6aed414610c5f578063fde924f714610c9a57610378565b8063bc694ea214610ad9578063be3bbd2e14610ae1578063c36596a6146104f2578063c6580d1214610b39578063cc77828d14610b41578063cd2ed8fb14610b49578063cf5e7bd314610b51578063d4cadf6814610b7757610378565b8063a221ee491161018a578063a221ee49146109a6578063a9059cbb146109db578063b02f0b7314610a07578063b0e0d13614610a7e578063b7b800a414610a86578063ba019dab14610a8e578063ba9530a614610a96578063bc063e1a14610ad157610378565b80638d4e40831461092a57806392eefe9b14610932578063936c3477146109585780639381cd2b14610960578063948d8ce61461096857806395d89b411461098e578063992e2a92146109965780639a86139b1461099e57610378565b806349b59552116102b757806376c7a3c71161025a57806376c7a3c7146107aa5780637c5e9ea4146107b25780638201aa3f1461080b57806382f652ad1461084b5780638656b65314610886578063867378c5146108c157806389298012146108c95780638c28cbe81461090457610378565b806349b595521461061b5780634bb278f31461063a5780634f69c0d4146106425780635c1bbaf7146106b95780635db34277146106f457806366188463146107265780636d06dfa01461075257806370a082311461078457610378565b8063218b53821161031f578063218b5382146104f257806323b872dd146104fa5780632f37b624146105305780633018205f14610556578063313ce5671461057a57806334e19907146105985780633fdddaa2146105b757806346ab38f1146105e957610378565b806302c967481461037d57806306fdde03146103c1578063095ea7b31461043e57806309a3bbe41461047e5780631446a7ff1461048657806315e84af9146104b457806318160ddd146104e2578063189d00ca146104ea575b600080fd5b6103af6004803603606081101561039357600080fd5b50600160a060020a038135169060208101359060400135610ca2565b60408051918252519081900360200190f35b6103c9610fef565b6040805160208082528351818301528351919283929083019185019080838360005b838110156104035781810151838201526020016103eb565b50505050905090810190601f1680156104305780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61046a6004803603604081101561045457600080fd5b50600160a060020a038135169060200135611085565b604080519115158252519081900360200190f35b6103af6110da565b6103af6004803603604081101561049c57600080fd5b50600160a060020a03813581169160200135166110e7565b6103af600480360360408110156104ca57600080fd5b50600160a060020a0381358116916020013516611241565b6103af611392565b6103af611398565b6103af6113ac565b61046a6004803603606081101561051057600080fd5b50600160a060020a038135811691602081013590911690604001356113b8565b61046a6004803603602081101561054657600080fd5b5035600160a060020a031661151d565b61055e61153b565b60408051600160a060020a039092168252519081900360200190f35b61058261159c565b6040805160ff9092168252519081900360200190f35b6105b5600480360360208110156105ae57600080fd5b50356115a5565b005b6105b5600480360360608110156105cd57600080fd5b50600160a060020a0381351690602081013590604001356117c9565b6103af600480360360608110156105ff57600080fd5b50600160a060020a038135169060208101359060400135611c15565b6105b56004803603602081101561063157600080fd5b50351515611f01565b6105b5612092565b6105b56004803603604081101561065857600080fd5b8135919081019060408101602082013564010000000081111561067a57600080fd5b82018360208201111561068c57600080fd5b803590602001918460208302840111640100000000831117156106ae57600080fd5b5090925090506122a9565b6103af600480360360c08110156106cf57600080fd5b5080359060208101359060408101359060608101359060808101359060a00135612590565b6103af6004803603606081101561070a57600080fd5b50600160a060020a038135169060208101359060400135612648565b61046a6004803603604081101561073c57600080fd5b50600160a060020a038135169060200135612919565b6103af6004803603606081101561076857600080fd5b50600160a060020a0381351690602081013590604001356129f1565b6103af6004803603602081101561079a57600080fd5b5035600160a060020a0316612cf0565b6103af612d0b565b6107f2600480360360a08110156107c857600080fd5b50600160a060020a0381358116916020810135916040820135169060608101359060800135612d1d565b6040805192835260208301919091528051918290030190f35b6107f2600480360360a081101561082157600080fd5b50600160a060020a038135811691602081013591604082013516906060810135906080013561320d565b6103af600480360360c081101561086157600080fd5b5080359060208101359060408101359060608101359060808101359060a001356136e4565b6103af600480360360c081101561089c57600080fd5b5080359060208101359060408101359060608101359060808101359060a001356137a3565b6103af613844565b6103af600480360360c08110156108df57600080fd5b5080359060208101359060408101359060608101359060808101359060a00135613858565b6105b56004803603602081101561091a57600080fd5b5035600160a060020a0316613908565b61046a613ad9565b6105b56004803603602081101561094857600080fd5b5035600160a060020a0316613ae2565b6103af613c2c565b6103af613c84565b6103af6004803603602081101561097e57600080fd5b5035600160a060020a0316613c91565b6103c9613d5f565b6103af613dc0565b6103af613dcc565b6103af600480360360a08110156109bc57600080fd5b5080359060208101359060408101359060608101359060800135613df0565b61046a600480360360408110156109f157600080fd5b50600160a060020a038135169060200135613e55565b6105b560048036036040811015610a1d57600080fd5b81359190810190604081016020820135640100000000811115610a3f57600080fd5b820183602082011115610a5157600080fd5b80359060200191846020830284011164010000000083111715610a7357600080fd5b509092509050613e6b565b6103af61419f565b6103af6141a4565b6103af6141a9565b6103af600480360360c0811015610aac57600080fd5b5080359060208101359060408101359060608101359060808101359060a001356141ae565b6103af61422f565b6103af61423f565b610ae961424b565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610b25578181015183820152602001610b0d565b505050509050019250505060405180910390f35b6103af614343565b610ae9614348565b6103af614399565b6105b560048036036020811015610b6757600080fd5b5035600160a060020a031661439f565b6103af61472c565b61046a60048036036040811015610b9557600080fd5b50600160a060020a038135169060200135614784565b6103af60048036036040811015610bc157600080fd5b50600160a060020a0381358116916020013516614805565b6105b560048036036060811015610bef57600080fd5b50600160a060020a038135169060208101359060400135614830565b6103af614ab4565b6103af60048036036020811015610c2957600080fd5b5035600160a060020a0316614ac4565b6103af60048036036020811015610c4f57600080fd5b5035600160a060020a0316614ba4565b6103af600480360360c0811015610c7557600080fd5b5080359060208101359060408101359060608101359060808101359060a00135614c72565b61046a614cf5565b600033600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615610d53576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff16610daa576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615680833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a602052604090205460ff16610e08576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a60205260409020600390810154610e3d91670de0b6b3a76400005b04600101614d05565b831115610e82576040805160e560020a62461bcd02815260206004820152601160248201526000805160206156e0833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a6020526040902060038101546002808301549054600b54600754610ebc949392919089906136e4565b915081610f01576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b82821115610f47576040805160e560020a62461bcd02815260206004820152600c60248201526000805160206156c0833981519152604482015290519081900360640190fd5b610f55816003015485614dee565b60038201556000610f668382614d05565b604080518781529051919250600160a060020a0388169133916000805160206157a0833981519152919081900360200190a3610fa23384614e5f565b610fb4610faf8483614dee565b614e6d565b600554610fd090620100009004600160a060020a031682614e79565b610fdb863387614e83565b50506005805461ff00191690559392505050565b60038054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561107b5780601f106110505761010080835404028352916020019161107b565b820191906000526020600020905b81548152906001019060200180831161105e57829003601f168201915b5050505050905090565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390926000805160206157c0833981519152928290030190a35060015b92915050565b6802b5e3af16b188000081565b600554600090610100900460ff1615611138576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b600160a060020a0383166000908152600a602052604090205460ff16611196576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0382166000908152600a602052604090205460ff166111f4576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a038084166000908152600a602052604080822092851682528120600380840154600280860154928401549084015493946112389492939290613df0565b95945050505050565b600554600090610100900460ff1615611292576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b600160a060020a0383166000908152600a602052604090205460ff166112f0576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0382166000908152600a602052604090205460ff1661134e576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a038084166000908152600a602052604080822092851682529020600380830154600280850154928401549084015460075461123894929190613df0565b60025490565b6402540be400670de0b6b3a76400005b0481565b670de0b6b3a764000081565b600033600160a060020a03851614806113f45750600160a060020a03841660009081526001602090815260408083203384529091529020548211155b611448576040805160e560020a62461bcd02815260206004820152601560248201527f4552525f42544f4b454e5f4241445f43414c4c45520000000000000000000000604482015290519081900360640190fd5b611453848484614f78565b33600160a060020a038516148015906114915750600160a060020a038416600090815260016020908152604080832033845290915290205460001914155b1561151357600160a060020a03841660009081526001602090815260408083203384529091529020546114c49083614dee565b600160a060020a03858116600090815260016020908152604080832033808552908352928190208590558051948552519287169391926000805160206157c08339815191529281900390910190a35b5060019392505050565b600160a060020a03166000908152600a602052604090205460ff1690565b600554600090610100900460ff161561158c576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b50600654600160a060020a031690565b60055460ff1690565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615611654576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff16156116ac576040805160e560020a62461bcd02815260206004820152601060248201526000805160206157e0833981519152604482015290519081900360640190fd5b600654600160a060020a031633146116fc576040805160e560020a62461bcd0281526020600482015260126024820152600080516020615720833981519152604482015290519081900360640190fd5b64e8d4a51000811015611759576040805160e560020a62461bcd02815260206004820152600b60248201527f4552525f4d494e5f464545000000000000000000000000000000000000000000604482015290519081900360640190fd5b67016345785d8a00008111156117b9576040805160e560020a62461bcd02815260206004820152600b60248201527f4552525f4d41585f464545000000000000000000000000000000000000000000604482015290519081900360640190fd5b6007556005805461ff0019169055565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615611878576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560065433600160a060020a03909116146118d9576040805160e560020a62461bcd0281526020600482015260126024820152600080516020615720833981519152604482015290519081900360640190fd5b600160a060020a0383166000908152600a602052604090205460ff16611937576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b60085460ff1615611980576040805160e560020a62461bcd02815260206004820152601060248201526000805160206157e0833981519152604482015290519081900360640190fd5b670de0b6b3a76400008110156119e0576040805160e560020a62461bcd02815260206004820152600e60248201527f4552525f4d494e5f574549474854000000000000000000000000000000000000604482015290519081900360640190fd5b6802b5e3af16b1880000811115611a41576040805160e560020a62461bcd02815260206004820152600e60248201527f4552525f4d41585f574549474854000000000000000000000000000000000000604482015290519081900360640190fd5b620f4240821015611a9c576040805160e560020a62461bcd02815260206004820152600f60248201527f4552525f4d494e5f42414c414e43450000000000000000000000000000000000604482015290519081900360640190fd5b600160a060020a0383166000908152600a602052604090206002015480821115611b3f57611ad5600b54611ad08484614dee565b615082565b600b8190556802b5e3af16b18800001015611b3a576040805160e560020a62461bcd02815260206004820152601460248201527f4552525f4d41585f544f54414c5f574549474854000000000000000000000000604482015290519081900360640190fd5b611b60565b80821015611b6057611b5c600b54611b578385614dee565b614dee565b600b555b600160a060020a0384166000908152600a602052604090206002810183905560030180549084905580841115611ba957611ba48533611b9f8785614dee565b6150df565b611c03565b80841015611c03576000611bbd8286614dee565b90506000611bcc826000614d05565b9050611be28733611bdd8585614dee565b614e83565b600554611c00908890620100009004600160a060020a031683614e83565b50505b50506005805461ff0019169055505050565b600033600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615611cc6576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff16611d1d576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615680833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a602052604090205460ff16611d7b576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a6020526040902060038101546002808301549054600b54600754611db594939291908990613858565b915082821015611dfd576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615800833981519152604482015290519081900360640190fd5b600160a060020a0385166000908152600a60205260409020600390810154611e2d91670de0b6b3a7640000610e34565b821115611e72576040805160e560020a62461bcd02815260206004820152601160248201526000805160206156e0833981519152604482015290519081900360640190fd5b611e80816003015483614dee565b60038201556000611e918582614d05565b604080518581529051919250600160a060020a0388169133916000805160206157a0833981519152919081900360200190a3611ecd3386614e5f565b611eda610faf8683614dee565b600554611ef690620100009004600160a060020a031682614e79565b610fdb863385614e83565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615611fb0576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff1615612008576040805160e560020a62461bcd02815260206004820152601060248201526000805160206157e0833981519152604482015290519081900360640190fd5b600654600160a060020a03163314612058576040805160e560020a62461bcd0281526020600482015260126024820152600080516020615720833981519152604482015290519081900360640190fd5b6006805491151560a060020a0274ff0000000000000000000000000000000000000000199092169190911790556005805461ff0019169055565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615612141576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560065433600160a060020a03909116146121a2576040805160e560020a62461bcd0281526020600482015260126024820152600080516020615720833981519152604482015290519081900360640190fd5b60085460ff16156121eb576040805160e560020a62461bcd02815260206004820152601060248201526000805160206157e0833981519152604482015290519081900360640190fd5b60095460021115612246576040805160e560020a62461bcd02815260206004820152600e60248201527f4552525f4d494e5f544f4b454e53000000000000000000000000000000000000604482015290519081900360640190fd5b6008805460ff191660011790556006805474ff0000000000000000000000000000000000000000191660a060020a17905561228968056bc75e2d63100000615151565b61229c3368056bc75e2d63100000614e79565b6005805461ff0019169055565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615612358576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff166123af576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615680833981519152604482015290519081900360640190fd5b60006123b9611392565b905060006123c7858361515a565b90508061240c576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b60005b60095481101561257c5760006009828154811061242857fe5b6000918252602080832090910154600160a060020a0316808352600a90915260408220600301549092509061245d8583614d05565b9050806124a2576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b8787858181106124ae57fe5b905060200201358111156124fa576040805160e560020a62461bcd02815260206004820152600c60248201526000805160206156c0833981519152604482015290519081900360640190fd5b600160a060020a0383166000908152600a60205260409020600301546125209082615082565b600160a060020a0384166000818152600a60209081526040918290206003019390935580518481529051919233926000805160206157008339815191529281900390910190a36125718333836150df565b50505060010161240f565b5061258685615151565b611c033386614e79565b60008061259d878661515a565b905060006125ab8786615082565b905060006125b9828961515a565b905060006125cf670de0b6b3a76400008561515a565b905060006125dd8383615296565b905060006125eb828e614d05565b905060006125f9828f614dee565b90506000612618612612670de0b6b3a76400008a614dee565b8b614d05565b905061263582612630670de0b6b3a764000084614dee565b61515a565b9f9e505050505050505050505050505050565b600033600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff16156126f9576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff16612750576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615680833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a602052604090205460ff166127ae576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a60205260409020600301546127e0906002670de0b6b3a76400005b04614d05565b831115612825576040805160e560020a62461bcd0281526020600482015260106024820152600080516020615740833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a6020526040902060038101546002808301549054600b5460075461285f949392919089906137a3565b9150828210156128a7576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615800833981519152604482015290519081900360640190fd5b6128b5816003015485615082565b6003820155604080518581529051600160a060020a0387169133916000805160206157008339815191529181900360200190a36128f182615151565b6128fb3383614e79565b6129068533866150df565b506005805461ff00191690559392505050565b336000908152600160209081526040808320600160a060020a03861684529091528120548083111561296e57336000908152600160209081526040808320600160a060020a038816845290915281205561299d565b6129788184614dee565b336000908152600160209081526040808320600160a060020a03891684529091529020555b336000818152600160209081526040808320600160a060020a0389168085529083529281902054815190815290519293926000805160206157c0833981519152929181900390910190a35060019392505050565b600033600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615612aa2576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff16612af9576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615680833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a602052604090205460ff16612b57576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a6020526040902060038101546002808301549054600b54600754612b9194939291908990612590565b915081612bd6576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b82821115612c1c576040805160e560020a62461bcd02815260206004820152600c60248201526000805160206156c0833981519152604482015290519081900360640190fd5b600160a060020a0385166000908152600a6020526040902060030154612c4c906002670de0b6b3a76400006127da565b821115612c91576040805160e560020a62461bcd0281526020600482015260106024820152600080516020615740833981519152604482015290519081900360640190fd5b612c9f816003015483615082565b6003820155604080518381529051600160a060020a0387169133916000805160206157008339815191529181900360200190a3612cdb84615151565b612ce53385614e79565b6129068533846150df565b600160a060020a031660009081526020819052604090205490565b620f4240670de0b6b3a76400006113a8565b6040805160208082523690820181905260009283923392600160e060020a03198535169285929081908101848480828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615612dbd576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff001916610100179055600160a060020a0387166000908152600a602052604090205460ff16612e2a576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0385166000908152600a602052604090205460ff16612e88576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b60065460a060020a900460ff16612ee9576040805160e560020a62461bcd02815260206004820152601360248201527f4552525f535741505f4e4f545f5055424c494300000000000000000000000000604482015290519081900360640190fd5b600160a060020a038088166000908152600a602052604080822092881682529020600380820154612f2291670de0b6b3a7640000610e34565b861115612f67576040805160e560020a62461bcd02815260206004820152601160248201526000805160206156e0833981519152604482015290519081900360640190fd5b6000612f888360030154846002015484600301548560020154600754613df0565b905085811115612fe2576040805160e560020a62461bcd02815260206004820152601360248201527f4552525f4241445f4c494d49545f505249434500000000000000000000000000604482015290519081900360640190fd5b61300283600301548460020154846003015485600201548b600754614c72565b94508885111561304a576040805160e560020a62461bcd02815260206004820152600c60248201526000805160206156c0833981519152604482015290519081900360640190fd5b613058836003015486615082565b836003018190555061306e826003015488614dee565b600380840182905584015460028086015490850154600754613091949190613df0565b9350808410156130d9576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b85841115613131576040805160e560020a62461bcd02815260206004820152600f60248201527f4552525f4c494d49545f50524943450000000000000000000000000000000000604482015290519081900360640190fd5b61313b858861515a565b811115613180576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b87600160a060020a03168a600160a060020a031633600160a060020a03167f908fb5ee8f16c6bc9bc3690973819f32a4d4b10188134543c88706e0e1d43378888b604051808381526020018281526020019250505060405180910390a46131e88a33876150df565b6131f3883389614e83565b5050506005805461ff001916905590969095509350505050565b6040805160208082523690820181905260009283923392600160e060020a03198535169285929081908101848480828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff16156132ad576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff001916610100179055600160a060020a0387166000908152600a602052604090205460ff1661331a576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0385166000908152600a602052604090205460ff16613378576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b60065460a060020a900460ff166133d9576040805160e560020a62461bcd02815260206004820152601360248201527f4552525f535741505f4e4f545f5055424c494300000000000000000000000000604482015290519081900360640190fd5b600160a060020a038088166000908152600a6020526040808220928816825290206003820154613413906002670de0b6b3a76400006127da565b881115613458576040805160e560020a62461bcd0281526020600482015260106024820152600080516020615740833981519152604482015290519081900360640190fd5b60006134798360030154846002015484600301548560020154600754613df0565b9050858111156134d3576040805160e560020a62461bcd02815260206004820152601360248201527f4552525f4241445f4c494d49545f505249434500000000000000000000000000604482015290519081900360640190fd5b6134f383600301548460020154846003015485600201548d6007546141ae565b94508685101561353b576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615800833981519152604482015290519081900360640190fd5b61354983600301548a615082565b836003018190555061355f826003015486614dee565b600380840182905584015460028086015490850154600754613582949190613df0565b9350808410156135ca576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b85841115613622576040805160e560020a62461bcd02815260206004820152600f60248201527f4552525f4c494d49545f50524943450000000000000000000000000000000000604482015290519081900360640190fd5b61362c898661515a565b811115613671576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b87600160a060020a03168a600160a060020a031633600160a060020a03167f908fb5ee8f16c6bc9bc3690973819f32a4d4b10188134543c88706e0e1d433788c89604051808381526020018281526020019250505060405180910390a46136d98a338b6150df565b6131f3883387614e83565b6000806136f1878661515a565b90506000613707670de0b6b3a764000083614dee565b905060006137158286614d05565b9050600061372f87612630670de0b6b3a764000085614dee565b9050600061373d8c83614dee565b9050600061374b828e61515a565b905060006137598288615296565b90506000613767828e614d05565b905060006137758e83614dee565b905061378e81612630670de0b6b3a76400006000614dee565b99505050505050505050509695505050505050565b6000806137b0878661515a565b905060006137cf6137c9670de0b6b3a764000084614dee565b85614d05565b905060006137ee866137e9670de0b6b3a764000085614dee565b614d05565b905060006137fc8b83615082565b9050600061380a828d61515a565b905060006138188287615296565b90506000613826828d614d05565b9050613832818d614dee565b9e9d5050505050505050505050505050565b64e8d4a51000670de0b6b3a76400006113a8565b600080613865878661515a565b90506000613880856137e9670de0b6b3a76400006000614dee565b9050600061388e8883614dee565b9050600061389c828a61515a565b905060006138bb826138b6670de0b6b3a76400008861515a565b615296565b905060006138c9828e614d05565b905060006138d78e83614dee565b905060006138f0612612670de0b6b3a76400008a614dee565b9050612635826137e9670de0b6b3a764000084614dee565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff16156139b7576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff001916610100179055600160a060020a0381166000908152600a602052604090205460ff16613a24576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600160a060020a038316916370a08231916024808301926020929190829003018186803b158015613a8357600080fd5b505afa158015613a97573d6000803e3d6000fd5b505050506040513d6020811015613aad57600080fd5b5051600160a060020a039091166000908152600a60205260409020600301556005805461ff0019169055565b60085460ff1690565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615613b91576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560065433600160a060020a0390911614613bf2576040805160e560020a62461bcd0281526020600482015260126024820152600080516020615720833981519152604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790556005805461ff0019169055565b600554600090610100900460ff1615613c7d576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b50600b5490565b68056bc75e2d6310000081565b600554600090610100900460ff1615613ce2576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b600160a060020a0382166000908152600a602052604090205460ff16613d40576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b50600160a060020a03166000908152600a602052604090206002015490565b60048054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561107b5780601f106110505761010080835404028352916020019161107b565b6704a03ce68d21555681565b7f42524f4e5a45000000000000000000000000000000000000000000000000000090565b600080613dfd878761515a565b90506000613e0b868661515a565b90506000613e19838361515a565b90506000613e3b670de0b6b3a7640000612630670de0b6b3a764000089614dee565b9050613e478282614d05565b9a9950505050505050505050565b6000613e62338484614f78565b50600192915050565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615613f1a576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff16613f71576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615680833981519152604482015290519081900360640190fd5b6000613f7b611392565b90506000613f8a856000614d05565b90506000613f988683614dee565b90506000613fa6828561515a565b905080613feb576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b613ff53388614e5f565b60055461401190620100009004600160a060020a031684614e79565b61401a82614e6d565b60005b60095481101561418a5760006009828154811061403657fe5b6000918252602080832090910154600160a060020a0316808352600a90915260408220600301549092509061406b8583614d05565b9050806140b0576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b8989858181106140bc57fe5b90506020020135811015614108576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615800833981519152604482015290519081900360640190fd5b600160a060020a0383166000908152600a602052604090206003015461412e9082614dee565b600160a060020a0384166000818152600a60209081526040918290206003019390935580518481529051919233926000805160206157a08339815191529281900390910190a361417f833383614e83565b50505060010161401d565b50506005805461ff0019169055505050505050565b600881565b600281565b600181565b6000806141bb878661515a565b905060006141d1670de0b6b3a764000085614dee565b90506141dd8582614d05565b905060006141ef8a6126308c85615082565b905060006141fd8285615296565b90506000614213670de0b6b3a764000083614dee565b905061421f8a82614d05565b9c9b505050505050505050505050565b600a670de0b6b3a76400006113a8565b671bc16d674ec7ffff81565b600554606090610100900460ff161561429c576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b60085460ff166142e4576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615680833981519152604482015290519081900360640190fd5b600980548060200260200160405190810160405280929190818152602001828054801561107b57602002820191906000526020600020905b8154600160a060020a0316815260019091019060200180831161431c575050505050905090565b600081565b600554606090610100900460ff16156142e4576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b60095490565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff161561444e576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560065433600160a060020a03909116146144af576040805160e560020a62461bcd0281526020600482015260126024820152600080516020615720833981519152604482015290519081900360640190fd5b600160a060020a0381166000908152600a602052604090205460ff1661450d576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b60085460ff1615614556576040805160e560020a62461bcd02815260206004820152601060248201526000805160206157e0833981519152604482015290519081900360640190fd5b600160a060020a0381166000908152600a60205260408120600301549061457d8282614d05565b600b54600160a060020a0385166000908152600a60205260409020600201549192506145a891614dee565b600b55600160a060020a0383166000908152600a60205260409020600101546009805460001981019190829081106145dc57fe5b60009182526020909120015460098054600160a060020a03909216918490811061460257fe5b9060005260206000200160006101000a815481600160a060020a030219169083600160a060020a0316021790555081600a60006009858154811061464257fe5b6000918252602080832090910154600160a060020a03168352820192909252604001902060010155600980548061467557fe5b600082815260208082206000199084018101805473ffffffffffffffffffffffffffffffffffffffff191690559092019092556040805160808101825283815280830184815281830185815260608301868152600160a060020a038c168752600a909552929094209051815460ff1916901515178155925160018401555160028301555160039091015561470e8533611bdd8787614dee565b600554611c03908690620100009004600160a060020a031685614e83565b600554600090610100900460ff161561477d576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b5060075490565b336000908152600160209081526040808320600160a060020a03861684529091528120546147b29083615082565b336000818152600160209081526040808320600160a060020a0389168085529083529281902085905580519485525191936000805160206157c0833981519152929081900390910190a350600192915050565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600654600160a060020a031633146148e1576040805160e560020a62461bcd0281526020600482015260126024820152600080516020615720833981519152604482015290519081900360640190fd5b600160a060020a0383166000908152600a602052604090205460ff1615614952576040805160e560020a62461bcd02815260206004820152600c60248201527f4552525f49535f424f554e440000000000000000000000000000000000000000604482015290519081900360640190fd5b60085460ff161561499b576040805160e560020a62461bcd02815260206004820152601060248201526000805160206157e0833981519152604482015290519081900360640190fd5b6009546008116149f5576040805160e560020a62461bcd02815260206004820152600e60248201527f4552525f4d41585f544f4b454e53000000000000000000000000000000000000604482015290519081900360640190fd5b604080516080810182526001808252600980546020808501918252600085870181815260608701828152600160a060020a038c16808452600a9094529782209651875460ff1916901515178755925186860155915160028601559451600390940193909355805491820181559091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af01805473ffffffffffffffffffffffffffffffffffffffff19169091179055614aaf8383836117c9565b505050565b6002670de0b6b3a76400006113a8565b600554600090610100900460ff1615614b15576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b600160a060020a0382166000908152600a602052604090205460ff16614b73576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0382166000908152600a6020526040902060020154600b54614b9d90829061515a565b9392505050565b600554600090610100900460ff1615614bf5576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b600160a060020a0382166000908152600a602052604090205460ff16614c53576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b50600160a060020a03166000908152600a602052604090206003015490565b600080614c7f858861515a565b90506000614c8d8786614dee565b90506000614c9b888361515a565b90506000614ca98285615296565b9050614cbd81670de0b6b3a7640000614dee565b9050614cd1670de0b6b3a764000087614dee565b9450614ce6614ce08c83614d05565b8661515a565b9b9a5050505050505050505050565b60065460a060020a900460ff1690565b6000828202831580614d1f575082848281614d1c57fe5b04145b614d73576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4d554c5f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b6706f05b59d3b20000810181811015614dd6576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4d554c5f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b6000670de0b6b3a7640000825b049695505050505050565b6000806000614dfd85856153b9565b915091508015614e57576040805160e560020a62461bcd02815260206004820152601160248201527f4552525f5355425f554e444552464c4f57000000000000000000000000000000604482015290519081900360640190fd5b509392505050565b614e6982826153de565b5050565b614e76816153e9565b50565b614e6982826154b3565b604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a03848116600483015260248201849052915160009286169163a9059cbb91604480830192602092919082900301818787803b158015614eef57600080fd5b505af1158015614f03573d6000803e3d6000fd5b505050506040513d6020811015614f1957600080fd5b5051905080614f72576040805160e560020a62461bcd02815260206004820152600f60248201527f4552525f45524332305f46414c53450000000000000000000000000000000000604482015290519081900360640190fd5b50505050565b600160a060020a038316600090815260208190526040902054811115614fe8576040805160e560020a62461bcd02815260206004820152601460248201527f4552525f494e53554646494349454e545f42414c000000000000000000000000604482015290519081900360640190fd5b600160a060020a03831660009081526020819052604090205461500b9082614dee565b600160a060020a03808516600090815260208190526040808220939093559084168152205461503a9082615082565b600160a060020a0380841660008181526020818152604091829020949094558051858152905191939287169260008051602061576083398151915292918290030190a3505050565b600082820183811015614b9d576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4144445f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a0384811660048301523060248301526044820184905291516000928616916323b872dd91606480830192602092919082900301818787803b158015614eef57600080fd5b614e76816154be565b6000816151b1576040805160e560020a62461bcd02815260206004820152600c60248201527f4552525f4449565f5a45524f0000000000000000000000000000000000000000604482015290519081900360640190fd5b670de0b6b3a764000083028315806151d95750670de0b6b3a76400008482816151d657fe5b04145b61522d576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4449565f494e5445524e414c00000000000000000000000000000000604482015290519081900360640190fd5b6002830481018181101561528b576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4449565f494e5445524e414c00000000000000000000000000000000604482015290519081900360640190fd5b6000848281614de357fe5b600060018310156152f1576040805160e560020a62461bcd02815260206004820152601560248201527f4552525f42504f575f424153455f544f4f5f4c4f570000000000000000000000604482015290519081900360640190fd5b671bc16d674ec7ffff831115615351576040805160e560020a62461bcd02815260206004820152601660248201527f4552525f42504f575f424153455f544f4f5f4849474800000000000000000000604482015290519081900360640190fd5b600061535c83615521565b9050600061536a8483614dee565b905060006153808661537b8561553c565b61554a565b9050816153915792506110d4915050565b60006153a287846305f5e1006155a1565b90506153ae8282614d05565b979650505050505050565b6000808284106153cf57505080820360006153d7565b505081810360015b9250929050565b614e69823083614f78565b30600090815260208190526040902054811115615450576040805160e560020a62461bcd02815260206004820152601460248201527f4552525f494e53554646494349454e545f42414c000000000000000000000000604482015290519081900360640190fd5b3060009081526020819052604090205461546a9082614dee565b306000908152602081905260409020556002546154879082614dee565b60025560408051828152905160009130916000805160206157608339815191529181900360200190a350565b614e69308383614f78565b306000908152602081905260409020546154d89082615082565b306000908152602081905260409020556002546154f59082615082565b60025560408051828152905130916000916000805160206157608339815191529181900360200190a350565b6000670de0b6b3a76400006155358361553c565b0292915050565b670de0b6b3a7640000900490565b6000806002830661556357670de0b6b3a7640000615565565b835b90506002830492505b8215614b9d5761557e8485614d05565b93506002830615615596576155938185614d05565b90505b60028304925061556e565b60008281806155b887670de0b6b3a76400006153b9565b9092509050670de0b6b3a764000080600060015b888410615670576000670de0b6b3a7640000820290506000806156008a6155fb85670de0b6b3a7640000614dee565b6153b9565b91509150615612876137e9848c614d05565b965061561e878461515a565b96508661562d57505050615670565b8715615637579315935b8015615641579315935b8415615658576156518688614dee565b9550615665565b6156628688615082565b95505b5050506001016155cc565b5090999850505050505050505056fe4552525f4e4f545f46494e414c495a45440000000000000000000000000000004552525f5245454e5452590000000000000000000000000000000000000000004552525f4c494d49545f494e00000000000000000000000000000000000000004552525f4d41585f4f55545f524154494f00000000000000000000000000000063982df10efd8dfaaaa0fcc7f50b2d93b7cba26ccc48adee2873220d485dc39a4552525f4e4f545f434f4e54524f4c4c455200000000000000000000000000004552525f4d41585f494e5f524154494f00000000000000000000000000000000ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef4552525f4e4f545f424f554e4400000000000000000000000000000000000000e74c91552b64c2e2e7bd255639e004e693bd3e1d01cc33e65610b86afcc1ffed8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9254552525f49535f46494e414c495a4544000000000000000000000000000000004552525f4c494d49545f4f5554000000000000000000000000000000000000004552525f4d4154485f415050524f580000000000000000000000000000000000a265627a7a72315820a6ed20be58469dda7b96f5cd85dbd70406a753a02b645704241ab59bf33344fe64736f6c634300050c0032a265627a7a723158201fb7c2c80fbc145fbafa4fbc21af09d0d3faf8acf13673c5517de0883d91e5f564736f6c634300050c0032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/BMath.abi b/runtime/near-evm-runner/tests/build/BMath.abi new file mode 100644 index 00000000000..6df234eb16b --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BMath.abi @@ -0,0 +1,574 @@ +[ + { + "constant": true, + "inputs": [], + "name": "BONE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "BPOW_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "EXIT_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "INIT_POOL_SUPPLY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_IN_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_OUT_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_TOTAL_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BALANCE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getColor", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcSpotPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "spotPrice", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcOutGivenIn", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcInGivenOut", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalWeight", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcPoolOutGivenSingleIn", + "outputs": [ + { + "internalType": "uint256", + "name": "poolAmountOut", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalWeight", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcSingleInGivenPoolOut", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalWeight", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcSingleOutGivenPoolIn", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalWeight", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcPoolInGivenSingleOut", + "outputs": [ + { + "internalType": "uint256", + "name": "poolAmountIn", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/BMath.bin b/runtime/near-evm-runner/tests/build/BMath.bin new file mode 100644 index 00000000000..73ade7f2077 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BMath.bin @@ -0,0 +1 @@ +608060405234801561001057600080fd5b50610e77806100206000396000f3fe608060405234801561001057600080fd5b5060043610610175576000357c010000000000000000000000000000000000000000000000000000000090048063a221ee49116100e0578063bc694ea211610099578063bc694ea214610348578063c36596a61461019c578063c6580d1214610350578063e4a28a521461017a578063ec09302114610358578063f8d6aed41461036057610175565b8063a221ee49146102b8578063b0e0d136146102ed578063b7b800a4146102f5578063ba019dab146102fd578063ba9530a614610305578063bc063e1a1461034057610175565b80638656b653116101325780638656b65314610222578063867378c51461025d57806389298012146102655780639381cd2b146102a0578063992e2a92146102a85780639a86139b146102b057610175565b806309a3bbe41461017a578063189d00ca14610194578063218b53821461019c5780635c1bbaf7146101a457806376c7a3c7146101df57806382f652ad146101e7575b600080fd5b61018261039b565b60408051918252519081900360200190f35b6101826103a8565b6101826103bc565b610182600480360360c08110156101ba57600080fd5b5080359060208101359060408101359060608101359060808101359060a001356103c8565b610182610480565b610182600480360360c08110156101fd57600080fd5b5080359060208101359060408101359060608101359060808101359060a00135610492565b610182600480360360c081101561023857600080fd5b5080359060208101359060408101359060608101359060808101359060a00135610551565b6101826105f2565b610182600480360360c081101561027b57600080fd5b5080359060208101359060408101359060608101359060808101359060a00135610606565b6101826106b6565b6101826106c3565b6101826106cf565b610182600480360360a08110156102ce57600080fd5b50803590602081013590604081013590606081013590608001356106f3565b610182610758565b61018261075d565b610182610762565b610182600480360360c081101561031b57600080fd5b5080359060208101359060408101359060608101359060808101359060a00135610767565b6101826107e8565b6101826107f8565b610182610804565b610182610809565b610182600480360360c081101561037657600080fd5b5080359060208101359060408101359060608101359060808101359060a00135610819565b6802b5e3af16b188000081565b6402540be400670de0b6b3a76400005b0481565b670de0b6b3a764000081565b6000806103d5878661089c565b905060006103e387866109e5565b905060006103f1828961089c565b90506000610407670de0b6b3a76400008561089c565b905060006104158383610a49565b90506000610423828e610b6c565b90506000610431828f610c4e565b9050600061045061044a670de0b6b3a76400008a610c4e565b8b610b6c565b905061046d82610468670de0b6b3a764000084610c4e565b61089c565b9f9e505050505050505050505050505050565b620f4240670de0b6b3a76400006103b8565b60008061049f878661089c565b905060006104b5670de0b6b3a764000083610c4e565b905060006104c38286610b6c565b905060006104dd87610468670de0b6b3a764000085610c4e565b905060006104eb8c83610c4e565b905060006104f9828e61089c565b905060006105078288610a49565b90506000610515828e610b6c565b905060006105238e83610c4e565b905061053c81610468670de0b6b3a76400006000610c4e565b99505050505050505050509695505050505050565b60008061055e878661089c565b9050600061057d610577670de0b6b3a764000084610c4e565b85610b6c565b9050600061059c86610597670de0b6b3a764000085610c4e565b610b6c565b905060006105aa8b836109e5565b905060006105b8828d61089c565b905060006105c68287610a49565b905060006105d4828d610b6c565b90506105e0818d610c4e565b9e9d5050505050505050505050505050565b64e8d4a51000670de0b6b3a76400006103b8565b600080610613878661089c565b9050600061062e85610597670de0b6b3a76400006000610c4e565b9050600061063c8883610c4e565b9050600061064a828a61089c565b9050600061066982610664670de0b6b3a76400008861089c565b610a49565b90506000610677828e610b6c565b905060006106858e83610c4e565b9050600061069e61044a670de0b6b3a76400008a610c4e565b905061046d82610597670de0b6b3a764000084610c4e565b68056bc75e2d6310000081565b6704a03ce68d21555681565b7f42524f4e5a45000000000000000000000000000000000000000000000000000090565b600080610700878761089c565b9050600061070e868661089c565b9050600061071c838361089c565b9050600061073e670de0b6b3a7640000610468670de0b6b3a764000089610c4e565b905061074a8282610b6c565b9a9950505050505050505050565b600881565b600281565b600181565b600080610774878661089c565b9050600061078a670de0b6b3a764000085610c4e565b90506107968582610b6c565b905060006107a88a6104688c856109e5565b905060006107b68285610a49565b905060006107cc670de0b6b3a764000083610c4e565b90506107d88a82610b6c565b9c9b505050505050505050505050565b600a670de0b6b3a76400006103b8565b671bc16d674ec7ffff81565b600081565b6002670de0b6b3a76400006103b8565b600080610826858861089c565b905060006108348786610c4e565b90506000610842888361089c565b905060006108508285610a49565b905061086481670de0b6b3a7640000610c4e565b9050610878670de0b6b3a764000087610c4e565b945061088d6108878c83610b6c565b8661089c565b9b9a5050505050505050505050565b6000816108f3576040805160e560020a62461bcd02815260206004820152600c60248201527f4552525f4449565f5a45524f0000000000000000000000000000000000000000604482015290519081900360640190fd5b670de0b6b3a7640000830283158061091b5750670de0b6b3a764000084828161091857fe5b04145b61096f576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4449565f494e5445524e414c00000000000000000000000000000000604482015290519081900360640190fd5b600283048101818110156109cd576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4449565f494e5445524e414c00000000000000000000000000000000604482015290519081900360640190fd5b60008482816109d857fe5b0493505050505b92915050565b600082820183811015610a42576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4144445f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b9392505050565b60006001831015610aa4576040805160e560020a62461bcd02815260206004820152601560248201527f4552525f42504f575f424153455f544f4f5f4c4f570000000000000000000000604482015290519081900360640190fd5b671bc16d674ec7ffff831115610b04576040805160e560020a62461bcd02815260206004820152601660248201527f4552525f42504f575f424153455f544f4f5f4849474800000000000000000000604482015290519081900360640190fd5b6000610b0f83610cbf565b90506000610b1d8483610c4e565b90506000610b3386610b2e85610cda565b610ce8565b905081610b445792506109df915050565b6000610b5587846305f5e100610d3f565b9050610b618282610b6c565b979650505050505050565b6000828202831580610b86575082848281610b8357fe5b04145b610bda576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4d554c5f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b6706f05b59d3b20000810181811015610c3d576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4d554c5f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b6000670de0b6b3a7640000826109d8565b6000806000610c5d8585610e1d565b915091508015610cb7576040805160e560020a62461bcd02815260206004820152601160248201527f4552525f5355425f554e444552464c4f57000000000000000000000000000000604482015290519081900360640190fd5b509392505050565b6000670de0b6b3a7640000610cd383610cda565b0292915050565b670de0b6b3a7640000900490565b60008060028306610d0157670de0b6b3a7640000610d03565b835b90506002830492505b8215610a4257610d1c8485610b6c565b93506002830615610d3457610d318185610b6c565b90505b600283049250610d0c565b6000828180610d5687670de0b6b3a7640000610e1d565b9092509050670de0b6b3a764000080600060015b888410610e0e576000670de0b6b3a764000082029050600080610d9e8a610d9985670de0b6b3a7640000610c4e565b610e1d565b91509150610db087610597848c610b6c565b9650610dbc878461089c565b965086610dcb57505050610e0e565b8715610dd5579315935b8015610ddf579315935b8415610df657610def8688610c4e565b9550610e03565b610e0086886109e5565b95505b505050600101610d6a565b50909998505050505050505050565b600080828410610e335750508082036000610e3b565b505081810360015b925092905056fea265627a7a723158205ed1b22832c14cf9e2efe6ea235b597639d6738dd598d3ea8203c58103f244c964736f6c634300050c0032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/BNum.abi b/runtime/near-evm-runner/tests/build/BNum.abi new file mode 100644 index 00000000000..42a7386d836 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BNum.abi @@ -0,0 +1,257 @@ +[ + { + "constant": true, + "inputs": [], + "name": "BONE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "BPOW_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "EXIT_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "INIT_POOL_SUPPLY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_IN_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_OUT_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_TOTAL_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BALANCE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getColor", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/BNum.bin b/runtime/near-evm-runner/tests/build/BNum.bin new file mode 100644 index 00000000000..aac89837d18 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BNum.bin @@ -0,0 +1 @@ +608060405234801561001057600080fd5b5061029c806100206000396000f3fe608060405234801561001057600080fd5b5060043610610108576000357c010000000000000000000000000000000000000000000000000000000090048063b0e0d136116100af578063b0e0d1361461015f578063b7b800a414610167578063ba019dab1461016f578063bc063e1a14610177578063bc694ea21461017f578063c36596a61461012f578063c6580d1214610187578063e4a28a521461010d578063ec0930211461018f57610108565b806309a3bbe41461010d578063189d00ca14610127578063218b53821461012f57806376c7a3c714610137578063867378c51461013f5780639381cd2b14610147578063992e2a921461014f5780639a86139b14610157575b600080fd5b610115610197565b60408051918252519081900360200190f35b6101156101a4565b6101156101b8565b6101156101c4565b6101156101d6565b6101156101ea565b6101156101f7565b610115610203565b610115610227565b61011561022c565b610115610231565b610115610236565b610115610246565b610115610252565b610115610257565b6802b5e3af16b188000081565b6402540be400670de0b6b3a76400005b0481565b670de0b6b3a764000081565b620f4240670de0b6b3a76400006101b4565b64e8d4a51000670de0b6b3a76400006101b4565b68056bc75e2d6310000081565b6704a03ce68d21555681565b7f42524f4e5a45000000000000000000000000000000000000000000000000000090565b600881565b600281565b600181565b600a670de0b6b3a76400006101b4565b671bc16d674ec7ffff81565b600081565b6002670de0b6b3a76400006101b456fea265627a7a7231582089365996d164956921d5302db8b5bd223216993fe8eda62ec774fd5ff6d7c3f164736f6c634300050c0032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/BPool.abi b/runtime/near-evm-runner/tests/build/BPool.abi new file mode 100644 index 00000000000..10600139942 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BPool.abi @@ -0,0 +1,1630 @@ +[ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": true, + "inputs": [ + { + "indexed": true, + "internalType": "bytes4", + "name": "sig", + "type": "bytes4" + }, + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "LOG_CALL", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + } + ], + "name": "LOG_EXIT", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + } + ], + "name": "LOG_JOIN", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + } + ], + "name": "LOG_SWAP", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "BONE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "BPOW_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "EXIT_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "INIT_POOL_SUPPLY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_IN_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_OUT_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_TOTAL_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BALANCE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "whom", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcInGivenOut", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcOutGivenIn", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalWeight", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcPoolInGivenSingleOut", + "outputs": [ + { + "internalType": "uint256", + "name": "poolAmountIn", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalWeight", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcPoolOutGivenSingleIn", + "outputs": [ + { + "internalType": "uint256", + "name": "poolAmountOut", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalWeight", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcSingleInGivenPoolOut", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalWeight", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcSingleOutGivenPoolIn", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcSpotPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "spotPrice", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "decreaseApproval", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getColor", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "increaseApproval", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isPublicSwap", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isFinalized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "t", + "type": "address" + } + ], + "name": "isBound", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getNumTokens", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getCurrentTokens", + "outputs": [ + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getFinalTokens", + "outputs": [ + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getDenormalizedWeight", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getTotalDenormalizedWeight", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getNormalizedWeight", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getSwapFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getController", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "setSwapFee", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "manager", + "type": "address" + } + ], + "name": "setController", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bool", + "name": "public_", + "type": "bool" + } + ], + "name": "setPublicSwap", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "finalize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "denorm", + "type": "uint256" + } + ], + "name": "bind", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "denorm", + "type": "uint256" + } + ], + "name": "rebind", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "unbind", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "gulp", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + } + ], + "name": "getSpotPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "spotPrice", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + } + ], + "name": "getSpotPriceSansFee", + "outputs": [ + { + "internalType": "uint256", + "name": "spotPrice", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "poolAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "maxAmountsIn", + "type": "uint256[]" + } + ], + "name": "joinPool", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "poolAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "minAmountsOut", + "type": "uint256[]" + } + ], + "name": "exitPool", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint256", + "name": "minAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxPrice", + "type": "uint256" + } + ], + "name": "swapExactAmountIn", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "spotPriceAfter", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "uint256", + "name": "maxAmountIn", + "type": "uint256" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxPrice", + "type": "uint256" + } + ], + "name": "swapExactAmountOut", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "spotPriceAfter", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minPoolAmountOut", + "type": "uint256" + } + ], + "name": "joinswapExternAmountIn", + "outputs": [ + { + "internalType": "uint256", + "name": "poolAmountOut", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "uint256", + "name": "poolAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxAmountIn", + "type": "uint256" + } + ], + "name": "joinswapPoolAmountOut", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint256", + "name": "poolAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minAmountOut", + "type": "uint256" + } + ], + "name": "exitswapPoolAmountIn", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxPoolAmountIn", + "type": "uint256" + } + ], + "name": "exitswapExternAmountOut", + "outputs": [ + { + "internalType": "uint256", + "name": "poolAmountIn", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/BPool.bin b/runtime/near-evm-runner/tests/build/BPool.bin new file mode 100644 index 00000000000..ed434055d39 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BPool.bin @@ -0,0 +1 @@ +60c0604052601360808190527f42616c616e63657220506f6f6c20546f6b656e0000000000000000000000000060a0908152620000409160039190620000f7565b506040805180820190915260038082527f425054000000000000000000000000000000000000000000000000000000000060209092019182526200008791600491620000f7565b506005805460ff19166012179055348015620000a257600080fd5b5060068054600580546201000060b060020a031916336201000081029190911790915564e8d4a51000600755600160a060020a03199091161760a060020a60ff02191690556008805460ff191690556200019c565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200013a57805160ff19168380011785556200016a565b828001600101855582156200016a579182015b828111156200016a5782518255916020019190600101906200014d565b50620001789291506200017c565b5090565b6200019991905b8082111562000178576000815560010162000183565b90565b61587480620001ac6000396000f3fe608060405234801561001057600080fd5b5060043610610378576000357c0100000000000000000000000000000000000000000000000000000000900480638d4e4083116101e7578063bc694ea211610122578063d73dd623116100c5578063d73dd62314610b7f578063dd62ed3e14610bab578063e4a28a521461047e578063e4e1e53814610bd9578063ec09302114610c0b578063f1b8a9b714610c13578063f8b2cb4f14610c39578063f8d6aed414610c5f578063fde924f714610c9a57610378565b8063bc694ea214610ad9578063be3bbd2e14610ae1578063c36596a6146104f2578063c6580d1214610b39578063cc77828d14610b41578063cd2ed8fb14610b49578063cf5e7bd314610b51578063d4cadf6814610b7757610378565b8063a221ee491161018a578063a221ee49146109a6578063a9059cbb146109db578063b02f0b7314610a07578063b0e0d13614610a7e578063b7b800a414610a86578063ba019dab14610a8e578063ba9530a614610a96578063bc063e1a14610ad157610378565b80638d4e40831461092a57806392eefe9b14610932578063936c3477146109585780639381cd2b14610960578063948d8ce61461096857806395d89b411461098e578063992e2a92146109965780639a86139b1461099e57610378565b806349b59552116102b757806376c7a3c71161025a57806376c7a3c7146107aa5780637c5e9ea4146107b25780638201aa3f1461080b57806382f652ad1461084b5780638656b65314610886578063867378c5146108c157806389298012146108c95780638c28cbe81461090457610378565b806349b595521461061b5780634bb278f31461063a5780634f69c0d4146106425780635c1bbaf7146106b95780635db34277146106f457806366188463146107265780636d06dfa01461075257806370a082311461078457610378565b8063218b53821161031f578063218b5382146104f257806323b872dd146104fa5780632f37b624146105305780633018205f14610556578063313ce5671461057a57806334e19907146105985780633fdddaa2146105b757806346ab38f1146105e957610378565b806302c967481461037d57806306fdde03146103c1578063095ea7b31461043e57806309a3bbe41461047e5780631446a7ff1461048657806315e84af9146104b457806318160ddd146104e2578063189d00ca146104ea575b600080fd5b6103af6004803603606081101561039357600080fd5b50600160a060020a038135169060208101359060400135610ca2565b60408051918252519081900360200190f35b6103c9610fef565b6040805160208082528351818301528351919283929083019185019080838360005b838110156104035781810151838201526020016103eb565b50505050905090810190601f1680156104305780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61046a6004803603604081101561045457600080fd5b50600160a060020a038135169060200135611085565b604080519115158252519081900360200190f35b6103af6110da565b6103af6004803603604081101561049c57600080fd5b50600160a060020a03813581169160200135166110e7565b6103af600480360360408110156104ca57600080fd5b50600160a060020a0381358116916020013516611241565b6103af611392565b6103af611398565b6103af6113ac565b61046a6004803603606081101561051057600080fd5b50600160a060020a038135811691602081013590911690604001356113b8565b61046a6004803603602081101561054657600080fd5b5035600160a060020a031661151d565b61055e61153b565b60408051600160a060020a039092168252519081900360200190f35b61058261159c565b6040805160ff9092168252519081900360200190f35b6105b5600480360360208110156105ae57600080fd5b50356115a5565b005b6105b5600480360360608110156105cd57600080fd5b50600160a060020a0381351690602081013590604001356117c9565b6103af600480360360608110156105ff57600080fd5b50600160a060020a038135169060208101359060400135611c15565b6105b56004803603602081101561063157600080fd5b50351515611f01565b6105b5612092565b6105b56004803603604081101561065857600080fd5b8135919081019060408101602082013564010000000081111561067a57600080fd5b82018360208201111561068c57600080fd5b803590602001918460208302840111640100000000831117156106ae57600080fd5b5090925090506122a9565b6103af600480360360c08110156106cf57600080fd5b5080359060208101359060408101359060608101359060808101359060a00135612590565b6103af6004803603606081101561070a57600080fd5b50600160a060020a038135169060208101359060400135612648565b61046a6004803603604081101561073c57600080fd5b50600160a060020a038135169060200135612919565b6103af6004803603606081101561076857600080fd5b50600160a060020a0381351690602081013590604001356129f1565b6103af6004803603602081101561079a57600080fd5b5035600160a060020a0316612cf0565b6103af612d0b565b6107f2600480360360a08110156107c857600080fd5b50600160a060020a0381358116916020810135916040820135169060608101359060800135612d1d565b6040805192835260208301919091528051918290030190f35b6107f2600480360360a081101561082157600080fd5b50600160a060020a038135811691602081013591604082013516906060810135906080013561320d565b6103af600480360360c081101561086157600080fd5b5080359060208101359060408101359060608101359060808101359060a001356136e4565b6103af600480360360c081101561089c57600080fd5b5080359060208101359060408101359060608101359060808101359060a001356137a3565b6103af613844565b6103af600480360360c08110156108df57600080fd5b5080359060208101359060408101359060608101359060808101359060a00135613858565b6105b56004803603602081101561091a57600080fd5b5035600160a060020a0316613908565b61046a613ad9565b6105b56004803603602081101561094857600080fd5b5035600160a060020a0316613ae2565b6103af613c2c565b6103af613c84565b6103af6004803603602081101561097e57600080fd5b5035600160a060020a0316613c91565b6103c9613d5f565b6103af613dc0565b6103af613dcc565b6103af600480360360a08110156109bc57600080fd5b5080359060208101359060408101359060608101359060800135613df0565b61046a600480360360408110156109f157600080fd5b50600160a060020a038135169060200135613e55565b6105b560048036036040811015610a1d57600080fd5b81359190810190604081016020820135640100000000811115610a3f57600080fd5b820183602082011115610a5157600080fd5b80359060200191846020830284011164010000000083111715610a7357600080fd5b509092509050613e6b565b6103af61419f565b6103af6141a4565b6103af6141a9565b6103af600480360360c0811015610aac57600080fd5b5080359060208101359060408101359060608101359060808101359060a001356141ae565b6103af61422f565b6103af61423f565b610ae961424b565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610b25578181015183820152602001610b0d565b505050509050019250505060405180910390f35b6103af614343565b610ae9614348565b6103af614399565b6105b560048036036020811015610b6757600080fd5b5035600160a060020a031661439f565b6103af61472c565b61046a60048036036040811015610b9557600080fd5b50600160a060020a038135169060200135614784565b6103af60048036036040811015610bc157600080fd5b50600160a060020a0381358116916020013516614805565b6105b560048036036060811015610bef57600080fd5b50600160a060020a038135169060208101359060400135614830565b6103af614ab4565b6103af60048036036020811015610c2957600080fd5b5035600160a060020a0316614ac4565b6103af60048036036020811015610c4f57600080fd5b5035600160a060020a0316614ba4565b6103af600480360360c0811015610c7557600080fd5b5080359060208101359060408101359060608101359060808101359060a00135614c72565b61046a614cf5565b600033600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615610d53576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff16610daa576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615680833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a602052604090205460ff16610e08576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a60205260409020600390810154610e3d91670de0b6b3a76400005b04600101614d05565b831115610e82576040805160e560020a62461bcd02815260206004820152601160248201526000805160206156e0833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a6020526040902060038101546002808301549054600b54600754610ebc949392919089906136e4565b915081610f01576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b82821115610f47576040805160e560020a62461bcd02815260206004820152600c60248201526000805160206156c0833981519152604482015290519081900360640190fd5b610f55816003015485614dee565b60038201556000610f668382614d05565b604080518781529051919250600160a060020a0388169133916000805160206157a0833981519152919081900360200190a3610fa23384614e5f565b610fb4610faf8483614dee565b614e6d565b600554610fd090620100009004600160a060020a031682614e79565b610fdb863387614e83565b50506005805461ff00191690559392505050565b60038054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561107b5780601f106110505761010080835404028352916020019161107b565b820191906000526020600020905b81548152906001019060200180831161105e57829003601f168201915b5050505050905090565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390926000805160206157c0833981519152928290030190a35060015b92915050565b6802b5e3af16b188000081565b600554600090610100900460ff1615611138576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b600160a060020a0383166000908152600a602052604090205460ff16611196576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0382166000908152600a602052604090205460ff166111f4576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a038084166000908152600a602052604080822092851682528120600380840154600280860154928401549084015493946112389492939290613df0565b95945050505050565b600554600090610100900460ff1615611292576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b600160a060020a0383166000908152600a602052604090205460ff166112f0576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0382166000908152600a602052604090205460ff1661134e576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a038084166000908152600a602052604080822092851682529020600380830154600280850154928401549084015460075461123894929190613df0565b60025490565b6402540be400670de0b6b3a76400005b0481565b670de0b6b3a764000081565b600033600160a060020a03851614806113f45750600160a060020a03841660009081526001602090815260408083203384529091529020548211155b611448576040805160e560020a62461bcd02815260206004820152601560248201527f4552525f42544f4b454e5f4241445f43414c4c45520000000000000000000000604482015290519081900360640190fd5b611453848484614f78565b33600160a060020a038516148015906114915750600160a060020a038416600090815260016020908152604080832033845290915290205460001914155b1561151357600160a060020a03841660009081526001602090815260408083203384529091529020546114c49083614dee565b600160a060020a03858116600090815260016020908152604080832033808552908352928190208590558051948552519287169391926000805160206157c08339815191529281900390910190a35b5060019392505050565b600160a060020a03166000908152600a602052604090205460ff1690565b600554600090610100900460ff161561158c576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b50600654600160a060020a031690565b60055460ff1690565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615611654576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff16156116ac576040805160e560020a62461bcd02815260206004820152601060248201526000805160206157e0833981519152604482015290519081900360640190fd5b600654600160a060020a031633146116fc576040805160e560020a62461bcd0281526020600482015260126024820152600080516020615720833981519152604482015290519081900360640190fd5b64e8d4a51000811015611759576040805160e560020a62461bcd02815260206004820152600b60248201527f4552525f4d494e5f464545000000000000000000000000000000000000000000604482015290519081900360640190fd5b67016345785d8a00008111156117b9576040805160e560020a62461bcd02815260206004820152600b60248201527f4552525f4d41585f464545000000000000000000000000000000000000000000604482015290519081900360640190fd5b6007556005805461ff0019169055565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615611878576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560065433600160a060020a03909116146118d9576040805160e560020a62461bcd0281526020600482015260126024820152600080516020615720833981519152604482015290519081900360640190fd5b600160a060020a0383166000908152600a602052604090205460ff16611937576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b60085460ff1615611980576040805160e560020a62461bcd02815260206004820152601060248201526000805160206157e0833981519152604482015290519081900360640190fd5b670de0b6b3a76400008110156119e0576040805160e560020a62461bcd02815260206004820152600e60248201527f4552525f4d494e5f574549474854000000000000000000000000000000000000604482015290519081900360640190fd5b6802b5e3af16b1880000811115611a41576040805160e560020a62461bcd02815260206004820152600e60248201527f4552525f4d41585f574549474854000000000000000000000000000000000000604482015290519081900360640190fd5b620f4240821015611a9c576040805160e560020a62461bcd02815260206004820152600f60248201527f4552525f4d494e5f42414c414e43450000000000000000000000000000000000604482015290519081900360640190fd5b600160a060020a0383166000908152600a602052604090206002015480821115611b3f57611ad5600b54611ad08484614dee565b615082565b600b8190556802b5e3af16b18800001015611b3a576040805160e560020a62461bcd02815260206004820152601460248201527f4552525f4d41585f544f54414c5f574549474854000000000000000000000000604482015290519081900360640190fd5b611b60565b80821015611b6057611b5c600b54611b578385614dee565b614dee565b600b555b600160a060020a0384166000908152600a602052604090206002810183905560030180549084905580841115611ba957611ba48533611b9f8785614dee565b6150df565b611c03565b80841015611c03576000611bbd8286614dee565b90506000611bcc826000614d05565b9050611be28733611bdd8585614dee565b614e83565b600554611c00908890620100009004600160a060020a031683614e83565b50505b50506005805461ff0019169055505050565b600033600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615611cc6576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff16611d1d576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615680833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a602052604090205460ff16611d7b576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a6020526040902060038101546002808301549054600b54600754611db594939291908990613858565b915082821015611dfd576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615800833981519152604482015290519081900360640190fd5b600160a060020a0385166000908152600a60205260409020600390810154611e2d91670de0b6b3a7640000610e34565b821115611e72576040805160e560020a62461bcd02815260206004820152601160248201526000805160206156e0833981519152604482015290519081900360640190fd5b611e80816003015483614dee565b60038201556000611e918582614d05565b604080518581529051919250600160a060020a0388169133916000805160206157a0833981519152919081900360200190a3611ecd3386614e5f565b611eda610faf8683614dee565b600554611ef690620100009004600160a060020a031682614e79565b610fdb863385614e83565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615611fb0576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff1615612008576040805160e560020a62461bcd02815260206004820152601060248201526000805160206157e0833981519152604482015290519081900360640190fd5b600654600160a060020a03163314612058576040805160e560020a62461bcd0281526020600482015260126024820152600080516020615720833981519152604482015290519081900360640190fd5b6006805491151560a060020a0274ff0000000000000000000000000000000000000000199092169190911790556005805461ff0019169055565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615612141576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560065433600160a060020a03909116146121a2576040805160e560020a62461bcd0281526020600482015260126024820152600080516020615720833981519152604482015290519081900360640190fd5b60085460ff16156121eb576040805160e560020a62461bcd02815260206004820152601060248201526000805160206157e0833981519152604482015290519081900360640190fd5b60095460021115612246576040805160e560020a62461bcd02815260206004820152600e60248201527f4552525f4d494e5f544f4b454e53000000000000000000000000000000000000604482015290519081900360640190fd5b6008805460ff191660011790556006805474ff0000000000000000000000000000000000000000191660a060020a17905561228968056bc75e2d63100000615151565b61229c3368056bc75e2d63100000614e79565b6005805461ff0019169055565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615612358576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff166123af576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615680833981519152604482015290519081900360640190fd5b60006123b9611392565b905060006123c7858361515a565b90508061240c576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b60005b60095481101561257c5760006009828154811061242857fe5b6000918252602080832090910154600160a060020a0316808352600a90915260408220600301549092509061245d8583614d05565b9050806124a2576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b8787858181106124ae57fe5b905060200201358111156124fa576040805160e560020a62461bcd02815260206004820152600c60248201526000805160206156c0833981519152604482015290519081900360640190fd5b600160a060020a0383166000908152600a60205260409020600301546125209082615082565b600160a060020a0384166000818152600a60209081526040918290206003019390935580518481529051919233926000805160206157008339815191529281900390910190a36125718333836150df565b50505060010161240f565b5061258685615151565b611c033386614e79565b60008061259d878661515a565b905060006125ab8786615082565b905060006125b9828961515a565b905060006125cf670de0b6b3a76400008561515a565b905060006125dd8383615296565b905060006125eb828e614d05565b905060006125f9828f614dee565b90506000612618612612670de0b6b3a76400008a614dee565b8b614d05565b905061263582612630670de0b6b3a764000084614dee565b61515a565b9f9e505050505050505050505050505050565b600033600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff16156126f9576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff16612750576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615680833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a602052604090205460ff166127ae576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a60205260409020600301546127e0906002670de0b6b3a76400005b04614d05565b831115612825576040805160e560020a62461bcd0281526020600482015260106024820152600080516020615740833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a6020526040902060038101546002808301549054600b5460075461285f949392919089906137a3565b9150828210156128a7576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615800833981519152604482015290519081900360640190fd5b6128b5816003015485615082565b6003820155604080518581529051600160a060020a0387169133916000805160206157008339815191529181900360200190a36128f182615151565b6128fb3383614e79565b6129068533866150df565b506005805461ff00191690559392505050565b336000908152600160209081526040808320600160a060020a03861684529091528120548083111561296e57336000908152600160209081526040808320600160a060020a038816845290915281205561299d565b6129788184614dee565b336000908152600160209081526040808320600160a060020a03891684529091529020555b336000818152600160209081526040808320600160a060020a0389168085529083529281902054815190815290519293926000805160206157c0833981519152929181900390910190a35060019392505050565b600033600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615612aa2576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff16612af9576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615680833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a602052604090205460ff16612b57576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0384166000908152600a6020526040902060038101546002808301549054600b54600754612b9194939291908990612590565b915081612bd6576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b82821115612c1c576040805160e560020a62461bcd02815260206004820152600c60248201526000805160206156c0833981519152604482015290519081900360640190fd5b600160a060020a0385166000908152600a6020526040902060030154612c4c906002670de0b6b3a76400006127da565b821115612c91576040805160e560020a62461bcd0281526020600482015260106024820152600080516020615740833981519152604482015290519081900360640190fd5b612c9f816003015483615082565b6003820155604080518381529051600160a060020a0387169133916000805160206157008339815191529181900360200190a3612cdb84615151565b612ce53385614e79565b6129068533846150df565b600160a060020a031660009081526020819052604090205490565b620f4240670de0b6b3a76400006113a8565b6040805160208082523690820181905260009283923392600160e060020a03198535169285929081908101848480828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615612dbd576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff001916610100179055600160a060020a0387166000908152600a602052604090205460ff16612e2a576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0385166000908152600a602052604090205460ff16612e88576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b60065460a060020a900460ff16612ee9576040805160e560020a62461bcd02815260206004820152601360248201527f4552525f535741505f4e4f545f5055424c494300000000000000000000000000604482015290519081900360640190fd5b600160a060020a038088166000908152600a602052604080822092881682529020600380820154612f2291670de0b6b3a7640000610e34565b861115612f67576040805160e560020a62461bcd02815260206004820152601160248201526000805160206156e0833981519152604482015290519081900360640190fd5b6000612f888360030154846002015484600301548560020154600754613df0565b905085811115612fe2576040805160e560020a62461bcd02815260206004820152601360248201527f4552525f4241445f4c494d49545f505249434500000000000000000000000000604482015290519081900360640190fd5b61300283600301548460020154846003015485600201548b600754614c72565b94508885111561304a576040805160e560020a62461bcd02815260206004820152600c60248201526000805160206156c0833981519152604482015290519081900360640190fd5b613058836003015486615082565b836003018190555061306e826003015488614dee565b600380840182905584015460028086015490850154600754613091949190613df0565b9350808410156130d9576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b85841115613131576040805160e560020a62461bcd02815260206004820152600f60248201527f4552525f4c494d49545f50524943450000000000000000000000000000000000604482015290519081900360640190fd5b61313b858861515a565b811115613180576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b87600160a060020a03168a600160a060020a031633600160a060020a03167f908fb5ee8f16c6bc9bc3690973819f32a4d4b10188134543c88706e0e1d43378888b604051808381526020018281526020019250505060405180910390a46131e88a33876150df565b6131f3883389614e83565b5050506005805461ff001916905590969095509350505050565b6040805160208082523690820181905260009283923392600160e060020a03198535169285929081908101848480828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff16156132ad576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff001916610100179055600160a060020a0387166000908152600a602052604090205460ff1661331a576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0385166000908152600a602052604090205460ff16613378576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b60065460a060020a900460ff166133d9576040805160e560020a62461bcd02815260206004820152601360248201527f4552525f535741505f4e4f545f5055424c494300000000000000000000000000604482015290519081900360640190fd5b600160a060020a038088166000908152600a6020526040808220928816825290206003820154613413906002670de0b6b3a76400006127da565b881115613458576040805160e560020a62461bcd0281526020600482015260106024820152600080516020615740833981519152604482015290519081900360640190fd5b60006134798360030154846002015484600301548560020154600754613df0565b9050858111156134d3576040805160e560020a62461bcd02815260206004820152601360248201527f4552525f4241445f4c494d49545f505249434500000000000000000000000000604482015290519081900360640190fd5b6134f383600301548460020154846003015485600201548d6007546141ae565b94508685101561353b576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615800833981519152604482015290519081900360640190fd5b61354983600301548a615082565b836003018190555061355f826003015486614dee565b600380840182905584015460028086015490850154600754613582949190613df0565b9350808410156135ca576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b85841115613622576040805160e560020a62461bcd02815260206004820152600f60248201527f4552525f4c494d49545f50524943450000000000000000000000000000000000604482015290519081900360640190fd5b61362c898661515a565b811115613671576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b87600160a060020a03168a600160a060020a031633600160a060020a03167f908fb5ee8f16c6bc9bc3690973819f32a4d4b10188134543c88706e0e1d433788c89604051808381526020018281526020019250505060405180910390a46136d98a338b6150df565b6131f3883387614e83565b6000806136f1878661515a565b90506000613707670de0b6b3a764000083614dee565b905060006137158286614d05565b9050600061372f87612630670de0b6b3a764000085614dee565b9050600061373d8c83614dee565b9050600061374b828e61515a565b905060006137598288615296565b90506000613767828e614d05565b905060006137758e83614dee565b905061378e81612630670de0b6b3a76400006000614dee565b99505050505050505050509695505050505050565b6000806137b0878661515a565b905060006137cf6137c9670de0b6b3a764000084614dee565b85614d05565b905060006137ee866137e9670de0b6b3a764000085614dee565b614d05565b905060006137fc8b83615082565b9050600061380a828d61515a565b905060006138188287615296565b90506000613826828d614d05565b9050613832818d614dee565b9e9d5050505050505050505050505050565b64e8d4a51000670de0b6b3a76400006113a8565b600080613865878661515a565b90506000613880856137e9670de0b6b3a76400006000614dee565b9050600061388e8883614dee565b9050600061389c828a61515a565b905060006138bb826138b6670de0b6b3a76400008861515a565b615296565b905060006138c9828e614d05565b905060006138d78e83614dee565b905060006138f0612612670de0b6b3a76400008a614dee565b9050612635826137e9670de0b6b3a764000084614dee565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff16156139b7576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff001916610100179055600160a060020a0381166000908152600a602052604090205460ff16613a24576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600160a060020a038316916370a08231916024808301926020929190829003018186803b158015613a8357600080fd5b505afa158015613a97573d6000803e3d6000fd5b505050506040513d6020811015613aad57600080fd5b5051600160a060020a039091166000908152600a60205260409020600301556005805461ff0019169055565b60085460ff1690565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615613b91576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560065433600160a060020a0390911614613bf2576040805160e560020a62461bcd0281526020600482015260126024820152600080516020615720833981519152604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790556005805461ff0019169055565b600554600090610100900460ff1615613c7d576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b50600b5490565b68056bc75e2d6310000081565b600554600090610100900460ff1615613ce2576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b600160a060020a0382166000908152600a602052604090205460ff16613d40576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b50600160a060020a03166000908152600a602052604090206002015490565b60048054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561107b5780601f106110505761010080835404028352916020019161107b565b6704a03ce68d21555681565b7f42524f4e5a45000000000000000000000000000000000000000000000000000090565b600080613dfd878761515a565b90506000613e0b868661515a565b90506000613e19838361515a565b90506000613e3b670de0b6b3a7640000612630670de0b6b3a764000089614dee565b9050613e478282614d05565b9a9950505050505050505050565b6000613e62338484614f78565b50600192915050565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff1615613f1a576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560085460ff16613f71576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615680833981519152604482015290519081900360640190fd5b6000613f7b611392565b90506000613f8a856000614d05565b90506000613f988683614dee565b90506000613fa6828561515a565b905080613feb576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b613ff53388614e5f565b60055461401190620100009004600160a060020a031684614e79565b61401a82614e6d565b60005b60095481101561418a5760006009828154811061403657fe5b6000918252602080832090910154600160a060020a0316808352600a90915260408220600301549092509061406b8583614d05565b9050806140b0576040805160e560020a62461bcd02815260206004820152600f6024820152600080516020615820833981519152604482015290519081900360640190fd5b8989858181106140bc57fe5b90506020020135811015614108576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615800833981519152604482015290519081900360640190fd5b600160a060020a0383166000908152600a602052604090206003015461412e9082614dee565b600160a060020a0384166000818152600a60209081526040918290206003019390935580518481529051919233926000805160206157a08339815191529281900390910190a361417f833383614e83565b50505060010161401d565b50506005805461ff0019169055505050505050565b600881565b600281565b600181565b6000806141bb878661515a565b905060006141d1670de0b6b3a764000085614dee565b90506141dd8582614d05565b905060006141ef8a6126308c85615082565b905060006141fd8285615296565b90506000614213670de0b6b3a764000083614dee565b905061421f8a82614d05565b9c9b505050505050505050505050565b600a670de0b6b3a76400006113a8565b671bc16d674ec7ffff81565b600554606090610100900460ff161561429c576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b60085460ff166142e4576040805160e560020a62461bcd0281526020600482015260116024820152600080516020615680833981519152604482015290519081900360640190fd5b600980548060200260200160405190810160405280929190818152602001828054801561107b57602002820191906000526020600020905b8154600160a060020a0316815260019091019060200180831161431c575050505050905090565b600081565b600554606090610100900460ff16156142e4576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b60095490565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600554610100900460ff161561444e576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b6005805461ff00191661010017905560065433600160a060020a03909116146144af576040805160e560020a62461bcd0281526020600482015260126024820152600080516020615720833981519152604482015290519081900360640190fd5b600160a060020a0381166000908152600a602052604090205460ff1661450d576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b60085460ff1615614556576040805160e560020a62461bcd02815260206004820152601060248201526000805160206157e0833981519152604482015290519081900360640190fd5b600160a060020a0381166000908152600a60205260408120600301549061457d8282614d05565b600b54600160a060020a0385166000908152600a60205260409020600201549192506145a891614dee565b600b55600160a060020a0383166000908152600a60205260409020600101546009805460001981019190829081106145dc57fe5b60009182526020909120015460098054600160a060020a03909216918490811061460257fe5b9060005260206000200160006101000a815481600160a060020a030219169083600160a060020a0316021790555081600a60006009858154811061464257fe5b6000918252602080832090910154600160a060020a03168352820192909252604001902060010155600980548061467557fe5b600082815260208082206000199084018101805473ffffffffffffffffffffffffffffffffffffffff191690559092019092556040805160808101825283815280830184815281830185815260608301868152600160a060020a038c168752600a909552929094209051815460ff1916901515178155925160018401555160028301555160039091015561470e8533611bdd8787614dee565b600554611c03908690620100009004600160a060020a031685614e83565b600554600090610100900460ff161561477d576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b5060075490565b336000908152600160209081526040808320600160a060020a03861684529091528120546147b29083615082565b336000818152600160209081526040808320600160a060020a0389168085529083529281902085905580519485525191936000805160206157c0833981519152929081900390910190a350600192915050565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b33600160a060020a0316600035600160e060020a031916600160e060020a03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600654600160a060020a031633146148e1576040805160e560020a62461bcd0281526020600482015260126024820152600080516020615720833981519152604482015290519081900360640190fd5b600160a060020a0383166000908152600a602052604090205460ff1615614952576040805160e560020a62461bcd02815260206004820152600c60248201527f4552525f49535f424f554e440000000000000000000000000000000000000000604482015290519081900360640190fd5b60085460ff161561499b576040805160e560020a62461bcd02815260206004820152601060248201526000805160206157e0833981519152604482015290519081900360640190fd5b6009546008116149f5576040805160e560020a62461bcd02815260206004820152600e60248201527f4552525f4d41585f544f4b454e53000000000000000000000000000000000000604482015290519081900360640190fd5b604080516080810182526001808252600980546020808501918252600085870181815260608701828152600160a060020a038c16808452600a9094529782209651875460ff1916901515178755925186860155915160028601559451600390940193909355805491820181559091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af01805473ffffffffffffffffffffffffffffffffffffffff19169091179055614aaf8383836117c9565b505050565b6002670de0b6b3a76400006113a8565b600554600090610100900460ff1615614b15576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b600160a060020a0382166000908152600a602052604090205460ff16614b73576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b600160a060020a0382166000908152600a6020526040902060020154600b54614b9d90829061515a565b9392505050565b600554600090610100900460ff1615614bf5576040805160e560020a62461bcd02815260206004820152600b60248201526000805160206156a0833981519152604482015290519081900360640190fd5b600160a060020a0382166000908152600a602052604090205460ff16614c53576040805160e560020a62461bcd02815260206004820152600d6024820152600080516020615780833981519152604482015290519081900360640190fd5b50600160a060020a03166000908152600a602052604090206003015490565b600080614c7f858861515a565b90506000614c8d8786614dee565b90506000614c9b888361515a565b90506000614ca98285615296565b9050614cbd81670de0b6b3a7640000614dee565b9050614cd1670de0b6b3a764000087614dee565b9450614ce6614ce08c83614d05565b8661515a565b9b9a5050505050505050505050565b60065460a060020a900460ff1690565b6000828202831580614d1f575082848281614d1c57fe5b04145b614d73576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4d554c5f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b6706f05b59d3b20000810181811015614dd6576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4d554c5f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b6000670de0b6b3a7640000825b049695505050505050565b6000806000614dfd85856153b9565b915091508015614e57576040805160e560020a62461bcd02815260206004820152601160248201527f4552525f5355425f554e444552464c4f57000000000000000000000000000000604482015290519081900360640190fd5b509392505050565b614e6982826153de565b5050565b614e76816153e9565b50565b614e6982826154b3565b604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a03848116600483015260248201849052915160009286169163a9059cbb91604480830192602092919082900301818787803b158015614eef57600080fd5b505af1158015614f03573d6000803e3d6000fd5b505050506040513d6020811015614f1957600080fd5b5051905080614f72576040805160e560020a62461bcd02815260206004820152600f60248201527f4552525f45524332305f46414c53450000000000000000000000000000000000604482015290519081900360640190fd5b50505050565b600160a060020a038316600090815260208190526040902054811115614fe8576040805160e560020a62461bcd02815260206004820152601460248201527f4552525f494e53554646494349454e545f42414c000000000000000000000000604482015290519081900360640190fd5b600160a060020a03831660009081526020819052604090205461500b9082614dee565b600160a060020a03808516600090815260208190526040808220939093559084168152205461503a9082615082565b600160a060020a0380841660008181526020818152604091829020949094558051858152905191939287169260008051602061576083398151915292918290030190a3505050565b600082820183811015614b9d576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4144445f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a0384811660048301523060248301526044820184905291516000928616916323b872dd91606480830192602092919082900301818787803b158015614eef57600080fd5b614e76816154be565b6000816151b1576040805160e560020a62461bcd02815260206004820152600c60248201527f4552525f4449565f5a45524f0000000000000000000000000000000000000000604482015290519081900360640190fd5b670de0b6b3a764000083028315806151d95750670de0b6b3a76400008482816151d657fe5b04145b61522d576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4449565f494e5445524e414c00000000000000000000000000000000604482015290519081900360640190fd5b6002830481018181101561528b576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4449565f494e5445524e414c00000000000000000000000000000000604482015290519081900360640190fd5b6000848281614de357fe5b600060018310156152f1576040805160e560020a62461bcd02815260206004820152601560248201527f4552525f42504f575f424153455f544f4f5f4c4f570000000000000000000000604482015290519081900360640190fd5b671bc16d674ec7ffff831115615351576040805160e560020a62461bcd02815260206004820152601660248201527f4552525f42504f575f424153455f544f4f5f4849474800000000000000000000604482015290519081900360640190fd5b600061535c83615521565b9050600061536a8483614dee565b905060006153808661537b8561553c565b61554a565b9050816153915792506110d4915050565b60006153a287846305f5e1006155a1565b90506153ae8282614d05565b979650505050505050565b6000808284106153cf57505080820360006153d7565b505081810360015b9250929050565b614e69823083614f78565b30600090815260208190526040902054811115615450576040805160e560020a62461bcd02815260206004820152601460248201527f4552525f494e53554646494349454e545f42414c000000000000000000000000604482015290519081900360640190fd5b3060009081526020819052604090205461546a9082614dee565b306000908152602081905260409020556002546154879082614dee565b60025560408051828152905160009130916000805160206157608339815191529181900360200190a350565b614e69308383614f78565b306000908152602081905260409020546154d89082615082565b306000908152602081905260409020556002546154f59082615082565b60025560408051828152905130916000916000805160206157608339815191529181900360200190a350565b6000670de0b6b3a76400006155358361553c565b0292915050565b670de0b6b3a7640000900490565b6000806002830661556357670de0b6b3a7640000615565565b835b90506002830492505b8215614b9d5761557e8485614d05565b93506002830615615596576155938185614d05565b90505b60028304925061556e565b60008281806155b887670de0b6b3a76400006153b9565b9092509050670de0b6b3a764000080600060015b888410615670576000670de0b6b3a7640000820290506000806156008a6155fb85670de0b6b3a7640000614dee565b6153b9565b91509150615612876137e9848c614d05565b965061561e878461515a565b96508661562d57505050615670565b8715615637579315935b8015615641579315935b8415615658576156518688614dee565b9550615665565b6156628688615082565b95505b5050506001016155cc565b5090999850505050505050505056fe4552525f4e4f545f46494e414c495a45440000000000000000000000000000004552525f5245454e5452590000000000000000000000000000000000000000004552525f4c494d49545f494e00000000000000000000000000000000000000004552525f4d41585f4f55545f524154494f00000000000000000000000000000063982df10efd8dfaaaa0fcc7f50b2d93b7cba26ccc48adee2873220d485dc39a4552525f4e4f545f434f4e54524f4c4c455200000000000000000000000000004552525f4d41585f494e5f524154494f00000000000000000000000000000000ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef4552525f4e4f545f424f554e4400000000000000000000000000000000000000e74c91552b64c2e2e7bd255639e004e693bd3e1d01cc33e65610b86afcc1ffed8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9254552525f49535f46494e414c495a4544000000000000000000000000000000004552525f4c494d49545f4f5554000000000000000000000000000000000000004552525f4d4154485f415050524f580000000000000000000000000000000000a265627a7a72315820a6ed20be58469dda7b96f5cd85dbd70406a753a02b645704241ab59bf33344fe64736f6c634300050c0032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/BToken.abi b/runtime/near-evm-runner/tests/build/BToken.abi new file mode 100644 index 00000000000..bd685b01c12 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BToken.abi @@ -0,0 +1,549 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "BONE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "BPOW_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "EXIT_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "INIT_POOL_SUPPLY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_IN_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_OUT_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_TOTAL_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BALANCE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getColor", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "whom", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "increaseApproval", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "decreaseApproval", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/BToken.bin b/runtime/near-evm-runner/tests/build/BToken.bin new file mode 100644 index 00000000000..3126375860d --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BToken.bin @@ -0,0 +1 @@ +60c0604052601360808190527f42616c616e63657220506f6f6c20546f6b656e0000000000000000000000000060a090815261003e91600391906100a3565b506040805180820190915260038082527f42505400000000000000000000000000000000000000000000000000000000006020909201918252610083916004916100a3565b506005805460ff1916601217905534801561009d57600080fd5b5061013e565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100e457805160ff1916838001178555610111565b82800160010185558215610111579182015b828111156101115782518255916020019190600101906100f6565b5061011d929150610121565b5090565b61013b91905b8082111561011d5760008155600101610127565b90565b610bd88061014d6000396000f3fe608060405234801561001057600080fd5b50600436106101a1576000357c010000000000000000000000000000000000000000000000000000000090048063992e2a92116100f6578063bc694ea2116100a4578063bc694ea2146103b7578063c36596a61461028d578063c6580d12146103bf578063d73dd623146103c7578063dd62ed3e146103f3578063e4a28a5214610263578063ec09302114610421576101a1565b8063992e2a921461035b5780639a86139b14610363578063a9059cbb1461036b578063b0e0d13614610397578063b7b800a41461039f578063ba019dab146103a7578063bc063e1a146103af576101a1565b8063313ce56711610153578063313ce567146102cb57806366188463146102e957806370a082311461031557806376c7a3c71461033b578063867378c5146103435780639381cd2b1461034b57806395d89b4114610353576101a1565b806306fdde03146101a6578063095ea7b31461022357806309a3bbe41461026357806318160ddd1461027d578063189d00ca14610285578063218b53821461028d57806323b872dd14610295575b600080fd5b6101ae610429565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101e85781810151838201526020016101d0565b50505050905090810190601f1680156102155780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61024f6004803603604081101561023957600080fd5b50600160a060020a0381351690602001356104bf565b604080519115158252519081900360200190f35b61026b610513565b60408051918252519081900360200190f35b61026b610520565b61026b610526565b61026b61053a565b61024f600480360360608110156102ab57600080fd5b50600160a060020a03813581169160208101359091169060400135610546565b6102d36106ab565b6040805160ff9092168252519081900360200190f35b61024f600480360360408110156102ff57600080fd5b50600160a060020a0381351690602001356106b4565b61026b6004803603602081101561032b57600080fd5b5035600160a060020a031661078c565b61026b6107a7565b61026b6107b9565b61026b6107cd565b6101ae6107da565b61026b61083b565b61026b610847565b61024f6004803603604081101561038157600080fd5b50600160a060020a03813516906020013561086b565b61026b610881565b61026b610886565b61026b61088b565b61026b610890565b61026b6108a0565b61026b6108ac565b61024f600480360360408110156103dd57600080fd5b50600160a060020a0381351690602001356108b1565b61026b6004803603604081101561040957600080fd5b50600160a060020a0381358116916020013516610932565b61026b61095d565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104b55780601f1061048a576101008083540402835291602001916104b5565b820191906000526020600020905b81548152906001019060200180831161049857829003601f168201915b5050505050905090565b336000818152600160209081526040808320600160a060020a03871680855290835281842086905581518681529151939490939092600080516020610b84833981519152928290030190a350600192915050565b6802b5e3af16b188000081565b60025490565b6402540be400670de0b6b3a76400005b0481565b670de0b6b3a764000081565b600033600160a060020a03851614806105825750600160a060020a03841660009081526001602090815260408083203384529091529020548211155b6105d6576040805160e560020a62461bcd02815260206004820152601560248201527f4552525f42544f4b454e5f4241445f43414c4c45520000000000000000000000604482015290519081900360640190fd5b6105e184848461096d565b33600160a060020a0385161480159061061f5750600160a060020a038416600090815260016020908152604080832033845290915290205460001914155b156106a157600160a060020a03841660009081526001602090815260408083203384529091529020546106529083610a89565b600160a060020a0385811660009081526001602090815260408083203380855290835292819020859055805194855251928716939192600080516020610b848339815191529281900390910190a35b5060019392505050565b60055460ff1690565b336000908152600160209081526040808320600160a060020a03861684529091528120548083111561070957336000908152600160209081526040808320600160a060020a0388168452909152812055610738565b6107138184610a89565b336000908152600160209081526040808320600160a060020a03891684529091529020555b336000818152600160209081526040808320600160a060020a038916808552908352928190205481519081529051929392600080516020610b84833981519152929181900390910190a35060019392505050565b600160a060020a031660009081526020819052604090205490565b620f4240670de0b6b3a7640000610536565b64e8d4a51000670de0b6b3a7640000610536565b68056bc75e2d6310000081565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104b55780601f1061048a576101008083540402835291602001916104b5565b6704a03ce68d21555681565b7f42524f4e5a45000000000000000000000000000000000000000000000000000090565b600061087833848461096d565b50600192915050565b600881565b600281565b600181565b600a670de0b6b3a7640000610536565b671bc16d674ec7ffff81565b600081565b336000908152600160209081526040808320600160a060020a03861684529091528120546108df9083610afa565b336000818152600160209081526040808320600160a060020a038916808552908352928190208590558051948552519193600080516020610b84833981519152929081900390910190a350600192915050565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b6002670de0b6b3a7640000610536565b600160a060020a0383166000908152602081905260409020548111156109dd576040805160e560020a62461bcd02815260206004820152601460248201527f4552525f494e53554646494349454e545f42414c000000000000000000000000604482015290519081900360640190fd5b600160a060020a038316600090815260208190526040902054610a009082610a89565b600160a060020a038085166000908152602081905260408082209390935590841681522054610a2f9082610afa565b600160a060020a038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000806000610a988585610b5e565b915091508015610af2576040805160e560020a62461bcd02815260206004820152601160248201527f4552525f5355425f554e444552464c4f57000000000000000000000000000000604482015290519081900360640190fd5b509392505050565b600082820183811015610b57576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4144445f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b9392505050565b600080828410610b745750508082036000610b7c565b505081810360015b925092905056fe8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925a265627a7a72315820a87af892d69e40e2c034544393d3427651f6eae9f394257394f44f1bd9738fdf64736f6c634300050c0032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/BTokenBase.abi b/runtime/near-evm-runner/tests/build/BTokenBase.abi new file mode 100644 index 00000000000..96908e29e8b --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BTokenBase.abi @@ -0,0 +1,307 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "BONE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "BPOW_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "EXIT_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "INIT_POOL_SUPPLY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_IN_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_OUT_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_TOTAL_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BALANCE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getColor", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/BTokenBase.bin b/runtime/near-evm-runner/tests/build/BTokenBase.bin new file mode 100644 index 00000000000..ff5c54e21c4 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/BTokenBase.bin @@ -0,0 +1 @@ +608060405234801561001057600080fd5b5061029c806100206000396000f3fe608060405234801561001057600080fd5b5060043610610108576000357c010000000000000000000000000000000000000000000000000000000090048063b0e0d136116100af578063b0e0d1361461015f578063b7b800a414610167578063ba019dab1461016f578063bc063e1a14610177578063bc694ea21461017f578063c36596a61461012f578063c6580d1214610187578063e4a28a521461010d578063ec0930211461018f57610108565b806309a3bbe41461010d578063189d00ca14610127578063218b53821461012f57806376c7a3c714610137578063867378c51461013f5780639381cd2b14610147578063992e2a921461014f5780639a86139b14610157575b600080fd5b610115610197565b60408051918252519081900360200190f35b6101156101a4565b6101156101b8565b6101156101c4565b6101156101d6565b6101156101ea565b6101156101f7565b610115610203565b610115610227565b61011561022c565b610115610231565b610115610236565b610115610246565b610115610252565b610115610257565b6802b5e3af16b188000081565b6402540be400670de0b6b3a76400005b0481565b670de0b6b3a764000081565b620f4240670de0b6b3a76400006101b4565b64e8d4a51000670de0b6b3a76400006101b4565b68056bc75e2d6310000081565b6704a03ce68d21555681565b7f42524f4e5a45000000000000000000000000000000000000000000000000000090565b600881565b600281565b600181565b600a670de0b6b3a76400006101b4565b671bc16d674ec7ffff81565b600081565b6002670de0b6b3a76400006101b456fea265627a7a7231582008760bf61cf90a4adde4f0558f43bdcd8f3e5cdf97aca2d1957bb4fef5289a1764736f6c634300050c0032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/ConstructorRevert.bin b/runtime/near-evm-runner/tests/build/ConstructorRevert.bin deleted file mode 100644 index eba8500764a..00000000000 --- a/runtime/near-evm-runner/tests/build/ConstructorRevert.bin +++ /dev/null @@ -1 +0,0 @@ -6080604052348015600f57600080fd5b5060056004146086576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f4572726f72204465706c6f79696e6720436f6e7472616374000000000000000081525060200191505060405180910390fd5b603e8060936000396000f3fe6080604052600080fdfea265627a7a723158203667e47f55606e5f72d16e0d9a81ed4435273fcfa1ee79bf9545dc524d930d2f64736f6c63430005100032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/Create2Factory.bin b/runtime/near-evm-runner/tests/build/Create2Factory.bin index da4baf5279f..5c18234a6ab 100644 --- a/runtime/near-evm-runner/tests/build/Create2Factory.bin +++ b/runtime/near-evm-runner/tests/build/Create2Factory.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b50610758806100206000396000f3fe6080604052600436106100295760003560e01c80639f45e8151461002b578063cdcb760a14610108575b005b6100ee6004803603604081101561004157600080fd5b81019080803590602001909291908035906020019064010000000081111561006857600080fd5b82018360208201111561007a57600080fd5b8035906020019184600183028401116401000000008311171561009c57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061021a565b604051808215151515815260200191505060405180910390f35b34801561011457600080fd5b506101d86004803603604081101561012b57600080fd5b81019080803590602001909291908035906020019064010000000081111561015257600080fd5b82018360208201111561016457600080fd5b8035906020019184600183028401116401000000008311171561018657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506106c7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60008061022784846106c7565b905060008190508073ffffffffffffffffffffffffffffffffffffffff1663eef4c90f60056040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561028257600080fd5b505af1158015610296573d6000803e3d6000fd5b5050505060058173ffffffffffffffffffffffffffffffffffffffff16636e4d2a346040518163ffffffff1660e01b815260040160206040518083038186803b1580156102e257600080fd5b505afa1580156102f6573d6000803e3d6000fd5b505050506040513d602081101561030c57600080fd5b810190808051906020019092919050505014610390576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f7072652d6465737472756374696f6e2077726f6e672075696e7400000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1663d37c6c9e6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156103d857600080fd5b505af11580156103ec573d6000803e3d6000fd5b5050505060606103fb826106db565b90506000815114610474576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f706f73742d6465737472756374696f6e20636f6465206c656e6774680000000081525060200191505060405180910390fd5b61047e86866106c7565b5060008273ffffffffffffffffffffffffffffffffffffffff16636e4d2a346040518163ffffffff1660e01b815260040160206040518083038186803b1580156104c757600080fd5b505afa1580156104db573d6000803e3d6000fd5b505050506040513d60208110156104f157600080fd5b810190808051906020019092919050505014610575576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f706f73742d6465737472756374696f6e2077726f6e672075696e74000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff1663eef4c90f60036040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156105c957600080fd5b505af11580156105dd573d6000803e3d6000fd5b5050505060038273ffffffffffffffffffffffffffffffffffffffff16636e4d2a346040518163ffffffff1660e01b815260040160206040518083038186803b15801561062957600080fd5b505afa15801561063d573d6000803e3d6000fd5b505050506040513d602081101561065357600080fd5b8101908080519060200190929190505050146106ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806107026022913960400191505060405180910390fd5b6001935050505092915050565b6000828251602084016000f5905092915050565b60606040519050813b8082526020820181600082863c818352818101604052505091905056fe706f73742d6465737472756374696f6e2073746f7265642077726f6e672075696e74a265627a7a7231582057b6addf30c31c49aa94429f78664940ffa8f1922153be7c94c853fa4932031c64736f6c63430005100032 \ No newline at end of file +608060405234801561001057600080fd5b50610758806100206000396000f3fe6080604052600436106100295760003560e01c80639f45e8151461002b578063cdcb760a14610108575b005b6100ee6004803603604081101561004157600080fd5b81019080803590602001909291908035906020019064010000000081111561006857600080fd5b82018360208201111561007a57600080fd5b8035906020019184600183028401116401000000008311171561009c57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061021a565b604051808215151515815260200191505060405180910390f35b34801561011457600080fd5b506101d86004803603604081101561012b57600080fd5b81019080803590602001909291908035906020019064010000000081111561015257600080fd5b82018360208201111561016457600080fd5b8035906020019184600183028401116401000000008311171561018657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506106c7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60008061022784846106c7565b905060008190508073ffffffffffffffffffffffffffffffffffffffff1663eef4c90f60056040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561028257600080fd5b505af1158015610296573d6000803e3d6000fd5b5050505060058173ffffffffffffffffffffffffffffffffffffffff16636e4d2a346040518163ffffffff1660e01b815260040160206040518083038186803b1580156102e257600080fd5b505afa1580156102f6573d6000803e3d6000fd5b505050506040513d602081101561030c57600080fd5b810190808051906020019092919050505014610390576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f7072652d6465737472756374696f6e2077726f6e672075696e7400000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1663d37c6c9e6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156103d857600080fd5b505af11580156103ec573d6000803e3d6000fd5b5050505060606103fb826106db565b90506000815114610474576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f706f73742d6465737472756374696f6e20636f6465206c656e6774680000000081525060200191505060405180910390fd5b61047e86866106c7565b5060008273ffffffffffffffffffffffffffffffffffffffff16636e4d2a346040518163ffffffff1660e01b815260040160206040518083038186803b1580156104c757600080fd5b505afa1580156104db573d6000803e3d6000fd5b505050506040513d60208110156104f157600080fd5b810190808051906020019092919050505014610575576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f706f73742d6465737472756374696f6e2077726f6e672075696e74000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff1663eef4c90f60036040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156105c957600080fd5b505af11580156105dd573d6000803e3d6000fd5b5050505060038273ffffffffffffffffffffffffffffffffffffffff16636e4d2a346040518163ffffffff1660e01b815260040160206040518083038186803b15801561062957600080fd5b505afa15801561063d573d6000803e3d6000fd5b505050506040513d602081101561065357600080fd5b8101908080519060200190929190505050146106ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806107026022913960400191505060405180910390fd5b6001935050505092915050565b6000828251602084016000f5905092915050565b60606040519050813b8082526020820181600082863c818352818101604052505091905056fe706f73742d6465737472756374696f6e2073746f7265642077726f6e672075696e74a265627a7a72315820e8aa482dbb1ad5a50769172bb326b40795aaa96e6340d1443c2ce7fdf22f071564736f6c63430005100032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/IERC20.abi b/runtime/near-evm-runner/tests/build/IERC20.abi new file mode 100644 index 00000000000..a8a6512c554 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/IERC20.abi @@ -0,0 +1,197 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "whom", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/Migrations.abi b/runtime/near-evm-runner/tests/build/Migrations.abi new file mode 100644 index 00000000000..bc177e8cb7a --- /dev/null +++ b/runtime/near-evm-runner/tests/build/Migrations.abi @@ -0,0 +1,68 @@ +[ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "constant": true, + "inputs": [], + "name": "lastCompletedMigration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "completed", + "type": "uint256" + } + ], + "name": "setCompleted", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "new_address", + "type": "address" + } + ], + "name": "upgrade", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/Migrations.bin b/runtime/near-evm-runner/tests/build/Migrations.bin new file mode 100644 index 00000000000..30bf5398e99 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/Migrations.bin @@ -0,0 +1 @@ +608060405234801561001057600080fd5b5060008054600160a060020a031916331790556101b9806100326000396000f3fe608060405234801561001057600080fd5b506004361061004f5760e060020a60003504630900f01081146100545780638da5cb5b1461007c578063fbdbad3c146100a0578063fdacd576146100ba575b600080fd5b61007a6004803603602081101561006a57600080fd5b5035600160a060020a03166100d7565b005b610084610157565b60408051600160a060020a039092168252519081900360200190f35b6100a8610166565b60408051918252519081900360200190f35b61007a600480360360208110156100d057600080fd5b503561016c565b600054600160a060020a031633141561015457600081905080600160a060020a031663fdacd5766001546040518263ffffffff1660e060020a02815260040180828152602001915050600060405180830381600087803b15801561013a57600080fd5b505af115801561014e573d6000803e3d6000fd5b50505050505b50565b600054600160a060020a031681565b60015481565b600054600160a060020a03163314156101545760015556fea265627a7a7231582023ed50b526b6a1b0948c964d1041e7f84e7a132d4284b38755f775875359435d64736f6c634300050c0032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/PrecompiledFunction.abi b/runtime/near-evm-runner/tests/build/PrecompiledFunction.abi new file mode 100644 index 00000000000..98369784154 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/PrecompiledFunction.abi @@ -0,0 +1,204 @@ +[ + { + "inputs": [], + "payable": true, + "stateMutability": "payable", + "type": "constructor" + }, + { + "constant": true, + "inputs": [], + "name": "noop", + "outputs": [], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "testSha256", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "testSha256_100bytes", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "testEcrecover", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "testRipemd160", + "outputs": [ + { + "internalType": "bytes20", + "name": "", + "type": "bytes20" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "testRipemd160_1kb", + "outputs": [ + { + "internalType": "bytes20", + "name": "", + "type": "bytes20" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "identity", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "test_identity", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "test_identity_100bytes", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "base", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "e", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "m", + "type": "uint256" + } + ], + "name": "modexp", + "outputs": [ + { + "internalType": "uint256", + "name": "o", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "testModExp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "testBn128Add", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/PrecompiledFunction.bin b/runtime/near-evm-runner/tests/build/PrecompiledFunction.bin new file mode 100644 index 00000000000..198e45d143f --- /dev/null +++ b/runtime/near-evm-runner/tests/build/PrecompiledFunction.bin @@ -0,0 +1 @@ +6080604052610c2c806100136000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c8063840f612011610071578063840f61201461026d5780638a6fa9da146103a1578063a449e8eb146103bf578063a7d4bbe6146103dd578063b7a0961a14610433578063e96cc75c1461046f576100b4565b806304e87187146100b9578063080e99331461013c5780631d82afc71461015a578063494236eb146101dd57806351163670146102195780635dfc2e4a14610263575b600080fd5b6100c161048d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101015780820151818401526020810190506100e6565b50505050905090810190601f16801561012e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101446104b5565b6040518082815260200191505060405180910390f35b610162610512565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101a2578082015181840152602081019050610187565b50505050905090810190601f1680156101cf5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101e5610531565b60405180826bffffffffffffffffffffffff19166bffffffffffffffffffffffff1916815260200191505060405180910390f35b610221610574565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61026b610640565b005b6103266004803603602081101561028357600080fd5b81019080803590602001906401000000008111156102a057600080fd5b8201836020820111156102b257600080fd5b803590602001918460018302840111640100000000831117156102d457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050610642565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561036657808201518184015260208101905061034b565b50505050905090810190601f1680156103935780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103a961069e565b6040518082815260200191505060405180910390f35b6103c76106a3565b6040518082815260200191505060405180910390f35b61041d600480360360608110156103f357600080fd5b810190808035906020019092919080359060200190929190803590602001909291905050506106f8565b6040518082815260200191505060405180910390f35b61043b610743565b60405180826bffffffffffffffffffffffff19166bffffffffffffffffffffffff1916815260200191505060405180910390f35b61047761077c565b6040518082815260200191505060405180910390f35b60606104b06040518060a0016040528060658152602001610b9360659139610642565b905090565b600060026040518080610b93606591396065019050602060405180830381855afa1580156104e7573d6000803e3d6000fd5b5050506040513d60208110156104fc57600080fd5b8101908080519060200190929190505050905090565b606061052c60405180602001604052806000815250610642565b905090565b6000600360405180806107936104009139610400019050602060405180830381855afa158015610565573d6000803e3d6000fd5b5050506040515160601b905090565b60006001601b6040516000815260200160405260405180807f11111111111111111111111111111111111111111111111111111111111111118152506020018260ff168152602001807fb9f0bb08640d3c1c00761cdd0121209268f6fd3816bc98b9e6f3cc77bf82b698815250602001807f12ac7a61788a0fdc0e19180f14c945a8e1088a27d92a74dce81c0981fb6447448152506020019150506020604051602081039080840390855afa158015610631573d6000803e3d6000fd5b50505060206040510351905090565b565b60608082516040519080825280601f01601f1916602001820160405280156106795781602001600182028038833980820191505090505b509050825180602083018260208701600060045af161069457fe5b5080915050919050565b600090565b60006002604051806000019050602060405180830381855afa1580156106cd573d6000803e3d6000fd5b5050506040513d60208110156106e257600080fd5b8101908080519060200190929190505050905090565b600060405160208152602080820152602060408201528460608201528360808201528260a082015260208160c08360056107d05a03fa61073757600080fd5b80519150509392505050565b60006003604051806000019050602060405180830381855afa15801561076d573d6000803e3d6000fd5b5050506040515160601b905090565b600061078d61303960ad60656106f8565b90509056fe6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f707172737475767778797a6162636465666768696a6b6c6d6e6f7071727374757677a265627a7a723158205d2c2b792d903870209e310c124cea57de9949e98fa1104d789ef0f5fea175cd64736f6c63430005100032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/SelfDestruct.bin b/runtime/near-evm-runner/tests/build/SelfDestruct.bin index fdf024159ad..176353f70ea 100644 --- a/runtime/near-evm-runner/tests/build/SelfDestruct.bin +++ b/runtime/near-evm-runner/tests/build/SelfDestruct.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b506101fc806100206000396000f3fe60806040526004361061004a5760003560e01c80636e4d2a341461004c5780638f63640e14610077578063d37c6c9e146100ce578063eef4c90f146100e5578063f2c4da9314610120575b005b34801561005857600080fd5b50610061610137565b6040518082815260200191505060405180910390f35b34801561008357600080fd5b5061008c61013d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156100da57600080fd5b506100e3610162565b005b3480156100f157600080fd5b5061011e6004803603602081101561010857600080fd5b810190808035906020019092919050505061017b565b005b34801561012c57600080fd5b50610135610185565b005b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b3373ffffffffffffffffffffffffffffffffffffffff16ff5b8060018190555050565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555056fea265627a7a7231582049134aca36ca008aa7d94838f31a297f561997c03ec02dedcb7b63aa26289cd664736f6c63430005100032 \ No newline at end of file +608060405234801561001057600080fd5b506101fc806100206000396000f3fe60806040526004361061004a5760003560e01c80636e4d2a341461004c5780638f63640e14610077578063d37c6c9e146100ce578063eef4c90f146100e5578063f2c4da9314610120575b005b34801561005857600080fd5b50610061610137565b6040518082815260200191505060405180910390f35b34801561008357600080fd5b5061008c61013d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156100da57600080fd5b506100e3610162565b005b3480156100f157600080fd5b5061011e6004803603602081101561010857600080fd5b810190808035906020019092919050505061017b565b005b34801561012c57600080fd5b50610135610185565b005b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b3373ffffffffffffffffffffffffffffffffffffffff16ff5b8060018190555050565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555056fea265627a7a72315820bc2518d7325b1a42a627271a1c315221090ec42188a01825fcea78176392f4c164736f6c63430005100032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/SolTests.bin b/runtime/near-evm-runner/tests/build/SolTests.bin index 186505b4e7f..b7bacad4583 100644 --- a/runtime/near-evm-runner/tests/build/SolTests.bin +++ b/runtime/near-evm-runner/tests/build/SolTests.bin @@ -1 +1 @@ -6080604052610a87806100136000396000f3fe6080604052600436106100705760003560e01c8063299fb0431161004e578063299fb043146101af5780632ccb1b30146101c65780639d9f9a6e14610235578063b69ef8a81461028657610070565b80630a84cba514610072578063111e0b12146100e757806314d54f541461015c575b005b61009e6004803603602081101561008857600080fd5b81019080803590602001909291905050506102b1565b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390f35b610113600480360360208110156100fd57600080fd5b8101908080359060200190929190505050610390565b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390f35b34801561016857600080fd5b506101956004803603602081101561017f57600080fd5b81019080803590602001909291905050506103dc565b604051808215151515815260200191505060405180910390f35b3480156101bb57600080fd5b506101c461041e565b005b3480156101d257600080fd5b5061021f600480360360408110156101e957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610756565b6040518082815260200191505060405180910390f35b61023d6107af565b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390f35b34801561029257600080fd5b5061029b610810565b6040518082815260200191505060405180910390f35b6000806000836040516102c390610818565b80828152602001915050604051809103906000f0801580156102e9573d6000803e3d6000fd5b5090508073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015610332573d6000803e3d6000fd5b508073ffffffffffffffffffffffffffffffffffffffff167fa53ffc4fb91f5ca8287e168fc73db3b0b384a6ca275650f885a1740ef7a0bc1c346040518082815260200191505060405180910390a280348191509250925050915091565b600080600034846040516103a390610818565b808281526020019150506040518091039082f0801580156103c8573d6000803e3d6000fd5b509050905080348191509250925050915091565b60007f379340f64b65a8890c7ea4f6d86d2359beaf41080f36a7ea64b78a2c06eee3f0826040518082815260200191505060405180910390a160019050919050565b7fe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8556002604051806000019050602060405180830381855afa158015610467573d6000803e3d6000fd5b5050506040513d602081101561047c57600080fd5b810190808051906020019092919050505014610500576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f7368613220646967657374206d69736d6174636800000000000000000000000081525060200191505060405180910390fd5b7f9c1185a5c5e9fc54612808977ee8f548b2258d310000000000000000000000006003604051806000019050602060405180830381855afa158015610549573d6000803e3d6000fd5b5050506040515160601b6bffffffffffffffffffffffff1916146105d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f726d6431363020646967657374206d69736d617463680000000000000000000081525060200191505060405180910390fd5b60006001601b6040516000815260200160405260405180807f11111111111111111111111111111111111111111111111111111111111111118152506020018260ff168152602001807fb9f0bb08640d3c1c00761cdd0121209268f6fd3816bc98b9e6f3cc77bf82b698815250602001807f12ac7a61788a0fdc0e19180f14c945a8e1088a27d92a74dce81c0981fb6447448152506020019150506020604051602081039080840390855afa158015610692573d6000803e3d6000fd5b505050602060405103519050731563915e194d8cfba1943570603f7606a311550873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610753576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f65637265636f766572206d69736d61746368000000000000000000000000000081525060200191505060405180910390fd5b50565b60008273ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f1935050505015801561079e573d6000803e3d6000fd5b506107a7610810565b905092915050565b6000803373ffffffffffffffffffffffffffffffffffffffff166108fc600234816107d657fe5b049081150290604051600060405180830381858888f19350505050158015610802573d6000803e3d6000fd5b503334819150915091509091565b600047905090565b61022d806108268339019056fe6080604052600660005560405161022d38038061022d8339818101604052602081101561002b57600080fd5b810190808051906020019092919050505080600081905550506101da806100536000396000f3fe60806040526004361061003f5760003560e01c80632ccb1b301461004157806339c117a4146100b0578063b69ef8a8146100df578063e6a899b61461010a575b005b34801561004d57600080fd5b5061009a6004803603604081101561006457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610135565b6040518082815260200191505060405180910390f35b3480156100bc57600080fd5b506100c561018e565b604051808215151515815260200191505060405180910390f35b3480156100eb57600080fd5b506100f4610197565b6040518082815260200191505060405180910390f35b34801561011657600080fd5b5061011f61019f565b6040518082815260200191505060405180910390f35b60008273ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f1935050505015801561017d573d6000803e3d6000fd5b50610186610197565b905092915050565b60006001905090565b600047905090565b6000548156fea265627a7a72315820bc102b3933ad6112eb436087a67714bf08814e4c202d3118307a3e280f47b6cb64736f6c63430005100032a265627a7a72315820fe8c0773a06b1128d9c03d755c55071d775ebea7ee4959a672d257e75225a51064736f6c63430005100032 \ No newline at end of file +6080604052610a87806100136000396000f3fe6080604052600436106100705760003560e01c8063299fb0431161004e578063299fb043146101af5780632ccb1b30146101c65780639d9f9a6e14610235578063b69ef8a81461028657610070565b80630a84cba514610072578063111e0b12146100e757806314d54f541461015c575b005b61009e6004803603602081101561008857600080fd5b81019080803590602001909291905050506102b1565b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390f35b610113600480360360208110156100fd57600080fd5b8101908080359060200190929190505050610390565b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390f35b34801561016857600080fd5b506101956004803603602081101561017f57600080fd5b81019080803590602001909291905050506103dc565b604051808215151515815260200191505060405180910390f35b3480156101bb57600080fd5b506101c461041e565b005b3480156101d257600080fd5b5061021f600480360360408110156101e957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610756565b6040518082815260200191505060405180910390f35b61023d6107af565b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390f35b34801561029257600080fd5b5061029b610810565b6040518082815260200191505060405180910390f35b6000806000836040516102c390610818565b80828152602001915050604051809103906000f0801580156102e9573d6000803e3d6000fd5b5090508073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015610332573d6000803e3d6000fd5b508073ffffffffffffffffffffffffffffffffffffffff167fa53ffc4fb91f5ca8287e168fc73db3b0b384a6ca275650f885a1740ef7a0bc1c346040518082815260200191505060405180910390a280348191509250925050915091565b600080600034846040516103a390610818565b808281526020019150506040518091039082f0801580156103c8573d6000803e3d6000fd5b509050905080348191509250925050915091565b60007f379340f64b65a8890c7ea4f6d86d2359beaf41080f36a7ea64b78a2c06eee3f0826040518082815260200191505060405180910390a160019050919050565b7fe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8556002604051806000019050602060405180830381855afa158015610467573d6000803e3d6000fd5b5050506040513d602081101561047c57600080fd5b810190808051906020019092919050505014610500576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f7368613220646967657374206d69736d6174636800000000000000000000000081525060200191505060405180910390fd5b7f9c1185a5c5e9fc54612808977ee8f548b2258d310000000000000000000000006003604051806000019050602060405180830381855afa158015610549573d6000803e3d6000fd5b5050506040515160601b6bffffffffffffffffffffffff1916146105d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f726d6431363020646967657374206d69736d617463680000000000000000000081525060200191505060405180910390fd5b60006001601b6040516000815260200160405260405180807f11111111111111111111111111111111111111111111111111111111111111118152506020018260ff168152602001807fb9f0bb08640d3c1c00761cdd0121209268f6fd3816bc98b9e6f3cc77bf82b698815250602001807f12ac7a61788a0fdc0e19180f14c945a8e1088a27d92a74dce81c0981fb6447448152506020019150506020604051602081039080840390855afa158015610692573d6000803e3d6000fd5b505050602060405103519050731563915e194d8cfba1943570603f7606a311550873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610753576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f65637265636f766572206d69736d61746368000000000000000000000000000081525060200191505060405180910390fd5b50565b60008273ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f1935050505015801561079e573d6000803e3d6000fd5b506107a7610810565b905092915050565b6000803373ffffffffffffffffffffffffffffffffffffffff166108fc600234816107d657fe5b049081150290604051600060405180830381858888f19350505050158015610802573d6000803e3d6000fd5b503334819150915091509091565b600047905090565b61022d806108268339019056fe6080604052600660005560405161022d38038061022d8339818101604052602081101561002b57600080fd5b810190808051906020019092919050505080600081905550506101da806100536000396000f3fe60806040526004361061003f5760003560e01c80632ccb1b301461004157806339c117a4146100b0578063b69ef8a8146100df578063e6a899b61461010a575b005b34801561004d57600080fd5b5061009a6004803603604081101561006457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610135565b6040518082815260200191505060405180910390f35b3480156100bc57600080fd5b506100c561018e565b604051808215151515815260200191505060405180910390f35b3480156100eb57600080fd5b506100f4610197565b6040518082815260200191505060405180910390f35b34801561011657600080fd5b5061011f61019f565b6040518082815260200191505060405180910390f35b60008273ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f1935050505015801561017d573d6000803e3d6000fd5b50610186610197565b905092915050565b60006001905090565b600047905090565b6000548156fea265627a7a72315820e36da559b208b35510871048d70a0d6e8f4b25035fff6508b43b8eb718e4959e64736f6c63430005100032a265627a7a72315820d93d617e67411c892e102bf050987a9d89de3c461d600c727f04c59dc88f078864736f6c63430005100032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/SubContract.bin b/runtime/near-evm-runner/tests/build/SubContract.bin deleted file mode 100644 index 54225e72d6b..00000000000 --- a/runtime/near-evm-runner/tests/build/SubContract.bin +++ /dev/null @@ -1 +0,0 @@ -6080604052600660005560405161022d38038061022d8339818101604052602081101561002b57600080fd5b810190808051906020019092919050505080600081905550506101da806100536000396000f3fe60806040526004361061003f5760003560e01c80632ccb1b301461004157806339c117a4146100b0578063b69ef8a8146100df578063e6a899b61461010a575b005b34801561004d57600080fd5b5061009a6004803603604081101561006457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610135565b6040518082815260200191505060405180910390f35b3480156100bc57600080fd5b506100c561018e565b604051808215151515815260200191505060405180910390f35b3480156100eb57600080fd5b506100f4610197565b6040518082815260200191505060405180910390f35b34801561011657600080fd5b5061011f61019f565b6040518082815260200191505060405180910390f35b60008273ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f1935050505015801561017d573d6000803e3d6000fd5b50610186610197565b905092915050565b60006001905090565b600047905090565b6000548156fea265627a7a72315820bc102b3933ad6112eb436087a67714bf08814e4c202d3118307a3e280f47b6cb64736f6c63430005100032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/TBPoolJoinExit.abi b/runtime/near-evm-runner/tests/build/TBPoolJoinExit.abi new file mode 100644 index 00000000000..8a33cf7ccaf --- /dev/null +++ b/runtime/near-evm-runner/tests/build/TBPoolJoinExit.abi @@ -0,0 +1,302 @@ +[ + { + "constant": true, + "inputs": [], + "name": "BONE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "BPOW_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "EXIT_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "INIT_POOL_SUPPLY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_IN_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_OUT_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_TOTAL_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BALANCE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "echidna_no_bug_found", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getColor", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "poolAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolTotal", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_records_t_balance", + "type": "uint256" + } + ], + "name": "joinAndExitPool", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/TBPoolJoinExit.bin b/runtime/near-evm-runner/tests/build/TBPoolJoinExit.bin new file mode 100644 index 00000000000..268dfee4a38 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/TBPoolJoinExit.bin @@ -0,0 +1 @@ +60806040526000805460ff1916600117905534801561001d57600080fd5b506108298061002d6000396000f3fe608060405234801561001057600080fd5b506004361061012e576000357c0100000000000000000000000000000000000000000000000000000000900480639a86139b116100ca578063bc694ea21161008e578063bc694ea2146101f2578063c36596a614610171578063c6580d12146101fa578063e4a28a5214610133578063ec093021146102025761012e565b80639a86139b146101ca578063b0e0d136146101d2578063b7b800a4146101da578063ba019dab146101e2578063bc063e1a146101ea5761012e565b806309a3bbe4146101335780631819aa421461014d578063189d00ca14610169578063218b5382146101715780632370e3a41461017957806376c7a3c7146101aa578063867378c5146101b25780639381cd2b146101ba578063992e2a92146101c2575b600080fd5b61013b61020a565b60408051918252519081900360200190f35b610155610217565b604080519115158252519081900360200190f35b61013b610220565b61013b610234565b6101a86004803603608081101561018f57600080fd5b5080359060208101359060408101359060600135610240565b005b61013b610317565b61013b610329565b61013b61033d565b61013b61034a565b61013b610356565b61013b61037a565b61013b61037f565b61013b610384565b61013b610389565b61013b610399565b61013b6103a5565b61013b6103aa565b6802b5e3af16b188000081565b60005460ff1681565b6402540be400670de0b6b3a76400005b0481565b670de0b6b3a764000081565b600061024d8584846103ba565b905068056bc75e2d6310000083111561026557600080fd5b670de0b6b3a764000083101561027a57600080fd5b678ac7230489e8000082111561028f57600080fd5b620f424082101561029f57600080fd5b6102a98386610436565b92506102b58282610436565b9150600081116102c457600080fd5b838310156102d157600080fd5b60006102de85858561049a565b9050808310156102ed57600080fd5b8486116102f957600080fd5b81811461030557600080fd5b50506000805460ff1916905550505050565b620f4240670de0b6b3a7640000610230565b64e8d4a51000670de0b6b3a7640000610230565b68056bc75e2d6310000081565b6704a03ce68d21555681565b7f42524f4e5a45000000000000000000000000000000000000000000000000000090565b600881565b600281565b600181565b600a670de0b6b3a7640000610230565b671bc16d674ec7ffff81565b600081565b6002670de0b6b3a7640000610230565b6000806103c78585610535565b90508061041e576040805160e560020a62461bcd02815260206004820152600f60248201527f4552525f4d4154485f415050524f580000000000000000000000000000000000604482015290519081900360640190fd5b82600061042b838361067c565b979650505050505050565b600082820183811015610493576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4144445f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b9392505050565b6000806104a885600061067c565b905060006104b6868361075e565b905060006104c48287610535565b90508061051b576040805160e560020a62461bcd02815260206004820152600f60248201527f4552525f4d4154485f415050524f580000000000000000000000000000000000604482015290519081900360640190fd5b846000610528838361067c565b9998505050505050505050565b60008161058c576040805160e560020a62461bcd02815260206004820152600c60248201527f4552525f4449565f5a45524f0000000000000000000000000000000000000000604482015290519081900360640190fd5b670de0b6b3a764000083028315806105b45750670de0b6b3a76400008482816105b157fe5b04145b610608576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4449565f494e5445524e414c00000000000000000000000000000000604482015290519081900360640190fd5b60028304810181811015610666576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4449565f494e5445524e414c00000000000000000000000000000000604482015290519081900360640190fd5b600084828161067157fe5b049695505050505050565b600082820283158061069657508284828161069357fe5b04145b6106ea576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4d554c5f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b6706f05b59d3b2000081018181101561074d576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4d554c5f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b6000670de0b6b3a764000082610671565b600080600061076d85856107cf565b9150915080156107c7576040805160e560020a62461bcd02815260206004820152601160248201527f4552525f5355425f554e444552464c4f57000000000000000000000000000000604482015290519081900360640190fd5b509392505050565b6000808284106107e557505080820360006107ed565b505081810360015b925092905056fea265627a7a723158201790844e1e2552cec4a67cc6ca52dd783178e8f791461ba35e1a0422e236dca664736f6c634300050c0032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/TBPoolJoinExitNoFee.abi b/runtime/near-evm-runner/tests/build/TBPoolJoinExitNoFee.abi new file mode 100644 index 00000000000..f47c54d1493 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/TBPoolJoinExitNoFee.abi @@ -0,0 +1,302 @@ +[ + { + "constant": true, + "inputs": [], + "name": "BONE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "BPOW_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "EXIT_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "INIT_POOL_SUPPLY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_IN_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_OUT_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_TOTAL_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BALANCE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "echidna_no_bug_found", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getColor", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "poolAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolTotal", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_records_t_balance", + "type": "uint256" + } + ], + "name": "joinAndExitNoFeePool", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/TBPoolJoinExitNoFee.bin b/runtime/near-evm-runner/tests/build/TBPoolJoinExitNoFee.bin new file mode 100644 index 00000000000..a42713dc1ac --- /dev/null +++ b/runtime/near-evm-runner/tests/build/TBPoolJoinExitNoFee.bin @@ -0,0 +1 @@ +60806040526000805460ff1916600117905534801561001d57600080fd5b506106f88061002d6000396000f3fe608060405234801561001057600080fd5b506004361061012e576000357c010000000000000000000000000000000000000000000000000000000090048063b0e0d136116100ca578063c36596a61161008e578063c36596a614610171578063c6580d12146101c9578063e15c7d42146101d1578063e4a28a5214610133578063ec093021146102025761012e565b8063b0e0d136146101a1578063b7b800a4146101a9578063ba019dab146101b1578063bc063e1a146101b9578063bc694ea2146101c15761012e565b806309a3bbe4146101335780631819aa421461014d578063189d00ca14610169578063218b53821461017157806376c7a3c714610179578063867378c5146101815780639381cd2b14610189578063992e2a92146101915780639a86139b14610199575b600080fd5b61013b61020a565b60408051918252519081900360200190f35b610155610217565b604080519115158252519081900360200190f35b61013b610220565b61013b610234565b61013b610240565b61013b610252565b61013b610266565b61013b610273565b61013b61027f565b61013b6102a3565b61013b6102a8565b61013b6102ad565b61013b6102b2565b61013b6102c2565b61013b6102ce565b610200600480360360808110156101e757600080fd5b50803590602081013590604081013590606001356102d3565b005b61013b6103aa565b6802b5e3af16b188000081565b60005460ff1681565b6402540be400670de0b6b3a76400005b0481565b670de0b6b3a764000081565b620f4240670de0b6b3a7640000610230565b64e8d4a51000670de0b6b3a7640000610230565b68056bc75e2d6310000081565b6704a03ce68d21555681565b7f42524f4e5a45000000000000000000000000000000000000000000000000000090565b600881565b600281565b600181565b600a670de0b6b3a7640000610230565b671bc16d674ec7ffff81565b600081565b60006102e08584846103ba565b905068056bc75e2d631000008311156102f857600080fd5b670de0b6b3a764000083101561030d57600080fd5b678ac7230489e8000082111561032257600080fd5b620f424082101561033257600080fd5b61033c8386610436565b92506103488282610436565b91506000811161035757600080fd5b8383101561036457600080fd5b60006103718585856103ba565b90508083101561038057600080fd5b84861161038c57600080fd5b81811461039857600080fd5b50506000805460ff1916905550505050565b6002670de0b6b3a7640000610230565b6000806103c7858561049a565b90508061041e576040805160e560020a62461bcd02815260206004820152600f60248201527f4552525f4d4154485f415050524f580000000000000000000000000000000000604482015290519081900360640190fd5b82600061042b83836105e1565b979650505050505050565b600082820183811015610493576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4144445f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b9392505050565b6000816104f1576040805160e560020a62461bcd02815260206004820152600c60248201527f4552525f4449565f5a45524f0000000000000000000000000000000000000000604482015290519081900360640190fd5b670de0b6b3a764000083028315806105195750670de0b6b3a764000084828161051657fe5b04145b61056d576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4449565f494e5445524e414c00000000000000000000000000000000604482015290519081900360640190fd5b600283048101818110156105cb576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4449565f494e5445524e414c00000000000000000000000000000000604482015290519081900360640190fd5b60008482816105d657fe5b049695505050505050565b60008282028315806105fb5750828482816105f857fe5b04145b61064f576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4d554c5f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b6706f05b59d3b200008101818110156106b2576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4d554c5f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b6000670de0b6b3a7640000826105d656fea265627a7a72315820ed2924388694d36bdbe4d7941a0e87d38ab5eeb0b511a244b36f45486e75febf64736f6c634300050c0032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/TBPoolJoinPool.abi b/runtime/near-evm-runner/tests/build/TBPoolJoinPool.abi new file mode 100644 index 00000000000..6f3372807ae --- /dev/null +++ b/runtime/near-evm-runner/tests/build/TBPoolJoinPool.abi @@ -0,0 +1,303 @@ +[ + { + "constant": true, + "inputs": [], + "name": "BONE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "BPOW_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "EXIT_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "INIT_POOL_SUPPLY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_IN_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_OUT_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_TOTAL_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BALANCE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "echidna_no_bug_found", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getColor", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "poolAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolTotal", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_records_t_balance", + "type": "uint256" + } + ], + "name": "joinPool", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/TBPoolJoinPool.bin b/runtime/near-evm-runner/tests/build/TBPoolJoinPool.bin new file mode 100644 index 00000000000..65ea9d6ab16 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/TBPoolJoinPool.bin @@ -0,0 +1 @@ +60806040526000805460ff1916600117905534801561001d57600080fd5b506106298061002d6000396000f3fe608060405234801561001057600080fd5b506004361061012e576000357c0100000000000000000000000000000000000000000000000000000000900480639a86139b116100ca578063bc694ea21161008e578063bc694ea2146101ea578063c36596a614610171578063c6580d12146101f2578063e4a28a5214610133578063ec093021146101fa5761012e565b80639a86139b146101c2578063b0e0d136146101ca578063b7b800a4146101d2578063ba019dab146101da578063bc063e1a146101e25761012e565b806309a3bbe4146101335780631819aa421461014d578063189d00ca14610169578063218b5382146101715780632e6884451461017957806376c7a3c7146101a2578063867378c5146101aa5780639381cd2b146101b2578063992e2a92146101ba575b600080fd5b61013b610202565b60408051918252519081900360200190f35b61015561020f565b604080519115158252519081900360200190f35b61013b610218565b61013b61022c565b61013b6004803603606081101561018f57600080fd5b5080359060208101359060400135610238565b61013b610328565b61013b61033a565b61013b61034e565b61013b61035b565b61013b610367565b61013b61038b565b61013b610390565b61013b610395565b61013b61039a565b61013b6103aa565b61013b6103b6565b61013b6103bb565b6802b5e3af16b188000081565b60005460ff1681565b6402540be400670de0b6b3a76400005b0481565b670de0b6b3a764000081565b600068056bc75e2d6310000083111561025057600080fd5b670de0b6b3a764000083101561026557600080fd5b678ac7230489e8000082111561027a57600080fd5b620f424082101561028a57600080fd5b600061029685856103cb565b9050806102ed576040805160e560020a62461bcd02815260206004820152600f60248201527f4552525f4d4154485f415050524f580000000000000000000000000000000000604482015290519081900360640190fd5b8260006102fa8383610512565b90506000871161030957600080fd5b801561031457600080fd5b50506000805460ff19169055509392505050565b620f4240670de0b6b3a7640000610228565b64e8d4a51000670de0b6b3a7640000610228565b68056bc75e2d6310000081565b6704a03ce68d21555681565b7f42524f4e5a45000000000000000000000000000000000000000000000000000090565b600881565b600281565b600181565b600a670de0b6b3a7640000610228565b671bc16d674ec7ffff81565b600081565b6002670de0b6b3a7640000610228565b600081610422576040805160e560020a62461bcd02815260206004820152600c60248201527f4552525f4449565f5a45524f0000000000000000000000000000000000000000604482015290519081900360640190fd5b670de0b6b3a7640000830283158061044a5750670de0b6b3a764000084828161044757fe5b04145b61049e576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4449565f494e5445524e414c00000000000000000000000000000000604482015290519081900360640190fd5b600283048101818110156104fc576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4449565f494e5445524e414c00000000000000000000000000000000604482015290519081900360640190fd5b600084828161050757fe5b049695505050505050565b600082820283158061052c57508284828161052957fe5b04145b610580576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4d554c5f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b6706f05b59d3b200008101818110156105e3576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4d554c5f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b6000670de0b6b3a76400008261050756fea265627a7a72315820f0f26278e3fc3369c41e852dd72450e07aafa81526408f333ccee8c0e34ee4c364736f6c634300050c0032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/TMath.abi b/runtime/near-evm-runner/tests/build/TMath.abi new file mode 100644 index 00000000000..14a08506688 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/TMath.abi @@ -0,0 +1,834 @@ +[ + { + "constant": true, + "inputs": [], + "name": "BONE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "BPOW_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "EXIT_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "INIT_POOL_SUPPLY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_IN_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_OUT_RATIO", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_TOTAL_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BALANCE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BOUND_TOKENS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_BPOW_BASE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_WEIGHT", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcInGivenOut", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcOutGivenIn", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalWeight", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcPoolInGivenSingleOut", + "outputs": [ + { + "internalType": "uint256", + "name": "poolAmountIn", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalWeight", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcPoolOutGivenSingleIn", + "outputs": [ + { + "internalType": "uint256", + "name": "poolAmountOut", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalWeight", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolAmountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcSingleInGivenPoolOut", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountIn", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolSupply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalWeight", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "poolAmountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcSingleOutGivenPoolIn", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenAmountOut", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "tokenBalanceIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenBalanceOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenWeightOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + } + ], + "name": "calcSpotPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "spotPrice", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getColor", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + } + ], + "name": "calc_btoi", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + } + ], + "name": "calc_bfloor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "b", + "type": "uint256" + } + ], + "name": "calc_badd", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "b", + "type": "uint256" + } + ], + "name": "calc_bsub", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "b", + "type": "uint256" + } + ], + "name": "calc_bsubSign", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "b", + "type": "uint256" + } + ], + "name": "calc_bmul", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "b", + "type": "uint256" + } + ], + "name": "calc_bdiv", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "n", + "type": "uint256" + } + ], + "name": "calc_bpowi", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "base", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "exp", + "type": "uint256" + } + ], + "name": "calc_bpow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "base", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "exp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "precision", + "type": "uint256" + } + ], + "name": "calc_bpowApprox", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/TMath.bin b/runtime/near-evm-runner/tests/build/TMath.bin new file mode 100644 index 00000000000..4a14f446467 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/TMath.bin @@ -0,0 +1 @@ +608060405234801561001057600080fd5b506110df806100206000396000f3fe608060405234801561001057600080fd5b50600436106101e3576000357c010000000000000000000000000000000000000000000000000000000090048063b0e0d13611610117578063c36596a6116100ba578063c36596a614610250578063c6580d12146104a9578063c6b3199d146104b1578063cd094b14146104ce578063e4a28a52146101e8578063ec093021146104f1578063f5f5b148146104f9578063f760324b1461051c578063f8d6aed41461053f576101e3565b8063b0e0d136146103ed578063b58d3e70146103f5578063b65fcf4014610412578063b7b800a41461044e578063ba019dab14610456578063ba9530a61461045e578063bc063e1a14610499578063bc694ea2146104a1576101e3565b806382f652ad1161018a57806382f652ad146102c45780638656b653146102ff578063867378c51461033a578063872289ab1461034257806389298012146103655780639381cd2b146103a0578063992e2a92146103a85780639a86139b146103b0578063a221ee49146103b8576101e3565b806309a3bbe4146101e8578063189d00ca146102025780631bcaf56f1461020a5780631fdee4071461022d578063218b53821461025057806331124372146102585780635c1bbaf71461028157806376c7a3c7146102bc575b600080fd5b6101f061057a565b60408051918252519081900360200190f35b6101f0610587565b6101f06004803603604081101561022057600080fd5b508035906020013561059b565b6101f06004803603604081101561024357600080fd5b50803590602001356105b0565b6101f06105bc565b6101f06004803603606081101561026e57600080fd5b50803590602081013590604001356105c8565b6101f0600480360360c081101561029757600080fd5b5080359060208101359060408101359060608101359060808101359060a001356105dd565b6101f0610695565b6101f0600480360360c08110156102da57600080fd5b5080359060208101359060408101359060608101359060808101359060a001356106a7565b6101f0600480360360c081101561031557600080fd5b5080359060208101359060408101359060608101359060808101359060a00135610766565b6101f0610807565b6101f06004803603604081101561035857600080fd5b508035906020013561081b565b6101f0600480360360c081101561037b57600080fd5b5080359060208101359060408101359060608101359060808101359060a00135610827565b6101f06108d7565b6101f06108e4565b6101f06108f0565b6101f0600480360360a08110156103ce57600080fd5b5080359060208101359060408101359060608101359060800135610914565b6101f0610979565b6101f06004803603602081101561040b57600080fd5b503561097e565b6104356004803603604081101561042857600080fd5b5080359060200135610989565b6040805192835290151560208301528051918290030190f35b6101f06109a2565b6101f06109a7565b6101f0600480360360c081101561047457600080fd5b5080359060208101359060408101359060608101359060808101359060a001356109ac565b6101f0610a2d565b6101f0610a3d565b6101f0610a49565b6101f0600480360360208110156104c757600080fd5b5035610a4e565b6101f0600480360360408110156104e457600080fd5b5080359060200135610a59565b6101f0610a65565b6101f06004803603604081101561050f57600080fd5b5080359060200135610a75565b6101f06004803603604081101561053257600080fd5b5080359060200135610a81565b6101f0600480360360c081101561055557600080fd5b5080359060208101359060408101359060608101359060808101359060a00135610a8d565b6802b5e3af16b188000081565b6402540be400670de0b6b3a76400005b0481565b60006105a78383610b10565b90505b92915050565b60006105a78383610b81565b670de0b6b3a764000081565b60006105d5848484610cc8565b949350505050565b6000806105ea8786610b81565b905060006105f88786610da6565b905060006106068289610b81565b9050600061061c670de0b6b3a764000085610b81565b9050600061062a8383610e03565b90506000610638828e610f26565b90506000610646828f610b10565b9050600061066561065f670de0b6b3a76400008a610b10565b8b610f26565b90506106828261067d670de0b6b3a764000084610b10565b610b81565b9f9e505050505050505050505050505050565b620f4240670de0b6b3a7640000610597565b6000806106b48786610b81565b905060006106ca670de0b6b3a764000083610b10565b905060006106d88286610f26565b905060006106f28761067d670de0b6b3a764000085610b10565b905060006107008c83610b10565b9050600061070e828e610b81565b9050600061071c8288610e03565b9050600061072a828e610f26565b905060006107388e83610b10565b90506107518161067d670de0b6b3a76400006000610b10565b99505050505050505050509695505050505050565b6000806107738786610b81565b9050600061079261078c670de0b6b3a764000084610b10565b85610f26565b905060006107b1866107ac670de0b6b3a764000085610b10565b610f26565b905060006107bf8b83610da6565b905060006107cd828d610b81565b905060006107db8287610e03565b905060006107e9828d610f26565b90506107f5818d610b10565b9e9d5050505050505050505050505050565b64e8d4a51000670de0b6b3a7640000610597565b60006105a78383610da6565b6000806108348786610b81565b9050600061084f856107ac670de0b6b3a76400006000610b10565b9050600061085d8883610b10565b9050600061086b828a610b81565b9050600061088a82610885670de0b6b3a764000088610b81565b610e03565b90506000610898828e610f26565b905060006108a68e83610b10565b905060006108bf61065f670de0b6b3a76400008a610b10565b9050610682826107ac670de0b6b3a764000084610b10565b68056bc75e2d6310000081565b6704a03ce68d21555681565b7f42524f4e5a45000000000000000000000000000000000000000000000000000090565b6000806109218787610b81565b9050600061092f8686610b81565b9050600061093d8383610b81565b9050600061095f670de0b6b3a764000061067d670de0b6b3a764000089610b10565b905061096b8282610f26565b9a9950505050505050505050565b600881565b60006105aa82611008565b6000806109968484611023565b915091505b9250929050565b600281565b600181565b6000806109b98786610b81565b905060006109cf670de0b6b3a764000085610b10565b90506109db8582610f26565b905060006109ed8a61067d8c85610da6565b905060006109fb8285610e03565b90506000610a11670de0b6b3a764000083610b10565b9050610a1d8a82610f26565b9c9b505050505050505050505050565b600a670de0b6b3a7640000610597565b671bc16d674ec7ffff81565b600081565b60006105aa82611045565b60006105a78383610f26565b6002670de0b6b3a7640000610597565b60006105a78383610e03565b60006105a78383611053565b600080610a9a8588610b81565b90506000610aa88786610b10565b90506000610ab68883610b81565b90506000610ac48285610e03565b9050610ad881670de0b6b3a7640000610b10565b9050610aec670de0b6b3a764000087610b10565b9450610b01610afb8c83610f26565b86610b81565b9b9a5050505050505050505050565b6000806000610b1f8585611023565b915091508015610b79576040805160e560020a62461bcd02815260206004820152601160248201527f4552525f5355425f554e444552464c4f57000000000000000000000000000000604482015290519081900360640190fd5b509392505050565b600081610bd8576040805160e560020a62461bcd02815260206004820152600c60248201527f4552525f4449565f5a45524f0000000000000000000000000000000000000000604482015290519081900360640190fd5b670de0b6b3a76400008302831580610c005750670de0b6b3a7640000848281610bfd57fe5b04145b610c54576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4449565f494e5445524e414c00000000000000000000000000000000604482015290519081900360640190fd5b60028304810181811015610cb2576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4449565f494e5445524e414c00000000000000000000000000000000604482015290519081900360640190fd5b6000848281610cbd57fe5b049695505050505050565b6000828180610cdf87670de0b6b3a7640000611023565b9092509050670de0b6b3a764000080600060015b888410610d97576000670de0b6b3a764000082029050600080610d278a610d2285670de0b6b3a7640000610b10565b611023565b91509150610d39876107ac848c610f26565b9650610d458784610b81565b965086610d5457505050610d97565b8715610d5e579315935b8015610d68579315935b8415610d7f57610d788688610b10565b9550610d8c565b610d898688610da6565b95505b505050600101610cf3565b50909998505050505050505050565b6000828201838110156105a7576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4144445f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b60006001831015610e5e576040805160e560020a62461bcd02815260206004820152601560248201527f4552525f42504f575f424153455f544f4f5f4c4f570000000000000000000000604482015290519081900360640190fd5b671bc16d674ec7ffff831115610ebe576040805160e560020a62461bcd02815260206004820152601660248201527f4552525f42504f575f424153455f544f4f5f4849474800000000000000000000604482015290519081900360640190fd5b6000610ec983611008565b90506000610ed78483610b10565b90506000610eed86610ee885611045565b611053565b905081610efe5792506105aa915050565b6000610f0f87846305f5e100610cc8565b9050610f1b8282610f26565b979650505050505050565b6000828202831580610f40575082848281610f3d57fe5b04145b610f94576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4d554c5f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b6706f05b59d3b20000810181811015610ff7576040805160e560020a62461bcd02815260206004820152601060248201527f4552525f4d554c5f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b6000670de0b6b3a764000082610cbd565b6000670de0b6b3a764000061101c83611045565b0292915050565b600080828410611039575050808203600061099b565b5050818103600161099b565b670de0b6b3a7640000900490565b6000806002830661106c57670de0b6b3a764000061106e565b835b90506002830492505b82156105a7576110878485610f26565b9350600283061561109f5761109c8185610f26565b90505b60028304925061107756fea265627a7a72315820ba5c88696fa9a89794667fd441404d301fffcf81987230fc5eda2a8253a37e0a64736f6c634300050c0032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/build/TToken.abi b/runtime/near-evm-runner/tests/build/TToken.abi new file mode 100644 index 00000000000..12a64cc0432 --- /dev/null +++ b/runtime/near-evm-runner/tests/build/TToken.abi @@ -0,0 +1,311 @@ +[ + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "uint8", + "name": "decimals", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "whom", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amt", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/runtime/near-evm-runner/tests/build/zombieAttack.bin b/runtime/near-evm-runner/tests/build/zombieAttack.bin index 3e21cb25c22..dd6826bc417 100644 --- a/runtime/near-evm-runner/tests/build/zombieAttack.bin +++ b/runtime/near-evm-runner/tests/build/zombieAttack.bin @@ -1 +1 @@ -60606040526010600155600154600a0a6002556201518060035566038d7ea4c6800060085560006009556046600a55336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506119d28061007d6000396000f3006060604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630ce90ec2146100d557806317a7f4cc146100ed5780632052465e146101195780633ccfd60b1461021d5780634412e10414610232578063528b7b8f146102c05780635f4623f1146103235780635faf28801461035c5780637bff0a01146103885780638da5cb5b146103e5578063c39cbef11461043a578063ccf670f814610471578063e1fa763814610494578063f2fde38b146104c0575b600080fd5b6100eb60048080359060200190919050506104f9565b005b34156100f857600080fd5b6101176004808035906020019091908035906020019091905050610565565b005b341561012457600080fd5b61013a60048080359060200190919050506106d2565b60405180806020018781526020018663ffffffff1663ffffffff1681526020018563ffffffff1663ffffffff1681526020018461ffff1661ffff1681526020018361ffff1661ffff1681526020018281038252888181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156102095780601f106101de57610100808354040283529160200191610209565b820191906000526020600020905b8154815290600101906020018083116101ec57829003601f168201915b505097505050505050505060405180910390f35b341561022857600080fd5b610230610758565b005b341561023d57600080fd5b610269600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061082d565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156102ac578082015181840152602081019050610291565b505050509050019250505060405180910390f35b34156102cb57600080fd5b6102e1600480803590602001909190505061095b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561032e57600080fd5b61035a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061098e565b005b341561036757600080fd5b6103866004808035906020019091908035906020019091905050610a2d565b005b341561039357600080fd5b6103e3600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610b0f565b005b34156103f057600080fd5b6103f8610b88565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561044557600080fd5b61046f60048080359060200190919080359060200190820180359060200191909192905050610bad565b005b341561047c57600080fd5b6104926004808035906020019091905050610c9b565b005b341561049f57600080fd5b6104be6004808035906020019091908035906020019091905050610d00565b005b34156104cb57600080fd5b6104f7600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610f93565b005b6008543414151561050957600080fd5b60048181548110151561051857fe5b9060005260206000209060030201600201600081819054906101000a900463ffffffff168092919060010191906101000a81548163ffffffff021916908363ffffffff1602179055505050565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e98b7f4d83600060405161014001526040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082815260200191505061014060405180830381600087803b151561060257600080fd5b6102c65a03f1151561061357600080fd5b50505060405180519060200180519060200180519060200180519060200180519060200180519060200180519060200180519060200180519060200180519050909192939495969798509091929394959697509091929394959650909192939495509091929394509091929350909192509091509050809150506106cd83826040805190810160405280600581526020017f6b697474790000000000000000000000000000000000000000000000000000008152506110e8565b505050565b6004818154811015156106e157fe5b906000526020600020906003020160009150905080600001908060010154908060020160009054906101000a900463ffffffff16908060020160049054906101000a900463ffffffff16908060020160089054906101000a900461ffff169080600201600a9054906101000a900461ffff16905086565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156107b357600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050151561082b57600080fd5b565b610835611764565b61083d611764565b600080600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460405180591061088d5750595b9080825280602002602001820160405250925060009150600090505b600480549050811015610950578473ffffffffffffffffffffffffffffffffffffffff166005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156109435780838381518110151561092c57fe5b906020019060200201818152505081806001019250505b80806001019150506108a9565b829350505050919050565b60056020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156109e957600080fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60148281600482815481101515610a4057fe5b906000526020600020906003020160020160009054906101000a900463ffffffff1663ffffffff1610151515610a7557600080fd5b836005600082815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ae357600080fd5b83600486815481101515610af357fe5b9060005260206000209060030201600101819055505050505050565b600080600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054141515610b5e57600080fd5b610b67826112bd565b9050606481811515610b7557fe5b0681039050610b84828261133f565b5050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028381600482815481101515610bc057fe5b906000526020600020906003020160020160009054906101000a900463ffffffff1663ffffffff1610151515610bf557600080fd5b846005600082815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c6357600080fd5b8484600488815481101515610c7457fe5b90600052602060002090600302016000019190610c92929190611778565b50505050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610cf657600080fd5b8060088190555050565b6000806000846005600082815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d7357600080fd5b600486815481101515610d8257fe5b90600052602060002090600302019350600485815481101515610da157fe5b90600052602060002090600302019250610dbb606461160e565b9150600a5482111515610ef157610df260018560020160089054906101000a900461ffff1661ffff166116a590919063ffffffff16565b8460020160086101000a81548161ffff021916908361ffff160217905550610e3e60018560020160009054906101000a900463ffffffff1663ffffffff166116cb90919063ffffffff16565b8460020160006101000a81548163ffffffff021916908363ffffffff160217905550610e8a600184600201600a9054906101000a900461ffff1661ffff166116a590919063ffffffff16565b83600201600a6101000a81548161ffff021916908361ffff160217905550610eec8684600101546040805190810160405280600681526020017f7a6f6d62696500000000000000000000000000000000000000000000000000008152506110e8565b610f8b565b610f1b600185600201600a9054906101000a900461ffff1661ffff166116a590919063ffffffff16565b84600201600a6101000a81548161ffff021916908361ffff160217905550610f6360018460020160089054906101000a900461ffff1661ffff166116a590919063ffffffff16565b8360020160086101000a81548161ffff021916908361ffff160217905550610f8a846116f5565b5b505050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610fee57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561102a57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080846005600082815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561115957600080fd5b60048681548110151561116857fe5b906000526020600020906003020192506111818361171f565b151561118c57600080fd5b6002548581151561119957fe5b0694506002858460010154018115156111ae57fe5b04915060405180807f6b697474790000000000000000000000000000000000000000000000000000008152506005019050604051809103902060001916846040518082805190602001908083835b60208310151561122157805182526020820191506020810190506020830392506111fc565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902060001916141561126d57606360648381151561126657fe5b0683030191505b6112ac6040805190810160405280600681526020017f4e6f4e616d6500000000000000000000000000000000000000000000000000008152508361133f565b6112b5836116f5565b505050505050565b600080826040518082805190602001908083835b6020831015156112f657805182526020820191506020810190506020830392506112d1565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206001900490506002548181151561133657fe5b06915050919050565b600060016004805480600101828161135791906117f8565b9160005260206000209060030201600060c060405190810160405280888152602001878152602001600163ffffffff168152602001600354420163ffffffff168152602001600061ffff168152602001600061ffff16815250909190915060008201518160000190805190602001906113d192919061182a565b506020820151816001015560408201518160020160006101000a81548163ffffffff021916908363ffffffff16021790555060608201518160020160046101000a81548163ffffffff021916908363ffffffff16021790555060808201518160020160086101000a81548161ffff021916908361ffff16021790555060a082015181600201600a6101000a81548161ffff021916908361ffff1602179055505050039050336005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061151a6001600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461174690919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507f88f026aacbbecc90c18411df4b1185fd8d9be2470f1962f192bf84a27d0704b78184846040518084815260200180602001838152602001828103825284818151815260200191508051906020019080838360005b838110156115cd5780820151818401526020810190506115b2565b50505050905090810190601f1680156115fa5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a1505050565b6000611626600160095461174690919063ffffffff16565b600981905550814233600954604051808481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000028152601401828152602001935050505060405180910390206001900481151561169d57fe5b069050919050565b60008082840190508361ffff168161ffff16101515156116c157fe5b8091505092915050565b60008082840190508363ffffffff168163ffffffff16101515156116eb57fe5b8091505092915050565b60035442018160020160046101000a81548163ffffffff021916908363ffffffff16021790555050565b6000428260020160049054906101000a900463ffffffff1663ffffffff1611159050919050565b600080828401905083811015151561175a57fe5b8091505092915050565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106117b957803560ff19168380011785556117e7565b828001600101855582156117e7579182015b828111156117e65782358255916020019190600101906117cb565b5b5090506117f491906118aa565b5090565b8154818355818115116118255760030281600302836000526020600020918201910161182491906118cf565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061186b57805160ff1916838001178555611899565b82800160010185558215611899579182015b8281111561189857825182559160200191906001019061187d565b5b5090506118a691906118aa565b5090565b6118cc91905b808211156118c85760008160009055506001016118b0565b5090565b90565b61195b91905b8082111561195757600080820160006118ee919061195e565b60018201600090556002820160006101000a81549063ffffffff02191690556002820160046101000a81549063ffffffff02191690556002820160086101000a81549061ffff021916905560028201600a6101000a81549061ffff0219169055506003016118d5565b5090565b90565b50805460018160011615610100020316600290046000825580601f1061198457506119a3565b601f0160209004906000526020600020908101906119a291906118aa565b5b505600a165627a7a72305820132b51da42f560f7184ac5aae47f26c9658881610ed4c49b0c5c00f7456864e60029 \ No newline at end of file +6080604052610a87806100136000396000f3fe6080604052600436106100705760003560e01c8063299fb0431161004e578063299fb043146101af5780632ccb1b30146101c65780639d9f9a6e14610235578063b69ef8a81461028657610070565b80630a84cba514610072578063111e0b12146100e757806314d54f541461015c575b005b61009e6004803603602081101561008857600080fd5b81019080803590602001909291905050506102b1565b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390f35b610113600480360360208110156100fd57600080fd5b8101908080359060200190929190505050610390565b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390f35b34801561016857600080fd5b506101956004803603602081101561017f57600080fd5b81019080803590602001909291905050506103dc565b604051808215151515815260200191505060405180910390f35b3480156101bb57600080fd5b506101c461041e565b005b3480156101d257600080fd5b5061021f600480360360408110156101e957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610756565b6040518082815260200191505060405180910390f35b61023d6107af565b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390f35b34801561029257600080fd5b5061029b610810565b6040518082815260200191505060405180910390f35b6000806000836040516102c390610818565b80828152602001915050604051809103906000f0801580156102e9573d6000803e3d6000fd5b5090508073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015610332573d6000803e3d6000fd5b508073ffffffffffffffffffffffffffffffffffffffff167fa53ffc4fb91f5ca8287e168fc73db3b0b384a6ca275650f885a1740ef7a0bc1c346040518082815260200191505060405180910390a280348191509250925050915091565b600080600034846040516103a390610818565b808281526020019150506040518091039082f0801580156103c8573d6000803e3d6000fd5b509050905080348191509250925050915091565b60007f379340f64b65a8890c7ea4f6d86d2359beaf41080f36a7ea64b78a2c06eee3f0826040518082815260200191505060405180910390a160019050919050565b7fe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8556002604051806000019050602060405180830381855afa158015610467573d6000803e3d6000fd5b5050506040513d602081101561047c57600080fd5b810190808051906020019092919050505014610500576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f7368613220646967657374206d69736d6174636800000000000000000000000081525060200191505060405180910390fd5b7f9c1185a5c5e9fc54612808977ee8f548b2258d310000000000000000000000006003604051806000019050602060405180830381855afa158015610549573d6000803e3d6000fd5b5050506040515160601b6bffffffffffffffffffffffff1916146105d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f726d6431363020646967657374206d69736d617463680000000000000000000081525060200191505060405180910390fd5b60006001601b6040516000815260200160405260405180807f11111111111111111111111111111111111111111111111111111111111111118152506020018260ff168152602001807fb9f0bb08640d3c1c00761cdd0121209268f6fd3816bc98b9e6f3cc77bf82b698815250602001807f12ac7a61788a0fdc0e19180f14c945a8e1088a27d92a74dce81c0981fb6447448152506020019150506020604051602081039080840390855afa158015610692573d6000803e3d6000fd5b505050602060405103519050731563915e194d8cfba1943570603f7606a311550873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610753576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f65637265636f766572206d69736d61746368000000000000000000000000000081525060200191505060405180910390fd5b50565b60008273ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f1935050505015801561079e573d6000803e3d6000fd5b506107a7610810565b905092915050565b6000803373ffffffffffffffffffffffffffffffffffffffff166108fc600234816107d657fe5b049081150290604051600060405180830381858888f19350505050158015610802573d6000803e3d6000fd5b503334819150915091509091565b600047905090565b61022d806108268339019056fe6080604052600660005560405161022d38038061022d8339818101604052602081101561002b57600080fd5b810190808051906020019092919050505080600081905550506101da806100536000396000f3fe60806040526004361061003f5760003560e01c80632ccb1b301461004157806339c117a4146100b0578063b69ef8a8146100df578063e6a899b61461010a575b005b34801561004d57600080fd5b5061009a6004803603604081101561006457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610135565b6040518082815260200191505060405180910390f35b3480156100bc57600080fd5b506100c561018e565b604051808215151515815260200191505060405180910390f35b3480156100eb57600080fd5b506100f4610197565b6040518082815260200191505060405180910390f35b34801561011657600080fd5b5061011f61019f565b6040518082815260200191505060405180910390f35b60008273ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f1935050505015801561017d573d6000803e3d6000fd5b50610186610197565b905092915050565b60006001905090565b600047905090565b6000548156fea265627a7a72315820f6f44f505670bac22a9333cd975c317fbaa88dc23152a224b1341fc02dd8764264736f6c63430005100032a265627a7a723158205890404b6d6a9f080f4d5156523ec567b299609c5d3e45e4baf5c0ee35c7a68764736f6c63430005100032 \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/contracts/SolTests.sol b/runtime/near-evm-runner/tests/contracts/SolTests.sol index 0e6973c4e46..cda1f28a318 100644 --- a/runtime/near-evm-runner/tests/contracts/SolTests.sol +++ b/runtime/near-evm-runner/tests/contracts/SolTests.sol @@ -78,3 +78,83 @@ contract SubContract is ExposesBalance { function () external payable {} } + +contract PrecompiledFunction { + constructor() public payable {} + + function noop() public pure { + + } + + function testSha256() public pure returns (bytes32) { + return sha256(""); + } + + function testSha256_100bytes() public pure returns (bytes32) { + return sha256("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw"); + } + + function testEcrecover() public pure returns (address) { + return ecrecover( + hex"1111111111111111111111111111111111111111111111111111111111111111", + 27, + hex"b9f0bb08640d3c1c00761cdd0121209268f6fd3816bc98b9e6f3cc77bf82b698", // r + hex"12ac7a61788a0fdc0e19180f14c945a8e1088a27d92a74dce81c0981fb644744" // s + ); + } + + function testRipemd160() public pure returns (bytes20) { + return ripemd160(""); + } + + function testRipemd160_1kb() public pure returns (bytes20) { + return ripemd160("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij"); + } + + function identity(bytes memory data) public returns (bytes memory) { + bytes memory ret = new bytes(data.length); + assembly { + let len := mload(data) + if iszero(call(gas, 0x04, 0, add(data, 0x20), len, add(ret,0x20), len)) { + invalid() + } + } + + return ret; + } + + function test_identity() public returns (bytes memory) { + return identity(""); + } + + function test_identity_100bytes() public returns (bytes memory) { + return identity("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw"); + } + + function modexp(uint base, uint e, uint m) public view returns (uint o) { + assembly { + // define pointer + let p := mload(0x40) + // store data assembly-favouring ways + mstore(p, 0x20) // Length of Base + mstore(add(p, 0x20), 0x20) // Length of Exponent + mstore(add(p, 0x40), 0x20) // Length of Modulus + mstore(add(p, 0x60), base) // Base + mstore(add(p, 0x80), e) // Exponent + mstore(add(p, 0xa0), m) // Modulus + if iszero(staticcall(sub(gas, 2000), 0x05, p, 0xc0, p, 0x20)) { + revert(0, 0) + } + // data + o := mload(p) + } + } + + function testModExp() public view returns (uint) { + return modexp(12345, 173, 101); + } + + function testBn128Add() public pure returns (uint) { + + } +} \ No newline at end of file diff --git a/runtime/near-evm-runner/tests/utils.rs b/runtime/near-evm-runner/tests/utils.rs index 30789eb9971..d25d7ce3aab 100644 --- a/runtime/near-evm-runner/tests/utils.rs +++ b/runtime/near-evm-runner/tests/utils.rs @@ -42,9 +42,15 @@ pub fn create_context<'a>( 0, 10u64.pow(14), false, + 1_000_000_000.into(), ) } +#[cfg(test)] +pub fn show_evm_gas_used(context: &EvmContext) { + println!("Accumulated EVM gas used: {}", &context.evm_gas_counter.used_gas); +} + /// Linter is suboptimal, because doesn't see that this is used in standard_ops.rs. #[allow(dead_code)] pub fn public_key_to_address(public_key: PublicKey) -> Address { diff --git a/runtime/near-runtime-fees/src/lib.rs b/runtime/near-runtime-fees/src/lib.rs index f357c2d3456..8d004a87c05 100644 --- a/runtime/near-runtime-fees/src/lib.rs +++ b/runtime/near-runtime-fees/src/lib.rs @@ -8,6 +8,7 @@ use serde::{Deserialize, Serialize}; pub type Balance = u128; pub type Gas = u64; +pub type EvmGas = u64; /// The amount is 1000 * 10e24 = 1000 NEAR. const EVM_DEPOSIT: Balance = 1_000_000_000_000_000_000_000_000_000; @@ -72,6 +73,10 @@ pub struct RuntimeFeesConfig { /// Pessimistic gas price inflation ratio. pub pessimistic_gas_price_inflation_ratio: Rational, + /// Describes cost of running method of evm, include deploy code and call contract function + pub evm_config: EvmCostConfig, + + /// New EVM deposit. /// Fee to create new EVM account. #[serde(with = "u128_dec_format", default = "default_evm_deposit")] pub evm_deposit: Balance, @@ -147,6 +152,27 @@ pub struct StorageUsageConfig { pub num_extra_bytes_record: u64, } +/// Describe cost of evm +#[derive(Debug, Serialize, Deserialize, Clone, Hash, PartialEq, Eq)] +pub struct EvmCostConfig { + /// Base cost of instantiate an evm instance for any evm operation + pub bootstrap_cost: Gas, + /// For every unit of gas used by evm in deploy evm contract, equivalent near gas cost + pub deploy_cost_per_evm_gas: Gas, + /// For every byte of evm contract, result near gas cost + pub deploy_cost_per_byte: Gas, + /// For bootstrapped evm, base cost to invoke a contract function + pub funcall_cost_base: Gas, + /// For every unit of gas used by evm in funcall, equivalent near gas cost + pub funcall_cost_per_evm_gas: Gas, + /// Evm precompiled function costs, note cost is in evm gas unit. + pub ecrecover_cost: EvmGas, + pub sha256_cost: EvmGas, + pub ripemd160_cost: EvmGas, + pub identity_cost: EvmGas, + pub modexp_cost: EvmGas, +} + impl Default for RuntimeFeesConfig { fn default() -> Self { #[allow(clippy::unreadable_literal)] @@ -240,6 +266,21 @@ impl Default for RuntimeFeesConfig { }, burnt_gas_reward: Rational::new(3, 10), pessimistic_gas_price_inflation_ratio: Rational::new(103, 100), + evm_config: EvmCostConfig { + // Got inside emu-cost docker, numbers differ slightly in different runs: + // cd /host/nearcore/runtime/near-evm-runner/tests + // ../../runtime-params-estimator/emu-cost/counter_plugin/qemu-x86_64 -cpu Westmere-v1 -plugin file=../../runtime-params-estimator/emu-cost/counter_plugin/libcounter.so ../../../target/release/runtime-params-estimator --home /tmp/data --accounts-num 200000 --iters 1 --warmup-iters 1 --evm-only + bootstrap_cost: 373945633846, + deploy_cost_per_evm_gas: 3004467, + deploy_cost_per_byte: 2732257, + funcall_cost_base: 300126401250, + funcall_cost_per_evm_gas: 116076934, + ecrecover_cost: 2418, + sha256_cost: 56, + ripemd160_cost: 52, + identity_cost: 115, + modexp_cost: 90, + }, evm_deposit: EVM_DEPOSIT, } } @@ -276,6 +317,18 @@ impl RuntimeFeesConfig { }, burnt_gas_reward: Rational::from_integer(0), pessimistic_gas_price_inflation_ratio: Rational::from_integer(0), + evm_config: EvmCostConfig { + bootstrap_cost: 0, + deploy_cost_per_evm_gas: 0, + deploy_cost_per_byte: 0, + funcall_cost_base: 0, + funcall_cost_per_evm_gas: 0, + ecrecover_cost: 0, + sha256_cost: 0, + ripemd160_cost: 0, + identity_cost: 0, + modexp_cost: 0, + }, evm_deposit: 0, } } diff --git a/runtime/near-vm-errors/Cargo.toml b/runtime/near-vm-errors/Cargo.toml index 3bdefd976e1..483461ddc98 100644 --- a/runtime/near-vm-errors/Cargo.toml +++ b/runtime/near-vm-errors/Cargo.toml @@ -20,5 +20,7 @@ borsh = "0.7.1" near-rpc-error-macro = { path = "../../tools/rpctypegen/macro", version = "0.1.0" } +ethereum-types = "0.6.0" + [features] dump_errors_schema = ["near-rpc-error-macro/dump_errors_schema"] diff --git a/runtime/near-vm-logic/src/gas_counter.rs b/runtime/near-vm-logic/src/gas_counter.rs index 7a99702f271..557f7dcf7a0 100644 --- a/runtime/near-vm-logic/src/gas_counter.rs +++ b/runtime/near-vm-logic/src/gas_counter.rs @@ -1,12 +1,24 @@ use crate::config::{ActionCosts, ExtCosts, ExtCostsConfig}; use crate::types::{Gas, ProfileData}; use crate::{HostError, VMLogicError}; -use near_runtime_fees::Fee; +use near_runtime_fees::{EvmGas, Fee}; #[cfg(feature = "costs_counting")] thread_local! { pub static EXT_COSTS_COUNTER: std::cell::RefCell> = Default::default(); + + pub static EVM_GAS_COUNTER: std::cell::RefCell = Default::default(); +} + +#[cfg(feature = "costs_counting")] +pub fn reset_evm_gas_counter() -> u64 { + let mut ret = 0; + EVM_GAS_COUNTER.with(|f| { + ret = *f.borrow(); + *f.borrow_mut() = 0; + }); + ret } type Result = ::std::result::Result; @@ -26,6 +38,13 @@ pub struct GasCounter { profile: Option, } +use std::fmt; +impl fmt::Debug for GasCounter { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("").finish() + } +} + impl GasCounter { pub fn new( ext_costs_config: ExtCostsConfig, @@ -73,6 +92,18 @@ impl GasCounter { } } + #[cfg(feature = "costs_counting")] + #[inline] + pub fn inc_evm_gas_counter(&mut self, value: EvmGas) { + EVM_GAS_COUNTER.with(|f| { + *f.borrow_mut() += value; + }) + } + + #[cfg(not(feature = "costs_counting"))] + #[inline] + pub fn inc_evm_gas_counter(&mut self, _value: EvmGas) {} + #[cfg(feature = "costs_counting")] #[inline] fn inc_ext_costs_counter(&mut self, cost: ExtCosts, value: u64) { @@ -117,6 +148,10 @@ impl GasCounter { self.deduct_gas(value, value) } + pub fn pay_evm_gas(&mut self, value: u64) -> Result<()> { + self.deduct_gas(value, value) + } + /// A helper function to pay per byte gas pub fn pay_per_byte(&mut self, cost: ExtCosts, num_bytes: u64) -> Result<()> { let use_gas = num_bytes diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index fe54ea0bf1c..768697b6274 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -23,6 +23,7 @@ anyhow = { version = "1.0.19", optional = true } near-runtime-fees = { path="../near-runtime-fees", version = "2.2.0" } near-vm-logic = { path="../near-vm-logic", version = "2.2.0", default-features = false, features = []} near-vm-errors = { path = "../near-vm-errors", version = "2.2.0" } +near-evm-runner = { path = "../near-evm-runner", version = "2.2.0"} [dev-dependencies] assert_matches = "1.3" diff --git a/runtime/runtime-params-estimator/Cargo.toml b/runtime/runtime-params-estimator/Cargo.toml index 9c002b643ef..88cf5b86a17 100644 --- a/runtime/runtime-params-estimator/Cargo.toml +++ b/runtime/runtime-params-estimator/Cargo.toml @@ -22,13 +22,23 @@ near-runtime-fees = { path = "../../runtime/near-runtime-fees" } near-crypto = { path = "../../core/crypto" } near-vm-logic = {path = "../../runtime/near-vm-logic" , features = ["costs_counting"]} near-vm-runner = {path = "../../runtime/near-vm-runner" , features = ["costs_counting", "no_cache", "no_cpu_compatibility_checks", "wasmtime_vm" ]} -node-runtime = { path = "../../runtime/runtime" , features = ["costs_counting", "no_cache"]} +node-runtime = { path = "../../runtime/runtime" , features = ["costs_counting", "no_cache", "protocol_feature_evm"]} near-store = { path = "../../core/store", features = ["no_cache", "single_thread_rocksdb"]} -near-primitives = { path = "../../core/primitives" } +near-primitives = { path = "../../core/primitives", features = ["protocol_feature_evm", "protocol_feature_forward_chunk_parts", "nightly_protocol"] } +testlib = { path = "../../test-utils/testlib" } +state-viewer = { path = "../../test-utils/state-viewer" } neard = { path = "../../neard" } rocksdb = { git = "https://github.com/nearprotocol/rust-rocksdb", branch="disable-thread" } glob = "0.3.0" walrus = "0.18.0" +near-evm-runner = { path = "../../runtime/near-evm-runner", features = ["costs_counting"] } +hex = "0.4" +ethabi = "8.0.0" +ethabi-contract = "8.0.0" +ethabi-derive = "8.0.0" +ethereum-types = "0.6.0" +lazy-static-include = "2.2.2" +num-traits = "0.2.12" [features] default = [] diff --git a/runtime/runtime-params-estimator/src/cases.rs b/runtime/runtime-params-estimator/src/cases.rs index 12f759db827..b8670b5d2d3 100644 --- a/runtime/runtime-params-estimator/src/cases.rs +++ b/runtime/runtime-params-estimator/src/cases.rs @@ -1,4 +1,5 @@ use num_rational::Ratio; +use num_traits::cast::FromPrimitive; use rand::seq::SliceRandom; use rand::{Rng, SeedableRng}; use std::cell::RefCell; @@ -20,7 +21,9 @@ use crate::stats::Measurements; use crate::testbed::RuntimeTestbed; use crate::testbed_runners::GasMetric; use crate::testbed_runners::{get_account_id, measure_actions, measure_transactions, Config}; -use crate::vm_estimator::{cost_per_op, cost_to_compile, load_and_compile}; +use crate::vm_estimator::{ + cost_of_evm, cost_per_op, cost_to_compile, load_and_compile, near_cost_to_evm_gas, +}; use near_runtime_fees::{ AccessKeyCreationConfig, ActionCreationConfig, DataReceiptCreationConfig, Fee, RuntimeFeesConfig, @@ -146,9 +149,11 @@ pub enum Metric { data_receipt_10b_1000, data_receipt_100kib_1000, cpu_ram_soak_test, + + deploy_evm_contract, } -pub fn run(mut config: Config, only_compile: bool) -> RuntimeConfig { +pub fn run(mut config: Config, only_compile: bool, only_evm: bool) -> RuntimeConfig { let mut m = Measurements::new(config.metric); if only_compile { let (contract_compile_cost, contract_compile_base_cost) = @@ -159,6 +164,67 @@ pub fn run(mut config: Config, only_compile: bool) -> RuntimeConfig { contract_byte_cost, ratio_to_gas(config.metric, contract_compile_base_cost) ); + process::exit(0); + } else if only_evm { + config.block_sizes = vec![100]; + let cost = cost_of_evm(&config, true); + println!( + "EVM base deploy (and init evm instance) cost: {}, deploy cost per EVM gas: {}, deploy cost per byte: {}", + ratio_to_gas(config.metric, Ratio::::from_f64(cost.deploy_cost.2).unwrap()), + ratio_to_gas(config.metric, Ratio::::from_f64(cost.deploy_cost.0).unwrap()), + ratio_to_gas(config.metric, Ratio::::from_f64(cost.deploy_cost.1).unwrap()), + ); + println!( + "EVM base function call cost: {}, function call cost per EVM gas: {}", + ratio_to_gas(config.metric, cost.funcall_cost.1), + ratio_to_gas(config.metric, cost.funcall_cost.0), + ); + println!("EVM precompiled function evm gas:"); + println!( + "ecrecover: {}", + near_cost_to_evm_gas(cost.funcall_cost, cost.precompiled_function_cost.ec_recover_cost) + ); + println!( + "sha256: {}", + near_cost_to_evm_gas(cost.funcall_cost, cost.precompiled_function_cost.sha256_cost) + ); + println!( + "sha256 per byte: {}", + near_cost_to_evm_gas( + cost.funcall_cost, + cost.precompiled_function_cost.sha256_cost_per_byte + ) + ); + println!( + "ripemd160: {}", + near_cost_to_evm_gas(cost.funcall_cost, cost.precompiled_function_cost.ripemd160_cost) + ); + println!( + "ripemd160 per byte: {}", + near_cost_to_evm_gas( + cost.funcall_cost, + cost.precompiled_function_cost.ripemd160_cost_per_byte + ) + ); + println!( + "identity: {}", + near_cost_to_evm_gas(cost.funcall_cost, cost.precompiled_function_cost.identity_cost) + ); + println!( + "identity per byte: {}", + near_cost_to_evm_gas( + cost.funcall_cost, + cost.precompiled_function_cost.identity_cost_per_byte + ) + ); + println!( + "modexp: {}", + near_cost_to_evm_gas( + cost.funcall_cost, + cost.precompiled_function_cost.modexp_impl_cost + ) + ); + process::exit(0); } config.block_sizes = vec![100]; diff --git a/runtime/runtime-params-estimator/src/main.rs b/runtime/runtime-params-estimator/src/main.rs index 4ff7df436d2..0d5d3aa60e6 100644 --- a/runtime/runtime-params-estimator/src/main.rs +++ b/runtime/runtime-params-estimator/src/main.rs @@ -71,6 +71,7 @@ fn main() { .long("transaction") .help("Disables transaction measurements"), ) + .arg(Arg::with_name("evm-only").long("evm-only").help("only test evm related cost")) .get_matches(); let state_dump_path = matches.value_of("home").unwrap().to_string(); @@ -102,6 +103,7 @@ fn main() { disable_measure_transaction, }, matches.is_present("compile-only"), + matches.is_present("evm-only"), ); println!("Generated RuntimeConfig:"); diff --git a/runtime/runtime-params-estimator/src/testbed.rs b/runtime/runtime-params-estimator/src/testbed.rs index 784231e63a0..b3c65d16b36 100644 --- a/runtime/runtime-params-estimator/src/testbed.rs +++ b/runtime/runtime-params-estimator/src/testbed.rs @@ -4,6 +4,7 @@ use std::path::Path; use borsh::BorshDeserialize; +use near_chain_configs::Genesis; use near_primitives::receipt::Receipt; use near_primitives::test_utils::MockEpochInfoProvider; use near_primitives::transaction::{ExecutionStatus, SignedTransaction}; @@ -23,9 +24,10 @@ pub struct RuntimeTestbed { /// Directory where we temporarily keep the storage. #[allow(dead_code)] workdir: tempfile::TempDir, - tries: ShardTries, - root: MerkleHash, - runtime: Runtime, + pub tries: ShardTries, + pub root: MerkleHash, + pub runtime: Runtime, + pub genesis: Genesis, prev_receipts: Vec, apply_state: ApplyState, epoch_info_provider: MockEpochInfoProvider, @@ -39,6 +41,7 @@ impl RuntimeTestbed { let store = create_store(&get_store_path(workdir.path())); let tries = ShardTries::new(store.clone(), 1); + let genesis = Genesis::from_file(dump_dir.join("genesis.json")); let mut state_file = dump_dir.to_path_buf(); state_file.push(STATE_DUMP_FILE); store.load_from_file(ColState, state_file.as_path()).expect("Failed to read state dump"); @@ -98,6 +101,7 @@ impl RuntimeTestbed { prev_receipts, apply_state, epoch_info_provider: MockEpochInfoProvider::default(), + genesis, } } diff --git a/runtime/runtime-params-estimator/src/testbed_runners.rs b/runtime/runtime-params-estimator/src/testbed_runners.rs index 67fa26e2afc..c4c40958cf7 100644 --- a/runtime/runtime-params-estimator/src/testbed_runners.rs +++ b/runtime/runtime-params-estimator/src/testbed_runners.rs @@ -18,7 +18,7 @@ pub fn get_account_id(account_index: usize) -> String { } /// Total number of transactions that we need to prepare. -fn total_transactions(config: &Config) -> usize { +pub fn total_transactions(config: &Config) -> usize { config.block_sizes.iter().sum::() * config.iter_per_block } diff --git a/runtime/runtime-params-estimator/src/vm_estimator.rs b/runtime/runtime-params-estimator/src/vm_estimator.rs index 80aacbcd422..75e6dbc3233 100644 --- a/runtime/runtime-params-estimator/src/vm_estimator.rs +++ b/runtime/runtime-params-estimator/src/vm_estimator.rs @@ -1,19 +1,42 @@ +use crate::testbed::RuntimeTestbed; use crate::testbed_runners::end_count; +use crate::testbed_runners::get_account_id; use crate::testbed_runners::start_count; +use crate::testbed_runners::total_transactions; +use crate::testbed_runners::Config; use crate::testbed_runners::GasMetric; +use ethabi_contract::use_contract; +use ethereum_types::H160; use glob::glob; +use indicatif::{ProgressBar, ProgressStyle}; +use lazy_static_include::lazy_static_include_str; +use near_crypto::{InMemorySigner, KeyType}; +use near_evm_runner::utils::encode_call_function_args; +use near_evm_runner::EvmContext; +use near_primitives::hash::CryptoHash; +use near_primitives::transaction::{Action, FunctionCallAction, SignedTransaction}; use near_primitives::version::PROTOCOL_VERSION; use near_runtime_fees::RuntimeFeesConfig; +use near_vm_logic::gas_counter::reset_evm_gas_counter; use near_vm_logic::mocks::mock_external::MockedExternal; use near_vm_logic::{VMConfig, VMContext, VMKind, VMOutcome}; use near_vm_runner::{compile_module, prepare, VMError}; use num_rational::Ratio; +use num_traits::cast::ToPrimitive; +use rand::Rng; +use rocksdb::Env; use std::collections::hash_map::DefaultHasher; +use std::collections::{HashMap, HashSet}; +use std::convert::TryFrom; use std::fs; +use std::sync::{Arc, Mutex, RwLock}; use std::{ hash::{Hash, Hasher}, + path::Path, path::PathBuf, }; +use testlib::node::{Node, RuntimeNode}; +use testlib::user::runtime_user::MockClient; use walrus::{Module, Result}; const CURRENT_ACCOUNT_ID: &str = "alice"; @@ -135,11 +158,570 @@ pub fn load_and_compile( } } +#[derive(Debug)] +pub struct EvmCost { + pub evm_gas: u64, + pub size: u64, + pub cost: Ratio, +} + +fn testbed_for_evm( + state_dump_path: &str, + accounts: usize, +) -> (Arc>, Arc>>) { + let path = PathBuf::from(state_dump_path); + let testbed = Arc::new(Mutex::new(RuntimeTestbed::from_state_dump(&path))); + let mut nonces: HashMap = HashMap::new(); + let bar = ProgressBar::new(accounts as _); + println!("Prepare a testbed of {} accounts all having a deployed evm contract", accounts); + bar.set_style(ProgressStyle::default_bar().template( + "[elapsed {elapsed_precise} remaining {eta_precise}] Evm contracts {bar} {pos:>7}/{len:7} {msg}", + )); + let mut env = Env::default().unwrap(); + env.set_background_threads(4); + for account_idx in 0..accounts { + let account_id = get_account_id(account_idx); + let signer = InMemorySigner::from_seed(&account_id, KeyType::ED25519, &account_id); + let code = hex::decode(&TEST).unwrap(); + let nonce = *nonces.entry(account_idx).and_modify(|x| *x += 1).or_insert(1); + + let block: Vec<_> = vec![SignedTransaction::from_actions( + nonce as u64, + account_id.clone(), + "evm".to_owned(), + &signer, + vec![Action::FunctionCall(FunctionCallAction { + method_name: "deploy_code".to_string(), + args: code, + gas: 10u64.pow(18), + deposit: 0, + })], + CryptoHash::default(), + )]; + let mut testbed = testbed.lock().unwrap(); + testbed.process_block(&block, false); + testbed.process_blocks_until_no_receipts(false); + bar.inc(1); + } + bar.finish(); + reset_evm_gas_counter(); + env.set_background_threads(0); + (testbed, Arc::new(Mutex::new(nonces))) +} + +fn deploy_evm_contract( + code: &[u8], + config: &Config, + testbed: Arc>, + nonces: Arc>>, +) -> Option { + let path = PathBuf::from(config.state_dump_path.as_str()); + println!("{:?}. Preparing testbed. Loading state.", config.metric); + let allow_failures = false; + let mut nonces = nonces.lock().unwrap(); + let mut accounts_deployed = HashSet::new(); + + let mut f = || { + let account_idx = loop { + let x = rand::thread_rng().gen::() % config.active_accounts; + if accounts_deployed.contains(&x) { + continue; + } + break x; + }; + accounts_deployed.insert(account_idx); + let account_id = get_account_id(account_idx); + let signer = InMemorySigner::from_seed(&account_id, KeyType::ED25519, &account_id); + + let nonce = *nonces.entry(account_idx).and_modify(|x| *x += 1).or_insert(1); + SignedTransaction::from_actions( + nonce as u64, + account_id.clone(), + "evm".to_owned(), + &signer, + vec![Action::FunctionCall(FunctionCallAction { + method_name: "deploy_code".to_string(), + args: hex::decode(code).unwrap(), + gas: 10u64.pow(18), + deposit: 0, + })], + CryptoHash::default(), + ) + }; + + for _ in 0..config.warmup_iters_per_block { + for block_size in config.block_sizes.clone() { + let block: Vec<_> = (0..block_size).map(|_| f()).collect(); + let mut testbed = testbed.lock().unwrap(); + testbed.process_block(&block, allow_failures); + testbed.process_blocks_until_no_receipts(allow_failures); + } + } + reset_evm_gas_counter(); + let mut evm_gas = 0; + let mut total_cost = 0; + for _ in 0..config.iter_per_block { + for block_size in config.block_sizes.clone() { + let block: Vec<_> = (0..block_size).map(|_| f()).collect(); + let mut testbed = testbed.lock().unwrap(); + testbed.process_block(&block, allow_failures); + // process_block create action receipt for FunctionCall Action, not count as gas used in evm. + // In real node, action receipt cost is deducted in validate_tx -> tx_cost so should only count + // and deduct evm execution cost + let start = start_count(config.metric); + testbed.process_blocks_until_no_receipts(allow_failures); + let cost = end_count(config.metric, &start); + total_cost += cost; + evm_gas += reset_evm_gas_counter(); + } + } + + let counts = total_transactions(config) as u64; + evm_gas /= counts; + + Some(EvmCost { evm_gas, size: code.len() as u64, cost: Ratio::new(total_cost, counts) }) +} + +fn load_and_deploy_evm_contract( + path: &PathBuf, + config: &Config, + testbed: Arc>, + nonces: Arc>>, +) -> Option { + match fs::read(path) { + Ok(code) => deploy_evm_contract(&code, config, testbed, nonces), + _ => None, + } +} + #[cfg(feature = "lightbeam")] const USING_LIGHTBEAM: bool = true; #[cfg(not(feature = "lightbeam"))] const USING_LIGHTBEAM: bool = false; +type Coef = (Ratio, Ratio); + +type Coef2D = (f64, f64, f64); + +pub struct EvmPrecompiledFunctionCost { + pub ec_recover_cost: Ratio, + pub sha256_cost: Ratio, + pub sha256_cost_per_byte: Ratio, + pub ripemd160_cost: Ratio, + pub ripemd160_cost_per_byte: Ratio, + pub identity_cost: Ratio, + pub identity_cost_per_byte: Ratio, + pub modexp_impl_cost: Ratio, + // pub bn128AddImplCost: Ratio, + // pub bn128MulImplCost: Ratio, + // pub bn128PairingImplCost: Ratio, + // pub blake2FImplCost: Ratio, + // pub lastPrecompileCost: Ratio, +} + +pub struct EvmCostCoef { + pub deploy_cost: Coef2D, + pub funcall_cost: Coef, + pub precompiled_function_cost: EvmPrecompiledFunctionCost, +} + +pub fn measure_evm_deploy( + config: &Config, + verbose: bool, + testbed: Arc>, + nonces: Arc>>, +) -> Coef2D { + let globbed_files = glob("./**/*.bin").expect("Failed to read glob pattern for bin files"); + let paths = globbed_files + .filter_map(|x| match x { + Ok(p) => Some(p), + _ => None, + }) + .collect::>(); + + let measurements = paths + .iter() + .filter(|path| fs::metadata(path).is_ok()) + .map(|path| { + if verbose { + print!("Testing {}: ", path.display()); + }; + // Evm counted gas already count on size of the contract, therefore we look for cost = m*evm_gas + b. + if let Some(EvmCost { evm_gas, size, cost }) = + load_and_deploy_evm_contract(path, config, testbed.clone(), nonces.clone()) + { + if verbose { + println!("({}, {}, {}),", evm_gas, size, cost); + }; + Some(EvmCost { evm_gas, size, cost }) + } else { + if verbose { + println!("FAILED") + }; + None + } + }) + .filter(|x| x.is_some()) + .map(|x| x.unwrap()) + .collect::>(); + measurements_to_coef_2d(measurements, true) +} + +use_contract!(soltest, "../near-evm-runner/tests/build/SolTests.abi"); +use_contract!(precompiled_function, "../near-evm-runner/tests/build/PrecompiledFunction.abi"); + +lazy_static_include_str!(TEST, "../near-evm-runner/tests/build/SolTests.bin"); +lazy_static_include_str!( + PRECOMPILED_TEST, + "../near-evm-runner/tests/build/PrecompiledFunction.bin" +); + +const CHAIN_ID: u128 = 0x99; + +pub fn create_evm_context<'a>( + external: &'a mut MockedExternal, + vm_config: &'a VMConfig, + fees_config: &'a RuntimeFeesConfig, + account_id: String, + attached_deposit: u128, +) -> EvmContext<'a> { + EvmContext::new( + external, + CHAIN_ID, + vm_config, + fees_config, + 1000, + account_id.to_string(), + account_id.to_string(), + account_id.to_string(), + attached_deposit, + 0, + 10u64.pow(14), + false, + 100_000_000.into(), + ) +} + +pub fn measure_evm_funcall( + config: &Config, + verbose: bool, + testbed: Arc>, + nonces: Arc>>, +) -> Coef { + let measurements = vec![ + measure_evm_function( + config, + verbose, + |sol_test_addr| { + vec![sol_test_addr, soltest::functions::deploy_new_guy::call(8).0].concat() + }, + "deploy_new_guy(8)", + testbed.clone(), + nonces.clone(), + ), + measure_evm_function( + config, + verbose, + |sol_test_addr| { + vec![sol_test_addr, soltest::functions::pay_new_guy::call(8).0].concat() + }, + "pay_new_guy(8)", + testbed.clone(), + nonces.clone(), + ), + measure_evm_function( + config, + verbose, + |sol_test_addr| { + vec![sol_test_addr, soltest::functions::return_some_funds::call().0].concat() + }, + "return_some_funds()", + testbed.clone(), + nonces.clone(), + ), + measure_evm_function( + config, + verbose, + |sol_test_addr| vec![sol_test_addr, soltest::functions::emit_it::call(8).0].concat(), + "emit_it(8)", + testbed.clone(), + nonces.clone(), + ), + ]; + println!("{:?}", measurements); + measurements_to_coef(measurements, true) +} + +pub fn measure_evm_precompile_function( + config: &Config, + verbose: bool, + context: &mut EvmContext, + args: Vec, + test_name: &str, +) -> EvmCost { + // adding action receipt etc is too big compare too evm precompile function itself and cause the error is bigger + // than evm precompile function cost, so measure this cost in evm context level to be precise + let gas_metric = config.metric; + let start = start_count(gas_metric); + let mut evm_gas = 0; + for i in 0..NUM_ITERATIONS { + if i == 0 { + evm_gas = context.evm_gas_counter.used_gas.as_u64(); + } else if i == 1 { + evm_gas = context.evm_gas_counter.used_gas.as_u64() - evm_gas; + } + let _ = context.call_function(args.clone()).unwrap(); + } + let end = end_count(gas_metric, &start); + let cost = Ratio::new(end, NUM_ITERATIONS); + if verbose { + println!("Testing call {}: ({}, {})", test_name, evm_gas, cost); + } + EvmCost { size: 0, evm_gas, cost } +} + +pub fn measure_evm_function) -> Vec + Copy>( + config: &Config, + verbose: bool, + args_encoder: F, + test_name: &str, + testbed: Arc>, + nonces: Arc>>, +) -> EvmCost { + let path = PathBuf::from(config.state_dump_path.as_str()); + println!("{:?}. Preparing testbed. Loading state.", config.metric); + let allow_failures = false; + let mut nonces = nonces.lock().unwrap(); + let mut accounts_deployed = HashSet::new(); + let code = hex::decode(&TEST).unwrap(); + + let mut f = || { + let account_idx = loop { + let x = rand::thread_rng().gen::() % config.active_accounts; + if accounts_deployed.contains(&x) { + continue; + } + break x; + }; + accounts_deployed.insert(account_idx); + let account_id = get_account_id(account_idx); + let signer = InMemorySigner::from_seed(&account_id, KeyType::ED25519, &account_id); + + let mut testbed = testbed.lock().unwrap(); + let runtime_node = RuntimeNode { + signer: Arc::new(signer.clone()), + client: Arc::new(RwLock::new(MockClient { + runtime: testbed.runtime, + runtime_config: testbed.genesis.config.runtime_config.clone(), + tries: testbed.tries.clone(), + state_root: testbed.root, + epoch_length: testbed.genesis.config.epoch_length, + })), + genesis: testbed.genesis.clone(), + }; + let node_user = runtime_node.user(); + let nonce = *nonces.entry(account_idx).and_modify(|x| *x += 1).or_insert(1); + let addr = node_user + .function_call( + account_id.clone(), + "evm".to_string(), + "deploy_code", + code.clone(), + 10u64.pow(14), + 10, + ) + .unwrap() + .status + .as_success_decoded() + .unwrap(); + + testbed.tries = runtime_node.client.read().unwrap().tries.clone(); + testbed.root = runtime_node.client.read().unwrap().state_root; + testbed.runtime = runtime_node.client.read().unwrap().runtime; + + let nonce = *nonces.entry(account_idx).and_modify(|x| *x += 1).or_insert(1); + SignedTransaction::from_actions( + nonce as u64, + account_id.clone(), + "evm".to_owned(), + &signer, + vec![Action::FunctionCall(FunctionCallAction { + method_name: "call_function".to_string(), + args: args_encoder(addr), + gas: 10u64.pow(18), + deposit: 0, + })], + CryptoHash::default(), + ) + }; + + for _ in 0..config.warmup_iters_per_block { + for block_size in config.block_sizes.clone() { + let block: Vec<_> = (0..block_size).map(|_| f()).collect(); + let mut testbed = testbed.lock().unwrap(); + testbed.process_block(&block, allow_failures); + testbed.process_blocks_until_no_receipts(allow_failures); + } + } + reset_evm_gas_counter(); + let mut evm_gas = 0; + let mut total_cost = 0; + for _ in 0..config.iter_per_block { + for block_size in config.block_sizes.clone() { + let block: Vec<_> = (0..block_size).map(|_| f()).collect(); + let mut testbed = testbed.lock().unwrap(); + testbed.process_block(&block, allow_failures); + let start = start_count(config.metric); + testbed.process_blocks_until_no_receipts(allow_failures); + let cost = end_count(config.metric, &start); + total_cost += cost; + evm_gas += reset_evm_gas_counter(); + } + } + + let counts = total_transactions(config) as u64; + evm_gas /= counts; + + let cost = Ratio::new(total_cost, counts); + if verbose { + println!("Testing call {}: ({}, {})", test_name, evm_gas, cost); + } + EvmCost { evm_gas, size: 0, cost } +} + +pub fn measure_evm_precompiled(config: &Config, verbose: bool) -> EvmPrecompiledFunctionCost { + let mut fake_external = MockedExternal::new(); + let vm_config = VMConfig::default(); + let fees = RuntimeFeesConfig::default(); + + let mut context = + create_evm_context(&mut fake_external, &vm_config, &fees, "alice".to_string(), 0); + let precompiled_function_addr = + context.deploy_code(hex::decode(&PRECOMPILED_TEST).unwrap()).unwrap(); + + let measurements = vec![ + measure_evm_precompile_function( + config, + verbose, + &mut context, + encode_call_function_args( + precompiled_function_addr, + precompiled_function::functions::noop::call().0, + ), + "noop()", + ), + measure_evm_precompile_function( + config, + verbose, + &mut context, + encode_call_function_args( + precompiled_function_addr, + precompiled_function::functions::test_ecrecover::call().0, + ), + "test_ecrecover()", + ), + measure_evm_precompile_function( + config, + verbose, + &mut context, + encode_call_function_args( + precompiled_function_addr, + precompiled_function::functions::test_sha256::call().0, + ), + "test_sha256()", + ), + measure_evm_precompile_function( + config, + verbose, + &mut context, + encode_call_function_args( + precompiled_function_addr, + precompiled_function::functions::test_sha256_100bytes::call().0, + ), + "test_sha256_100bytes()", + ), + measure_evm_precompile_function( + config, + verbose, + &mut context, + encode_call_function_args( + precompiled_function_addr, + precompiled_function::functions::test_ripemd160::call().0, + ), + "test_ripemd160()", + ), + measure_evm_precompile_function( + config, + verbose, + &mut context, + encode_call_function_args( + precompiled_function_addr, + precompiled_function::functions::test_ripemd160_1kb::call().0, + ), + "test_ripemd160_1kb()", + ), + measure_evm_precompile_function( + config, + verbose, + &mut context, + encode_call_function_args( + precompiled_function_addr, + precompiled_function::functions::test_identity::call().0, + ), + "test_identity()", + ), + measure_evm_precompile_function( + config, + verbose, + &mut context, + encode_call_function_args( + precompiled_function_addr, + precompiled_function::functions::test_identity_100bytes::call().0, + ), + "test_identity_100bytes()", + ), + measure_evm_precompile_function( + config, + verbose, + &mut context, + encode_call_function_args( + precompiled_function_addr, + precompiled_function::functions::test_mod_exp::call().0, + ), + "test_mod_exp()", + ), + ]; + + println!("measurements: {:?}", measurements); + let r = EvmPrecompiledFunctionCost { + ec_recover_cost: measurements[1].cost - measurements[0].cost, + sha256_cost: measurements[2].cost - measurements[0].cost, + sha256_cost_per_byte: (measurements[3].cost - measurements[2].cost) / 100, + ripemd160_cost: measurements[4].cost - measurements[0].cost, + ripemd160_cost_per_byte: (measurements[5].cost - measurements[4].cost) / 1024, + identity_cost: measurements[6].cost - measurements[0].cost, + identity_cost_per_byte: (measurements[7].cost - measurements[6].cost) / 100, + modexp_impl_cost: measurements[8].cost - measurements[0].cost, + }; + println!("sha256_cost_per_byte {}", r.sha256_cost_per_byte); + r +} + +pub fn near_cost_to_evm_gas(funcall_cost: Coef, cost: Ratio) -> u64 { + return u64::try_from((cost / funcall_cost.0).to_integer()).unwrap(); +} + +/// Cost of all evm related +pub fn cost_of_evm(config: &Config, verbose: bool) -> EvmCostCoef { + let (testbed, nonces) = testbed_for_evm(&config.state_dump_path, config.active_accounts); + let evm_cost_config = EvmCostCoef { + deploy_cost: measure_evm_deploy(config, verbose, testbed.clone(), nonces.clone()), + funcall_cost: measure_evm_funcall(config, verbose, testbed.clone(), nonces.clone()), + precompiled_function_cost: measure_evm_precompiled(config, verbose), + }; + evm_cost_config +} + /// Cost of the compile contract with vm_kind pub fn cost_to_compile( gas_metric: GasMetric, @@ -175,7 +757,7 @@ pub fn cost_to_compile( .filter(|path| fs::metadata(path).is_ok()) .map(|path| { if verbose { - print!("Testing {}: ", path.display()); + print!("Testing deploy {}: ", path.display()); }; if let Some((size, cost)) = load_and_compile(path, gas_metric, vm_kind) { if verbose { @@ -200,6 +782,77 @@ pub fn cost_to_compile( (m, b) } +fn dot(v1: &Vec, v2: &Vec) -> f64 { + let mut ret = 0.0; + for (i, u) in v1.iter().enumerate() { + ret += u * v2[i]; + } + ret +} + +struct Matrix2x2 { + a: f64, + b: f64, + c: f64, + d: f64, +} + +fn inverse2x2(m: Matrix2x2) -> Matrix2x2 { + let Matrix2x2 { a, b, c, d } = m; + let delta = a * d - b * c; + Matrix2x2 { a: d / delta, b: -b / delta, c: -c / delta, d: a / delta } +} + +fn normalize(v: &Vec) -> (Vec, f64) { + let mean = v.iter().sum::() / (v.len() as f64); + // default sklearn LinearRegression only normalize mean to 0, but not normalize stddev to 1, and that gives a very good result. + + let v: Vec<_> = v.iter().map(|x| (*x - mean)).collect(); + (v, mean) +} + +fn measurements_to_coef_2d(measurements: Vec, verbose: bool) -> Coef2D { + let v1: Vec<_> = measurements.iter().map(|m| m.evm_gas as f64).collect(); + let (v1, _) = normalize(&v1); + let v2: Vec<_> = measurements.iter().map(|m| m.size as f64).collect(); + let (v2, _) = normalize(&v2); + let a = dot(&v1, &v1); + let b = dot(&v1, &v2); + let c = dot(&v2, &v1); + let d = dot(&v2, &v2); + + let xt_x_inverse = inverse2x2(Matrix2x2 { a, b, c, d }); + + let y: Vec<_> = measurements.iter().map(|m| m.cost.to_f64().unwrap()).collect(); + let xt_y1 = dot(&v1, &y); + let xt_y2 = dot(&v2, &y); + + let beta1 = (xt_x_inverse.a * xt_y1 + xt_x_inverse.b * xt_y2); + let beta2 = (xt_x_inverse.c * xt_y1 + xt_x_inverse.d * xt_y2); + + let delta: Vec<_> = measurements + .iter() + .map(|m| m.cost.to_f64().unwrap() - (m.evm_gas as f64) * beta1 - (m.size as f64) * beta2) + .collect(); + let r = (beta1, beta2, delta.iter().sum::() / delta.len() as f64); + println!("evm calc data {:?}", r); + println!("delta: {:?}", delta); + r +} + +fn measurements_to_coef(measurements: Vec, verbose: bool) -> Coef { + let ratio = Ratio::new(0 as u64, 1); + let base = Ratio::new(u64::MAX, 1); + let b = measurements.iter().fold(base, |b, EvmCost { evm_gas: _, size: _, cost }| b.min(*cost)); + let m = measurements + .iter() + .fold(ratio, |r, EvmCost { evm_gas, size: _, cost }| r.max((*cost - b) / evm_gas)); + if verbose { + println!("raw data: ({},{})", m, b); + } + (m, b) +} + fn delete_all_data(wasm_bin: &mut Vec) -> Result<&Vec> { let m = &mut Module::from_buffer(wasm_bin)?; for id in get_ids(m.data.iter().map(|t| t.id())) { diff --git a/runtime/runtime/Cargo.toml b/runtime/runtime/Cargo.toml index fa5d1e22564..8b0e57cd6e2 100644 --- a/runtime/runtime/Cargo.toml +++ b/runtime/runtime/Cargo.toml @@ -36,6 +36,7 @@ near-vm-errors = { path = "../../runtime/near-vm-errors" } [features] default = [] dump_errors_schema = ["near-vm-errors/dump_errors_schema"] +protocol_feature_evm = ["near-primitives/protocol_feature_evm"] # Use this feature to enable counting of fees and costs applied. costs_counting = ["near-vm-logic/costs_counting", "near-vm-runner/costs_counting"] diff --git a/runtime/runtime/src/lib.rs b/runtime/runtime/src/lib.rs index eeea07e71ab..7a68cfc6d96 100644 --- a/runtime/runtime/src/lib.rs +++ b/runtime/runtime/src/lib.rs @@ -195,6 +195,7 @@ impl Default for ActionResult { } } +#[derive(Copy, Clone)] pub struct Runtime {} impl Runtime { @@ -303,6 +304,7 @@ impl Runtime { actions: &[Action], epoch_info_provider: &dyn EpochInfoProvider, ) -> Result { + // println!("enter apply_action"); let mut result = ActionResult::default(); let exec_fees = exec_fee( &apply_state.config.transaction_costs, diff --git a/runtime/runtime/tests/runtime_group_tools/random_config.rs b/runtime/runtime/tests/runtime_group_tools/random_config.rs index 2ca9be698a9..e0ba6b09af3 100644 --- a/runtime/runtime/tests/runtime_group_tools/random_config.rs +++ b/runtime/runtime/tests/runtime_group_tools/random_config.rs @@ -1,5 +1,5 @@ use near_runtime_fees::{ - AccessKeyCreationConfig, ActionCreationConfig, DataReceiptCreationConfig, Fee, + AccessKeyCreationConfig, ActionCreationConfig, DataReceiptCreationConfig, EvmCostConfig, Fee, RuntimeFeesConfig, StorageUsageConfig, }; use node_runtime::config::RuntimeConfig; @@ -46,6 +46,18 @@ pub fn random_config() -> RuntimeConfig { (101 + rng.next_u32() % 10).try_into().unwrap(), 100, ), + evm_config: EvmCostConfig { + bootstrap_cost: rng.next_u64() % 1000, + deploy_cost_per_evm_gas: rng.next_u64() % 1000, + deploy_cost_per_byte: rng.next_u64() % 1000, + funcall_cost_base: rng.next_u64() % 1000, + funcall_cost_per_evm_gas: rng.next_u64() % 1000, + ecrecover_cost: rng.next_u64() % 1000, + sha256_cost: rng.next_u64() % 1000, + ripemd160_cost: rng.next_u64() % 1000, + identity_cost: rng.next_u64() % 1000, + modexp_cost: rng.next_u64() % 1000, + }, evm_deposit: (rng.next_u64() % 10000) as u128 * 10u128.pow(23), }, ..Default::default() diff --git a/test-utils/state-viewer/src/lib.rs b/test-utils/state-viewer/src/lib.rs new file mode 100644 index 00000000000..c54d8b02d76 --- /dev/null +++ b/test-utils/state-viewer/src/lib.rs @@ -0,0 +1,2 @@ +mod state_dump; +pub use crate::state_dump::state_dump;