Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add set_owner method for Aurora DAO #690

Merged
merged 48 commits into from
Feb 28, 2023
Merged

Add set_owner method for Aurora DAO #690

merged 48 commits into from
Feb 28, 2023

Conversation

hskang9
Copy link
Contributor

@hskang9 hskang9 commented Feb 15, 2023

Description

Aurora DAO requires an owner shift from the contract creator to Aurora DAO contract to execute its admin functions in the future. To achieve this, previous owner have to set the owner address from before to a new address that the previous owner sets.

set_owner method checks whether the sender is marked as the owner of the engine contract's state.

Then converts string input into AccountId.

Performance / NEAR gas cost considerations

It changes owner property in Aurora engine's contract state.

Testing

Tests were done in https://github.com/hskang9/aurora-silo-tests/blob/main/src/test.rs#L156.

How should this be reviewed

I am concerned if converting a random string into NEAR account id is still safe.

Additional information

@hskang9 hskang9 marked this pull request as ready for review February 15, 2023 13:00
@hskang9 hskang9 requested review from birchmd and joshuajbouw and removed request for joshuajbouw February 15, 2023 13:00
Copy link
Member

@birchmd birchmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would also be nice to add a test for calling this method (one which runs both through the Wasm contract and the standalone engine).

engine/src/lib.rs Outdated Show resolved Hide resolved
engine/src/lib.rs Show resolved Hide resolved
engine/src/lib.rs Outdated Show resolved Hide resolved
@hskang9 hskang9 requested a review from birchmd February 16, 2023 02:37
engine-standalone-storage/src/sync/types.rs Outdated Show resolved Hide resolved
engine/src/lib.rs Show resolved Hide resolved
engine/src/lib.rs Outdated Show resolved Hide resolved
engine/src/lib.rs Outdated Show resolved Hide resolved
engine/src/lib.rs Outdated Show resolved Hide resolved
@hskang9 hskang9 requested a review from birchmd February 20, 2023 15:06
Copy link
Contributor

@joshuajbouw joshuajbouw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be borsh, for now. I know it'll be JSON later, but I'm not too fond of this senseless flip-flopping between serializations.

@hskang9
Copy link
Contributor Author

hskang9 commented Feb 21, 2023

So I was told by @joshuajbouw to overhaul the json encode/decode after adding this method as borsh, because it is inconsistent for admin methods to have it while all other methods use borsh encode/decode for now.

@hskang9
Copy link
Contributor Author

hskang9 commented Feb 22, 2023

@joshuajbouw it is now used with borsh.

@aleksuss
Copy link
Member

Resolve the conflicts.

engine/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@aleksuss aleksuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@joshuajbouw joshuajbouw added this pull request to the merge queue Feb 28, 2023
Merged via the queue into develop with commit 5f5e241 Feb 28, 2023
@joshuajbouw joshuajbouw deleted the feat/add-set-owner branch February 28, 2023 09:47
@joshuajbouw joshuajbouw mentioned this pull request Apr 5, 2023
birchmd pushed a commit that referenced this pull request Apr 5, 2023
* add set_owner method

* fix format

* refactor set_owner method with borsh args parameters and adding new transaction kind

* remove warnings

* add traits for new TransactionKind parameter

* add a match fill arm for new TransactionKind parameter

* add match arms for BorshTransaction and TransactionKind

* replace `as` coversions to `from` conversions

* explicitly declare types on number constants

* add custom type conversion From trait for handling data loss on `as` type casting

* replace `as` to `try_into`

* fix typo

* lint fix

* lint fix

* set variant order in BorshTransactionKind and return json encoded bool for the method result

* use TryFrom in type conversions

* format code

* remove as keyword

* Panic on same previous owner input

* Update engine-standalone-storage/src/relayer_db/types.rs

Co-authored-by: Oleksandr Anyshchenko <oleksandr.anyshchenko@aurora.dev>

* Update engine-standalone-storage/src/relayer_db/types.rs

Co-authored-by: Oleksandr Anyshchenko <oleksandr.anyshchenko@aurora.dev>

* add tests for setting owner in standalone environment

* format codes

* update Error type on TransactionDuration

TryFromIntError is for integral integers; including unsigned ones.

