Skip to content

Commit 5b5c548

Browse files
authored
[ETHEREUM-CONTRACTS] split DMZForwarder into SimpleForwarder and ERC2771Forwarder (#2037)
* split into SimpleForwarder and ERC2771Forwarder * rename SuperfluidFrameworkDeployer.sol to SuperfluidFrameworkDeployer.t.sol and FoundrySuperfluidTester.sol to FoundrySuperfluidTester.t.sol * allow oversized test contracts
1 parent c8795f8 commit 5b5c548

File tree

56 files changed

+349
-205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+349
-205
lines changed

packages/automation-contracts/autowrap/test/Manager.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pragma solidity ^0.8.0;
33
import { ISuperToken } from "@superfluid-finance/ethereum-contracts/contracts/superfluid/SuperToken.sol";
44
import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";
5-
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.sol";
5+
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.t.sol";
66
import { Manager } from "./../contracts/Manager.sol";
77
import { IManager } from "./../contracts/interfaces/IManager.sol";
88
import { WrapStrategy } from "./../contracts/strategies/WrapStrategy.sol";

packages/automation-contracts/autowrap/test/WrapStrategy.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity ^0.8.0;
33

44
import { ISuperToken } from "@superfluid-finance/ethereum-contracts/contracts/superfluid/SuperToken.sol";
55
import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";
6-
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.sol";
6+
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.t.sol";
77
import { Manager } from "./../contracts/Manager.sol";
88
import { WrapStrategy } from "./../contracts/strategies/WrapStrategy.sol";
99
import { IStrategy } from "./../contracts/interfaces/IStrategy.sol";

packages/automation-contracts/autowrap/test/WrapUp.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity ^0.8.0;
33

44
import { ISuperToken } from "@superfluid-finance/ethereum-contracts/contracts/superfluid/SuperToken.sol";
55
import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";
6-
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.sol";
6+
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.t.sol";
77
import { Manager } from "./../contracts/Manager.sol";
88
import { WrapStrategy } from "./../contracts/strategies/WrapStrategy.sol";
99
import { ISETH } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/tokens/ISETH.sol";

packages/automation-contracts/scheduler/test/FlowScheduler.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ISuperToken } from "@superfluid-finance/ethereum-contracts/contracts/in
55
import { FlowOperatorDefinitions } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
66
import { IFlowScheduler } from "./../contracts/interface/IFlowScheduler.sol";
77
import { FlowScheduler } from "./../contracts/FlowScheduler.sol";
8-
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.sol";
8+
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.t.sol";
99
import { SuperToken } from "@superfluid-finance/ethereum-contracts/contracts/superfluid/SuperToken.sol";
1010
import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";
1111

packages/automation-contracts/scheduler/test/FlowSchedulerResolver.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ISuperToken } from "@superfluid-finance/ethereum-contracts/contracts/in
55
import { FlowOperatorDefinitions } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
66
import { FlowScheduler } from "./../contracts/FlowScheduler.sol";
77
import { FlowSchedulerResolver } from "./../contracts/FlowSchedulerResolver.sol";
8-
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.sol";
8+
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.t.sol";
99
import { SuperToken } from "@superfluid-finance/ethereum-contracts/contracts/superfluid/SuperToken.sol";
1010
import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";
1111

packages/automation-contracts/scheduler/test/VestingScheduler.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ISuperToken } from "@superfluid-finance/ethereum-contracts/contracts/in
55
import { FlowOperatorDefinitions } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
66
import { IVestingScheduler } from "./../contracts/interface/IVestingScheduler.sol";
77
import { VestingScheduler } from "./../contracts/VestingScheduler.sol";
8-
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.sol";
8+
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.t.sol";
99
import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";
1010

1111
/// @title VestingSchedulerTests

packages/automation-contracts/scheduler/test/VestingSchedulerV2.StatefulFuzz.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {ISuperToken} from "@superfluid-finance/ethereum-contracts/contracts/inte
55
import {FlowOperatorDefinitions} from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
66
import {IVestingSchedulerV2} from "./../contracts/interface/IVestingSchedulerV2.sol";
77
import {VestingSchedulerV2} from "./../contracts/VestingSchedulerV2.sol";
8-
import {FoundrySuperfluidTester} from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.sol";
8+
import {FoundrySuperfluidTester} from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.t.sol";
99
import {SuperTokenV1Library} from "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";
1010
import "forge-std/console2.sol";
1111

