Skip to content

Commit af55d55

Browse files
authored
chore: revert the check to allow arbitrary calldata length use cases (#57)
## Summary The calling contract should be responsible for checking the calldata length when they call `executeFromPluginToExternal`. ## Detail ### Changeset * reverted the change and added a new test. ### Checklist - [x] Did you add new tests and confirm all tests pass? (`yarn test`) - [ ] Did you update relevant docs? (docs are found in the `docs` folder) - [x] Do your commits follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard? - [x] Does your PR title also follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard? - [ ] If you have a breaking change, is it [correctly reflected in your commit message](https://www.conventionalcommits.org/en/v1.0.0/#examples)? (e.g. `feat!: breaking change`) - [x] Did you run lint (`yarn lint`) and fix any issues? - [x] Did you run formatter (`yarn format:check`) and fix any issues (`yarn format:write`)? ## Testing * added a test case to verify native token transfer is allowed ## Documentation n/a
1 parent 9f8c6de commit af55d55

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/msca/6900/v0.7/managers/PluginExecutor.sol

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ library PluginExecutor {
7777
internal
7878
returns (bytes memory)
7979
{
80-
if (data.length < 4) {
81-
revert NotFoundSelector();
82-
}
8380
if (target == address(this) || ERC165Checker.supportsInterface(target, type(IPlugin).interfaceId)) {
8481
revert ExecuteFromPluginToExternalNotPermitted();
8582
}

test/msca/6900/v0.7/PluginExecutor.t.sol

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,8 @@ contract PluginExecutorTest is TestUtils {
11861186
function testShortCalldataIntoExecuteFromPluginToExternal() public {
11871187
// deployment was done in setUp
11881188
assertTrue(address(msca).code.length != 0);
1189+
// start with balance
1190+
vm.deal(address(msca), 10 ether);
11891191
bytes32 manifestHash = keccak256(abi.encode(testTokenPlugin.pluginManifest()));
11901192
// airdrop 1000 tokens
11911193
bytes memory pluginInstallData = abi.encode(1000);
@@ -1195,11 +1197,11 @@ contract PluginExecutorTest is TestUtils {
11951197
dependencies[0] =
11961198
FunctionReference(address(singleOwnerPlugin), uint8(ISingleOwnerPlugin.FunctionId.USER_OP_VALIDATION_OWNER));
11971199
msca.installPlugin(address(testTokenPlugin), manifestHash, pluginInstallData, dependencies);
1198-
1199-
// fail early even before InvalidValidationFunctionId is reverted
1200-
vm.expectRevert(NotFoundSelector.selector);
1201-
bytes memory data = abi.encodeCall(testTokenPlugin.callExecuteFromPluginExternal, (bytes("aaa")));
1200+
address externalTarget = testTokenPlugin.LONG_LIQUIDITY_POOL_ADDR();
1201+
uint256 initialBal = externalTarget.balance;
1202+
bytes memory data = abi.encodeCall(testTokenPlugin.callExecuteFromPluginExternal, (1, bytes("")));
12021203
address(msca).callWithReturnDataOrRevert(0, data);
1204+
assertEq(externalTarget.balance, initialBal + 1);
12031205
vm.stopPrank();
12041206
}
12051207
}

test/msca/6900/v0.7/TestTokenPlugin.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ contract TestTokenPlugin is BasePlugin {
115115
return true;
116116
}
117117

118-
function callExecuteFromPluginExternal(bytes calldata data) external returns (bool) {
119-
IPluginExecutor(msg.sender).executeFromPluginExternal(LONG_LIQUIDITY_POOL_ADDR, 0, data);
118+
function callExecuteFromPluginExternal(uint256 value, bytes calldata data) external returns (bool) {
119+
IPluginExecutor(msg.sender).executeFromPluginExternal(LONG_LIQUIDITY_POOL_ADDR, value, data);
120120
return true;
121121
}
122122

@@ -517,6 +517,7 @@ contract TestTokenPlugin is BasePlugin {
517517
})
518518
});
519519

520+
manifest.canSpendNativeToken = true;
520521
manifest.dependencyInterfaceIds = new bytes4[](1);
521522
manifest.dependencyInterfaceIds[0] = type(ISingleOwnerPlugin).interfaceId;
522523
return manifest;

0 commit comments

Comments
 (0)