diff --git a/.forge-snapshots/manySstore.snap b/.forge-snapshots/manySstore.snap index ef72e9b..1fbb791 100644 --- a/.forge-snapshots/manySstore.snap +++ b/.forge-snapshots/manySstore.snap @@ -1 +1 @@ -70348 \ No newline at end of file +49284 \ No newline at end of file diff --git a/.forge-snapshots/singleSstore.snap b/.forge-snapshots/singleSstore.snap index d049b15..80ecb46 100644 --- a/.forge-snapshots/singleSstore.snap +++ b/.forge-snapshots/singleSstore.snap @@ -1 +1 @@ -48459 \ No newline at end of file +27395 \ No newline at end of file diff --git a/.forge-snapshots/singleSstoreClosure.snap b/.forge-snapshots/singleSstoreClosure.snap index c59e906..962f066 100644 --- a/.forge-snapshots/singleSstoreClosure.snap +++ b/.forge-snapshots/singleSstoreClosure.snap @@ -1 +1 @@ -46269 \ No newline at end of file +25205 \ No newline at end of file diff --git a/.forge-snapshots/singleSstoreLastCall.snap b/.forge-snapshots/singleSstoreLastCall.snap index 4c52430..97400eb 100644 --- a/.forge-snapshots/singleSstoreLastCall.snap +++ b/.forge-snapshots/singleSstoreLastCall.snap @@ -1 +1 @@ -43429 \ No newline at end of file +22365 \ No newline at end of file diff --git a/.forge-snapshots/sstoreClosure.snap b/.forge-snapshots/sstoreClosure.snap index 5ed0938..edc2416 100644 --- a/.forge-snapshots/sstoreClosure.snap +++ b/.forge-snapshots/sstoreClosure.snap @@ -1 +1 @@ -68158 \ No newline at end of file +47094 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2c4088a..3f55d40 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ out/ lib/ cache/ +dependencies/ diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 888d42d..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "lib/forge-std"] - path = lib/forge-std - url = https://github.com/foundry-rs/forge-std diff --git a/.soldeerignore b/.soldeerignore new file mode 100644 index 0000000..6ae3add --- /dev/null +++ b/.soldeerignore @@ -0,0 +1,5 @@ +.git/ +.github/ +.forge_snapshots/ +out/ +dependencies/ diff --git a/README.md b/README.md index 00f4491..ff76ec3 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Forge has native gas reporting with `forge snapshot` and `forge test --gas-repor # Installation ```solidity -forge install marktoda/forge-gas-snapshot +soldeer install forge-gas-snapshot~v0.0.5 ``` - NOTE: foundry.toml must be updated to allow forge to write the snapshots diff --git a/foundry.toml b/foundry.toml index 692a1c0..cb0294f 100644 --- a/foundry.toml +++ b/foundry.toml @@ -4,3 +4,16 @@ out = 'out' libs = ['lib'] ffi = true fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}] + +[soldeer] +# whether soldeer manages remappings +remappings_generated = true + +# whether soldeer re-generates all remappings when installing, updating or uninstalling deps +remappings_regenerate = true + +# whether to suffix the remapping with the version: `name-a.b.c` +remappings_version = false + +[dependencies] +forge-std = "1.9.2" diff --git a/lib/forge-std b/lib/forge-std deleted file mode 160000 index 2d8b7b8..0000000 --- a/lib/forge-std +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2d8b7b876a5b328d6a73e13c4740ed7a0d72d5f4 diff --git a/remappings.txt b/remappings.txt new file mode 100644 index 0000000..bc90c1e --- /dev/null +++ b/remappings.txt @@ -0,0 +1 @@ +forge-std/=dependencies/forge-std-1.9.2/ diff --git a/soldeer.lock b/soldeer.lock new file mode 100644 index 0000000..74aa013 --- /dev/null +++ b/soldeer.lock @@ -0,0 +1,6 @@ +[[dependencies]] +name = "forge-std" +version = "1.9.2" +source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/1_9_2_06-08-2024_17:31:25_forge-std-1.9.2.zip" +checksum = "20fd008c7c69b6c737cc0284469d1c76497107bc3e004d8381f6d8781cb27980" +integrity = "ae8b0d2637a0bdd85b6134117c0a7549dbe0ee8af66db454c66060547b654a89" diff --git a/src/GasSnapshot.sol b/src/GasSnapshot.sol index b879755..0782b29 100644 --- a/src/GasSnapshot.sol +++ b/src/GasSnapshot.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.15; -import "forge-std/console2.sol"; -import {Script} from "forge-std/Script.sol"; +import "forge-std/src/console2.sol"; +import {Script} from "forge-std/src/Script.sol"; import {UintString} from "./utils/UintString.sol"; contract GasSnapshot is Script { diff --git a/test/GasSnapshot.t.sol b/test/GasSnapshot.t.sol index cc68ff8..5973a35 100644 --- a/test/GasSnapshot.t.sol +++ b/test/GasSnapshot.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; -import "forge-std/console2.sol"; -import {Test} from "forge-std/Test.sol"; +import "forge-std/src/console2.sol"; +import {Test} from "forge-std/src/Test.sol"; import {GasSnapshot} from "../src/GasSnapshot.sol"; import {SimpleOperations} from "../src/test/SimpleOperations.sol"; @@ -26,7 +26,7 @@ contract GasSnapshotTest is Test, GasSnapshot { snapEnd(); string memory value = vm.readLine(".forge-snapshots/singleSstore.snap"); - assertEq(value, "48459"); + assertEq(value, "27395"); } function testSingleSstoreLastCall() public { @@ -35,21 +35,21 @@ contract GasSnapshotTest is Test, GasSnapshot { string memory value = vm.readLine(".forge-snapshots/singleSstoreLastCall.snap"); // includes 21,000 overhead for transaction, 20,000 clean SSTORE - assertEq(value, "43429"); + assertEq(value, "22365"); } function testSingleSstoreClosure() public { snap("singleSstoreClosure", simpleOperations.singleSstore); string memory value = vm.readLine(".forge-snapshots/singleSstoreClosure.snap"); - assertEq(value, "46269"); + assertEq(value, "25205"); } function testManySstoreClosure() public { snap("sstoreClosure", simpleOperations.manySstore); string memory value = vm.readLine(".forge-snapshots/sstoreClosure.snap"); - assertEq(value, "68158"); + assertEq(value, "47094"); } function testInternalClosure() public { @@ -96,7 +96,7 @@ contract GasSnapshotTest is Test, GasSnapshot { snapEnd(); string memory value = vm.readLine(".forge-snapshots/manySstore.snap"); - assertEq(value, "70348"); + assertEq(value, "49284"); } function testSnapshotCodeSize() public { @@ -132,7 +132,7 @@ contract GasSnapshotTest is Test, GasSnapshot { // preloaded with the wrong value snapStart("checkManySstore"); simpleOperations.manySstore(); - vm.expectRevert(abi.encodeWithSelector(GasSnapshot.GasMismatch.selector, 1, 73825)); + vm.expectRevert(abi.encodeWithSelector(GasSnapshot.GasMismatch.selector, 1, 52761)); snapEnd(); }