packages/automation-contracts/scheduler/test/VestingSchedulerV2.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ISuperToken } from "@superfluid-finance/ethereum-contracts/contracts/in
55
import { FlowOperatorDefinitions, ISuperfluid, BatchOperation, ISuperApp } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
66
import { IVestingSchedulerV2 } from "./../contracts/interface/IVestingSchedulerV2.sol";
77
import { VestingSchedulerV2 } from "./../contracts/VestingSchedulerV2.sol";
8-
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.sol";
8+
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.t.sol";
99
import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";
1010
import { SafeMath } from "@openzeppelin/contracts/utils/math/SafeMath.sol";
1111
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";

packages/ethereum-contracts/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ All notable changes to the ethereum-contracts will be documented in this file.
33

44
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
## [Unreleased]
7+
8+
### Added
9+
* `ISuperfluid.getERC2771Forwarder()`: to be used by batch call targets who want to use ERC-2771 for msg sender preservation.
10+
* Utility contracts for forwarding of calls in the context of batch operations:
11+
* `SimpleForwarder`: for forwarding arbitrary calls to arbitrary targets
12+
* `ERC2771Forwarder`: for forwarding arbitrary calls to arbitrary targets with msg sender authenticated according to ERC-2771. Requires the target contract to recognize it as trusted forwarder.
13+
14+
### Breaking
15+
* Source file `SuperfluidFrameworkDeployer.sol` renamed to `SuperfluidFrameworkDeployer.t.sol`
16+
* Source file `FoundrySuperfluidTester.sol` renamed to `FoundrySuperfluidTester.t.sol`
17+
618
## [v1.11.1]
719

820
### Changed

packages/ethereum-contracts/contracts/interfaces/superfluid/Definitions.sol

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,22 @@ library BatchOperation {
231231
*/
232232
uint32 constant internal OPERATION_TYPE_SUPERFLUID_CALL_APP_ACTION = 2 + 200;
233233
/**
234-
* @dev DMZForwarder.forwardCall batch operation type
234+
* @dev SimpleForwarder.forwardCall batch operation type
235235
*
236236
* Call spec:
237237
* forwardCall(
238238
* target,
239239
* data
240240
* )
241+
* NOTE: This operation allows to make arbitrary calls to arbitrary targets.
242+
* The calls are routed through a dedicated utility contract `SimpleForwarder`.
243+
* This is important because the host contract has privileged access to other framework contracts,
244+
* SuperTokens, SuperApps etc.
245+
* Allowing arbitrary calls to arbitrary targets with the host as sender would thus be unsafe.
241246
*/
242247
uint32 constant internal OPERATION_TYPE_SIMPLE_FORWARD_CALL = 1 + 300;
243248
/**
244-
* @dev DMZForwarder.forward2771Call batch operation type
249+
* @dev ERC2771Forwarder.forward2771Call batch operation type
245250
*
246251
* Call spec:
247252
* forward2771Call(
@@ -250,17 +255,17 @@ library BatchOperation {
250255
* data
251256
* )
252257
*
253-
* NOTE: In the context of this operation, the `DZMForwarder` contract acts as the
258+
* NOTE: In the context of this operation, the `ERC2771Forwarder` contract acts as the
254259
* _trusted forwarder_ which must be trusted by the _recipient contract_ (operation target).
255-
* It shall do so by dynamically looking up the DMZForwarder used by the host, like this:
260+
* It shall do so by dynamically looking up the ERC2771Forwarder used by the host, like this:
256261
*
257262
* function isTrustedForwarder(address forwarder) public view returns(bool) {
258-
* return forwarder == address(host.DMZ_FORWARDER());
263+
* return forwarder == address(host.getERC2771Forwarder());
259264
* }
260265
*
261266
* If used in the context of a `forwardBatchCall`, we effectively have a chaining/nesting
262267
* of ERC-2771 calls where the host acts as _recipient contract_ of the enveloping 2771 call
263-
* and the DMZForwarder acts as the _trusted forwarder_ of the nested 2771 call(s).
268+
* and the ERC2771Forwarder acts as the _trusted forwarder_ of the nested 2771 call(s).
264269
* That's why `msgSender` could be either the actual `msg.sender` (if using `batchCall`)
265270
* or the relayed sender address (if using `forwardBatchCall`).
266271
*/

0 commit comments

Comments
 (0)