diff --git a/foundry.toml b/foundry.toml index eadf4fa..d88e2ca 100644 --- a/foundry.toml +++ b/foundry.toml @@ -19,7 +19,7 @@ remappings = [ 'seaport-types/=src/types/', 'seaport-core/src/=src/core/', 'seaport-core/=src/core/', - 'seaport/=src/main/' + 'seaport/=src/main/', ] optimizer_runs = 4_294_967_295 fs_permissions = [ @@ -28,7 +28,7 @@ fs_permissions = [ { access = "write", path = "./call-metrics.txt" }, { access = "write", path = "./mutation-metrics.txt" }, { access = "write", path = "./assume-metrics.txt" }, - { access = "write", path = "./fuzz_debug.json" } + { access = "write", path = "./fuzz_debug.json" }, ] [profile.validator] @@ -47,7 +47,7 @@ out = 'reference-out' script = 'reference' # specify something so it doesn't try to compile the files in test/foundry test = 'test/foundry' -cache_path='reference-cache' +cache_path = 'reference-cache' [profile.optimized] src = 'src' @@ -57,14 +57,14 @@ out = 'optimized-out' script = 'script' bytecode_hash = 'none' # no need to compile tests with via-ir since they load optimized bytecode directly by default -test ='src/main' +test = 'src/main' evm_version = 'cancun' -cache_path='optimized-cache' -extra_output_files=['irOptimized'] +cache_path = 'optimized-cache' +extra_output_files = ['irOptimized'] [profile.test] src = 'test/foundry' -cache_path='test-cache' +cache_path = 'test-cache' [profile.test.fuzz] runs = 1_000 @@ -81,11 +81,14 @@ optimizer = false test = 'test/foundry/new' [profile.offerers] -src='offerers' -test='offerers' +src = 'offerers' +test = 'offerers' out = 'offerers-out' script = 'offerers' +[profile.tstorish] +test = 'tstorish' + [fmt] line_length = 80 tab_width = 4 diff --git a/script/TstorishDeploy.s.sol b/script/TstorishDeploy.s.sol new file mode 100644 index 0000000..06f6d65 --- /dev/null +++ b/script/TstorishDeploy.s.sol @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import { Script, console2 } from "forge-std/Script.sol"; +import { ConduitController } from + "seaport-core/src/conduit/ConduitController.sol"; +import { Consideration } from "seaport-core/src/lib/Consideration.sol"; + +contract TstorishDeploy is Script { + function run() public { + vm.broadcast(); + ConduitController controller = new ConduitController(); + vm.label(address(controller), "controller"); + vm.broadcast(); + Consideration seaport = new Consideration(address(controller)); + } +} diff --git a/tstorish.sh b/tstorish.sh new file mode 100644 index 0000000..e0a7ce4 --- /dev/null +++ b/tstorish.sh @@ -0,0 +1,29 @@ +# remove old dump +rm -f seaport.dump +# spin up anvil and prepare to dump state +anvil --hardfork shanghai --dump-state ./seaport.dump & +# save pid to kill later +pid=$! +# execute foundry script to deploy seaport +FOUNDRY_PROFILE=optimized forge script TstorishDeploy --rpc-url http://localhost:8545 --slow --skip-simulation --broadcast --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 +# get code of 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 +seaport=$(curl -sX POST --data '{"jsonrpc":"2.0","method":"eth_getCode","params":["0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512", "latest"],"id":1}' -H "Content-Type: application/json" http://localhost:8545 | jq '.result') +# exit anvil +echo $seaport +kill $pid +anvil --hardfork shanghai & +# save pid to kill later +pid=$! +# wait for anvil to warm up +sleep 5 +# call setCode on the 0xe7f address with the $seaport var +curl -X POST --data '{"jsonrpc":"2.0","method":"anvil_setCode","params":["0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512", '"$seaport"'],"id":1}' -H "Content-Type: application/json" http://localhost:8545 +# mine a block +# execute Tstorish test +FOUNDRY_PROFILE=tstorish forge test -vvvv --fork-url http://localhost:8545 +# get exit code of previous +exit_code=$? +# kill anvil +kill $pid +# exit with exit code of previous +exit $exit_code diff --git a/tstorish/Tstorish.t.sol b/tstorish/Tstorish.t.sol new file mode 100644 index 0000000..ab8220e --- /dev/null +++ b/tstorish/Tstorish.t.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import { Test } from "forge-std/Test.sol"; + +import { + ReentrancyGuard, + ReentrancyErrors +} from "seaport-core/src/lib/ReentrancyGuard.sol"; + +contract TstorishTest is Test { + ReentrancyGuard seaport; + + function setUp() public { + seaport = ReentrancyGuard( + payable( + // second contract deployed by first anvil pk + 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 + ) + ); + } + + function testActivate() public { + vm.etch( + 0xCafac3dD18aC6c6e92c921884f9E4176737C052c, + hex"3d5c" + ); + + // first call updates storage + vm.record(); + seaport.__activateTstore(); + (bytes32[] memory reads, bytes32[] memory writes) = + vm.accesses(address(seaport)); + assertEq(writes.length, 1); + // second call reverts + vm.expectRevert(ReentrancyErrors.TStoreAlreadyActivated.selector); + seaport.__activateTstore(); + } +}