New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ETH connector #59
ETH connector #59
Conversation
* EIP712-Withdraw: fixed encoding rules and order. * EIP712-Withdraw: `verify_withdraw_eip712` returns `true` only if the sender address equals to the address of message signer. * EIP712-Withdraw: update tests. * EIP712-Withdraw: refactoring. * ethabit::encode_token_packed: use right-padded encoding for `Address`. * WithdrawFromEthCallArgs: fixed `amount` type conversion.
…ra-engine into evm-deposit-withdraw
} else { | ||
None | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong as according to the NEP-145 specs: If the account is unknown to the contract then the total account storage balance returned will be zero.
So we need to always return StorageBalance
, and zero for unknown accounts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed at #98
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note the appropriate issue in near-sdk-rs
.
* Eugene's review 2021-05-08 * Eth connector improvements after review 2021-05-18 (#98) * Adde improvements afterreview - account checking, msg len check, json lib * Added json parser. Changed balance_of * Fixed balance_of test * json for ft_transfer & fix test * Json args for ft_transfer_call & fixed tests * Added json for FT storage methods * Fix ft_resolve transfer promise result check. Removed total_supply_near * Fix to NEP-145: storage_balance_of * Fix storage_balance_of to NEP-145 * Eth connector statistic (#104) * Added get_accounts_counter & tests * Clippy fix * Fixed: check accounts_contains_key & added comments * Lint: cargo fmt * Chanched key for Statistics * Update src/connector.rs Imptove comments Co-authored-by: Michael Birch <michael@near.org> * Changed: - get_accounts_counter - return le_bytes Added: - test_get_accounts_counter_and_transfer - check recalculation accounts Co-authored-by: Michael Birch <michael@near.org> Co-authored-by: Michael Birch <michael@near.org> Co-authored-by: Evgeny Ukhanov <mrlsd@ya.ru> Co-authored-by: Michael Birch <michael@near.org>
src/storage.rs
Outdated
Contract = 0x0, | ||
FungibleToken = 0x1, | ||
UsedEvent = 0x2, | ||
StatisticsAuroraAccountsCounter = 0x3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to start statistics Id from something like 0xF
or 0x10
. So if other fields related to the contract itself are added in the future, they will come in order and not going to be mixed with Ids for Statistics.
I'll create a PR for that.
* Added tests: * test_deposit_near_with_zero_fee * test_deposit_evm_with_zero_fee * Added: * test_deposit_evm_amount_equal_fee_non_zero * check_execution_status_failure * Improved: * test_deposit_with_same_proof Added: * test_deposit_wrong_custodian_address * Added tests: * test_deposit_near_amount_less_fee * test_deposit_evm_amount_less_fee * test_deposit_near_amount_zero_fee_non_zero * test_deposit_evm_amount_zero_fee_non_zero * test_deposit_near_amount_equal_fee_non_zero * Changed: test_deposit_wrong_custodian_address
* EthConnector: make AdminControlled and pausable. * EthConnector: add AdminControlled&pausability tests. * Stylystic fixes. * AdminControlled: add panic message when paused. * AdminControlled: minor refactoring. * AdminControlled: add errors. Naming improvements. * AdminControlled: doc improvements. * Test fixes. * Fix fmt * AdminControlled: make IO in main contract module. * AdminControlled:explicitly check panic msg in tests.
* Rename `check_execution_status_failure()` method to `assert_execution_status_failure()`; * `assert_execution_status_failure()`: accept panic message as an arg. * Explicitly specify the panic message for each `assert_execution_status_failure()` if the promise didn't fail with the provided error message. * Eth-connector tests: improve checks for failure msg. * Usually the converted to string has either of the following two messages formats: "Action #0: Smart contract panicked: ERR_MSG [src/some_file.rs:LINE_NUMBER:COLUMN_NUMBER]" "right: 'MISMATCHED_DATA': ERR_MSG [src/some_file.rs:LINE_NUMBER:COLUMN_NUMBER]" So the ": ERR_MSG [" pattern should catch all invariants of error, even if one of the errors message is a subset of another one (e.g. `ERR_MSG_FAILED` is a subset of `ERR_MSG_FAILED_FOO`).
* Document `aurora encode-address` usage. * Cache cargo artifacts between CI runs. (#92) * Address comments from audit. (#86) * Validate register length in `read_input_arr20()` * Only read register length in `Engine::get_code_size` * Add `read_input_borsh()` * Ensure `method.args.len() == args_decoded.len()` * Ensure register size is 8 in `read_u64` * Use constant to specify the register ID used in `read_input()` * Reduce size of `cargo cache` in CI. (#95) * Define a `Wei` newtype for balances. (#96) * Fix evm-bully builds after recent refactoring. (#100) * Refactor `Engine::get_state` to return a `Result`. (#99) * Ensure that `Cargo.lock` in the repo is valid. (#101) * Remove unneeded nightly feature. (#102) * Dispatch precompiles on the full address. (#107) * Support state migration on upgrade. (#103) * Remove resolved TODOs * Fix state migration test * Conditional compilation minor improvements. Co-authored-by: Arto Bendiken <arto@aurora.dev> Co-authored-by: Michael Birch <michael@near.org> Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
* Add `set_eth_connector_contract_data()` method. * Minor refactoring: `init_contract()` method now accepts `InitCallArgs` instead of making IO operations in it.
…gine into eth-connector-merge-develop-after-target-change
* Base precompile code between connectors (#73) * Base precompile code between connectors * Handle errors and validate input * Use proper result * Document `aurora encode-address` usage. * Cache cargo artifacts between CI runs. (#92) * Address comments from audit. (#86) * Validate register length in `read_input_arr20()` * Only read register length in `Engine::get_code_size` * Add `read_input_borsh()` * Ensure `method.args.len() == args_decoded.len()` * Ensure register size is 8 in `read_u64` * Use constant to specify the register ID used in `read_input()` * Reduce size of `cargo cache` in CI. (#95) * Define a `Wei` newtype for balances. (#96) * Fix evm-bully builds after recent refactoring. (#100) * Refactor `Engine::get_state` to return a `Result`. (#99) * Ensure that `Cargo.lock` in the repo is valid. (#101) * Remove unneeded nightly feature. (#102) * Implement BC generational storage. * fix address input * remove note * put key on the end of the storage key * remove pub from methods * Dispatch precompiles on the full address. (#107) * Support state migration on upgrade. (#103) * Implement the ETH connector. (#59) * Move when to call `set_generation` * Fix arg Co-authored-by: Marcelo Fornet <mfornet94@gmail.com> Co-authored-by: Arto Bendiken <arto@aurora.dev> Co-authored-by: Michael Birch <michael@near.org> Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com> Co-authored-by: Evgeny Ukhanov <mrlsd@ya.ru>
* Add tests for state check after selfdestruct * Aurora runner tracks storage usage to avoid underflow when storage is released in future transactions (#85) * Implement generational storage (#87) * Base precompile code between connectors (#73) * Base precompile code between connectors * Handle errors and validate input * Use proper result * Document `aurora encode-address` usage. * Cache cargo artifacts between CI runs. (#92) * Address comments from audit. (#86) * Validate register length in `read_input_arr20()` * Only read register length in `Engine::get_code_size` * Add `read_input_borsh()` * Ensure `method.args.len() == args_decoded.len()` * Ensure register size is 8 in `read_u64` * Use constant to specify the register ID used in `read_input()` * Reduce size of `cargo cache` in CI. (#95) * Define a `Wei` newtype for balances. (#96) * Fix evm-bully builds after recent refactoring. (#100) * Refactor `Engine::get_state` to return a `Result`. (#99) * Ensure that `Cargo.lock` in the repo is valid. (#101) * Remove unneeded nightly feature. (#102) * Implement BC generational storage. * fix address input * remove note * put key on the end of the storage key * remove pub from methods * Dispatch precompiles on the full address. (#107) * Support state migration on upgrade. (#103) * Implement the ETH connector. (#59) * Move when to call `set_generation` * Fix arg Co-authored-by: Marcelo Fornet <mfornet94@gmail.com> Co-authored-by: Arto Bendiken <arto@aurora.dev> Co-authored-by: Michael Birch <michael@near.org> Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com> Co-authored-by: Evgeny Ukhanov <mrlsd@ya.ru> * Fix layout of the key * Fix all tests (don't wipe the storage all the time) * Use correct generation in writing storage * Remove unnecessary references Co-authored-by: Michael Birch <michael@near.org> Co-authored-by: Joshua J. Bouw <dev@joshuajbouw.com> Co-authored-by: Arto Bendiken <arto@aurora.dev> Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com> Co-authored-by: Evgeny Ukhanov <mrlsd@ya.ru> Co-authored-by: Michael Birch <michael.birch@aurora.dev>
ETH connector contains fugible token logic for specific flow.
To verify logic: