-
Notifications
You must be signed in to change notification settings - Fork 77
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
Address trail of bits issues #4
Conversation
b56d7a8
to
a94557c
Compare
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.
Could you run forc-fmt
and Cargo clippy --fix
, some of my suggestions will be resolved by these formatters. Overall looks good to me, but I'll await a review from @Braqzen who has worked on this repo most recently
packages/fungible-token/bridge-fungible-token/src/bridge_fungible_token.sw
Outdated
Show resolved
Hide resolved
packages/fungible-token/bridge-fungible-token/tests/utils/environment.rs
Outdated
Show resolved
Hide resolved
packages/fungible-token/bridge-fungible-token/tests/utils/environment.rs
Outdated
Show resolved
Hide resolved
packages/fungible-token/bridge-fungible-token/src/bridge_fungible_token.sw
Outdated
Show resolved
Hide resolved
msg.1.clone(), | ||
)) | ||
)); | ||
message_nonce[0] += 1; |
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.
Just adding a note because I'm unsure if this is an issue. I believe this will only go up to the u8
limit so if we ever create (if we even can create that many) more than the limit then this may make the entire suite fail.
Perhaps we should add a comment stating this in case this ever becomes an issue
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.
Shouldn't message_nonce[0]
only overflow at 2^64? message_nonce
is really just 4 64bit number, right?
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.
I believe it's [u8; 32] under the hood
Co-authored-by: Braqzen <[email protected]>
…ures overflow checks
fb02103
to
c33d368
Compare
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.
CI is complaining
I would run
forc fmt
cargo fmt
cargo clippy --all-features --all-targets -- -D warnings
and fix any issuescargo test
packages/fungible-token/bridge-fungible-token/src/bridge_fungible_token.sw
Outdated
Show resolved
Hide resolved
@@ -190,7 +213,11 @@ impl FRC20 for Contract { | |||
// Storage-dependant private functions | |||
#[storage(write)] | |||
fn register_refund(from: b256, asset: b256, amount: b256) { | |||
storage.refund_amounts.get(from).insert(asset, amount); | |||
let previous_amount = U256::from(storage.refund_amounts.get(from).get(asset).try_read().unwrap_or(ZERO_B256)); | |||
let new_amount = U256::from(amount).add(previous_amount); // U256 has overflow checks built in; |
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.
@pixelcircuits should we be doing conversions here or should we change the API to use a U256 directly (probably in another PR)?
Co-authored-by: Braqzen <[email protected]>
Co-authored-by: Braqzen <[email protected]>
Co-authored-by: Braqzen <[email protected]>
Co-authored-by: Braqzen <[email protected]>
This PR:
Closes #5