Skip to content
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
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "metabased-contracts/lib/forge-std"]
path = metabased-contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "metabased-contracts/lib/openzeppelin-contracts"]
path = metabased-contracts/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
3 changes: 3 additions & 0 deletions metabased-contracts/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This private key is common knowledge, you should not use them on any network other than this dev network. Using these private keys on mainnet, or even a testnet, will most likely result in a loss of funds.
# https://docs.optimism.io/chain/testing/dev-node#additional-info
ETH_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
8 changes: 4 additions & 4 deletions metabased-contracts/.gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "contracts/lib/forge-std"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file can now be deleted? since we have the .gitmodules file at project root

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Foundry specific submodules. It needs these for tests to work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also foundry keep the run-* files as historical deployment artifacts. I will keep these in case we need to check which contracts were deployed to which chains while we are testing.

path = contracts/lib/forge-std
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "contracts/lib/openzeppelin-contracts"]
path = contracts/lib/openzeppelin-contracts
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
82 changes: 33 additions & 49 deletions metabased-contracts/Makefile
Original file line number Diff line number Diff line change
@@ -1,63 +1,47 @@
# Heavily inspired by Reth's Makefile: https://github.com/paradigmxyz/reth/blob/main/Makefile
.DEFAULT_GOAL := help
# include .env file and export its env vars
# (-include to ignore error if it does not exist)
# Note that any unset variables here will wipe the variables if they are set in
# .zshrc or .bashrc. Make sure that the variables are set in .env, especially if
# you're running into issues with fork tests
-include .env

BIN_DIR = "dist/bin"
# deploy DeployMetabasedSequencerChain to Base Sepolia
deploy-metabased-sequencerchain :; forge script script/DeployContractsForSequencerChain.s.sol:DeployMetabasedSequencerChain --rpc-url base_sepolia --private-key ${ETH_PRIVATE_KEY} --broadcast -vv

BUILD_PATH = "target"
# deploy DeployMetabasedSequencerChainForTestnet to Metabased Testnet
deploy-metabased-sequencerchain-testnet :; forge script script/DeployContractsForSequencerChain.s.sol:DeployMetabasedSequencerChainForTestnet --rpc-url metabased_testnet --private-key ${ETH_PRIVATE_KEY} --broadcast -vv

# List of features to use when building. Can be overridden via the environment.
# No jemalloc on Windows
# ifeq ($(OS),Windows_NT)
FEATURES ?=
# else
# FEATURES ?= jemalloc asm-keccak
# endif
# run AddModuleToMetabasedSequencerChain script on Base Sepolia
add-module-to-metabased-sequencerchain :; forge script script/DeployContractsForSequencerChain.s.sol:AddModuleToMetabasedSequencerChain --rpc-url base_sepolia --private-key ${ETH_PRIVATE_KEY} --broadcast -vv

# Cargo profile for builds. Default is for local builds, CI uses an override.
PROFILE ?= release
# deploy DeploySealedBidAuctionSequencingModule to Base Sepolia
deploy-sealed-bid-auction-sequencing-module :; forge script script/DeployContractsForSequencerChain.s.sol:DeploySealedBidAuctionSequencingModule --rpc-url base_sepolia --private-key ${ETH_PRIVATE_KEY} --broadcast -vv

# Extra flags for Cargo
CARGO_INSTALL_EXTRA_FLAGS ?=
# deploy DeployTokenBalanceSequencingModule to Base Sepolia
deploy-token-balance-sequencing-module :; forge script script/DeployContractsForSequencerChain.s.sol:DeployTokenBalanceSequencingModule --rpc-url base_sepolia --private-key ${ETH_PRIVATE_KEY} --broadcast -vv

# Features in reth/op-reth binary crate other than "ethereum" and "optimism"
BIN_OTHER_FEATURES := asm-keccak jemalloc jemalloc-prof min-error-logs min-warn-logs min-info-logs min-debug-logs min-trace-logs
# deploy DeployAllowlistSequencingModule to Base Sepolia
deploy-allowlist-sequencing-module :; forge script script/DeployContractsForSequencerChain.s.sol:DeployAllowlistSequencingModule --rpc-url base_sepolia --private-key ${ETH_PRIVATE_KEY} --broadcast -vv

##@ Help
# deploy DeployAlwaysAllowedModule to Base Sepolia
deploy-always-allowed-module :; forge script script/DeployContractsForSequencerChain.s.sol:DeployAlwaysAllowedModule --rpc-url base_sepolia --private-key ${ETH_PRIVATE_KEY} --broadcast -vv

.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
# run AddBatchTransactionsToMetabasedSequencerChainContract script on Base Sepolia
add-batch-transactions-to-metabased-sequencerchain :; forge script script/AddBatchTransactionsToMetabasedSequencerChainContract.s.sol:AddBatchTransactionsToMetabasedSequencerChainContract --rpc-url base_sepolia --private-key ${ETH_PRIVATE_KEY} --broadcast -vv

##@ Build
# run AddBatchTransactionsToMetabasedSequencerChainContract script on localhost
add-batch-transactions-to-metabased-sequencerchain-localhost :; forge script script/AddBatchTransactionsToMetabasedSequencerChainContract.s.sol:AddBatchTransactionsToMetabasedSequencerChainContract --rpc-url localhost --private-key ${ETH_PRIVATE_KEY} --broadcast -vv

.PHONY: install-foundry
install-foundry: ## Install Foundry if the forge command is not found or is corrupted.
@if [ -z "$$(which forge)" ]; then \
echo "Forge not found. Installing Foundry..."; \
curl -L https://foundry.paradigm.xyz | bash && bash -c "source ~/.bashrc && foundryup"; \
fi
@forge build --help > /dev/null 2>&1 || (echo "Forge is corrupted. Reinstalling Foundry..." && curl -L https://foundry.paradigm.xyz | bash && bash -c "source ~/.bashrc && foundryup")
@echo "Foundry is installed and ready to use."
# run tx limit test against OP Mainnet or Base Sepolia
# and save output to file
# need to change target network in the test file
test-tx-limit :; forge test --match-contract MetabaseSequencerChainIntegrationTest -vv > test/integration/metabase-tx-limit-data/optimism_test_output_$(date +%Y%m%d_%H%M%S).log 2>&1

.PHONY: build-op-reth-syn
build-op-reth-syn: ## Build and install the op-reth binary under `~/.cargo/bin`.
cd ./reth-and-exexs && cargo install --path . --bin op-reth-syn --force --locked \
--features "$(FEATURES)" \
--profile "$(PROFILE)" \
$(CARGO_INSTALL_EXTRA_FLAGS)
test-events-limit :; forge test --match-contract MetabaseSequencerChainEventLimitTest -vv > test/integration/metabase-events-limit-data/base_sepolia_test_output_$(date +%Y%m%d_%H%M%S).md 2>&1

.PHONY: build-contracts
build-contracts: install-foundry ## Build contracts using forge.
cd ./contracts && forge build
@echo "Contract compilation complete"
# deploy L3BackfillData to Metabased Testnet
deploy-l3-backfill-data :; forge create --rpc-url metabased_testnet --private-key ${ETH_PRIVATE_KEY} src/backfill/L3BackfillData.sol:L3BackfillData --constructor-args ${ADMIN} ${MANAGER}

.PHONY: test
test: build-contracts ## Run tests after building the contracts.
cd ./reth-and-exexs && cargo test --all
@echo "Tests complete"
deploy-l3-backfill-storage :; forge create --rpc-url metabased_testnet --private-key ${ETH_PRIVATE_KEY} src/backfill/L3BackfillStorage.sol:L3BackfillStorage --constructor-args ${ADMIN} ${MANAGER}

##@ Custom Build

.PHONY: install
install: build-contracts build-op-reth-syn ## Run build steps.
@echo "Install complete. You can now run op-reth-syn from your terminal."
deploy-l3-backfill-mapper :; forge create --rpc-url metabased_testnet --private-key ${ETH_PRIVATE_KEY} src/backfill/L3BackfillMapper.sol:L3BackfillMapper --constructor-args ${ADMIN} ${MANAGER}
66 changes: 64 additions & 2 deletions metabased-contracts/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,64 @@
# metabased-rollup
The monorepo for the Metabased rollup stack. Containers the sequencer, smart contracts, RPC node, dev environments, and more!
## Base Sequencer Chain Contracts

### install

Ensure Foundry is installed.

```shell
$ forge install
```

### Build

```shell
$ forge build
```

### Test

```shell
$ forge test
```

### Deploy

Look at Makefile for more details.

Example:

```shell
$ make deploy-based-sequencerchain-frame
```

### Deployed Contracts

#### Syndicate Frame Chain

| Contract Name | Address |
| ------------------------- | ------------------------------------------ |
| BasedSequencerChain | 0x8430FDed8bb66c6EA2f1f966E2abF9D481eEF418 |
| AllowlistSequencingModule | 0xA3d1304Afff72a8aD77F7c6A7B0c18d63629062d |

#### Base Sepolia

| Contract Name | Address |
| ----------------------- | ------------------------------------------ |
| MetabasedSequencerChain | 0x0E3E7d53c6451D62CE9f86201743587419Dc88Be |
| AlwaysAllowedModule | 0x33aB24E0a47A7aAe869755420950A6326e3CB9F3 |

#### Optimism

| Contract Name | Address |
| ----------------------- | ------------------------------------------ |
| MetabasedSequencerChain | 0x7DEdabB3Db89310B316bA49D96Aa6517aFC44294 |
| AlwaysAllowedModule | 0x21e1C6bE46E53693381Cef9BECD3B0A947A590e4 |

#### Metabased Testnet

| Contract Name | Address |
| ----------------------- | ------------------------------------------ |
| MetabasedSequencerChain | 0xcFc46cEBB3eAEc9b5776e3FDe5879125B8BBA05d |
| AlwaysAllowedModule | 0x471584f0B8e35faEB2a618BD58A62316D8882d63 |
| L3BackfillData | 0xA67d13E3227B68bFc96DB9f5AFe7197ca32F0033 |
| L3BackfillStorage | 0x0E15475575E06461e376a9954F4cb54fC61bC1a5 |
| L3BackfillMapper | 0x609272C1D46E652aaf095a4F7F2eCC208C61c7F5 |
7 changes: 0 additions & 7 deletions metabased-contracts/contracts/.env.example

This file was deleted.

49 changes: 0 additions & 49 deletions metabased-contracts/contracts/Makefile

This file was deleted.

56 changes: 0 additions & 56 deletions metabased-contracts/contracts/README.md

This file was deleted.

1 change: 1 addition & 0 deletions metabased-contracts/lib/forge-std
Submodule forge-std added at 8f24d6
1 change: 1 addition & 0 deletions metabased-contracts/lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at dbb610
5 changes: 0 additions & 5 deletions metabased-contracts/reth-and-exexs/.env.example

This file was deleted.

3 changes: 0 additions & 3 deletions metabased-contracts/reth-and-exexs/.gitignore

This file was deleted.

Loading