Skip to content

Commit

Permalink
chore: update PackedUO struct usage
Browse files Browse the repository at this point in the history
  • Loading branch information
howydev committed Apr 20, 2024
1 parent e838c93 commit f0a3643
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 40 deletions.
41 changes: 17 additions & 24 deletions test/account/UpgradeableModularAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ contract UpgradeableModularAccountTest is AccountTestBase {
event PluginUninstalled(address indexed plugin, bool indexed callbacksSucceeded);
event ReceivedCall(bytes msgData, uint256 msgValue);

// helper function to compress 2 gas values into a single bytes32
function _encodeGas(uint256 g1, uint256 g2) internal returns (bytes32) {
return bytes32(uint256(g1 << 128 + uint128(g2)));
}

function setUp() public {
tokenReceiverPlugin = _deployTokenReceiverPlugin();

Expand All @@ -67,11 +72,9 @@ contract UpgradeableModularAccountTest is AccountTestBase {
nonce: 0,
initCode: "",
callData: abi.encodeCall(UpgradeableModularAccount.execute, (ethRecipient, 1 wei, "")),
callGasLimit: CALL_GAS_LIMIT,
verificationGasLimit: VERIFICATION_GAS_LIMIT,
accountGasLimits: _encodeGas(VERIFICATION_GAS_LIMIT, CALL_GAS_LIMIT),
preVerificationGas: 0,
maxFeePerGas: 1,
maxPriorityFeePerGas: 1,
gasFees: _encodeGas(1, 1),
paymasterAndData: "",
signature: ""
});
Expand All @@ -95,11 +98,9 @@ contract UpgradeableModularAccountTest is AccountTestBase {
nonce: 0,
initCode: abi.encodePacked(address(factory), abi.encodeCall(factory.createAccount, (owner2, 0))),
callData: abi.encodeCall(SingleOwnerPlugin.transferOwnership, (owner2)),
callGasLimit: CALL_GAS_LIMIT,
verificationGasLimit: VERIFICATION_GAS_LIMIT,
accountGasLimits: _encodeGas(VERIFICATION_GAS_LIMIT, CALL_GAS_LIMIT),
preVerificationGas: 0,
maxFeePerGas: 2,
maxPriorityFeePerGas: 1,
gasFees: _encodeGas(1, 2),
paymasterAndData: "",
signature: ""
});
Expand All @@ -123,11 +124,9 @@ contract UpgradeableModularAccountTest is AccountTestBase {
nonce: 0,
initCode: abi.encodePacked(address(factory), abi.encodeCall(factory.createAccount, (owner2, 0))),
callData: abi.encodeCall(UpgradeableModularAccount.execute, (recipient, 1 wei, "")),
callGasLimit: CALL_GAS_LIMIT,
verificationGasLimit: VERIFICATION_GAS_LIMIT,
accountGasLimits: _encodeGas(VERIFICATION_GAS_LIMIT, CALL_GAS_LIMIT),
preVerificationGas: 0,
maxFeePerGas: 2,
maxPriorityFeePerGas: 1,
gasFees: _encodeGas(1, 1),
paymasterAndData: "",
signature: ""
});
Expand All @@ -151,11 +150,9 @@ contract UpgradeableModularAccountTest is AccountTestBase {
nonce: 0,
initCode: "",
callData: abi.encodeCall(UpgradeableModularAccount.execute, (ethRecipient, 1 wei, "")),
callGasLimit: CALL_GAS_LIMIT,
verificationGasLimit: VERIFICATION_GAS_LIMIT,
accountGasLimits: _encodeGas(VERIFICATION_GAS_LIMIT, CALL_GAS_LIMIT),
preVerificationGas: 0,
maxFeePerGas: 1,
maxPriorityFeePerGas: 1,
gasFees: _encodeGas(1, 1),
paymasterAndData: "",
signature: ""
});
Expand All @@ -181,11 +178,9 @@ contract UpgradeableModularAccountTest is AccountTestBase {
callData: abi.encodeCall(
UpgradeableModularAccount.execute, (address(counter), 0, abi.encodeCall(counter.increment, ()))
),
callGasLimit: CALL_GAS_LIMIT,
verificationGasLimit: VERIFICATION_GAS_LIMIT,
accountGasLimits: _encodeGas(VERIFICATION_GAS_LIMIT, CALL_GAS_LIMIT),
preVerificationGas: 0,
maxFeePerGas: 1,
maxPriorityFeePerGas: 1,
gasFees: _encodeGas(1, 1),
paymasterAndData: "",
signature: ""
});
Expand Down Expand Up @@ -214,11 +209,9 @@ contract UpgradeableModularAccountTest is AccountTestBase {
nonce: 0,
initCode: "",
callData: abi.encodeCall(UpgradeableModularAccount.executeBatch, (calls)),
callGasLimit: CALL_GAS_LIMIT,
verificationGasLimit: VERIFICATION_GAS_LIMIT,
accountGasLimits: _encodeGas(VERIFICATION_GAS_LIMIT, CALL_GAS_LIMIT),
preVerificationGas: 0,
maxFeePerGas: 1,
maxPriorityFeePerGas: 1,
gasFees: _encodeGas(1, 1),
paymasterAndData: "",
signature: ""
});
Expand Down
32 changes: 16 additions & 16 deletions test/comparison/CompareSimpleAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ contract CompareSimpleAccountTest is Test {

Counter public counter;

uint256 public constant CALL_GAS_LIMIT = 500000;
uint256 public constant VERIFICATION_GAS_LIMIT = 500000;

// helper function to compress 2 gas values into a single bytes32
function _encodeGas(uint256 g1, uint256 g2) internal returns (bytes32) {
return bytes32(uint256(g1 << 128 + uint128(g2)));
}

function setUp() public {
entryPoint = new EntryPoint();
(owner1, owner1Key) = makeAddrAndKey("owner1");
Expand Down Expand Up @@ -59,11 +67,9 @@ contract CompareSimpleAccountTest is Test {
nonce: 0,
initCode: abi.encodePacked(address(factory), abi.encodeCall(factory.createAccount, (owner1, 0))),
callData: abi.encodeCall(SimpleAccount.execute, (beneficiary, 1, "")),
callGasLimit: 5000000,
verificationGasLimit: 5000000,
accountGasLimits: _encodeGas(VERIFICATION_GAS_LIMIT, CALL_GAS_LIMIT),
preVerificationGas: 0,
maxFeePerGas: 2,
maxPriorityFeePerGas: 1,
gasFees: _encodeGas(1, 2),
paymasterAndData: "",
signature: ""
});
Expand All @@ -84,11 +90,9 @@ contract CompareSimpleAccountTest is Test {
nonce: 0,
initCode: abi.encodePacked(address(factory), abi.encodeCall(factory.createAccount, (owner1, 0))),
callData: "",
callGasLimit: 5000000,
verificationGasLimit: 5000000,
accountGasLimits: _encodeGas(VERIFICATION_GAS_LIMIT, CALL_GAS_LIMIT),
preVerificationGas: 0,
maxFeePerGas: 2,
maxPriorityFeePerGas: 1,
gasFees: _encodeGas(1, 2),
paymasterAndData: "",
signature: ""
});
Expand All @@ -109,11 +113,9 @@ contract CompareSimpleAccountTest is Test {
nonce: 0,
initCode: "",
callData: abi.encodeCall(SimpleAccount.execute, (beneficiary, 1, "")),
callGasLimit: 5000000,
verificationGasLimit: 5000000,
accountGasLimits: _encodeGas(VERIFICATION_GAS_LIMIT, CALL_GAS_LIMIT),
preVerificationGas: 0,
maxFeePerGas: 2,
maxPriorityFeePerGas: 1,
gasFees: _encodeGas(1, 2),
paymasterAndData: "",
signature: ""
});
Expand All @@ -136,11 +138,9 @@ contract CompareSimpleAccountTest is Test {
callData: abi.encodeCall(
SimpleAccount.execute, (address(counter), 0, abi.encodeCall(Counter.increment, ()))
),
callGasLimit: 5000000,
verificationGasLimit: 5000000,
accountGasLimits: _encodeGas(VERIFICATION_GAS_LIMIT, CALL_GAS_LIMIT),
preVerificationGas: 0,
maxFeePerGas: 2,
maxPriorityFeePerGas: 1,
gasFees: _encodeGas(1, 2),
paymasterAndData: "",
signature: ""
});
Expand Down

0 comments on commit f0a3643

Please sign in to comment.