Skip to content

Commit

Permalink
Enable via-ir
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeSandwich committed Feb 26, 2024
1 parent c9dbd6e commit 4b99ee0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
if: ${{ github.event_name == 'push' }}
run: echo FOUNDRY_FUZZ_RUNS=50000 >> $GITHUB_ENV
- name: run tests
run: forge test --deny-warnings
run: FOUNDRY_PROFILE=optimized forge test --deny-warnings
- name: run Slither
uses: crytic/slither-action@v0.3.0
with:
Expand Down
6 changes: 5 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[profile.default]
solc_version = '0.8.24'
evm_version = 'shanghai'
optimizer_runs = 7_700
optimizer = false
verbosity = 1
fuzz_runs = 5
[profile.optimized]
via_ir = true
optimizer = true
optimizer_runs = 1_000_000_000
[fmt]
line_length = 100
[fuzz]
Expand Down
8 changes: 5 additions & 3 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ ffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b61
}

drips_deployer() {
local GET_DEPLOYED="getDeployed(address deployer, bytes32 salt)(address deployed))"
local GET_DEPLOYED="getDeployed(address deployer, bytes32 salt)(address deployed)"
local SALT="$(cast format-bytes32-string "$DRIPS_DEPLOYER_SALT")"
cast call "$CREATE3_FACTORY" "$GET_DEPLOYED" "$WALLET" "$SALT"
}
Expand Down Expand Up @@ -197,6 +197,8 @@ query() {
}

main() {
export FOUNDRY_PROFILE=optimized

verify_parameter ETH_RPC_URL
verify_parameter WALLET_ARGS
verify_parameter DRIPS_DEPLOYER_SALT
Expand Down Expand Up @@ -278,8 +280,8 @@ main() {
esac
done

print_title "Installing dependencies"
forge install
print_title "Building the contracts"
forge build --skip test

if [ -n "$DEPLOY_DETERMINISTIC_DEPLOYER" ]; then
deploy_deterministic_deployer
Expand Down
2 changes: 2 additions & 0 deletions scripts/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ verify_single() {
}

main() {
export FOUNDRY_PROFILE=optimized

if [ -z "$1" ]; then
echo "Error: expected 1 argument, the DripsDeployer address, see README.md"
exit 1
Expand Down
12 changes: 6 additions & 6 deletions src/DripsDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ abstract contract ProxyDeployerModule is BaseModule {
}

abstract contract DripsDependentModule is BaseModule {
bytes32 internal immutable _dripsModuleSalt = "Drips";
bytes32 internal constant _DRIPS_MODULE_SALT = "Drips";

function _dripsModule() internal view returns (DripsModule) {
address module = _moduleAddress(_dripsModuleSalt);
address module = _moduleAddress(_DRIPS_MODULE_SALT);
require(Address.isContract(module), "Drips module not deployed");
return DripsModule(module);
}
Expand All @@ -150,7 +150,7 @@ contract DripsModule is DripsDependentModule, ProxyDeployerModule {
}

constructor(DripsDeployer dripsDeployer_, uint32 dripsCycleSecs_, address proxyAdmin_)
BaseModule(dripsDeployer_, _dripsModuleSalt)
BaseModule(dripsDeployer_, _DRIPS_MODULE_SALT)
{
dripsCycleSecs = dripsCycleSecs_;
// slither-disable-next-line too-many-digits
Expand Down Expand Up @@ -179,10 +179,10 @@ contract DripsModule is DripsDependentModule, ProxyDeployerModule {
}

abstract contract CallerDependentModule is BaseModule {
bytes32 internal immutable _callerModuleSalt = "Caller";
bytes32 internal constant _CALLER_MODULE_SALT = "Caller";

function _callerModule() internal view returns (CallerModule) {
address module = _moduleAddress(_callerModuleSalt);
address module = _moduleAddress(_CALLER_MODULE_SALT);
require(Address.isContract(module), "Caller module not deployed");
return CallerModule(module);
}
Expand All @@ -193,7 +193,7 @@ contract CallerModule is ContractDeployerModule, CallerDependentModule {
return abi.encode(dripsDeployer);
}

constructor(DripsDeployer dripsDeployer_) BaseModule(dripsDeployer_, _callerModuleSalt) {
constructor(DripsDeployer dripsDeployer_) BaseModule(dripsDeployer_, _CALLER_MODULE_SALT) {
// slither-disable-next-line too-many-digits
_deployContract(type(Caller).creationCode);
}
Expand Down
2 changes: 1 addition & 1 deletion test/Caller.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ contract CallerTest is Test {

function testCallSignedRejectsExpiredDeadline() public {
bytes memory data = abi.encodeCall(target.run, (1));
uint256 deadline = block.timestamp;
skip(1);
uint256 deadline = block.timestamp - 1;
(bytes32 r, bytes32 sv) = signCall(senderKey, target, data, 0, 0, deadline);

vm.expectRevert(ERROR_DEADLINE);
Expand Down
20 changes: 10 additions & 10 deletions test/Streams.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -508,16 +508,15 @@ contract StreamsTest is Test, PseudoRandomUtils, Streams {
StreamsHistory[] memory streamsHistory,
uint256 expectedAmt
) internal {
(uint128 amtBefore,,,,) =
Streams._squeezeStreamsResult(accountId, erc20, senderId, historyHash, streamsHistory);
uint128 amtBefore =
this.squeezeStreamsResultExternal(accountId, senderId, historyHash, streamsHistory);
assertEq(amtBefore, expectedAmt, "Invalid squeezable amount before squeezing");

uint128 amt =
Streams._squeezeStreams(accountId, erc20, senderId, historyHash, streamsHistory);
uint128 amt = this.squeezeStreamsExternal(accountId, senderId, historyHash, streamsHistory);

assertEq(amt, expectedAmt, "Invalid squeezed amount");
(uint128 amtAfter,,,,) =
Streams._squeezeStreamsResult(accountId, erc20, senderId, historyHash, streamsHistory);
uint128 amtAfter =
this.squeezeStreamsResultExternal(accountId, senderId, historyHash, streamsHistory);
assertEq(amtAfter, 0, "Squeezable amount after squeezing non-zero");
}

Expand All @@ -539,17 +538,18 @@ contract StreamsTest is Test, PseudoRandomUtils, Streams {
uint256 senderId,
bytes32 historyHash,
StreamsHistory[] memory streamsHistory
) external {
Streams._squeezeStreams(accountId, erc20, senderId, historyHash, streamsHistory);
) external returns (uint128 amt) {
return Streams._squeezeStreams(accountId, erc20, senderId, historyHash, streamsHistory);
}

function squeezeStreamsResultExternal(
uint256 accountId,
uint256 senderId,
bytes32 historyHash,
StreamsHistory[] memory streamsHistory
) external view {
Streams._squeezeStreamsResult(accountId, erc20, senderId, historyHash, streamsHistory);
) external view returns (uint128 amt) {
(amt,,,,) =
Streams._squeezeStreamsResult(accountId, erc20, senderId, historyHash, streamsHistory);
}

function testStreamsConfigStoresParameters() public {
Expand Down

0 comments on commit 4b99ee0

Please sign in to comment.