Skip to content

Commit

Permalink
♻️ Tidy (Vectorized#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized authored Feb 12, 2024
1 parent 69071ea commit 4f1ca86
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 98 deletions.
118 changes: 59 additions & 59 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
DN404MirrorTest:testBaseERC20() (gas: 114725)
DN404MirrorTest:testLinkMirrorContract() (gas: 45776)
DN404MirrorTest:testLogTransfer() (gas: 120709)
DN404MirrorTest:testNameAndSymbol(string,string) (runs: 256, μ: 207115, ~: 207456)
DN404MirrorTest:testNotLinked() (gas: 12471)
DN404MirrorTest:testSafeTransferFrom(uint32) (runs: 256, μ: 467616, ~: 467604)
DN404MirrorTest:testSetAndGetApprovalForAll() (gas: 323366)
DN404MirrorTest:testSetAndGetApproved() (gas: 316486)
DN404MirrorTest:testSupportsInterface() (gas: 7534)
DN404MirrorTest:testTokenURI(string,uint256) (runs: 256, μ: 157898, ~: 135596)
DN404MirrorTest:testTransferFrom(uint32) (runs: 256, μ: 343000, ~: 342990)
DN404MirrorTest:test__codesize() (gas: 28678)
DN404OnlyERC20Test:testApprove() (gas: 35897)
DN404OnlyERC20Test:testApprove(address,uint256) (runs: 256, μ: 30205, ~: 31449)
DN404OnlyERC20Test:testBurn() (gas: 49737)
DN404OnlyERC20Test:testBurn(address,uint256,uint256) (runs: 256, μ: 50781, ~: 50926)
DN404OnlyERC20Test:testBurnInsufficientBalanceReverts(address,uint256,uint256) (runs: 256, μ: 43779, ~: 43859)
DN404OnlyERC20Test:testInfiniteApproveTransferFrom() (gas: 101946)
DN404OnlyERC20Test:testMaxSupplyTrick(uint256) (runs: 256, μ: 537, ~: 537)
DN404OnlyERC20Test:testMetadata() (gas: 10075)
DN404OnlyERC20Test:testMint() (gas: 45298)
DN404OnlyERC20Test:testMintOverMaxLimitReverts() (gas: 40523)
DN404OnlyERC20Test:testMintz(address,uint256) (runs: 256, μ: 45615, ~: 45716)
DN404OnlyERC20Test:testTransfer() (gas: 74507)
DN404OnlyERC20Test:testTransfer(address,uint256) (runs: 256, μ: 74856, ~: 74960)
DN404OnlyERC20Test:testTransferFrom() (gas: 84569)
DN404OnlyERC20Test:testTransferFrom(address,address,address,uint256,uint256) (runs: 256, μ: 105382, ~: 107530)
DN404OnlyERC20Test:testTransferFromInsufficientAllowanceReverts() (gas: 68056)
DN404OnlyERC20Test:testTransferFromInsufficientAllowanceReverts(address,uint256,uint256) (runs: 256, μ: 68564, ~: 69146)
DN404OnlyERC20Test:testTransferFromInsufficientBalanceReverts() (gas: 74987)
DN404OnlyERC20Test:testTransferFromInsufficientBalanceReverts(address,uint256,uint256) (runs: 256, μ: 76053, ~: 76106)
DN404OnlyERC20Test:testTransferInsufficientBalanceReverts() (gas: 66230)
DN404OnlyERC20Test:testTransferInsufficientBalanceReverts(address,uint256,uint256) (runs: 256, μ: 67330, ~: 67310)
DN404OnlyERC20Test:test__codesize() (gas: 28984)
DN404Test:testBatchNFTLog() (gas: 314203)
DN404Test:testBurnOnTransfer(uint32,address) (runs: 256, μ: 263645, ~: 263665)
DN404Test:testInitialize(uint32,address) (runs: 256, μ: 111985, ~: 116419)
DN404Test:testMintAndBurn() (gas: 338977)
DN404Test:testMintAndBurn2() (gas: 262779)
DN404Test:testMintOnTransfer(uint32,address) (runs: 256, μ: 262357, ~: 262367)
DN404Test:testNameAndSymbol(string,string) (runs: 256, μ: 207227, ~: 207568)
DN404Test:testRegisterAndResolveAlias(address,address) (runs: 256, μ: 127024, ~: 127024)
DN404Test:testSetAndGetAux(address,uint88) (runs: 256, μ: 21959, ~: 22232)
DN404Test:testSetAndGetOperatorApprovals(address,address,bool) (runs: 256, μ: 129679, ~: 120744)
DN404Test:testSetAndGetSkipNFT() (gas: 89094)
DN404Test:testTokenURI(string,uint256) (runs: 256, μ: 158054, ~: 135752)
DN404Test:testTransfersAndBurns() (gas: 452718)
DN404Test:testWrapAround(uint32,uint256) (runs: 256, μ: 354978, ~: 347270)
DN404Test:test__codesize() (gas: 34350)
ERC20Invariants:invariantBalanceSum() (runs: 256, calls: 3840, reverts: 2639)
ERC20Invariants:test__codesize() (gas: 16554)
SimpleDN404Test:testMint() (gas: 45177)
SimpleDN404Test:testName() (gas: 9656)
SimpleDN404Test:testSetBaseURI() (gas: 38540)
SimpleDN404Test:testSymbol() (gas: 9699)
SimpleDN404Test:testWithdraw() (gas: 27344)
SimpleDN404Test:test__codesize() (gas: 18931)
SoladyTest:test__codesize() (gas: 1075)
TestPlus:test__codesize() (gas: 398)
DN404MirrorTest:testBaseERC20() (gas: 114753)
DN404MirrorTest:testLinkMirrorContract() (gas: 45802)
DN404MirrorTest:testLogTransfer() (gas: 120757)
DN404MirrorTest:testNameAndSymbol(string,string) (runs: 256, μ: 207213, ~: 207554)
DN404MirrorTest:testNotLinked() (gas: 12483)
DN404MirrorTest:testSafeTransferFrom(uint32) (runs: 256, μ: 468025, ~: 468017)
DN404MirrorTest:testSetAndGetApprovalForAll() (gas: 323557)
DN404MirrorTest:testSetAndGetApproved() (gas: 316662)
DN404MirrorTest:testSupportsInterface() (gas: 7544)
DN404MirrorTest:testTokenURI(string,uint256) (runs: 256, μ: 157965, ~: 135664)
DN404MirrorTest:testTransferFrom(uint32) (runs: 256, μ: 343172, ~: 343164)
DN404MirrorTest:test__codesize() (gas: 29410)
DN404OnlyERC20Test:testApprove() (gas: 35912)
DN404OnlyERC20Test:testApprove(address,uint256) (runs: 256, μ: 30219, ~: 31463)
DN404OnlyERC20Test:testBurn() (gas: 49769)
DN404OnlyERC20Test:testBurn(address,uint256,uint256) (runs: 256, μ: 50842, ~: 50970)
DN404OnlyERC20Test:testBurnInsufficientBalanceReverts(address,uint256,uint256) (runs: 256, μ: 43987, ~: 43888)
DN404OnlyERC20Test:testInfiniteApproveTransferFrom() (gas: 102011)
DN404OnlyERC20Test:testMaxSupplyTrick(uint256) (runs: 256, μ: 541, ~: 541)
DN404OnlyERC20Test:testMetadata() (gas: 10111)
DN404OnlyERC20Test:testMint() (gas: 45320)
DN404OnlyERC20Test:testMintOverMaxLimitReverts() (gas: 40544)
DN404OnlyERC20Test:testMintz(address,uint256) (runs: 256, μ: 45634, ~: 45742)
DN404OnlyERC20Test:testTransfer() (gas: 74556)
DN404OnlyERC20Test:testTransfer(address,uint256) (runs: 256, μ: 74882, ~: 75013)
DN404OnlyERC20Test:testTransferFrom() (gas: 84636)
DN404OnlyERC20Test:testTransferFrom(address,address,address,uint256,uint256) (runs: 256, μ: 105493, ~: 107617)
DN404OnlyERC20Test:testTransferFromInsufficientAllowanceReverts() (gas: 68086)
DN404OnlyERC20Test:testTransferFromInsufficientAllowanceReverts(address,uint256,uint256) (runs: 256, μ: 68700, ~: 69196)
DN404OnlyERC20Test:testTransferFromInsufficientBalanceReverts() (gas: 75030)
DN404OnlyERC20Test:testTransferFromInsufficientBalanceReverts(address,uint256,uint256) (runs: 256, μ: 76271, ~: 76151)
DN404OnlyERC20Test:testTransferInsufficientBalanceReverts() (gas: 66261)
DN404OnlyERC20Test:testTransferInsufficientBalanceReverts(address,uint256,uint256) (runs: 256, μ: 67297, ~: 67412)
DN404OnlyERC20Test:test__codesize() (gas: 29742)
DN404Test:testBatchNFTLog() (gas: 314418)
DN404Test:testBurnOnTransfer(uint32,address) (runs: 256, μ: 263883, ~: 263883)
DN404Test:testInitialize(uint32,address) (runs: 256, μ: 112442, ~: 116471)
DN404Test:testMintAndBurn() (gas: 339353)
DN404Test:testMintAndBurn2() (gas: 263064)
DN404Test:testMintOnTransfer(uint32,address) (runs: 256, μ: 262533, ~: 262533)
DN404Test:testNameAndSymbol(string,string) (runs: 256, μ: 207325, ~: 207666)
DN404Test:testRegisterAndResolveAlias(address,address) (runs: 256, μ: 126968, ~: 127056)
DN404Test:testSetAndGetAux(address,uint88) (runs: 256, μ: 21985, ~: 22257)
DN404Test:testSetAndGetOperatorApprovals(address,address,bool) (runs: 256, μ: 129740, ~: 120806)
DN404Test:testSetAndGetSkipNFT() (gas: 89217)
DN404Test:testTokenURI(string,uint256) (runs: 256, μ: 158121, ~: 135820)
DN404Test:testTransfersAndBurns() (gas: 453124)
DN404Test:testWrapAround(uint32,uint256) (runs: 256, μ: 355194, ~: 347518)
DN404Test:test__codesize() (gas: 35268)
ERC20Invariants:invariantBalanceSum() (runs: 256, calls: 3840, reverts: 2671)
ERC20Invariants:test__codesize() (gas: 16929)
SimpleDN404Test:testMint() (gas: 45198)
SimpleDN404Test:testName() (gas: 9674)
SimpleDN404Test:testSetBaseURI() (gas: 38574)
SimpleDN404Test:testSymbol() (gas: 9716)
SimpleDN404Test:testWithdraw() (gas: 27356)
SimpleDN404Test:test__codesize() (gas: 19396)
SoladyTest:test__codesize() (gas: 1102)
TestPlus:test__codesize() (gas: 406)
10 changes: 10 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- Emoji Table: -->
<!-- readme/docs 📝 -->
<!-- new feature ✨ -->
<!-- refactor/cleanup ♻️ -->
<!-- nit 🥢 -->
<!-- security fix 🔒 -->
<!-- optimization ⚡️ -->
<!-- configuration 👷‍♂️ -->
<!-- events 🔊 -->
<!-- bug fix 🐞 -->
56 changes: 56 additions & 0 deletions .github/workflows/ci-all-via-ir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: ci-all-via-ir

on:
workflow_dispatch:

jobs:
tests:
name: Forge Testing all via-ir
runs-on: ubuntu-latest

strategy:
matrix:
profile: [via-ir-0,via-ir-1,via-ir-2,via-ir-3]

steps:
- uses: actions/checkout@v4

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Install Dependencies
run: forge install

- name: Run Tests with ${{ matrix.profile }}
run: >
( [ "${{ matrix.profile }}" = "via-ir-0" ] &&
forge test --use 0.8.4 --via-ir &&
forge test --use 0.8.5 --via-ir &&
forge test --use 0.8.6 --via-ir &&
forge test --use 0.8.7 --via-ir &&
forge test --use 0.8.8 --via-ir &&
forge test --use 0.8.9 --via-ir
) ||
( [ "${{ matrix.profile }}" = "via-ir-1" ] &&
forge test --use 0.8.13 --via-ir &&
forge test --use 0.8.12 --via-ir &&
forge test --use 0.8.11 --via-ir &&
forge test --use 0.8.10 --via-ir
) ||
( [ "${{ matrix.profile }}" = "via-ir-2" ] &&
forge test --use 0.8.14 --via-ir &&
forge test --use 0.8.15 --via-ir &&
forge test --use 0.8.16 --via-ir &&
forge test --use 0.8.17 --via-ir
) ||
( [ "${{ matrix.profile }}" = "via-ir-3" ] &&
forge test --use 0.8.24 --via-ir &&
forge test --use 0.8.23 --via-ir &&
forge test --use 0.8.22 --via-ir &&
forge test --use 0.8.21 --via-ir &&
forge test --use 0.8.20 --via-ir &&
forge test --use 0.8.19 --via-ir &&
forge test --use 0.8.18 --via-ir
)
53 changes: 46 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ on:
push:
paths:
- '**.sol'
pull_request:
types: [opened, synchronize, reopened]
- '**.yml'

jobs:
tests:
Expand All @@ -14,7 +13,7 @@ jobs:

strategy:
matrix:
profile: [via-ir,intense]
profile: [post-shanghai,post-shanghai-via-ir,solc-past-versions-0,solc-past-versions-1,via-ir,min-solc,min-solc-via-ir,intense]

steps:
- uses: actions/checkout@v4
Expand All @@ -27,11 +26,51 @@ jobs:
- name: Install Dependencies
run: forge install

- name: Run Lint Check
run: forge fmt --check

- name: Run Tests with ${{ matrix.profile }}
run: FOUNDRY_PROFILE=${{ matrix.profile }} forge test
run: >
( [ "${{ matrix.profile }}" = "post-shanghai" ] &&
forge test --use 0.8.24 --evm-version "shanghai"
) ||
( [ "${{ matrix.profile }}" = "post-shanghai-via-ir" ] &&
forge test --use 0.8.24 --evm-version "shanghai" --via-ir
) ||
( [ "${{ matrix.profile }}" = "solc-past-versions-0" ] &&
forge test --use 0.8.5 --fuzz-runs 16 &&
forge test --use 0.8.6 --fuzz-runs 16 &&
forge test --use 0.8.7 --fuzz-runs 16 &&
forge test --use 0.8.8 --fuzz-runs 16 &&
forge test --use 0.8.9 --fuzz-runs 16 &&
forge test --use 0.8.10 --fuzz-runs 16 &&
forge test --use 0.8.11 --fuzz-runs 16 &&
forge test --use 0.8.12 --fuzz-runs 16
) ||
( [ "${{ matrix.profile }}" = "solc-past-versions-1" ] &&
forge test --use 0.8.13 --fuzz-runs 16 &&
forge test --use 0.8.14 --fuzz-runs 16 &&
forge test --use 0.8.15 --fuzz-runs 16 &&
forge test --use 0.8.16 --fuzz-runs 16 &&
forge test --use 0.8.17 --fuzz-runs 16 &&
forge test --use 0.8.18 --fuzz-runs 16 &&
forge test --use 0.8.19 --fuzz-runs 16 &&
forge test --use 0.8.20 --fuzz-runs 16 &&
forge test --use 0.8.21 --fuzz-runs 16 &&
forge test --use 0.8.22 --fuzz-runs 16 &&
forge test --use 0.8.23 --fuzz-runs 16 &&
forge test --use 0.8.24 --fuzz-runs 16
) ||
( [ "${{ matrix.profile }}" = "via-ir" ] &&
forge test --via-ir
) ||
( [ "${{ matrix.profile }}" = "min-solc" ] &&
forge fmt --check &&
forge test --use 0.8.4
) ||
( [ "${{ matrix.profile }}" = "min-solc-via-ir" ] &&
forge test --use 0.8.4 --via-ir
) ||
( [ "${{ matrix.profile }}" = "intense" ] &&
forge test --fuzz-runs 5000
)
codespell:
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ src
├─ DN404 — "ERC20 contract for DN404"
├─ DN404Mirror — "ERC721 contract for DN404"
└─ example
└─ SimpleDN404 — "Simple DN404 example."
└─ SimpleDN404 — "Simple DN404 example"
```

## Contributing
Expand Down
25 changes: 1 addition & 24 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# The Default Profile
[profile.default]
solc_version = "0.8.24"
evm_version = "cancun"
evm_version = "paris" # Shanghai will be tested in the CI.
auto_detect_solc = false
ignored_error_codes = [2394]
optimizer = true
optimizer_runs = 1_000
gas_limit = 100_000_000 # ETH is 30M, but we use a higher value.
Expand All @@ -20,25 +19,3 @@ line_length = 100 # While we allow up to 120, we lint at 100 for readability.

[profile.default.fuzz]
runs = 256

[profile.intense.fuzz]
runs = 5_000

[profile.via-ir]
via_ir = true

[profile.via-ir.fuzz]
runs = 1_000

[profile.min-solc]
solc_version = "0.8.4"

[profile.min-solc.fuzz]
runs = 1_000

[profile.min-solc-via-ir]
via_ir = true
solc_version = "0.8.4"

[profile.min-solc-via-ir.fuzz]
runs = 1_000
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dn404",
"license": "MIT",
"version": "0.0.1",
"description": "DN.",
"description": "Implementation of a co-joined ERC20 and ERC721 pair.",
"files": [
"src/**/*.sol"
],
Expand Down
2 changes: 1 addition & 1 deletion src/DN404Mirror.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
pragma solidity ^0.8.4;

/// @title DN404Mirror
/// @notice DN404Mirror provides an interface for interacting with the
Expand Down
2 changes: 1 addition & 1 deletion test/DN404.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
pragma solidity ^0.8.4;

import "./utils/SoladyTest.sol";
import {DN404, MockDN404} from "./utils/mocks/MockDN404.sol";
Expand Down
6 changes: 3 additions & 3 deletions test/DN404Mirror.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
pragma solidity ^0.8.4;

import "./utils/SoladyTest.sol";
import {DN404, MockDN404} from "./utils/mocks/MockDN404.sol";
Expand Down Expand Up @@ -174,9 +174,9 @@ contract DN404MirrorTest is SoladyTest {

vm.prank(address(dn));
vm.expectEmit(true, true, true, true);
emit DN404Mirror.Transfer(address(0), to, id);
emit Transfer(address(0), to, id);
vm.expectEmit(true, true, true, true);
emit DN404Mirror.Transfer(from, address(0), id);
emit Transfer(from, address(0), id);
(bool success,) =
address(mirror).call(abi.encodeWithSignature("logTransfer(uint256[])", packedLogs));
assertTrue(success);
Expand Down
2 changes: 1 addition & 1 deletion test/SimpleDN404.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
pragma solidity ^0.8.4;

import "./utils/SoladyTest.sol";
import {SimpleDN404} from "../src/example/SimpleDN404.sol";
Expand Down

0 comments on commit 4f1ca86

Please sign in to comment.