Skip to content

Conversation

@duncancmt
Copy link
Collaborator

No description provided.

@duncancmt duncancmt mentioned this pull request Oct 16, 2024
@duncancmt duncancmt force-pushed the dcmt/allowanceholder2 branch from 4c54af8 to 1444d8c Compare October 16, 2024 10:44
@duncancmt duncancmt changed the base branch from dcmt/golf to dcmt/golf2 October 16, 2024 10:45
@duncancmt duncancmt changed the title WIP: Incoporate learnings into a new iteration of AllowanceHolder Incoporate learnings into a new iteration of AllowanceHolder Oct 16, 2024
@duncancmt duncancmt marked this pull request as ready for review October 16, 2024 10:45
Base automatically changed from dcmt/golf2 to master October 29, 2024 13:03
@duncancmt duncancmt marked this pull request as draft January 24, 2025 18:16
@duncancmt duncancmt changed the title Incoporate learnings into a new iteration of AllowanceHolder WIP: Incoporate learnings into a new iteration of AllowanceHolder Jan 24, 2025
assembly ("memory-safe") {
testData := mload(0x40)
mstore(add(0x24, testData), target)
mstore(add(0x10, testData), 0x70a08231000000000000000000000000)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add the comment we always have mentioning the padding

mstore(add(0x24, testData), target)
mstore(add(0x10, testData), 0x70a08231000000000000000000000000)
mstore(testData, 0x24)
mstore(0x40, add(0x60, testData))
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you doing 0x60 to keep the memory alignment?

Comment on lines +210 to +216
// Pad `returndata` to a multiple of 32 bytes.
let len := mload(result)
let m := and(0x1f, len)
if m {
mstore(add(add(0x20, result), len), 0x00)
len := add(sub(0x20, m), len)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

what made you add this padding here?

target := calldataload(add(0x04, data.offset))
// `shl(0x08, data.length)` can't overflow because we're going to
// `calldatacopy(..., data.length)` later. It would OOG.
let mask := shr(shl(0x08, sub(data.length, 0x04)), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
Copy link
Contributor

@e1Ru1o e1Ru1o Aug 5, 2025

Choose a reason for hiding this comment

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

Shouldn't this be mul? or shr(0x03, ...)

Suggested change
let mask := shr(shl(0x08, sub(data.length, 0x04)), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
let mask := shr(mul(0x08, sub(data.length, 0x04)), 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah it should be shl(0x03, ...)

Comment on lines +51 to +56
// We apply the "all but one 64th" rule three times because `target` could
// plausibly be a proxy. We apply it only three times because we assume only
// two levels of indirection.
let remainingGas := shr(0x06, beforeGas)
remainingGas := add(remainingGas, shr(0x06, sub(beforeGas, remainingGas)))
remainingGas := add(remainingGas, shr(0x06, sub(beforeGas, remainingGas)))
Copy link
Contributor

Choose a reason for hiding this comment

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

The two levels of indirection will be what? a beacon proxy? So there are 3 calls, this => proxy, proxy => beacon, proxy => implementation? Anything else?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants