Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Deployment scripts for Base chain #24

Merged
merged 7 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
AuthorshipTokenTest:test_curtaMint() (gas: 85648)
AuthorshipTokenTest:test_curtaMint_SenderIsNotCurta_RevertsUnauthorized(address) (runs: 256, μ: 10204, ~: 10204)
AuthorshipTokenTest:test_ownerMint_FuzzMintTimestamps_IssuesTokensCorrectly(uint256) (runs: 256, μ: 6505633, ~: 6043360)
AuthorshipTokenTest:test_ownerMint_FuzzMintTimestamps_IssuesTokensCorrectly(uint256) (runs: 256, μ: 6541307, ~: 6006304)
AuthorshipTokenTest:test_ownerMint_SenderIsNotOwner_RevertUnauthorized(address) (runs: 256, μ: 12935, ~: 12935)
AuthorshipTokenTest:test_ownerMint_SenderIsOwner_AllowsMint() (gas: 108202)
AuthorshipTokenTest:test_tokenURI_MintedToken_Succeeds() (gas: 232)
AuthorshipTokenTest:test_tokenURI_UnmintedToken_Fails() (gas: 11055)
AuthorshipTokenTest:test_tokenURI_UnmintedToken_Fails() (gas: 12629)
CurtaTest:test_Initialization_DeployAddressesMatch() (gas: 11297)
CurtaTest:test_addPuzzle() (gas: 303991)
CurtaTest:test_addPuzzle_UseAuthorshipToken_UpdatesStorage() (gas: 297194)
Expand All @@ -17,7 +17,7 @@ CurtaTest:test_balanceOf_ZeroAddress_Fails() (gas: 8674)
CurtaTest:test_setApprovalForAll_False_UpdatesStorage() (gas: 15966)
CurtaTest:test_setApprovalForAll_True_UpdatesStorage() (gas: 35841)
CurtaTest:test_setFermat_AsRandomAccount_Succeeds(address) (runs: 256, μ: 453796, ~: 453796)
CurtaTest:test_setFermat_InitialSet_UpdatesStorage() (gas: 509601)
CurtaTest:test_setFermat_InitialSet_UpdatesStorage() (gas: 510466)
CurtaTest:test_setFermat_SetAfterTransfer_Succeeds(address) (runs: 256, μ: 873913, ~: 873913)
CurtaTest:test_setFermat_SetDifferentPuzzlesTwiceInIncreasingOrder_Succeeds() (gas: 867472)
CurtaTest:test_setFermat_SetNonFermatPuzzle_Fails() (gas: 777525)
Expand All @@ -26,13 +26,13 @@ CurtaTest:test_setFermat_SetUnsolvedPuzzle_Fails() (gas: 298803)
CurtaTest:test_setPuzzleColors() (gas: 304888)
CurtaTest:test_setPuzzleColors_SetUnauthoredPuzzle_RevertsUnauthorized() (gas: 298166)
CurtaTest:test_solve() (gas: 656199)
CurtaTest:test_solve_DuringAllPhases_FirstSolveTimestampOnlySetOnFirstBlood(uint40) (runs: 256, μ: 519608, ~: 518934)
CurtaTest:test_solve_DuringAllPhases_FirstSolveTimestampOnlySetOnFirstBlood(uint40) (runs: 256, μ: 519878, ~: 518934)
CurtaTest:test_solve_DuringPhase1WithPayment_PaysAuthor(uint256) (runs: 256, μ: 494376, ~: 495633)
CurtaTest:test_solve_DuringPhase2WithPayment_PaysAuthor(uint256) (runs: 256, μ: 532556, ~: 532556)
CurtaTest:test_solve_DuringPhase2_RequiresETH(uint256) (runs: 256, μ: 488065, ~: 486303)
CurtaTest:test_solve_DuringPhase2_RequiresETH(uint256) (runs: 256, μ: 488012, ~: 486303)
CurtaTest:test_solve_DuringPhase3_Fails(uint40) (runs: 256, μ: 432757, ~: 432757)
CurtaTest:test_solve_FirstBlood_AuthorshipTokenMintPotentialRevertBranch() (gas: 309908)
CurtaTest:test_solve_FirstBlood_MintsAuthorshipToken() (gas: 411160)
CurtaTest:test_solve_FirstBlood_MintsAuthorshipToken() (gas: 412017)
CurtaTest:test_solve_FirstBlood_UpdatesFirstSolveTimestamp(uint40) (runs: 256, μ: 405999, ~: 405999)
CurtaTest:test_solve_IncorrectSolution_Fails(uint256) (runs: 256, μ: 307909, ~: 307909)
CurtaTest:test_solve_NonExistantPuzzle_Fails() (gas: 13650)
Expand All @@ -42,14 +42,26 @@ CurtaTest:test_solve_Success_UpdatesSolveCounters() (gas: 612407)
CurtaTest:test_solve_Success_UpdatesStorage() (gas: 406659)
CurtaTest:test_supportsInterface() (gas: 8058)
CurtaTest:test_tokenURI_MintedToken_Succeeds() (gas: 234)
CurtaTest:test_tokenURI_UnmintedToken_Fails() (gas: 11378)
CurtaTest:test_tokenURI_UnmintedToken_Fails() (gas: 12952)
CurtaTest:test_transferFrom() (gas: 449268)
CurtaTest:test_transferFrom_SenderIsOwner_AllowsTransfer() (gas: 433241)
CurtaTest:test_transferFrom_ToZeroAddress_Fails() (gas: 406595)
CurtaTest:test_transferFrom_Unauthorized_RevertsUnauthorized() (gas: 411497)
CurtaTest:test_transferFrom_WithApprovalForAllTrue_AllowsTransfer() (gas: 459002)
CurtaTest:test_transferFrom_WithTokenApproval_AllowsTransfer() (gas: 439426)
CurtaTest:test_transferFrom_WrongFrom_Fails() (gas: 406517)
DeployBaseGoerliTest:test_AddressInitializationCorrectness() (gas: 23494)
DeployBaseGoerliTest:test_authorshipTokenAuthorsEquality() (gas: 13651)
DeployBaseGoerliTest:test_authorshipTokenIssueLengthEquality() (gas: 11460)
DeployBaseGoerliTest:test_authorshipTokenMinting() (gas: 108701)
DeployBaseGoerliTest:test_authorshipTokenOwnerEquality() (gas: 13799)
DeployBaseGoerliTest:test_curtaOwnerEquality() (gas: 13832)
DeployBaseMainnetTest:test_AddressInitializationCorrectness() (gas: 23494)
DeployBaseMainnetTest:test_authorshipTokenAuthorsEquality() (gas: 27900)
DeployBaseMainnetTest:test_authorshipTokenIssueLengthEquality() (gas: 11460)
DeployBaseMainnetTest:test_authorshipTokenMinting() (gas: 91601)
DeployBaseMainnetTest:test_authorshipTokenOwnerEquality() (gas: 13799)
DeployBaseMainnetTest:test_curtaOwnerEquality() (gas: 13832)
DeployConstellationTest:test_AddressInitializationCorrectness() (gas: 23494)
DeployConstellationTest:test_authorshipTokenAuthorsEquality() (gas: 20777)
DeployConstellationTest:test_authorshipTokenIssueLengthEquality() (gas: 11460)
Expand All @@ -68,4 +80,4 @@ DeployMainnetTest:test_authorshipTokenIssueLengthEquality() (gas: 11460)
DeployMainnetTest:test_authorshipTokenMinting() (gas: 91601)
DeployMainnetTest:test_authorshipTokenOwnerEquality() (gas: 13799)
DeployMainnetTest:test_curtaOwnerEquality() (gas: 13832)
OptimizationsTest:testFuzzComputePhaseFromTimestampBranchlessOptimization(uint40,uint40) (runs: 256, μ: 3534, ~: 3531)
OptimizationsTest:testFuzzComputePhaseFromTimestampBranchlessOptimization(uint40,uint40) (runs: 256, μ: 3545, ~: 3531)
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Since puzzles are on-chain, everyone can view everyone else's submissions. The g
<table>

## Usage
This project uses [**Foundry**](https://github.com/foundry-rs/foundry) as its development/testing framework and a [**Constellation**](https://constellation.so/) roll-up for testing.
This project uses [**Foundry**](https://github.com/foundry-rs/foundry) as its development/testing framework.

### Installation

Expand Down Expand Up @@ -158,11 +158,6 @@ If you are deploying to a public chain, replace `DeployMainnet` and `mainnet` wi
forge script script/deploy/DeployMainnet.s.sol:DeployMainnet -f mainnet --broadcast --verify
```

If you are deploying to the Constellation roll-up, remove `--verify` and add `--legacy`:
```sh
forge script script/deploy/DeployConstellation.s.sol:DeployConstellation -f constellation --broadcast --legacy --sender $SENDER_ADDRESS
```

## Acknowledgements
* [**Solmate**](https://github.com/transmissions11/solmate)
* [**Art Gobblers**](https://github.com/artgobblers/art-gobblers)
Expand Down
11 changes: 11 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ libs = ['lib']
solc = "0.8.17"
optimizer_runs = 875
bytecode_hash = "none"
remappings = [
"colormap-registry/=lib/colormap-registry/src/",
"forge-std/=lib/forge-std/src/",
"solady/=lib/solady/src/",
"shields-api/=lib/shields-api-contract/contracts/",
"solmate/=lib/solmate/src/",
"@/script/=script/",
"@/contracts/=src/",
"@/test/=test/"
]
no-match-path = "test/deploy/deprecated/*"

[fmt]
line_length = 100
Expand Down
8 changes: 0 additions & 8 deletions remappings.txt

This file was deleted.

5 changes: 2 additions & 3 deletions script/deploy/DeployBase.s.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { Script } from "forge-std/Script.sol";
import { console } from "forge-std/Test.sol";
import { Script, console } from "forge-std/Script.sol";

import { AuthorshipToken } from "@/contracts/AuthorshipToken.sol";
import { Curta } from "@/contracts/Curta.sol";
Expand All @@ -16,7 +15,7 @@ import { LibRLP } from "@/contracts/utils/LibRLP.sol";
/// @dev The script requires 3 private keys: `DEPLOYER_PRIVATE_KEY`,
/// `AUTHORSHIP_TOKEN_PRIVATE_KEY` and `CURTA_PRIVATE_KEY`, which are all read
/// as environment variables via `vm.envUint`. The account specified by
/// `DEPLOYER_PRIVATE_KEY` will fund the other 2 accounts 0.25 ETH each for gas.
/// `DEPLOYER_PRIVATE_KEY` will fund the other 2 accounts 0.4 ETH each for gas.
/// Note that if accounts specified by `AUTHORSHIP_TOKEN_PRIVATE_KEY` or
/// `CURTA_PRIVATE_KEY` have a nonzero account nonce or are equal, the script
/// will most likely fail due to incorrect contract address precomputation
Expand Down
22 changes: 22 additions & 0 deletions script/deploy/DeployBaseGoerli.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { DeployBase } from "./DeployBase.s.sol";

contract DeployBaseGoerli is DeployBase {
/// @notice The address to transfer the ownership of the Authorship Token
/// to.
address constant AUTHORSHIP_TOKEN_OWNER = 0xDbAacdcadD7c51a325B771ff75B261a1e7baE11c;

/// @notice The address to transfer the ownership of Curta to.
address constant CURTA_OWNER = 0xDbAacdcadD7c51a325B771ff75B261a1e7baE11c;

/// @notice The number of seconds until an additional token is made
/// available for minting by the author.
uint256 constant ISSUE_LENGTH = 3 days;

/// @notice The list of authors in the initial batch.
address[] internal AUTHORS = new address[](0);

constructor() DeployBase(AUTHORSHIP_TOKEN_OWNER, CURTA_OWNER, ISSUE_LENGTH, AUTHORS) { }
}
27 changes: 27 additions & 0 deletions script/deploy/DeployBaseMainnet.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { DeployBase } from "./DeployBase.s.sol";

contract DeployBaseMainnet is DeployBase {
/// @notice The address to transfer the ownership of the Authorship Token
/// to.
address constant AUTHORSHIP_TOKEN_OWNER = 0xA85572Cd96f1643458f17340b6f0D6549Af482F5;

/// @notice The address to transfer the ownership of Curta to.
address constant CURTA_OWNER = 0xA85572Cd96f1643458f17340b6f0D6549Af482F5;

/// @notice The number of seconds until an additional token is made
/// available for minting by the author.
uint256 constant ISSUE_LENGTH = 3 days;

/// @notice The list of authors in the initial batch.
address[] internal AUTHORS = [
// fiveoutofnine.eth
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
// sabnock.eth
0xDbAacdcadD7c51a325B771ff75B261a1e7baE11c
];

constructor() DeployBase(AUTHORSHIP_TOKEN_OWNER, CURTA_OWNER, ISSUE_LENGTH, AUTHORS) { }
}
51 changes: 0 additions & 51 deletions script/deploy/DeployTest.s.sol

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { DeployBase } from "./DeployBase.s.sol";
import { DeployBase } from "../DeployBase.s.sol";

/// @notice A script to deploy the protocol on Constellation.
contract DeployConstellation is DeployBase {
Expand Down
86 changes: 86 additions & 0 deletions test/deploy/DeployBaseGoerli.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { Test } from "forge-std/Test.sol";

import { AuthorshipToken } from "@/contracts/AuthorshipToken.sol";
import { Curta } from "@/contracts/Curta.sol";
import { DeployBaseGoerli } from "@/script/deploy/DeployBaseGoerli.s.sol";

/// @notice Tests the Base Goerli deploy script.
contract DeployBaseGoerliTest is Test {
// -------------------------------------------------------------------------
// Contracts
// -------------------------------------------------------------------------

/// @notice The Base Goerli deploy script.
DeployBaseGoerli internal deployBaseGoerli;

// -------------------------------------------------------------------------
// Setup
// -------------------------------------------------------------------------

function setUp() public {
vm.deal(vm.addr(vm.envUint("DEPLOYER_PRIVATE_KEY")), type(uint64).max);

deployBaseGoerli = new DeployBaseGoerli();
deployBaseGoerli.run();
}

// -------------------------------------------------------------------------
// Tests
// -------------------------------------------------------------------------

/// @notice Test that the addresses were set correctly in each contract's
/// deploy.
function test_AddressInitializationCorrectness() public {
assertEq(address(deployBaseGoerli.curta().flagRenderer()), address(deployBaseGoerli.flagRenderer()));
assertEq(
address(deployBaseGoerli.curta().authorshipToken()), address(deployBaseGoerli.authorshipToken())
);
assertEq(deployBaseGoerli.authorshipToken().curta(), address(deployBaseGoerli.curta()));
}

/// @notice Test that the Authorship Token's issue length was set correctly.
function test_authorshipTokenIssueLengthEquality() public {
assertEq(deployBaseGoerli.authorshipToken().issueLength(), deployBaseGoerli.issueLength());
}

/// @notice Test that the Authorship Token's authors were set.
function test_authorshipTokenAuthorsEquality() public {
uint256 totalSupply = deployBaseGoerli.authorshipToken().totalSupply();
assertEq(totalSupply, deployBaseGoerli.authorsLength());

unchecked {
for (uint256 i; i < totalSupply; ++i) {
assertEq(deployBaseGoerli.authorshipToken().ownerOf(i + 1), deployBaseGoerli.authors(i));
}
}
}

/// @notice Test that an Authorship Token can be minted after deploy.
function test_authorshipTokenMinting() public {
AuthorshipToken authorshipToken = deployBaseGoerli.authorshipToken();

// Warp 1 `issueLength` period forward in time to ensure the owner can
// mint 1.
vm.warp(block.timestamp + authorshipToken.issueLength() + 1);

// Mint as owner.
vm.prank(authorshipToken.owner());
authorshipToken.ownerMint(address(this));
}

/// @notice Test that the Authorship Token's ownership was transferred
/// correctly.
function test_authorshipTokenOwnerEquality() public {
assertEq(deployBaseGoerli.authorshipToken().owner(), deployBaseGoerli.authorshipTokenOwner());
}

/// @notice Test that Curta's ownership was transferred correctly.
function test_curtaOwnerEquality() public {
assertEq(deployBaseGoerli.curta().owner(), deployBaseGoerli.curtaOwner());
}

}

Loading
Loading