-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 - reading/writing more than 32 bytes into the TendConfig.extraData
field
#43
base: main
Are you sure you want to change the base?
Conversation
….extraData` field
TendConfig.extraData
fieldTendConfig.extraData
field
|
||
/// @dev Tests that `TendConfig.extraData` is fully loaded even when the | ||
/// content is greater than a single storage slot. | ||
function test_extraData_large() external { |
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.
You'll probably want to add tests for cases that assert when extraData
is ""
, < bytes32
bytes, and > bytes32
bytes.
I re-ran the original test with a single char bytes
input and the output wasn't matching the input.
Ensure you include assertions on minOutput
, minVaultSharePrice
, and positionClosureLimit
when populated with non-zero values as well.
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 re-ran the original test with a single char bytes input and the output wasn't matching the input.
I couldn't reproduce this, can you show the example. (but agree with adding different test cases for different extreme cases of slots occupied.)
TendConfig.extraData
fieldTendConfig.extraData
field
// Pointer to the actual data. | ||
let extraDataData := add(extraData, 0x20) | ||
|
||
// Store the length in the `extraDataSlot`. | ||
tstore(extraDataSlot, extraDataLength) | ||
|
||
// Store the data in subsequent slots. | ||
for { | ||
let i := 0 | ||
} lt(i, extraDataLength) { | ||
i := add(i, 32) | ||
} { | ||
tstore( | ||
add(extraDataSlot, add(div(i, 32), 1)), | ||
mload(add(extraDataData, i)) | ||
) | ||
} |
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.
Nit: We're mixing and matching hex and decimals here. It's up to you whether or not you want to fix this, but I generally prefer all hex in inline assembly.
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 got a concern here which involves some low level memory layout that I'm very certain about the details: does the compiler ensure that the extraDataData
always gets padded into 32 bytes for the last few remaining words if it's short of 32?
Here the mload
is always loading 32 in each iteration, I'm thinking if it has risks of reading unwanted data for the last piece if the memory layout didn't get padded to a full 32? Maybe some quick tests of extraDataLength
not being exactly multiples of 32 can help answering it.
Only the first 32 bytes of
extraData
are read/written fromTendConfig
.This PR adds logic to handle more than 32 bytes for
TendConfig.extraData
.issue