-
Notifications
You must be signed in to change notification settings - Fork 4
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
Migrate slots to U256 #328
Conversation
aajj999
commented
Jun 6, 2024
- Migrate slot library to U256
- Use 256 in ERC721Token & ERC20Token
- Implement From and Into for U256 type (Bytes32)
- Add from_field function for U256
} | ||
|
||
bytes | ||
} |
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.
Why not inline?
let low = U128::from_le_bytes(low_bytes); | ||
|
||
U256::new(high, low) | ||
} |
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.
Why not inline?
ethereum/circuits/lib/src/uint256.nr
Outdated
|
||
fn from_field(field: Field) -> Self { | ||
U256::from_bytes32(field_to_bytes32(field)) | ||
} |
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.
As From
trait?
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.
#nextPR
let mut bytes = [0x00; 32]; | ||
bytes[31] = 0x10; | ||
assert_eq(U256::into(big_number), bytes); | ||
} |
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.
Some more tests pls :)
|
||
#[test] | ||
fn from_bytes32_zero() { | ||
let mut bytes = [0x00; 32]; |
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.
Unnecessary mut
global limit_u256 = U256 {high: limit, low:limit}; | ||
|
||
#[test] | ||
fn from_bytes32_zero() { |
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.
mod from_bytes32 {
}
mod into_bytes32 {
}
|
||
#[test] | ||
fn from_bytes32_limit() { | ||
let mut bytes = [0xff; 32]; |
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.
Unnecessary mut
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.
Unnecessary import bytes32::field_to_bytes32
can be removed
|
||
global TOKEN_BALANCE_INDEX = 0; | ||
|
||
struct ERC20Token { | ||
address: Address, | ||
balances_slot: Bytes32, | ||
allowances_slot: Bytes32, | ||
balances_slot: U256, |
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.
Bytes32
import can be removed