* Optimize set_owner tests

and place them in sanity.rs

* Refactor set_owner standalone tests

use `test_utils` function

* fix lint

* fix input on test_set_owner_fail_on_same_owner

* add error type on standalone tests

* lint fix

* remove unused dependancy

* remove wrong comments

* add set_owner method to standalone env

* format codes

* remove unneeded output in set_owner

* refactor json args parse in set_owner

* modify tests

* remove outdated comment

* refactor standalone test with json input

* format codes

* refactor standalone input method handler with json input

* use borsh for now

* merge all converted types into one struct type

* remove unused comment

* remove unnecessary output in set_owner

---------

Co-authored-by: Oleksandr Anyshchenko <oleksandr.anyshchenko@aurora.dev>
joshuajbouw added a commit that referenced this pull request Apr 5, 2023
## [2.9.0] 2023-04-05

### Added

- Enabled XCC for mainnet release by [@birchmd]. ([#694])
- Added `set_owner` contract method which sets the owner of the contract
by [@hskang9]. ([#690])
- New variant of submit function `submit_with_args` which accepts
additional arguments along with the transaction such as the max gas
price a user is ready to pay by [@aleksuss]. ([#696])
- Added the ability to create and fund XCC sub-accounts from external
NEAR accounts by [@birchmd]. ([#735])

### Changes

- Replaced `rjson` with `serde_json` by [@aleksuss]. ([#677])
- Changed owner intended contract methods to now require owner or the
contract itself by [@hskang9]. ([#676])

### Fixes

- Fixed nonce incorrectly being incremented on an out of fund failure by
[@joshuajbouw]. ([#671])
- Fixed a check in promise results before executing cross contract calls
(XCC) callbacks by [@birchmd]. ([#693])
- Fixed a reachable panic in `receive_erc20_tokens` by [@0x3bfc].
([#709])
- Fixed a lack of minimum size checks when instantiating a new `EthGas`
object by [@lempire123]. ([#722])
- Fixed a lack of division by 0 checks in `EthGas::Div()` by
[@lempire123]. ([#718])
- Fixed the validation of the return of `exports:storage_remove` by
[@0x3bfc]. ([#712])
- Fixed missing account validations of NEAR account IDs by [@0x3bfc].
([#703])
- Fixed a reachable panic in the `exitToNear` and `exitToEthereum`
precompiles if the input amount is greater than 1^128 when cast from a
`U256` to `u128` by [@0x3bfc]. ([#681])
- Fixed a reachable panic in `modExp` due to arithmetic overflow by
[@0x3bfc]. ([#688])
- Fixed the ability attaching values to Aurora specific precompiles,
this no longer is possible, by [@0x3bfc]. ([#714])
- Fixed a return error if an ecrecover signature length is not exactly
65 by [@0x3bfc]. ([#717])
- Fixed size checks on input array passed to `exitToNear` and
`exitToEthereum` precompiles by [@0x3bfc]. ([#684])
- Fixed missing gas costs in `exitToNear` and `exitToEthereum`
precompiles by [@lempire123]. ([#687])
- Fixed a reachable panic due to out of memory in the `modExp`
precompile by [@0x3bfc]. ([#689])
- Fixed an assurance that the `sender_id` has a balance greater than the
amount in `ft_transfer_call` by [@0x3bfc]. ([#708])
- Fixed returning `0x` when a length cannot be cast as `usize` instead
of returning an error in the `modExp` precompile by [@birchmd]. ([#737])
- Miscellaneous minor fixes by [@0x3bfc]. ([#738])

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Leandro Casuso Montero <leandro.montero@aurora.dev>
Co-authored-by: Michael Birch <michael.birch@aurora.dev>
Co-authored-by: Alexey Lapitsky <lex@realisticgroup.com>
Co-authored-by: Oleksandr Anyshchenko <oleksandr.anyshchenko@aurora.dev>
Co-authored-by: Alexey Lapitsky <alexey.lapitsky@aurora.dev>
Co-authored-by: Hyungsuk Kang <hskang9@gmail.com>
Co-authored-by: Ahmed Ali <ahmedaabdulwahed@gmail.com>
Co-authored-by: lempire123 <61431140+lempire123@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants