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

[4/n] validation series - delete SingleOwnerPlugin #97

Merged
merged 2 commits into from
Jul 17, 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Reference implementation for [ERC-6900](https://eips.ethereum.org/EIPS/eip-6900). It is an early draft implementation.

The implementation includes an upgradable modular account with two plugins (`SingleOwnerPlugin` and `TokenReceiverPlugin`). It is compliant with ERC-6900 with the latest updates.
The implementation includes an upgradable modular account with two plugins (`SingleSignerValidation` and `TokenReceiverPlugin`). It is compliant with ERC-6900 with the latest updates.

## Important Callouts

Expand Down
191 changes: 0 additions & 191 deletions src/plugins/owner/SingleOwnerPlugin.sol

This file was deleted.

4 changes: 2 additions & 2 deletions test/account/AccountLoupe.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ contract AccountLoupeTest is CustomValidationTestBase {
}

function test_pluginLoupe_getValidationHooks() public {
PluginEntity[] memory hooks = account1.getPreValidationHooks(_ownerValidation);
PluginEntity[] memory hooks = account1.getPreValidationHooks(_signerValidation);

assertEq(hooks.length, 2);
assertEq(
Expand Down Expand Up @@ -154,7 +154,7 @@ contract AccountLoupeTest is CustomValidationTestBase {

bytes[] memory installDatas = new bytes[](2);
return (
_ownerValidation,
_signerValidation,
true,
true,
new bytes4[](0),
Expand Down
6 changes: 3 additions & 3 deletions test/account/AccountReturnData.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ResultConsumerPlugin
} from "../mocks/plugins/ReturnDataPluginMocks.sol";
import {AccountTestBase} from "../utils/AccountTestBase.sol";
import {TEST_DEFAULT_OWNER_FUNCTION_ID} from "../utils/TestConstants.sol";
import {TEST_DEFAULT_VALIDATION_ENTITY_ID} from "../utils/TestConstants.sol";

// Tests all the different ways that return data can be read from plugins through an account
contract AccountReturnDataTest is AccountTestBase {
Expand Down Expand Up @@ -58,7 +58,7 @@ contract AccountReturnDataTest is AccountTestBase {
(address(regularResultContract), 0, abi.encodeCall(RegularResultContract.foo, ()))
),
_encodeSignature(
PluginEntityLib.pack(address(singleOwnerPlugin), TEST_DEFAULT_OWNER_FUNCTION_ID),
PluginEntityLib.pack(address(singleSignerValidation), TEST_DEFAULT_VALIDATION_ENTITY_ID),
GLOBAL_VALIDATION,
""
)
Expand Down Expand Up @@ -86,7 +86,7 @@ contract AccountReturnDataTest is AccountTestBase {
bytes memory retData = account1.executeWithAuthorization(
abi.encodeCall(account1.executeBatch, (calls)),
_encodeSignature(
PluginEntityLib.pack(address(singleOwnerPlugin), TEST_DEFAULT_OWNER_FUNCTION_ID),
PluginEntityLib.pack(address(singleSignerValidation), TEST_DEFAULT_VALIDATION_ENTITY_ID),
GLOBAL_VALIDATION,
""
)
Expand Down
7 changes: 4 additions & 3 deletions test/account/GlobalValidationTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ contract GlobalValidationTest is AccountTestBase {
account2 = UpgradeableModularAccount(payable(factory.getAddress(owner2, 0)));
vm.deal(address(account2), 100 ether);

_ownerValidation = PluginEntityLib.pack(address(singleOwnerPlugin), TEST_DEFAULT_OWNER_FUNCTION_ID);
_signerValidation =
PluginEntityLib.pack(address(singleSignerValidation), TEST_DEFAULT_VALIDATION_ENTITY_ID);

ethRecipient = makeAddr("ethRecipient");
vm.deal(ethRecipient, 1 wei);
Expand All @@ -48,7 +49,7 @@ contract GlobalValidationTest is AccountTestBase {
// Generate signature
bytes32 userOpHash = entryPoint.getUserOpHash(userOp);
(uint8 v, bytes32 r, bytes32 s) = vm.sign(owner2Key, userOpHash.toEthSignedMessageHash());
userOp.signature = _encodeSignature(_ownerValidation, GLOBAL_VALIDATION, abi.encodePacked(r, s, v));
userOp.signature = _encodeSignature(_signerValidation, GLOBAL_VALIDATION, abi.encodePacked(r, s, v));

PackedUserOperation[] memory userOps = new PackedUserOperation[](1);
userOps[0] = userOp;
Expand All @@ -65,7 +66,7 @@ contract GlobalValidationTest is AccountTestBase {
vm.prank(owner2);
account2.executeWithAuthorization(
abi.encodeCall(UpgradeableModularAccount.execute, (ethRecipient, 1 wei, "")),
_encodeSignature(_ownerValidation, GLOBAL_VALIDATION, "")
_encodeSignature(_signerValidation, GLOBAL_VALIDATION, "")
);

assertEq(ethRecipient.balance, 2 wei);
Expand Down
26 changes: 13 additions & 13 deletions test/account/MultiValidation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,39 @@ import {PluginEntity} from "../../src/interfaces/IPluginManager.sol";
import {IStandardExecutor} from "../../src/interfaces/IStandardExecutor.sol";
import {PluginEntityLib} from "../../src/helpers/PluginEntityLib.sol";
import {ValidationConfigLib} from "../../src/helpers/ValidationConfigLib.sol";
import {SingleOwnerPlugin} from "../../src/plugins/owner/SingleOwnerPlugin.sol";
import {SingleSignerValidation} from "../../src/plugins/validation/SingleSignerValidation.sol";

import {AccountTestBase} from "../utils/AccountTestBase.sol";
import {TEST_DEFAULT_OWNER_FUNCTION_ID} from "../utils/TestConstants.sol";
import {TEST_DEFAULT_VALIDATION_ENTITY_ID} from "../utils/TestConstants.sol";

contract MultiValidationTest is AccountTestBase {
using ECDSA for bytes32;
using MessageHashUtils for bytes32;

SingleOwnerPlugin public validator2;
SingleSignerValidation public validator2;

address public owner2;
uint256 public owner2Key;

function setUp() public {
validator2 = new SingleOwnerPlugin();
validator2 = new SingleSignerValidation();

(owner2, owner2Key) = makeAddrAndKey("owner2");
}

function test_overlappingValidationInstall() public {
vm.prank(address(entryPoint));
account1.installValidation(
ValidationConfigLib.pack(address(validator2), TEST_DEFAULT_OWNER_FUNCTION_ID, true, true),
ValidationConfigLib.pack(address(validator2), TEST_DEFAULT_VALIDATION_ENTITY_ID, true, true),
new bytes4[](0),
abi.encode(TEST_DEFAULT_OWNER_FUNCTION_ID, owner2),
abi.encode(TEST_DEFAULT_VALIDATION_ENTITY_ID, owner2),
"",
""
);

PluginEntity[] memory validations = new PluginEntity[](2);
validations[0] = PluginEntityLib.pack(address(singleOwnerPlugin), TEST_DEFAULT_OWNER_FUNCTION_ID);
validations[1] = PluginEntityLib.pack(address(validator2), TEST_DEFAULT_OWNER_FUNCTION_ID);
validations[0] = PluginEntityLib.pack(address(singleSignerValidation), TEST_DEFAULT_VALIDATION_ENTITY_ID);
validations[1] = PluginEntityLib.pack(address(validator2), TEST_DEFAULT_VALIDATION_ENTITY_ID);

bytes4[] memory selectors0 = account1.getSelectors(validations[0]);
bytes4[] memory selectors1 = account1.getSelectors(validations[1]);
Expand All @@ -64,22 +64,22 @@ contract MultiValidationTest is AccountTestBase {
abi.encodeWithSelector(
UpgradeableModularAccount.RuntimeValidationFunctionReverted.selector,
address(validator2),
0,
1,
abi.encodeWithSignature("NotAuthorized()")
)
);
account1.executeWithAuthorization(
abi.encodeCall(IStandardExecutor.execute, (address(0), 0, "")),
_encodeSignature(
PluginEntityLib.pack(address(validator2), TEST_DEFAULT_OWNER_FUNCTION_ID), GLOBAL_VALIDATION, ""
PluginEntityLib.pack(address(validator2), TEST_DEFAULT_VALIDATION_ENTITY_ID), GLOBAL_VALIDATION, ""
)
);

vm.prank(owner2);
account1.executeWithAuthorization(
abi.encodeCall(IStandardExecutor.execute, (address(0), 0, "")),
_encodeSignature(
PluginEntityLib.pack(address(validator2), TEST_DEFAULT_OWNER_FUNCTION_ID), GLOBAL_VALIDATION, ""
PluginEntityLib.pack(address(validator2), TEST_DEFAULT_VALIDATION_ENTITY_ID), GLOBAL_VALIDATION, ""
)
);
}
Expand All @@ -105,7 +105,7 @@ contract MultiValidationTest is AccountTestBase {
bytes32 userOpHash = entryPoint.getUserOpHash(userOp);
(uint8 v, bytes32 r, bytes32 s) = vm.sign(owner2Key, userOpHash.toEthSignedMessageHash());
userOp.signature = _encodeSignature(
PluginEntityLib.pack(address(validator2), TEST_DEFAULT_OWNER_FUNCTION_ID),
PluginEntityLib.pack(address(validator2), TEST_DEFAULT_VALIDATION_ENTITY_ID),
GLOBAL_VALIDATION,
abi.encodePacked(r, s, v)
);
Expand All @@ -120,7 +120,7 @@ contract MultiValidationTest is AccountTestBase {
userOp.nonce = 1;
(v, r, s) = vm.sign(owner1Key, userOpHash.toEthSignedMessageHash());
userOp.signature = _encodeSignature(
PluginEntityLib.pack(address(validator2), TEST_DEFAULT_OWNER_FUNCTION_ID),
PluginEntityLib.pack(address(validator2), TEST_DEFAULT_VALIDATION_ENTITY_ID),
GLOBAL_VALIDATION,
abi.encodePacked(r, s, v)
);
Expand Down
Loading
Loading