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

feat: wasm and wasm cache access for dev eoas #306

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
32 changes: 28 additions & 4 deletions src/apps/KintoAppRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,43 @@ contract KintoAppRegistry is
/// @notice The address of the admin deployer
address public constant ADMIN_DEPLOYER = 0x660ad4B5A74130a4796B4d54BC6750Ae93C86e6c;

/// @notice
/// @notice Address of the EntryPoint v6 contract that processes UserOperations
address public constant ENTRYPOINT_V6 = 0x2843C269D2a64eCfA63548E8B3Fc0FD23B7F70cb;

/// @notice
/// @notice Address of the EntryPoint v7 contract that processes UserOperations
address public constant ENTRYPOINT_V7 = 0x0000000071727De22E5E9d8BAf0edAc6f37da032;

/// @notice
/// @notice Address of the Arbitrum retryable transaction contract
address public constant ARB_RETRAYABLE_TX = 0x000000000000000000000000000000000000006E;

/// @notice Address of the Arbitrum WASM executor contract
address public constant ARB_WASM = 0x0000000000000000000000000000000000000071;

/// @notice Address of the Arbitrum WASM cache contract
address public constant ARB_WASM_CACHE = 0x0000000000000000000000000000000000000072;

/// @notice Function selector for EntryPoint's withdrawStake function
bytes4 public constant SELECTOR_EP_WITHDRAW_STAKE = 0xc23a5cea;

/// @notice Function selector for EntryPoint's withdrawTo function
bytes4 public constant SELECTOR_EP_WITHDRAW_TO = 0x205c2878;

/// @notice Function selector for EntryPoint's handleAggregatedOps function
bytes4 public constant SELECTOR_EP_HANDLEO_AGGREGATED_OPS = 0x4b1d7cf5;

/// @notice Function selector for EntryPoint v7's handleAggregatedOps function
bytes4 public constant SELECTOR_EP_HANDLE_AGGREGATED_OPS_V7 = 0xdbed18e0;

/// @notice Function selector for EntryPoint's handleOps function
bytes4 public constant SELECTOR_EP_HANDLEOPS = 0x1fad948c;

/// @notice Function selector for EntryPoint v7's handleOps function
bytes4 public constant SELECTOR_EP_HANDLE_OPS_V7 = 0x765e827f;

/// @notice Function selector for EntryPoint's deposit function
bytes4 public constant SELECTOR_EP_DEPOSIT = 0xb760faf9;

/// @notice Empty function selector used for validation checks
bytes4 public constant SELECTOR_EMPTY = 0x00000000;

/* ============ State Variables ============ */
Expand Down Expand Up @@ -448,7 +469,10 @@ contract KintoAppRegistry is
if (isSystemContract(destination)) return true;

// Deployer EOAs are allowed to use CREATE and CREATE2
if (destination == address(0) || destination == CREATE2) {
if (
destination == address(0) || destination == CREATE2 || destination == ARB_WASM
|| destination == ARB_WASM_CACHE
) {
address wallet = deployerToWallet[sender];
// Only dev wallets can deploy
if (wallet == address(0)) return false;
Expand Down
31 changes: 31 additions & 0 deletions test/unit/ContractCall.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ contract ContractCallTest is SharedSetup {
address public constant ENTRYPOINT_V6 = 0x2843C269D2a64eCfA63548E8B3Fc0FD23B7F70cb;
address public constant ENTRYPOINT_V7 = 0x0000000071727De22E5E9d8BAf0edAc6f37da032;
address public constant ARB_RETRAYABLE_TX = 0x000000000000000000000000000000000000006E;
address public constant ARB_WASM = 0x0000000000000000000000000000000000000071;
address public constant ARB_WASM_CACHE = 0x0000000000000000000000000000000000000072;

function setUp() public virtual override {
super.setUp();
Expand Down Expand Up @@ -45,6 +47,16 @@ contract ContractCallTest is SharedSetup {
assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(_user2, address(0), selectorCalldata, 0), false);
}

function testIsContractCallAllowedFromEOA_WhenRandomEOAArbWasm() public view {
assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(_user2, address(ARB_WASM), selectorCalldata, 0), false);
}

function testIsContractCallAllowedFromEOA_WhenRandomEOAArbWasmCache() public view {
assertEq(
_kintoAppRegistry.isContractCallAllowedFromEOA(_user2, address(ARB_WASM_CACHE), selectorCalldata, 0), false
);
}

function testIsContractCallAllowedFromEOA_WhenRandomEOA() public view {
assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(_user2, address(0xdead), selectorCalldata, 0), false);
}
Expand All @@ -65,6 +77,25 @@ contract ContractCallTest is SharedSetup {
assertEq(_kintoAppRegistry.isContractCallAllowedFromEOA(address(0xde), address(0), selectorCalldata, 0), true);
}

function testIsContractCallAllowedFromEOA_WhenWasm() public {
vm.prank(address(_kintoWallet));
_kintoAppRegistry.setDeployerEOA(address(_kintoWallet), address(0xde));

assertEq(
_kintoAppRegistry.isContractCallAllowedFromEOA(address(0xde), address(ARB_WASM), selectorCalldata, 0), true
);
}

function testIsContractCallAllowedFromEOA_WhenWasmCache() public {
vm.prank(address(_kintoWallet));
_kintoAppRegistry.setDeployerEOA(address(_kintoWallet), address(0xde));

assertEq(
_kintoAppRegistry.isContractCallAllowedFromEOA(address(0xde), address(ARB_WASM_CACHE), selectorCalldata, 0),
true
);
}

function testIsContractCallAllowedFromEOA_WhenEntryPointWithdraw() public view {
bytes memory withdrawStakeCallData = abi.encodeWithSelector(bytes4(keccak256("withdrawStake(address)")), _user);
bytes memory withdrawToCallData =
Expand Down
Loading