Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

feat: update account and paymaster validation return format #12

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions packages/contracts-bedrock/test/mocks/TestAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ contract TestAccount {
{
(version, txHash, transaction);
// limited to 48 bits
uint64 validUntil = type(uint64).max & 0xFFFFFFFFFFFF;
uint64 validAfter = 0;
validationData =
(bytes32(MAGIC_VALUE_SENDER) |
bytes32(uint256(validUntil) << (6 * 8)) |
bytes32(uint256(validAfter)));
uint48 validUntil = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was wondering why you set the until value to 0?

Copy link
Author

Choose a reason for hiding this comment

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

If both values of validUntil and validAfter are 0, it will be recognized as [0, type(uint48).max] automatically at validateValidityTimeRange function in geth.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, right.
Passing validUntil = 0 and validAfter = 0 in the specification disables the check. So this part applies

uint48 validAfter = 0;
validationData = bytes32(
uint256(uint32(MAGIC_VALUE_SENDER)) |
((uint256(validUntil)) << 160) |
(uint256(validAfter) << (160 + 48))
);
}

function execute(address dest, uint256 value, bytes calldata func) external {
Expand Down
13 changes: 7 additions & 6 deletions packages/contracts-bedrock/test/mocks/TestPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ contract TestPaymaster {
(version, txHash, transaction);
context = new bytes(1);
// limited to 48 bits
uint64 validUntil = type(uint64).max & 0xFFFFFFFFFFFF;
uint64 validAfter = 0;
validationData =
(bytes32(MAGIC_VALUE_PAYMASTER) |
bytes32(uint256(validUntil) << (6 * 8)) |
bytes32(uint256(validAfter)));
uint48 validUntil = 0;
uint48 validAfter = 0;
validationData = bytes32(
uint256(uint32(MAGIC_VALUE_PAYMASTER)) |
((uint256(validUntil)) << 160) |
(uint256(validAfter) << (160 + 48))
);
}
}