Skip to content

Eth-connector: merge develop branch#109

Merged
sept-en merged 18 commits intoeth-connectorfrom
eth-connector-merge-develop
May 28, 2021
Merged

Eth-connector: merge develop branch#109
sept-en merged 18 commits intoeth-connectorfrom
eth-connector-merge-develop

Conversation

@sept-en
Copy link
Copy Markdown
Contributor

@sept-en sept-en commented May 28, 2021

Merge develop branch & resolve conflicts.

@sept-en sept-en added C-enhancement Category: New feature or request P-critical Priority: critical labels May 28, 2021
Copy link
Copy Markdown
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.

Nice job!

I think we can remove most of the TODOs you called out. The only thing I think needs additional attention is refactoring internal_set_eth_balance to accept Wei, but we could do that as a follow-up PR if we are in a hurry to merge this one.

Comment thread src/engine.rs Outdated
Comment thread src/engine.rs Outdated
Comment thread src/fungible_token.rs Outdated
Comment thread etc/state-migration-test/Cargo.toml Outdated
@sept-en sept-en merged commit 540ccb1 into eth-connector May 28, 2021
@sept-en sept-en deleted the eth-connector-merge-develop branch May 28, 2021 17:41
Comment thread src/fungible_token.rs
sdk::read_u64(&Self::get_statistic_key()).unwrap_or(0)
sdk::read_u64(&Self::get_statistic_key())
.unwrap_or(Ok(0))
.unwrap_or(0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks really strange.

Comment thread src/lib.rs
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

#[cfg(target_arch = "wasm32")]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did it move up top of contract feature?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's needed for a test contract which uses the production contract as a dependency, but I can't have the production public exports (i.e. contract feature) because I want to override the definition in the test contract and you can't export a two methods with the same name.

Comment thread src/sdk.rs
exports::input(0);
let bytes: Vec<u8> = vec![0; exports::register_len(0) as usize];
exports::read_register(0, bytes.as_ptr() as *const u64 as u64);
exports::input(INPUT_REGISTER_ID);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@birchmd IMHO all those changes really redundant.
WASM has an infinity register stack. We don't need to unify as some standard get/read/write register flow. Most important read from the same register. And it was. it will be misleading that we should only use one given register.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think giving constants a name is useful for two reasons:

  1. It provides a semantic meaning to an otherwise ambiguous value (0 could mean lots of things, but here it is a register ID)
  2. It makes changing the value less error prone in the future because all occurrences of it now point back to one definition. For example, if we decide to reserve register 0 for some purpose then we can change INPUT_REGISTER_ID to be some other value easily without carefully double-checking we changed all the right places.

Comment thread src/sdk.rs
pub fn read_u64(key: &[u8]) -> Option<u64> {
unsafe {
if exports::storage_read(key.len() as u64, key.as_ptr() as u64, 0) == 1 {
pub(crate) fn read_u64(key: &[u8]) -> Option<Result<u64, InvalidU64>> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@birchmd I think we should return only Result type and remove Option. It's not informative. We can return Err(...) for the first part of the contract too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, agreed. See #109 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-enhancement Category: New feature or request P-critical Priority: critical

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants