@bananapus/core-v6 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADMINISTRATION.md +1 -1
- package/ARCHITECTURE.md +2 -1
- package/AUDIT_INSTRUCTIONS.md +342 -0
- package/CHANGE_LOG.md +400 -0
- package/README.md +4 -4
- package/RISKS.md +171 -50
- package/SKILLS.md +9 -6
- package/USER_JOURNEYS.md +622 -0
- package/package.json +2 -2
- package/script/DeployPeriphery.s.sol +7 -1
- package/src/JBController.sol +5 -0
- package/src/JBDeadline.sol +3 -0
- package/src/JBDirectory.sol +2 -1
- package/src/JBMultiTerminal.sol +50 -9
- package/src/JBPermissions.sol +2 -0
- package/src/JBPrices.sol +8 -2
- package/src/JBRulesets.sol +3 -0
- package/src/JBSplits.sol +9 -5
- package/src/JBTerminalStore.sol +54 -47
- package/src/JBTokens.sol +3 -0
- package/src/interfaces/IJBTerminalStore.sol +3 -0
- package/src/libraries/JBFees.sol +2 -0
- package/src/libraries/JBMetadataResolver.sol +17 -4
- package/src/structs/JBBeforeCashOutRecordedContext.sol +4 -0
- package/test/TestAuditResponseDesignProofs.sol +434 -0
- package/test/TestDataHookFuzzing.sol +520 -0
- package/test/TestFeeFreeCashOutBypass.sol +617 -0
- package/test/TestL2SequencerPriceFeed.sol +292 -0
- package/test/TestMetadataOffsetOverflow.sol +179 -0
- package/test/TestMultiTerminalSurplus.sol +348 -0
- package/test/TestPermit2DataHook.t.sol +360 -0
- package/test/TestRulesetQueueing.sol +1 -2
- package/test/TestRulesetWeightCaching.sol +122 -124
- package/test/WeirdTokenTests.t.sol +37 -0
- package/test/regression/HoldFeesCashOutReserved.t.sol +415 -0
- package/test/regression/WeightCacheBoundary.t.sol +291 -0
- package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +2 -2
- package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +18 -17
- package/test/units/static/JBMultiTerminal/TestPay.sol +6 -4
- package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +206 -18
- package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +280 -0
- package/test/units/static/JBSplits/TestSelfManagedSplitGroups.sol +55 -12
- package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +72 -0
- package/docs/book.css +0 -13
- package/docs/book.toml +0 -12
- package/docs/solidity.min.js +0 -74
- package/docs/src/README.md +0 -703
- package/docs/src/SUMMARY.md +0 -94
- package/docs/src/src/JBChainlinkV3PriceFeed.sol/contract.JBChainlinkV3PriceFeed.md +0 -83
- package/docs/src/src/JBChainlinkV3SequencerPriceFeed.sol/contract.JBChainlinkV3SequencerPriceFeed.md +0 -88
- package/docs/src/src/JBController.sol/contract.JBController.md +0 -1121
- package/docs/src/src/JBDeadline.sol/contract.JBDeadline.md +0 -84
- package/docs/src/src/JBDirectory.sol/contract.JBDirectory.md +0 -294
- package/docs/src/src/JBERC20.sol/contract.JBERC20.md +0 -190
- package/docs/src/src/JBFeelessAddresses.sol/contract.JBFeelessAddresses.md +0 -80
- package/docs/src/src/JBFundAccessLimits.sol/contract.JBFundAccessLimits.md +0 -253
- package/docs/src/src/JBMultiTerminal.sol/contract.JBMultiTerminal.md +0 -1472
- package/docs/src/src/JBPermissions.sol/contract.JBPermissions.md +0 -199
- package/docs/src/src/JBPrices.sol/contract.JBPrices.md +0 -154
- package/docs/src/src/JBProjects.sol/contract.JBProjects.md +0 -131
- package/docs/src/src/JBRulesets.sol/contract.JBRulesets.md +0 -677
- package/docs/src/src/JBSplits.sol/contract.JBSplits.md +0 -237
- package/docs/src/src/JBTerminalStore.sol/contract.JBTerminalStore.md +0 -591
- package/docs/src/src/JBTokens.sol/contract.JBTokens.md +0 -353
- package/docs/src/src/README.md +0 -25
- package/docs/src/src/abstract/JBControlled.sol/abstract.JBControlled.md +0 -64
- package/docs/src/src/abstract/JBPermissioned.sol/abstract.JBPermissioned.md +0 -84
- package/docs/src/src/abstract/README.md +0 -5
- package/docs/src/src/enums/JBApprovalStatus.sol/enum.JBApprovalStatus.md +0 -17
- package/docs/src/src/enums/README.md +0 -4
- package/docs/src/src/interfaces/IJBCashOutHook.sol/interface.IJBCashOutHook.md +0 -29
- package/docs/src/src/interfaces/IJBCashOutTerminal.sol/interface.IJBCashOutTerminal.md +0 -57
- package/docs/src/src/interfaces/IJBControlled.sol/interface.IJBControlled.md +0 -12
- package/docs/src/src/interfaces/IJBController.sol/interface.IJBController.md +0 -334
- package/docs/src/src/interfaces/IJBDirectory.sol/interface.IJBDirectory.md +0 -108
- package/docs/src/src/interfaces/IJBDirectoryAccessControl.sol/interface.IJBDirectoryAccessControl.md +0 -19
- package/docs/src/src/interfaces/IJBFeeTerminal.sol/interface.IJBFeeTerminal.md +0 -91
- package/docs/src/src/interfaces/IJBFeelessAddresses.sol/interface.IJBFeelessAddresses.md +0 -26
- package/docs/src/src/interfaces/IJBFundAccessLimits.sol/interface.IJBFundAccessLimits.md +0 -88
- package/docs/src/src/interfaces/IJBMigratable.sol/interface.IJBMigratable.md +0 -29
- package/docs/src/src/interfaces/IJBMultiTerminal.sol/interface.IJBMultiTerminal.md +0 -50
- package/docs/src/src/interfaces/IJBPayHook.sol/interface.IJBPayHook.md +0 -28
- package/docs/src/src/interfaces/IJBPayoutTerminal.sol/interface.IJBPayoutTerminal.md +0 -105
- package/docs/src/src/interfaces/IJBPermissioned.sol/interface.IJBPermissioned.md +0 -12
- package/docs/src/src/interfaces/IJBPermissions.sol/interface.IJBPermissions.md +0 -74
- package/docs/src/src/interfaces/IJBPermitTerminal.sol/interface.IJBPermitTerminal.md +0 -15
- package/docs/src/src/interfaces/IJBPriceFeed.sol/interface.IJBPriceFeed.md +0 -12
- package/docs/src/src/interfaces/IJBPrices.sol/interface.IJBPrices.md +0 -74
- package/docs/src/src/interfaces/IJBProjectUriRegistry.sol/interface.IJBProjectUriRegistry.md +0 -19
- package/docs/src/src/interfaces/IJBProjects.sol/interface.IJBProjects.md +0 -49
- package/docs/src/src/interfaces/IJBRulesetApprovalHook.sol/interface.IJBRulesetApprovalHook.md +0 -35
- package/docs/src/src/interfaces/IJBRulesetDataHook.sol/interface.IJBRulesetDataHook.md +0 -97
- package/docs/src/src/interfaces/IJBRulesets.sol/interface.IJBRulesets.md +0 -165
- package/docs/src/src/interfaces/IJBSplitHook.sol/interface.IJBSplitHook.md +0 -31
- package/docs/src/src/interfaces/IJBSplits.sol/interface.IJBSplits.md +0 -35
- package/docs/src/src/interfaces/IJBTerminal.sol/interface.IJBTerminal.md +0 -141
- package/docs/src/src/interfaces/IJBTerminalStore.sol/interface.IJBTerminalStore.md +0 -198
- package/docs/src/src/interfaces/IJBToken.sol/interface.IJBToken.md +0 -54
- package/docs/src/src/interfaces/IJBTokenUriResolver.sol/interface.IJBTokenUriResolver.md +0 -12
- package/docs/src/src/interfaces/IJBTokens.sol/interface.IJBTokens.md +0 -151
- package/docs/src/src/interfaces/README.md +0 -33
- package/docs/src/src/libraries/JBCashOuts.sol/library.JBCashOuts.md +0 -40
- package/docs/src/src/libraries/JBConstants.sol/library.JBConstants.md +0 -52
- package/docs/src/src/libraries/JBCurrencyIds.sol/library.JBCurrencyIds.md +0 -19
- package/docs/src/src/libraries/JBFees.sol/library.JBFees.md +0 -52
- package/docs/src/src/libraries/JBFixedPointNumber.sol/library.JBFixedPointNumber.md +0 -12
- package/docs/src/src/libraries/JBMetadataResolver.sol/library.JBMetadataResolver.md +0 -242
- package/docs/src/src/libraries/JBRulesetMetadataResolver.sol/library.JBRulesetMetadataResolver.md +0 -180
- package/docs/src/src/libraries/JBSplitGroupIds.sol/library.JBSplitGroupIds.md +0 -14
- package/docs/src/src/libraries/JBSurplus.sol/library.JBSurplus.md +0 -44
- package/docs/src/src/libraries/README.md +0 -12
- package/docs/src/src/periphery/JBDeadline1Day.sol/contract.JBDeadline1Day.md +0 -15
- package/docs/src/src/periphery/JBDeadline3Days.sol/contract.JBDeadline3Days.md +0 -15
- package/docs/src/src/periphery/JBDeadline3Hours.sol/contract.JBDeadline3Hours.md +0 -15
- package/docs/src/src/periphery/JBDeadline7Days.sol/contract.JBDeadline7Days.md +0 -15
- package/docs/src/src/periphery/JBMatchingPriceFeed.sol/contract.JBMatchingPriceFeed.md +0 -22
- package/docs/src/src/periphery/README.md +0 -8
- package/docs/src/src/structs/JBAccountingContext.sol/struct.JBAccountingContext.md +0 -20
- package/docs/src/src/structs/JBAfterCashOutRecordedContext.sol/struct.JBAfterCashOutRecordedContext.md +0 -43
- package/docs/src/src/structs/JBAfterPayRecordedContext.sol/struct.JBAfterPayRecordedContext.md +0 -42
- package/docs/src/src/structs/JBBeforeCashOutRecordedContext.sol/struct.JBBeforeCashOutRecordedContext.md +0 -45
- package/docs/src/src/structs/JBBeforePayRecordedContext.sol/struct.JBBeforePayRecordedContext.md +0 -41
- package/docs/src/src/structs/JBCashOutHookSpecification.sol/struct.JBCashOutHookSpecification.md +0 -22
- package/docs/src/src/structs/JBCurrencyAmount.sol/struct.JBCurrencyAmount.md +0 -17
- package/docs/src/src/structs/JBFee.sol/struct.JBFee.md +0 -20
- package/docs/src/src/structs/JBFundAccessLimitGroup.sol/struct.JBFundAccessLimitGroup.md +0 -39
- package/docs/src/src/structs/JBPayHookSpecification.sol/struct.JBPayHookSpecification.md +0 -22
- package/docs/src/src/structs/JBPermissionsData.sol/struct.JBPermissionsData.md +0 -21
- package/docs/src/src/structs/JBRuleset.sol/struct.JBRuleset.md +0 -55
- package/docs/src/src/structs/JBRulesetConfig.sol/struct.JBRulesetConfig.md +0 -51
- package/docs/src/src/structs/JBRulesetMetadata.sol/struct.JBRulesetMetadata.md +0 -79
- package/docs/src/src/structs/JBRulesetWeightCache.sol/struct.JBRulesetWeightCache.md +0 -16
- package/docs/src/src/structs/JBRulesetWithMetadata.sol/struct.JBRulesetWithMetadata.md +0 -16
- package/docs/src/src/structs/JBSingleAllowance.sol/struct.JBSingleAllowance.md +0 -26
- package/docs/src/src/structs/JBSplit.sol/struct.JBSplit.md +0 -49
- package/docs/src/src/structs/JBSplitGroup.sol/struct.JBSplitGroup.md +0 -17
- package/docs/src/src/structs/JBSplitHookContext.sol/struct.JBSplitHookContext.md +0 -29
- package/docs/src/src/structs/JBTerminalConfig.sol/struct.JBTerminalConfig.md +0 -16
- package/docs/src/src/structs/JBTokenAmount.sol/struct.JBTokenAmount.md +0 -23
- package/docs/src/src/structs/README.md +0 -25
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity >=0.8.6;
|
|
3
|
+
|
|
4
|
+
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
5
|
+
import {MetadataResolverHelper} from "./helpers/MetadataResolverHelper.sol";
|
|
6
|
+
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
7
|
+
import {IJBPrices} from "../src/interfaces/IJBPrices.sol";
|
|
8
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
9
|
+
import {IJBRulesetDataHook} from "../src/interfaces/IJBRulesetDataHook.sol";
|
|
10
|
+
import {IJBTerminal} from "../src/interfaces/IJBTerminal.sol";
|
|
11
|
+
import {IJBTokens} from "../src/interfaces/IJBTokens.sol";
|
|
12
|
+
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
13
|
+
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
14
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
15
|
+
import {JBPayHookSpecification} from "../src/structs/JBPayHookSpecification.sol";
|
|
16
|
+
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
17
|
+
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
18
|
+
import {JBSingleAllowance} from "../src/structs/JBSingleAllowance.sol";
|
|
19
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
20
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
21
|
+
import {IAllowanceTransfer, IPermit2} from "@uniswap/permit2/src/interfaces/IPermit2.sol";
|
|
22
|
+
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
23
|
+
import {MockPriceFeed} from "./mock/MockPriceFeed.sol";
|
|
24
|
+
import {mulDiv} from "@prb/math/src/Common.sol";
|
|
25
|
+
|
|
26
|
+
/// @notice Tests combining Permit2 ERC-20 transfers with data hook weight overrides.
|
|
27
|
+
contract TestPermit2DataHook_Local is TestBaseWorkflow {
|
|
28
|
+
uint112 private constant _WEIGHT = uint112(1000 * 10 ** 18);
|
|
29
|
+
address private constant _DATA_HOOK = address(bytes20(keccak256("permit2datahook")));
|
|
30
|
+
|
|
31
|
+
IJBController private _controller;
|
|
32
|
+
IJBTerminal private _terminal;
|
|
33
|
+
IJBPrices private _prices;
|
|
34
|
+
IJBTokens private _tokens;
|
|
35
|
+
IERC20 private _usdc;
|
|
36
|
+
IPermit2 private _permit2;
|
|
37
|
+
MetadataResolverHelper private _helper;
|
|
38
|
+
address private _projectOwner;
|
|
39
|
+
|
|
40
|
+
uint256 _projectId;
|
|
41
|
+
|
|
42
|
+
// Permit2 params.
|
|
43
|
+
// forge-lint: disable-next-line(mixed-case-variable)
|
|
44
|
+
bytes32 DOMAIN_SEPARATOR;
|
|
45
|
+
address from;
|
|
46
|
+
uint256 fromPrivateKey;
|
|
47
|
+
|
|
48
|
+
// Price.
|
|
49
|
+
uint256 _nativePricePerUsd = 0.0005 * 10 ** 18; // 1/2000
|
|
50
|
+
|
|
51
|
+
function setUp() public override {
|
|
52
|
+
super.setUp();
|
|
53
|
+
|
|
54
|
+
vm.label(_DATA_HOOK, "Data Hook");
|
|
55
|
+
|
|
56
|
+
_controller = jbController();
|
|
57
|
+
_projectOwner = multisig();
|
|
58
|
+
_terminal = jbMultiTerminal();
|
|
59
|
+
_prices = jbPrices();
|
|
60
|
+
_tokens = jbTokens();
|
|
61
|
+
_helper = metadataHelper();
|
|
62
|
+
_usdc = usdcToken();
|
|
63
|
+
_permit2 = permit2();
|
|
64
|
+
|
|
65
|
+
fromPrivateKey = 0x12341234;
|
|
66
|
+
from = vm.addr(fromPrivateKey);
|
|
67
|
+
DOMAIN_SEPARATOR = permit2().DOMAIN_SEPARATOR();
|
|
68
|
+
|
|
69
|
+
// First project: fee collector with data hook disabled.
|
|
70
|
+
JBRulesetMetadata memory _feeMetadata = JBRulesetMetadata({
|
|
71
|
+
reservedPercent: 0,
|
|
72
|
+
cashOutTaxRate: JBConstants.MAX_CASH_OUT_TAX_RATE,
|
|
73
|
+
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
74
|
+
pausePay: false,
|
|
75
|
+
pauseCreditTransfers: false,
|
|
76
|
+
allowOwnerMinting: true,
|
|
77
|
+
allowSetCustomToken: true,
|
|
78
|
+
allowTerminalMigration: false,
|
|
79
|
+
allowSetTerminals: false,
|
|
80
|
+
ownerMustSendPayouts: false,
|
|
81
|
+
allowSetController: false,
|
|
82
|
+
allowAddAccountingContext: true,
|
|
83
|
+
allowAddPriceFeed: true,
|
|
84
|
+
holdFees: false,
|
|
85
|
+
useTotalSurplusForCashOuts: false,
|
|
86
|
+
useDataHookForPay: false,
|
|
87
|
+
useDataHookForCashOut: false,
|
|
88
|
+
dataHook: address(0),
|
|
89
|
+
metadata: 0
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
JBRulesetConfig[] memory _feeRulesetConfig = new JBRulesetConfig[](1);
|
|
93
|
+
_feeRulesetConfig[0].mustStartAtOrAfter = 0;
|
|
94
|
+
_feeRulesetConfig[0].duration = 0;
|
|
95
|
+
_feeRulesetConfig[0].weight = _WEIGHT;
|
|
96
|
+
_feeRulesetConfig[0].weightCutPercent = 0;
|
|
97
|
+
_feeRulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
|
|
98
|
+
_feeRulesetConfig[0].metadata = _feeMetadata;
|
|
99
|
+
_feeRulesetConfig[0].splitGroups = new JBSplitGroup[](0);
|
|
100
|
+
_feeRulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
|
|
101
|
+
|
|
102
|
+
JBTerminalConfig[] memory _terminalConfigurations = new JBTerminalConfig[](1);
|
|
103
|
+
JBAccountingContext[] memory _tokensToAccept = new JBAccountingContext[](2);
|
|
104
|
+
_tokensToAccept[0] = JBAccountingContext({
|
|
105
|
+
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
106
|
+
});
|
|
107
|
+
_tokensToAccept[1] = JBAccountingContext({
|
|
108
|
+
token: address(usdcToken()), decimals: 6, currency: uint32(uint160(address(usdcToken())))
|
|
109
|
+
});
|
|
110
|
+
_terminalConfigurations[0] =
|
|
111
|
+
JBTerminalConfig({terminal: _terminal, accountingContextsToAccept: _tokensToAccept});
|
|
112
|
+
|
|
113
|
+
// Create fee project (project ID 1).
|
|
114
|
+
_controller.launchProjectFor({
|
|
115
|
+
owner: _projectOwner,
|
|
116
|
+
projectUri: "feeProject",
|
|
117
|
+
rulesetConfigurations: _feeRulesetConfig,
|
|
118
|
+
terminalConfigurations: _terminalConfigurations,
|
|
119
|
+
memo: ""
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Second project: data hook enabled for pay, uses USDC via Permit2.
|
|
123
|
+
JBRulesetMetadata memory _metadata = JBRulesetMetadata({
|
|
124
|
+
reservedPercent: 0,
|
|
125
|
+
cashOutTaxRate: JBConstants.MAX_CASH_OUT_TAX_RATE,
|
|
126
|
+
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
127
|
+
pausePay: false,
|
|
128
|
+
pauseCreditTransfers: false,
|
|
129
|
+
allowOwnerMinting: true,
|
|
130
|
+
allowSetCustomToken: true,
|
|
131
|
+
allowTerminalMigration: false,
|
|
132
|
+
allowSetTerminals: false,
|
|
133
|
+
ownerMustSendPayouts: false,
|
|
134
|
+
allowSetController: false,
|
|
135
|
+
allowAddAccountingContext: true,
|
|
136
|
+
allowAddPriceFeed: true,
|
|
137
|
+
holdFees: false,
|
|
138
|
+
useTotalSurplusForCashOuts: false,
|
|
139
|
+
useDataHookForPay: true,
|
|
140
|
+
useDataHookForCashOut: false,
|
|
141
|
+
dataHook: _DATA_HOOK,
|
|
142
|
+
metadata: 0
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
JBRulesetConfig[] memory _rulesetConfig = new JBRulesetConfig[](1);
|
|
146
|
+
_rulesetConfig[0].mustStartAtOrAfter = 0;
|
|
147
|
+
_rulesetConfig[0].duration = 0;
|
|
148
|
+
_rulesetConfig[0].weight = _WEIGHT;
|
|
149
|
+
_rulesetConfig[0].weightCutPercent = 0;
|
|
150
|
+
_rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
|
|
151
|
+
_rulesetConfig[0].metadata = _metadata;
|
|
152
|
+
_rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
|
|
153
|
+
_rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
|
|
154
|
+
|
|
155
|
+
_projectId = _controller.launchProjectFor({
|
|
156
|
+
owner: _projectOwner,
|
|
157
|
+
projectUri: "permit2DataHookProject",
|
|
158
|
+
rulesetConfigurations: _rulesetConfig,
|
|
159
|
+
terminalConfigurations: _terminalConfigurations,
|
|
160
|
+
memo: ""
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
vm.startPrank(_projectOwner);
|
|
164
|
+
MockPriceFeed _priceFeedNativeUsd = new MockPriceFeed(_nativePricePerUsd, 18);
|
|
165
|
+
vm.label(address(_priceFeedNativeUsd), "Mock Price Feed Native-USD");
|
|
166
|
+
|
|
167
|
+
_controller.addPriceFeed({
|
|
168
|
+
projectId: _projectId,
|
|
169
|
+
pricingCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
170
|
+
unitCurrency: uint32(uint160(address(usdcToken()))),
|
|
171
|
+
feed: _priceFeedNativeUsd
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
vm.stopPrank();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/// @notice Builds Permit2 metadata for the given coin amount and nonce.
|
|
178
|
+
function _buildPermit2Metadata(uint256 coins, uint48 nonce) internal view returns (bytes memory packedData) {
|
|
179
|
+
uint256 deadline = block.timestamp + 1 days;
|
|
180
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
181
|
+
uint48 expiration = uint48(block.timestamp + 1 days);
|
|
182
|
+
|
|
183
|
+
IAllowanceTransfer.PermitDetails memory details = IAllowanceTransfer.PermitDetails({
|
|
184
|
+
token: address(_usdc),
|
|
185
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
186
|
+
amount: uint160(coins),
|
|
187
|
+
expiration: expiration,
|
|
188
|
+
nonce: nonce
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
IAllowanceTransfer.PermitSingle memory permitSingle =
|
|
192
|
+
IAllowanceTransfer.PermitSingle({details: details, spender: address(_terminal), sigDeadline: deadline});
|
|
193
|
+
|
|
194
|
+
bytes memory sig = getPermitSignature(permitSingle, fromPrivateKey, DOMAIN_SEPARATOR);
|
|
195
|
+
|
|
196
|
+
JBSingleAllowance memory permitData = JBSingleAllowance({
|
|
197
|
+
sigDeadline: deadline,
|
|
198
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
199
|
+
amount: uint160(coins),
|
|
200
|
+
expiration: expiration,
|
|
201
|
+
nonce: nonce,
|
|
202
|
+
signature: sig
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
bytes4[] memory ids = new bytes4[](1);
|
|
206
|
+
bytes[] memory datas = new bytes[](1);
|
|
207
|
+
datas[0] = abi.encode(permitData);
|
|
208
|
+
ids[0] = _helper.getId("permit2", address(_terminal));
|
|
209
|
+
|
|
210
|
+
packedData = _helper.createMetadata(ids, datas);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/// @notice Pay via Permit2 with a data hook that returns the original weight -- tokens should match normal
|
|
214
|
+
/// issuance.
|
|
215
|
+
function test_permit2_withDataHook_paySucceeds() public {
|
|
216
|
+
uint256 _coins = 1_000_000; // 1 USDC (6 decimals)
|
|
217
|
+
|
|
218
|
+
// Data hook returns the original weight and empty hook specifications.
|
|
219
|
+
JBPayHookSpecification[] memory _emptySpecs = new JBPayHookSpecification[](0);
|
|
220
|
+
vm.mockCall(
|
|
221
|
+
_DATA_HOOK,
|
|
222
|
+
abi.encodeWithSelector(IJBRulesetDataHook.beforePayRecordedWith.selector),
|
|
223
|
+
abi.encode(uint256(_WEIGHT), _emptySpecs)
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
// Build Permit2 metadata.
|
|
227
|
+
bytes memory _packedData = _buildPermit2Metadata(_coins, 0);
|
|
228
|
+
|
|
229
|
+
// Setup: give coins and approve permit2 contract.
|
|
230
|
+
deal(address(_usdc), from, _coins);
|
|
231
|
+
vm.prank(from);
|
|
232
|
+
IERC20(address(_usdc)).approve(address(permit2()), _coins);
|
|
233
|
+
|
|
234
|
+
// Pay using Permit2 with data hook.
|
|
235
|
+
vm.prank(from);
|
|
236
|
+
uint256 _minted = _terminal.pay({
|
|
237
|
+
projectId: _projectId,
|
|
238
|
+
amount: _coins,
|
|
239
|
+
token: address(_usdc),
|
|
240
|
+
beneficiary: from,
|
|
241
|
+
minReturnedTokens: 0,
|
|
242
|
+
memo: "Permit2 + data hook",
|
|
243
|
+
metadata: _packedData
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// Check: tokens were transferred.
|
|
247
|
+
assertEq(_usdc.balanceOf(address(_terminal)), _coins, "terminal should hold the USDC");
|
|
248
|
+
|
|
249
|
+
// Check: payer receives project tokens.
|
|
250
|
+
assertEq(_tokens.totalBalanceOf(from, _projectId), _minted, "payer should have minted tokens");
|
|
251
|
+
|
|
252
|
+
// Check: minted amount matches expected calculation.
|
|
253
|
+
// The baseCurrency is NATIVE_TOKEN (ETH), so USDC amounts get converted via price feed.
|
|
254
|
+
// 1 USDC = 0.0005 ETH (from _nativePricePerUsd). So 1e6 USDC = 0.0005e18 = 5e14 ETH.
|
|
255
|
+
// Token count = ethEquivalent * weight / 10^18
|
|
256
|
+
// ethEquivalent = _coins * 10^12 (6->18 decimals) * _nativePricePerUsd / 10^18
|
|
257
|
+
uint256 adjustedAmount = _coins * 10 ** 12; // adjust from 6 to 18 decimals
|
|
258
|
+
uint256 ethEquivalent = mulDiv(adjustedAmount, _nativePricePerUsd, 10 ** 18);
|
|
259
|
+
uint256 expectedTokens = mulDiv(ethEquivalent, _WEIGHT, 10 ** 18);
|
|
260
|
+
assertEq(_minted, expectedTokens, "minted tokens should match weight calculation");
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/// @notice Pay via Permit2 with a data hook that modifies the weight (2x) -- tokens should reflect the modified
|
|
264
|
+
/// weight.
|
|
265
|
+
function test_permit2_withDataHook_hookModifiesWeight() public {
|
|
266
|
+
uint256 _coins = 500_000; // 0.5 USDC (6 decimals)
|
|
267
|
+
|
|
268
|
+
// Data hook returns 2x the original weight.
|
|
269
|
+
uint256 _modifiedWeight = uint256(_WEIGHT) * 2;
|
|
270
|
+
JBPayHookSpecification[] memory _emptySpecs = new JBPayHookSpecification[](0);
|
|
271
|
+
vm.mockCall(
|
|
272
|
+
_DATA_HOOK,
|
|
273
|
+
abi.encodeWithSelector(IJBRulesetDataHook.beforePayRecordedWith.selector),
|
|
274
|
+
abi.encode(_modifiedWeight, _emptySpecs)
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
// Build Permit2 metadata.
|
|
278
|
+
bytes memory _packedData = _buildPermit2Metadata(_coins, 0);
|
|
279
|
+
|
|
280
|
+
// Setup: give coins and approve permit2 contract.
|
|
281
|
+
deal(address(_usdc), from, _coins);
|
|
282
|
+
vm.prank(from);
|
|
283
|
+
IERC20(address(_usdc)).approve(address(permit2()), _coins);
|
|
284
|
+
|
|
285
|
+
// Pay using Permit2 with data hook.
|
|
286
|
+
vm.prank(from);
|
|
287
|
+
uint256 _minted = _terminal.pay({
|
|
288
|
+
projectId: _projectId,
|
|
289
|
+
amount: _coins,
|
|
290
|
+
token: address(_usdc),
|
|
291
|
+
beneficiary: from,
|
|
292
|
+
minReturnedTokens: 0,
|
|
293
|
+
memo: "Permit2 + modified weight",
|
|
294
|
+
metadata: _packedData
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// Check: correct ERC-20 amount transferred via Permit2.
|
|
298
|
+
assertEq(_usdc.balanceOf(address(_terminal)), _coins, "terminal should hold the USDC");
|
|
299
|
+
|
|
300
|
+
// Check: tokens minted matches the MODIFIED weight (2x), not the original.
|
|
301
|
+
// USDC amounts are converted to ETH via price feed before token calculation.
|
|
302
|
+
// 500_000 USDC (0.5 USDC) = 0.00025 ETH = 2.5e14 at 18 decimals.
|
|
303
|
+
// Token count = ethEquivalent * modifiedWeight / 10^18
|
|
304
|
+
uint256 adjustedAmount = _coins * 10 ** 12; // adjust from 6 to 18 decimals
|
|
305
|
+
uint256 ethEquivalent = mulDiv(adjustedAmount, _nativePricePerUsd, 10 ** 18);
|
|
306
|
+
uint256 expectedTokens = mulDiv(ethEquivalent, _modifiedWeight, 10 ** 18);
|
|
307
|
+
assertEq(_minted, expectedTokens, "minted tokens should match 2x modified weight");
|
|
308
|
+
|
|
309
|
+
// Check: payer balance matches.
|
|
310
|
+
assertEq(_tokens.totalBalanceOf(from, _projectId), _minted, "payer should have all minted tokens");
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/// Permit2 signature helpers.
|
|
314
|
+
/// (required because `permit2/test/utils/PermitSignature.sol` imports `draft-EIP712.sol` which is no longer a
|
|
315
|
+
/// draft.)
|
|
316
|
+
|
|
317
|
+
bytes32 public constant _PERMIT_DETAILS_TYPEHASH =
|
|
318
|
+
keccak256("PermitDetails(address token,uint160 amount,uint48 expiration,uint48 nonce)");
|
|
319
|
+
|
|
320
|
+
bytes32 public constant _PERMIT_SINGLE_TYPEHASH = keccak256(
|
|
321
|
+
"PermitSingle(PermitDetails details,address spender,uint256 sigDeadline)PermitDetails(address token,uint160 amount,uint48 expiration,uint48 nonce)"
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
function getPermitSignatureRaw(
|
|
325
|
+
IAllowanceTransfer.PermitSingle memory permitSingle,
|
|
326
|
+
uint256 privateKey,
|
|
327
|
+
bytes32 domainSeparator
|
|
328
|
+
)
|
|
329
|
+
internal
|
|
330
|
+
pure
|
|
331
|
+
returns (uint8 v, bytes32 r, bytes32 s)
|
|
332
|
+
{
|
|
333
|
+
bytes32 permitHash = keccak256(abi.encode(_PERMIT_DETAILS_TYPEHASH, permitSingle.details));
|
|
334
|
+
|
|
335
|
+
bytes32 msgHash = keccak256(
|
|
336
|
+
abi.encodePacked(
|
|
337
|
+
"\x19\x01",
|
|
338
|
+
domainSeparator,
|
|
339
|
+
keccak256(
|
|
340
|
+
abi.encode(_PERMIT_SINGLE_TYPEHASH, permitHash, permitSingle.spender, permitSingle.sigDeadline)
|
|
341
|
+
)
|
|
342
|
+
)
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
(v, r, s) = vm.sign(privateKey, msgHash);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function getPermitSignature(
|
|
349
|
+
IAllowanceTransfer.PermitSingle memory permitSingle,
|
|
350
|
+
uint256 privateKey,
|
|
351
|
+
bytes32 domainSeparator
|
|
352
|
+
)
|
|
353
|
+
internal
|
|
354
|
+
pure
|
|
355
|
+
returns (bytes memory sig)
|
|
356
|
+
{
|
|
357
|
+
(uint8 v, bytes32 r, bytes32 s) = getPermitSignatureRaw(permitSingle, privateKey, domainSeparator);
|
|
358
|
+
return bytes.concat(r, s, bytes1(v));
|
|
359
|
+
}
|
|
360
|
+
}
|
|
@@ -32,8 +32,7 @@ contract TestRulesetQueuing_Local is TestBaseWorkflow {
|
|
|
32
32
|
uint256 private _DEADLINE_DURATION = 3 days;
|
|
33
33
|
// forge-lint: disable-next-line(mixed-case-variable)
|
|
34
34
|
uint256 private _RULESET_DURATION_DAYS = 6;
|
|
35
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
36
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
35
|
+
// forge-lint: disable-next-line(unsafe-typecast, mixed-case-variable)
|
|
37
36
|
uint32 private _RULESET_DURATION = uint32(_RULESET_DURATION_DAYS * 1 days);
|
|
38
37
|
|
|
39
38
|
function setUp() public override {
|
|
@@ -4,8 +4,14 @@ pragma solidity >=0.8.6;
|
|
|
4
4
|
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
5
5
|
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
6
6
|
import {IJBRulesets} from "../src/interfaces/IJBRulesets.sol";
|
|
7
|
+
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
7
8
|
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
8
9
|
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
10
|
+
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
11
|
+
import {JBRuleset} from "../src/structs/JBRuleset.sol";
|
|
12
|
+
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
13
|
+
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
14
|
+
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
9
15
|
|
|
10
16
|
// A ruleset's weight can be cached to make larger intervals calculable while staying within the gas limit.
|
|
11
17
|
contract TestRulesetWeightCaching_Local is TestBaseWorkflow {
|
|
@@ -51,130 +57,122 @@ contract TestRulesetWeightCaching_Local is TestBaseWorkflow {
|
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
/// Test that caching a ruleset's weight yields the same result as computing it.
|
|
60
|
+
/// @dev Bounded to 1,000 rulesets for CI speed. For full coverage (80,000), run:
|
|
61
|
+
/// forge test --match-test testWeightCaching -vvv --fuzz-runs 8
|
|
54
62
|
function testWeightCaching(uint256 _rulesetDiff) public {
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
//
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
//
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
//
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
//
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
//
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
// // Go many rolled over rulesets into the future.
|
|
170
|
-
// vm.warp(block.timestamp + (_DURATION * _rulesetDiff));
|
|
171
|
-
|
|
172
|
-
// // Queue the ruleset.
|
|
173
|
-
// vm.prank(_projectOwner);
|
|
174
|
-
// _controller.queueRulesetsOf({
|
|
175
|
-
// projectId: _projectId2,
|
|
176
|
-
// rulesetConfigurations: _rulesetConfigurations,
|
|
177
|
-
// memo: ""
|
|
178
|
-
// });
|
|
63
|
+
// Bound to a CI-friendly range. The cache threshold is 20,000 iterations;
|
|
64
|
+
// 1,000 is enough to exercise the caching path without extreme gas usage.
|
|
65
|
+
_rulesetDiff = bound(_rulesetDiff, 0, 1000);
|
|
66
|
+
|
|
67
|
+
// Keep references to the projects.
|
|
68
|
+
uint256 _projectId1;
|
|
69
|
+
uint256 _projectId2;
|
|
70
|
+
|
|
71
|
+
// Package up the ruleset configuration.
|
|
72
|
+
JBRulesetConfig[] memory _rulesetConfigurations = new JBRulesetConfig[](1);
|
|
73
|
+
|
|
74
|
+
{
|
|
75
|
+
_rulesetConfigurations[0].mustStartAtOrAfter = 0;
|
|
76
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
77
|
+
_rulesetConfigurations[0].duration = uint32(_DURATION); // safe: _DURATION = 1
|
|
78
|
+
_rulesetConfigurations[0].weight = uint112(1000 * 10 ** _WEIGHT_DECIMALS);
|
|
79
|
+
// forge-lint: disable-next-line(unsafe-typecast)
|
|
80
|
+
_rulesetConfigurations[0].weightCutPercent = uint32(_WEIGHT_CUT_PERCENT); // safe: _WEIGHT_CUT_PERCENT = 1
|
|
81
|
+
_rulesetConfigurations[0].approvalHook = IJBRulesetApprovalHook(address(0));
|
|
82
|
+
_rulesetConfigurations[0].metadata = _metadata;
|
|
83
|
+
_rulesetConfigurations[0].splitGroups = new JBSplitGroup[](0);
|
|
84
|
+
_rulesetConfigurations[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
|
|
85
|
+
|
|
86
|
+
// Create the project to test.
|
|
87
|
+
_projectId1 = _controller.launchProjectFor({
|
|
88
|
+
owner: _projectOwner,
|
|
89
|
+
projectUri: "myIPFSHash",
|
|
90
|
+
rulesetConfigurations: _rulesetConfigurations,
|
|
91
|
+
terminalConfigurations: new JBTerminalConfig[](0),
|
|
92
|
+
memo: ""
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Create the project to test.
|
|
96
|
+
_projectId2 = _controller.launchProjectFor({
|
|
97
|
+
owner: _projectOwner,
|
|
98
|
+
projectUri: "myIPFSHash",
|
|
99
|
+
rulesetConfigurations: _rulesetConfigurations,
|
|
100
|
+
terminalConfigurations: new JBTerminalConfig[](0),
|
|
101
|
+
memo: ""
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Keep a reference to the current rulesets.
|
|
106
|
+
JBRuleset memory _ruleset1 = jbRulesets().currentOf(_projectId1);
|
|
107
|
+
JBRuleset memory _ruleset2 = jbRulesets().currentOf(_projectId2);
|
|
108
|
+
|
|
109
|
+
// Go a few rolled over rulesets into the future.
|
|
110
|
+
vm.warp(block.timestamp + (_DURATION * 10));
|
|
111
|
+
|
|
112
|
+
// Keep a reference to the amount of gas before the caching call.
|
|
113
|
+
uint256 _gasBeforeCache = gasleft();
|
|
114
|
+
|
|
115
|
+
// Cache the weight in the second project using the latest ruleset ID.
|
|
116
|
+
_rulesets.updateRulesetWeightCache(_projectId2, _rulesets.latestRulesetIdOf(_projectId2));
|
|
117
|
+
|
|
118
|
+
// Keep a reference to the amount of gas spent on the call.
|
|
119
|
+
uint256 _gasDiffCache = _gasBeforeCache - gasleft();
|
|
120
|
+
|
|
121
|
+
// Make sure the difference is within the gas limit.
|
|
122
|
+
assertLe(_gasDiffCache, _GAS_LIMIT);
|
|
123
|
+
|
|
124
|
+
// Go many rolled over rulesets into the future.
|
|
125
|
+
vm.warp(block.timestamp + (_DURATION * _rulesetDiff));
|
|
126
|
+
|
|
127
|
+
// Cache the weight in the second project again.
|
|
128
|
+
_rulesets.updateRulesetWeightCache(_projectId2, _rulesets.latestRulesetIdOf(_projectId2));
|
|
129
|
+
|
|
130
|
+
// Inherit the weight (weight=1 is the inherit sentinel in the current API).
|
|
131
|
+
_rulesetConfigurations[0].weight = 1;
|
|
132
|
+
|
|
133
|
+
// Keep a reference to the amount of gas before the call.
|
|
134
|
+
uint256 _gasBefore1 = gasleft();
|
|
135
|
+
|
|
136
|
+
// Queue the ruleset.
|
|
137
|
+
vm.startPrank(_projectOwner);
|
|
138
|
+
_controller.queueRulesetsOf({projectId: _projectId1, rulesetConfigurations: _rulesetConfigurations, memo: ""});
|
|
139
|
+
|
|
140
|
+
// Keep a reference to the amount of gas spent on the call.
|
|
141
|
+
uint256 _gasDiff1 = _gasBefore1 - gasleft();
|
|
142
|
+
|
|
143
|
+
// Make sure the difference is within the gas limit.
|
|
144
|
+
assertLe(_gasDiff1, _GAS_LIMIT);
|
|
145
|
+
|
|
146
|
+
// Keep a reference to the amount of gas before the call.
|
|
147
|
+
uint256 _gasBefore2 = gasleft();
|
|
148
|
+
|
|
149
|
+
_controller.queueRulesetsOf({projectId: _projectId2, rulesetConfigurations: _rulesetConfigurations, memo: ""});
|
|
150
|
+
vm.stopPrank();
|
|
151
|
+
|
|
152
|
+
// Keep a reference to the amount of gas spent on the call.
|
|
153
|
+
uint256 _gasDiff2 = _gasBefore2 - gasleft();
|
|
154
|
+
|
|
155
|
+
// Make sure the difference is within the gas limit.
|
|
156
|
+
assertLe(_gasDiff2, _GAS_LIMIT);
|
|
157
|
+
|
|
158
|
+
// Renew the reference to the current ruleset.
|
|
159
|
+
_ruleset1 = jbRulesets().currentOf(_projectId1);
|
|
160
|
+
_ruleset2 = jbRulesets().currentOf(_projectId2);
|
|
161
|
+
|
|
162
|
+
// The cached call should have been cheaper.
|
|
163
|
+
assertLe(_gasDiff2, _gasDiff1);
|
|
164
|
+
|
|
165
|
+
// Make sure the rulesets have the same weight.
|
|
166
|
+
assertEq(_ruleset1.weight, _ruleset2.weight);
|
|
167
|
+
|
|
168
|
+
// Cache the weight in the second project again.
|
|
169
|
+
_rulesets.updateRulesetWeightCache(_projectId2, _rulesets.latestRulesetIdOf(_projectId2));
|
|
170
|
+
|
|
171
|
+
// Go many rolled over rulesets into the future.
|
|
172
|
+
vm.warp(block.timestamp + (_DURATION * _rulesetDiff));
|
|
173
|
+
|
|
174
|
+
// Queue the ruleset.
|
|
175
|
+
vm.prank(_projectOwner);
|
|
176
|
+
_controller.queueRulesetsOf({projectId: _projectId2, rulesetConfigurations: _rulesetConfigurations, memo: ""});
|
|
179
177
|
}
|
|
180
178
|
}
|