-
Notifications
You must be signed in to change notification settings - Fork 3
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
Version 0 Review PR #29
base: Version-0-Review
Are you sure you want to change the base?
Conversation
using SafeTransferLib for address; | ||
|
||
// Storage slot seed for ERC6909 state, used in computing balance slots. | ||
uint256 private constant _ERC6909_MASTER_SLOT_SEED = 0xedcaa89a82293940; |
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.
what is this value? where did it come from?
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.
this is from solady's ERC6909 implementation, since the _release
and _withdraw
functions use the same general pathways as the standard transfers (but skip allowance checks and transfer hooks)
* @param fnIn Function pointer to `ClaimProcessorLib.processSimpleClaim`. | ||
* @return fnOut Modified function used in `ClaimProcessorLogic._processBasicClaim`. | ||
*/ | ||
function usingBasicClaim(function(bytes32, uint256, uint256, bytes32, bytes32, function(address, address, uint256, uint256) internal returns (bool)) internal returns (bool) fnIn) |
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.
Can you explain at a high level why this is necessary? I've read the natspec but still not sure. Which one is the correct function type for the function thats going to be called? Why would the type ever be incorrect and need changing?
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.
Yeah, using this function as an example:
ClaimProcessorLib
has a functionprocessSimpleClaim
that is used as a shared entrypoint for processing four different claim types (basic claim, claim with witness, multichain claim, and multichain claim with witness) where the only key differences are how the claim hash is derived and what the calldata offset to the relevant data is. To facilitate this, theprocessSimpleClaim
function takes auint256 calldataPointer
argument instead of like aBasicClaim
calldata argument.- When we're actually calling
processSimpleClaim
inside ofClaimProcessorLogic._processBasicClaim
, theclaimPayload
has aBasicClaim calldata claimPayload
type. While you could do a typecast to a uint256 inside of that function before callingprocessSimpleClaim
, it uses extra gas and critically takes up more contract size, so instead we can use a function cast as a "zero-cost abstraction" to accomplish the same thing - The
fnIn
function matches the arguments thatprocessSimpleClaim
expects, but thefnOut
function matches the argument types that are actually being provided
// Message signed by the sponsor that specifies the conditions under which their | ||
// tokens can be claimed; the specified arbiter verifies that those conditions | ||
// have been met and specifies a set of beneficiaries that will receive up to the | ||
// specified amount of tokens. | ||
struct Compact { | ||
address arbiter; // The account tasked with verifying and submitting the claim. | ||
address sponsor; // The account to source the tokens from. | ||
uint256 nonce; // A parameter to enforce replay protection, scoped to allocator. | ||
uint256 expires; // The time at which the claim expires. | ||
uint256 id; // The token ID of the ERC6909 token to allocate. | ||
uint256 amount; // The amount of ERC6909 tokens to allocate. | ||
// Optional witness may follow. | ||
} |
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.
do you expect that the "conditions under which their tokens can be claimed" to be encapsulated in optional witness data or in the address of the arbiter
?
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 think generally the conditions would be specified in the witness data which is in turn leveraged by the arbiter; that way the arbiter can be more general-purpose!
This PR is meant to serve as a hub for review comments on Version 0.