-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat: blob_hash #489
base: main
Are you sure you want to change the base?
feat: blob_hash #489
Conversation
|
||
// If index is within bounds, get the hash at that index | ||
// Otherwise return zero bytes | ||
let (high, low) = split_felt(blob_hashes.value.len); |
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 guess it's fine to do this because we don't want to over analyze the evm
but blob_hashes.value.len right now is between 2 and 5, in the future it'll be at most 200 or maybe 1000
if (out_of_bounds.value == 0) { | ||
tempvar blob_hash = Bytes32(new Bytes32Struct(0, 0)); | ||
} else { | ||
tempvar blob_hash = blob_hashes.value.data[index.value.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.
if we're only using index.value.low, we should probably assert index.value.high == 0, as well as blob_hashes.value.len.high ==0,
then just compare the two low felt values
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.
we should probably assert index.value.high == 0,
no, this would be a deviation to spec. MAX_U256 would be a valid blob_hash index query and would return zero. We must not assume anything on the validity range of this input value.
for len(blob_hashes), we can assume (and assert) that this number is way below 2**128.
so either:
- just do u256 comparison, which is done now and is correct
- assert len(blob_hashes) < 2128, and return zero if input >= 2128 or if input < len
// If index is within bounds, get the hash at that index | ||
// Otherwise return zero bytes | ||
let (high, low) = split_felt(blob_hashes.value.len); | ||
let out_of_bounds = U256_lt(index, U256(new U256Struct(low, high))); |
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.
in_bounds ?
let out_of_bounds = U256_lt(index, U256(new U256Struct(low, high))); | |
let in_bounds = U256_lt(index, U256(new U256Struct(low, high))); |
if (out_of_bounds.value == 0) { | ||
tempvar blob_hash = Bytes32(new Bytes32Struct(0, 0)); | ||
} else { | ||
tempvar blob_hash = blob_hashes.value.data[index.value.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.
we should probably assert index.value.high == 0,
no, this would be a deviation to spec. MAX_U256 would be a valid blob_hash index query and would return zero. We must not assume anything on the validity range of this input value.
for len(blob_hashes), we can assume (and assert) that this number is way below 2**128.
so either:
- just do u256 comparison, which is done now and is correct
- assert len(blob_hashes) < 2128, and return zero if input >= 2128 or if input < len
Close #479