Skip to content
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

Open
wants to merge 3 commits into
base: Version-0-Review
Choose a base branch
from
Open

Conversation

0age
Copy link
Collaborator

@0age 0age commented Nov 7, 2024

This PR is meant to serve as a hub for review comments on Version 0.

@0age 0age changed the title add files back Version 0 Review PR Nov 7, 2024
using SafeTransferLib for address;

// Storage slot seed for ERC6909 state, used in computing balance slots.
uint256 private constant _ERC6909_MASTER_SLOT_SEED = 0xedcaa89a82293940;

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?

Copy link
Collaborator Author

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)

src/lib/ClaimProcessorFunctionCastLib.sol Outdated Show resolved Hide resolved
* @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)

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?

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, using this function as an example:

  • ClaimProcessorLib has a function processSimpleClaim 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, the processSimpleClaim function takes a uint256 calldataPointer argument instead of like a BasicClaim calldata argument.
  • When we're actually calling processSimpleClaim inside of ClaimProcessorLogic._processBasicClaim, the claimPayload has a BasicClaim calldata claimPayload type. While you could do a typecast to a uint256 inside of that function before calling processSimpleClaim, 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 that processSimpleClaim expects, but the fnOut function matches the argument types that are actually being provided

Comment on lines +4 to +16
// 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.
}
Copy link

@yorhodes yorhodes Nov 13, 2024

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?

Copy link
Collaborator Author

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!

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