Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

Owner + upgrade functionality for EVM contract #63

Closed
wants to merge 8 commits into from

Conversation

ilblackdragon
Copy link
Member

Allows to set owner at new call and then change it.
Allows to stage new code and upgrade after 24 hours.

TODO: adding sim tests

@artob artob self-assigned this Feb 22, 2021
@joshuajbouw
Copy link
Member

I followed the dependencies to see which each of them are using and the last being bindgen v0.54.0 sets proc-macro2 which sets the version as 1 but then I realised what actually happened. A Cargo.lock was shipped in for the library. Deleting this fixes it or just simply running cargo update.

@joshuajbouw
Copy link
Member

joshuajbouw commented Feb 23, 2021

#65 addresses this current build issue you have. Review, pull and rebase.

@joshuajbouw
Copy link
Member

Current issue is a plethora of, needs further investigating whats going on over there as we are getting this straight from git itself which indicates to me that cargo check wasn't ran when pushing there.

error[E0432]: unresolved import `syn::export`
 --> /home/joshuajbouw/.cargo/git/checkouts/near-sdk-rs-7ba52202f378a9d9/477056f/near-sdk-core/src/code_generator/attr_sig_info.rs:1:10
  |
1 | use syn::export::TokenStream2;
  |          ^^^^^^ could not find `export` in `syn`

@joshuajbouw
Copy link
Member

Pinned funty here to get compiling again. v1.2.0 is broke API in parity's ETH code upon cargo update to fix another issue.

src/lib.rs Show resolved Hide resolved
sdk::panic_utf8(b"LackBalanceForStorage");
}
} else {
// TODO: return funds to caller?
Copy link
Member

Choose a reason for hiding this comment

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

Needs discussion and completing.

if sdk::attached_deposit()
< ((final_storage - initial_storage) as u128) * sdk::storage_byte_cost()
{
// TODO: add how much storage needed to error?
Copy link
Member

Choose a reason for hiding this comment

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

Needs discussion and completing.

}

pub fn get_owner() -> Vec<u8> {
sdk::read_storage(OWNER_KEY).unwrap_or_else(Vec::new)
Copy link
Member

Choose a reason for hiding this comment

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

Should this be erroring?

}

pub fn get_bridge_prover() -> Vec<u8> {
sdk::read_storage(BRIDGE_PROVER_KEY).unwrap_or_else(Vec::new)
Copy link
Member

Choose a reason for hiding this comment

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

Should this be erroring?

src/sdk.rs Show resolved Hide resolved
@artob
Copy link
Contributor

artob commented Mar 5, 2021

@joshuajbouw Please sort out the merge conflict due to #65, and give me an idea about whether I should proceed to merge this as-is or you figure the sim tests will be forthcoming in short order if you're unblocked now?

@joshuajbouw
Copy link
Member

Tests are going great and working as expected so far. I can't test the actual upgrade but everything else is tested up til this point. I am currently blocked with not being able to produce blocks which will trigger the upgrade as I need to produce a days worth of blocks: near/near-sdk-rs#320

Prior, it was based off of 24 hour waiting period but, of course, we can't -exactly- wait 24 hours for us to check if the test went through and since our block times are 1 block per second, I can instead create that many blocks in the test to trigger.

The tricky thing is that is a lot of blocks to produce. What I would suggest is to create some test methods in the WASM itself to produce a WASM test binary which allow us to alter values internally to simulate that a day has passed.

Thoughts?

@ilblackdragon
Copy link
Member Author

There is a method in standalone runtime to produce a bunch of empty blocks:

    /// use near_sdk_sim::runtime::init_runtime;
    /// let (mut runtime, _, _) = init_runtime(None);
    /// runtime.produce_blocks(5);
    /// assert_eq!(runtime.current_block().block_height, 5);
    /// assert_eq!(runtime.current_block().epoch_height, 1);

If producing 86k blocks takes too long in test (I would not expect that but who knows) - let's just add the wait time as a parameter in constructor and store in storage. This way it can be configured to longer as code matures as well. Further upgrades can change that parameter on migration.

@joshuajbouw
Copy link
Member

Right, I had to add a PR to be able to produce the blocks. I do like the idea of adding in that extra argument though for time to wait. Though, it makes me wonder what the minimum value could be. To be safe, you obviously would want at least 1 day.

@artob
Copy link
Contributor

artob commented Mar 25, 2021

Superseded by aurora-is-near/aurora-engine#6

@artob artob closed this Mar 25, 2021
EVM Phase 2 [Betanet] automation moved this from In progress to Done Mar 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants