Commit 22623fea authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #3001 from ethereum-optimism/develop

Develop -> Master Begin Release
parents e716b5fc 0f0a81a7
---
'@eth-optimism/foundry': minor
---
Initial release, pin to b7b1ec471bdd38221773e1a569dc4f20297bd7db
---
'@eth-optimism/contracts-bedrock': patch
---
Move encoding and hashing into Encoding and Hashing libraries
---
'@eth-optimism/contracts-bedrock': patch
---
Cleans up hashing and encoding library natspec and function names
---
'@eth-optimism/contracts-governance': patch
---
Clean up the hardhat config
---
'@eth-optimism/contracts-bedrock': patch
---
Port RLPWriter tests
---
'@eth-optimism/ci-builder': patch
---
Use ethereumoptimism/foundry:latest
---
'@eth-optimism/contracts-periphery': patch
---
Add typechain with ethers v5 support
---
'@eth-optimism/contracts-bedrock': patch
---
Use external version of ExcessivelySafeCall
---
'@eth-optimism/contracts-bedrock': patch
---
Fix solc warnings in ProxyAdmin
---
'@eth-optimism/contracts-bedrock': patch
---
Remove unnecessary DefaultValues library
---
'@eth-optimism/contracts-bedrock': patch
---
Fixes a bug that caused L2 timestamps to be computed incorrectly
---
'@eth-optimism/contracts-bedrock': patch
---
Standardizes comments, errors, and events for contracts in the /universal package
---
'@eth-optimism/contracts-bedrock': patch
---
Bump typechain to 8.1.0
---
'@eth-optimism/contracts-periphery': patch
---
Add TeleportrDeposit and TeleportrDisburser to contracts-periphery
---
'@eth-optimism/data-transport-layer': patch
---
Upgrade import path for new typechain
---
'@eth-optimism/contracts-bedrock': patch
---
Clean up comments and errors for legacy contracts
---
'@eth-optimism/contracts-bedrock': patch
---
Cleaned up enums, should be CapitalCase enums and UPPER_CASE values
---
'@eth-optimism/contracts-bedrock': patch
---
Add comments to RLP libraries
---
'@eth-optimism/contracts-bedrock': patch
---
Update to new L2 tx hash style for deposits
---
'@eth-optimism/contracts-bedrock': patch
---
Standardizes initialization logic for L1 contracts
---
'@eth-optimism/contracts-bedrock': patch
---
Move contracts written by external parties into a vendor folder
---
'@eth-optimism/contracts-bedrock': patch
---
Reduce the number of compiler warnings
---
'@eth-optimism/contracts-bedrock': patch
---
Remove storage slot buffer in xdomain messengers
---
'@eth-optimism/contracts-bedrock': patch
---
Cleans up initialization logic everywhere
---
'@eth-optimism/contracts-bedrock': patch
---
Rename OptimismMintableTokenFactory to OptimismMintableERC20Factory
---
'@eth-optimism/contracts-periphery': patch
---
Cleaned up natspec for Drippie and its dependencies
---
'@eth-optimism/foundry': patch
---
Use alpine:3.14
---
'@eth-optimism/contracts-bedrock': patch
---
Fix initialization logic
---
'@eth-optimism/contracts-bedrock': patch
---
Clean up the PredeployAddresses library
---
'@eth-optimism/hardhat-deploy-config': patch
---
Use lazyObject
---
'@eth-optimism/contracts-bedrock': patch
---
Tests for RLPReader
---
'@eth-optimism/contracts-periphery': patch
---
Moves TeleportrWithdrawer to L1 contracts folder
---
'@eth-optimism/indexer': patch
---
Fix contract bindings
---
'@eth-optimism/contracts-bedrock': patch
'@eth-optimism/contracts-periphery': patch
---
Bump forge-std to 62caef29b0f87a2c6aaaf634b2ca4c09b6867c92
---
'@eth-optimism/contracts-bedrock': patch
---
Add semver to L2 contracts
---
'@eth-optimism/contracts-bedrock': patch
---
Resolve compiler warnings in Proxy.sol
---
'@eth-optimism/contracts-periphery': minor
---
Fixes a bug in the OptimismMintableERC721. Requires an interface change, so this is a minor and not patch.
---
'@eth-optimism/l2geth': patch
---
fix NPE in debug_standardTraceBlockToFile
---
'@eth-optimism/contracts': patch
---
Properly export typechain
---
'@eth-optimism/contracts-bedrock': patch
'@eth-optimism/core-utils': patch
---
Move the `DepositTx` type to `core-utils`. This way it can be more easily used across projects
---
'@eth-optimism/ci-builder': minor
---
Update foundry in ci builder
---
'@eth-optimism/contracts-bedrock': minor
---
Remove Lib* and OVM* prefixes from all contracts
---
'@eth-optimism/contracts-bedrock': patch
---
Remove "not implemented" errors in virtual functions
---
'@eth-optimism/contracts-bedrock': patch
---
Update typechain pipeline
---
'@eth-optimism/contracts-bedrock': patch
'@eth-optimism/contracts-periphery': patch
'@eth-optimism/fault-detector': patch
'@eth-optimism/hardhat-deploy-config': patch
---
Update dev deps
......@@ -14,6 +14,7 @@ jobs:
- run:
name: Check if we should run
command: |
shopt -s inherit_errexit
CHANGED=$(check-changed "packages/")
if [[ "$CHANGED" = "FALSE" ]]; then
circleci step halt
......@@ -108,24 +109,27 @@ jobs:
- image: ethereumoptimism/ci-builder:latest
resource_class: medium
steps:
- restore_cache:
keys:
- v2-cache-yarn-build-{{ .Revision }}
- checkout
- run:
name: Check if we should run
command: |
shopt -s inherit_errexit
CHANGED=$(check-changed "(contracts-bedrock|hardhat-deploy-config)")
if [[ "$CHANGED" = "FALSE" ]]; then
circleci step halt
fi
- restore_cache:
keys:
- v2-cache-yarn-build-{{ .Revision }}
- checkout
- run:
name: lint
command: yarn lint:check
working_directory: packages/contracts-bedrock
- run:
name: slither
command: yarn slither || exit 0
command: |
slither --version
yarn slither || exit 0
working_directory: packages/contracts-bedrock
- run:
name: test
......@@ -166,6 +170,7 @@ jobs:
- run:
name: Check if we should run
command: |
shopt -s inherit_errexit
CHANGED=$(check-changed "(packages/<<parameters.package_name>>|packages/<<parameters.dependencies>>)")
if [[ "$CHANGED" = "FALSE" ]]; then
circleci step halt
......@@ -187,6 +192,7 @@ jobs:
- run:
name: Check if we should run
command: |
shopt -s inherit_errexit
CHANGED=$(check-changed "op-(batcher|bindings|e2e|node|proposer)")
if [[ "$CHANGED" = "FALSE" ]]; then
circleci step halt
......@@ -266,6 +272,7 @@ jobs:
- run:
name: Check if we should run
command: |
shopt -s inherit_errexit
CHANGED=$(check-changed "op-node")
if [[ "$CHANGED" = "FALSE" ]]; then
circleci step halt
......@@ -286,6 +293,7 @@ jobs:
- run:
name: Check if we should run
command: |
shopt -s inherit_errexit
CHANGED=$(check-changed "packages/")
if [[ "$CHANGED" = "FALSE" ]]; then
circleci step halt
......@@ -341,6 +349,7 @@ jobs:
- run:
name: Check if we should run
command: |
shopt -s inherit_errexit
CHANGED=$(check-changed "(<<parameters.working_directory>>|<<parameters.dependencies>>)")
echo $CHANGED
if [[ "$CHANGED" = "FALSE" ]]; then
......@@ -375,6 +384,7 @@ jobs:
- run:
name: Check if we should run
command: |
shopt -s inherit_errexit
CHANGED=$(check-changed "l2geth")
if [[ "$CHANGED" = "FALSE" ]]; then
circleci step halt
......@@ -384,6 +394,51 @@ jobs:
command: make test
working_directory: l2geth
devnet:
machine:
image: ubuntu-2004:202201-01
docker_layer_caching: true
environment:
DOCKER_BUILDKIT: 1
steps:
- checkout
- run:
name: Check if we should run
command: |
CHANGED=$(bash ./ops/docker/ci-builder/check-changed.sh "(contracts-bedrock|op-bindings|op-batcher|op-node|op-proposer|ops-bedrock)/")
if [[ "$CHANGED" = "FALSE" ]]; then
circleci step halt
fi
- run:
name: foundryup
command: |
curl -L https://foundry.paradigm.xyz | bash
source $HOME/.bashrc
foundryup
echo 'export PATH=$HOME/.foundry/bin:$PATH' >> $BASH_ENV
- run:
name: Install and build
command: |
yarn install
yarn build
- run:
name: Bring up the stack
command: |
make devnet-up
- run:
name: Do a deposit
no_output_timeout: 5m
command: |
npx hardhat compile
npx hardhat deposit \
--to 0xB79f76EF2c5F0286176833E7B2eEe103b1CC3244 \
--amount-eth 1 \
--private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
--network devnetL1
working_directory: packages/contracts-bedrock/contracts-bedrock
- run:
command: echo "Deposit complete."
integration-tests:
machine:
image: ubuntu-2004:202201-01
......@@ -396,7 +451,8 @@ jobs:
- run:
name: Check if we should run
command: |
CHANGED=$(bash ./ops/docker/ci-builder/check-changed.sh "(l2geth|common-ts|contracts|core-utils|message-relayer|data-transport-layer|replica-healthcheck|sdk|batch-submitter|gas-oracle|bss-core|integration-tests)")
shopt -s inherit_errexit
CHANGED=$(bash ./ops/docker/ci-builder/check-changed.sh "(l2geth|common-ts|contracts|core-utils|message-relayer|data-transport-layer|replica-healthcheck|sdk|batch-submitter|gas-oracle|bss-core|integration-tests)/")
if [[ "$CHANGED" = "FALSE" ]]; then
circleci step halt
fi
......@@ -458,6 +514,16 @@ jobs:
name: "Semgrep scan"
command: semgrep ci
go-mod-tidy:
docker:
- image: ethereumoptimism/ci-builder:latest
steps:
- checkout
- run:
name: "Go mod tidy"
command: make mod-tidy && git diff --exit-code
workflows:
main:
jobs:
......@@ -535,6 +601,7 @@ workflows:
- bedrock-go-tests
- fuzz-op-node
- bedrock-markdown
- devnet
- go-lint-test-build:
name: batch-submitter-tests
binary_name: batch-submitter
......@@ -557,6 +624,7 @@ workflows:
name: indexer-tests
binary_name: indexer
working_directory: indexer
dependencies: op-bindings
- go-lint-test-build:
name: bss-core-tests
binary_name: bss-core
......@@ -565,6 +633,7 @@ workflows:
- geth-tests
- integration-tests
- semgrep-scan
- go-mod-tidy
nightly:
triggers:
......
......@@ -6,6 +6,7 @@
- 'packages/batch-submitter/**/*'
- 'packages/contracts/**/*'
- 'packages/contracts-periphery/**/*'
- 'packages/contracts-bedrock/**/*'
- 'packages/data-transport-layer/**/*'
- 'packages/drippie-mon/**/*'
- 'packages/message-relayer/**/*'
......@@ -30,6 +31,9 @@ M-contracts:
M-contracts-periphery:
- any: ['packages/contracts-periphery/**/*']
M-contracts-bedrock:
- any: ['packages/contracts-bedrock/**/*']
M-core-utils:
- any: ['packages/core-utils/**/*']
......
......@@ -29,6 +29,8 @@ jobs:
teleportr: ${{ steps.packages.outputs.teleportr }}
go-builder: ${{ steps.packages.outputs.go-builder }}
js-builder: ${{ steps.packages.outputs.js-builder }}
ci-builder: ${{ steps.packages.outputs.ci-builder }}
foundry: ${{ steps.packages.outputs.foundry }}
steps:
- name: Checkout Repo
......@@ -209,6 +211,58 @@ jobs:
push: true
tags: ethereumoptimism/js-builder:${{ needs.release.outputs.js-builder }},ethereumoptimism/js-builder:latest
ci-builder:
name: Publish ci-builder ${{ needs.release.outputs.ci-builder }}
needs: release
if: needs.release.outputs.ci-builder != ''
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_ACCESS_TOKEN_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN_SECRET }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Publish ci-builder
uses: docker/build-push-action@v2
with:
context: .
file: ./ops/docker/ci-builder/Dockerfile
push: true
tags: ethereumoptimism/ci-builder:${{ needs.release.outputs.ci-builder }},ethereumoptimism/ci-builder:latest
foundry:
name: Publish foundry ${{ needs.release.outputs.foundry }}
needs: release
if: needs.release.outputs.foundry != ''
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_ACCESS_TOKEN_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN_SECRET }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Publish foundry
uses: docker/build-push-action@v2
with:
context: .
file: ./ops/docker/foundry/Dockerfile
push: true
tags: ethereumoptimism/foundry:${{ needs.release.outputs.foundry }},ethereumoptimism/foundry:latest
proxyd:
name: Publish proxyd Version ${{ needs.release.outputs.proxyd }}
needs: release
......
......@@ -25,6 +25,7 @@ packages/contracts/hardhat*
packages/contracts-periphery/coverage*
packages/contracts-periphery/@openzeppelin*
packages/contracts-periphery/hardhat*
packages/contracts-periphery/forge-artifacts*
packages/data-transport-layer/db
......
......@@ -71,6 +71,10 @@ devnet-clean:
docker volume ls --filter name=ops-bedrock --format='{{.Name}}' | xargs -r docker volume rm
.PHONY: devnet-clean
devnet-logs:
@(cd ./ops-bedrock && docker-compose logs -f)
.PHONY: devnet-logs
test-unit:
make -C ./op-node test
make -C ./op-proposer test
......
......@@ -136,9 +136,12 @@ func (s *Service) eventLoop() {
}
}
ticker := time.NewTicker(s.cfg.PollInterval)
defer ticker.Stop()
for {
select {
case <-time.After(s.cfg.PollInterval):
case <-ticker.C:
// Record the submitter's current ETH balance. This is done first in
// case any of the remaining steps fail, we can at least have an
// accurate view of the submitter's balance.
......
......@@ -18,7 +18,7 @@ use (
./state-surgery
)
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220711171946-f579014dc46d
// For local debugging:
//replace github.com/ethereum/go-ethereum v1.10.17 => ../go-ethereum
This diff is collapsed.
......@@ -29,7 +29,7 @@ func NewAddresses(client bind.ContractBackend, addrMgrAddr common.Address) (*Add
}
ret.addrs["AddressManager"] = addrMgrAddr
mgr, err := bindings.NewLibAddressManager(addrMgrAddr, client)
mgr, err := bindings.NewAddressManager(addrMgrAddr, client)
if err != nil {
return nil, err
}
......
/* Imports: External */
import { Contract, ContractFactory, utils, Wallet } from 'ethers'
import { ethers } from 'hardhat'
import { getChainId } from '@eth-optimism/core-utils'
import { predeploys } from '@eth-optimism/contracts'
import Artifact__TestERC721 from '@eth-optimism/contracts-periphery/artifacts/contracts/testing/helpers/TestERC721.sol/TestERC721.json'
import Artifact__L1ERC721Bridge from '@eth-optimism/contracts-periphery/artifacts/contracts/L1/messaging/L1ERC721Bridge.sol/L1ERC721Bridge.json'
import Artifact__L2ERC721Bridge from '@eth-optimism/contracts-periphery/artifacts/contracts/L2/messaging/L2ERC721Bridge.sol/L2ERC721Bridge.json'
import Artifact__L1ERC721Bridge from '@eth-optimism/contracts-periphery/artifacts/contracts/L1/L1ERC721Bridge.sol/L1ERC721Bridge.json'
import Artifact__L2ERC721Bridge from '@eth-optimism/contracts-periphery/artifacts/contracts/L2/L2ERC721Bridge.sol/L2ERC721Bridge.json'
import Artifact__OptimismMintableERC721Factory from '@eth-optimism/contracts-periphery/artifacts/contracts/universal/op-erc721/OptimismMintableERC721Factory.sol/OptimismMintableERC721Factory.json'
import Artifact__OptimismMintableERC721 from '@eth-optimism/contracts-periphery/artifacts/contracts/universal/op-erc721/OptimismMintableERC721.sol/OptimismMintableERC721.json'
......@@ -99,7 +100,8 @@ describe('ERC721 Bridge', () => {
OptimismMintableERC721Factory =
await Factory__OptimismMintableERC721Factory.deploy(
L2ERC721Bridge.address
L2ERC721Bridge.address,
await getChainId(env.l1Wallet.provider)
)
await OptimismMintableERC721Factory.deployed()
......@@ -268,7 +270,10 @@ describe('ERC721 Bridge', () => {
// - Returns the address of the legitimate L1 token from its l1Token() getter.
// - Allows the L2 bridge to call its burn() function.
const FakeOptimismMintableERC721 = await (
await ethers.getContractFactory('FakeOptimismMintableERC721', bobWalletL2)
await ethers.getContractFactory(
'FakeOptimismMintableERC721',
bobWalletL2
)
).deploy(L1ERC721.address, L2ERC721Bridge.address)
await FakeOptimismMintableERC721.deployed()
......
......@@ -65,7 +65,7 @@ type TraceConfig struct {
// StdTraceConfig holds extra parameters to standard-json trace functions.
type StdTraceConfig struct {
*vm.LogConfig
vm.LogConfig
Reexec *uint64
TxHash common.Hash
}
......@@ -550,9 +550,7 @@ func (api *PrivateDebugAPI) standardTraceBlockToFile(ctx context.Context, block
txHash common.Hash
)
if config != nil {
if config.LogConfig != nil {
logConfig = *config.LogConfig
}
logConfig = config.LogConfig
txHash = config.TxHash
}
logConfig.Debug = true
......
......@@ -2,6 +2,8 @@ FROM golang:1.18.0-alpine3.15 as builder
RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash
# build op-batcher with local monorepo go modules
COPY ./op-batcher/docker.go.work /app/go.work
COPY ./op-bindings /app/op-bindings
COPY ./op-node /app/op-node
COPY ./op-proposer /app/op-proposer
......
This diff is collapsed.
......@@ -14,10 +14,10 @@ type Config struct {
// L1EthRpc is the HTTP provider URL for L1.
L1EthRpc string
// L2EthRpc is the HTTP provider URL for L2.
// L2EthRpc is the HTTP provider URL for the L2 execution engine.
L2EthRpc string
// RollupRpc is the HTTP provider URL for the rollup node.
// RollupRpc is the HTTP provider URL for the L2 rollup node.
RollupRpc string
// MinL1TxSize is the minimum size of a batch tx submitted to L1.
......@@ -26,6 +26,10 @@ type Config struct {
// MaxL1TxSize is the maximum size of a batch tx submitted to L1.
MaxL1TxSize uint64
// ChannelTimeout is the maximum amount of time to attempt completing an opened channel,
// as opposed to submitting missing blocks in new channels
ChannelTimeout uint64
// PollInterval is the delay between querying L2 for more transaction
// and creating a new batch.
PollInterval time.Duration
......@@ -52,13 +56,6 @@ type Config struct {
// batched submission of sequencer transactions.
SequencerHDPath string
// SequencerHistoryDBFilename is the filename of the database used to track
// the latest L2 sequencer batches that were published.
SequencerHistoryDBFilename string
// SequencerGenesisHash is the genesis hash of the L2 chain.
SequencerGenesisHash string
// SequencerBatchInboxAddress is the address in which to send batch
// transactions.
SequencerBatchInboxAddress string
......@@ -82,14 +79,13 @@ func NewConfig(ctx *cli.Context) Config {
RollupRpc: ctx.GlobalString(flags.RollupRpcFlag.Name),
MinL1TxSize: ctx.GlobalUint64(flags.MinL1TxSizeBytesFlag.Name),
MaxL1TxSize: ctx.GlobalUint64(flags.MaxL1TxSizeBytesFlag.Name),
ChannelTimeout: ctx.GlobalUint64(flags.ChannelTimeoutFlag.Name),
PollInterval: ctx.GlobalDuration(flags.PollIntervalFlag.Name),
NumConfirmations: ctx.GlobalUint64(flags.NumConfirmationsFlag.Name),
SafeAbortNonceTooLowCount: ctx.GlobalUint64(flags.SafeAbortNonceTooLowCountFlag.Name),
ResubmissionTimeout: ctx.GlobalDuration(flags.ResubmissionTimeoutFlag.Name),
Mnemonic: ctx.GlobalString(flags.MnemonicFlag.Name),
SequencerHDPath: ctx.GlobalString(flags.SequencerHDPathFlag.Name),
SequencerHistoryDBFilename: ctx.GlobalString(flags.SequencerHistoryDBFilenameFlag.Name),
SequencerGenesisHash: ctx.GlobalString(flags.SequencerGenesisHashFlag.Name),
SequencerBatchInboxAddress: ctx.GlobalString(flags.SequencerBatchInboxAddressFlag.Name),
/* Optional Flags */
LogLevel: ctx.GlobalString(flags.LogLevelFlag.Name),
......
package db
import (
"encoding/json"
"io/ioutil"
"os"
"sort"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum/go-ethereum/common"
)
type History struct {
BlockIDs []eth.BlockID `json:"block_ids"`
}
func (h *History) LatestID() eth.BlockID {
return h.BlockIDs[len(h.BlockIDs)-1]
}
func (h *History) AppendEntry(blockID eth.BlockID, maxEntries uint64) {
for _, id := range h.BlockIDs {
if id.Hash == blockID.Hash {
return
}
}
h.BlockIDs = append(h.BlockIDs, blockID)
if uint64(len(h.BlockIDs)) > maxEntries {
h.BlockIDs = h.BlockIDs[len(h.BlockIDs)-int(maxEntries):]
}
}
func (h *History) Ancestors() []common.Hash {
var sortedBlockIDs = make([]eth.BlockID, 0, len(h.BlockIDs))
sortedBlockIDs = append(sortedBlockIDs, h.BlockIDs...)
// Keep block ids sorted in ascending order to minimize the number of swaps.
// Use stable sort so that newest are prioritized over older ones.
sort.SliceStable(sortedBlockIDs, func(i, j int) bool {
return sortedBlockIDs[i].Number < sortedBlockIDs[j].Number
})
var ancestors = make([]common.Hash, 0, len(h.BlockIDs))
for i := len(h.BlockIDs) - 1; i >= 0; i-- {
ancestors = append(ancestors, h.BlockIDs[i].Hash)
}
return ancestors
}
type HistoryDatabase interface {
LoadHistory() (*History, error)
AppendEntry(eth.BlockID) error
Close() error
}
type JSONFileDatabase struct {
filename string
maxEntries uint64
genesisHash common.Hash
}
func OpenJSONFileDatabase(
filename string,
maxEntries uint64,
genesisHash common.Hash,
) (*JSONFileDatabase, error) {
_, err := os.Stat(filename)
if os.IsNotExist(err) {
file, err := os.Create(filename)
if err != nil {
return nil, err
}
err = file.Close()
if err != nil {
return nil, err
}
}
return &JSONFileDatabase{
filename: filename,
maxEntries: maxEntries,
genesisHash: genesisHash,
}, nil
}
func (d *JSONFileDatabase) LoadHistory() (*History, error) {
fileContents, err := os.ReadFile(d.filename)
if err != nil {
return nil, err
}
if len(fileContents) == 0 {
return &History{
BlockIDs: []eth.BlockID{
{
Number: 0,
Hash: d.genesisHash,
},
},
}, nil
}
var history History
err = json.Unmarshal(fileContents, &history)
if err != nil {
return nil, err
}
return &history, nil
}
func (d *JSONFileDatabase) AppendEntry(blockID eth.BlockID) error {
history, err := d.LoadHistory()
if err != nil {
return err
}
history.AppendEntry(blockID, d.maxEntries)
newFileContents, err := json.Marshal(history)
if err != nil {
return err
}
return ioutil.WriteFile(d.filename, newFileContents, 0644)
}
func (d *JSONFileDatabase) Close() error {
return nil
}
package db_test
import (
"io/ioutil"
"os"
"testing"
"github.com/ethereum-optimism/optimism/op-batcher/db"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
)
const (
testMaxDepth uint64 = 10
)
var (
testGenesisHash = common.HexToHash("0xabcd")
genesisEntry = eth.BlockID{
Number: 0,
Hash: testGenesisHash,
}
)
func TestOpenJSONFileDatabaseNoFile(t *testing.T) {
file, err := ioutil.TempFile("", "history_db.*.json")
require.Nil(t, err)
filename := file.Name()
err = os.Remove(filename)
require.Nil(t, err)
hdb, err := db.OpenJSONFileDatabase(filename, testMaxDepth, testGenesisHash)
require.Nil(t, err)
require.NotNil(t, hdb)
err = hdb.Close()
require.Nil(t, err)
}
func TestOpenJSONFileDatabaseEmptyFile(t *testing.T) {
file, err := ioutil.TempFile("", "history_db.*.json")
require.Nil(t, err)
filename := file.Name()
defer os.Remove(filename)
hdb, err := db.OpenJSONFileDatabase(filename, testMaxDepth, testGenesisHash)
require.Nil(t, err)
require.NotNil(t, hdb)
err = hdb.Close()
require.Nil(t, err)
}
func TestOpenJSONFileDatabase(t *testing.T) {
file, err := ioutil.TempFile("", "history_db.*.json")
require.Nil(t, err)
filename := file.Name()
defer os.Remove(filename)
hdb, err := db.OpenJSONFileDatabase(filename, testMaxDepth, testGenesisHash)
require.Nil(t, err)
require.NotNil(t, hdb)
err = hdb.Close()
require.Nil(t, err)
}
func makeDB(t *testing.T) (*db.JSONFileDatabase, func()) {
file, err := ioutil.TempFile("", "history_db.*.json")
require.Nil(t, err)
filename := file.Name()
hdb, err := db.OpenJSONFileDatabase(filename, testMaxDepth, testGenesisHash)
require.Nil(t, err)
require.NotNil(t, hdb)
cleanup := func() {
_ = hdb.Close()
_ = os.Remove(filename)
}
return hdb, cleanup
}
func TestLoadHistoryEmpty(t *testing.T) {
hdb, cleanup := makeDB(t)
defer cleanup()
history, err := hdb.LoadHistory()
require.Nil(t, err)
require.NotNil(t, history)
require.Equal(t, int(1), len(history.BlockIDs))
expHistory := &db.History{
BlockIDs: []eth.BlockID{genesisEntry},
}
require.Equal(t, expHistory, history)
}
func TestAppendEntry(t *testing.T) {
hdb, cleanup := makeDB(t)
defer cleanup()
genExpHistory := func(n uint64) *db.History {
var history db.History
history.AppendEntry(genesisEntry, testMaxDepth)
for i := uint64(0); i < n+1; i++ {
history.AppendEntry(eth.BlockID{
Number: i,
Hash: common.Hash{byte(i)},
}, testMaxDepth)
}
return &history
}
for i := uint64(0); i < 2*testMaxDepth; i++ {
err := hdb.AppendEntry(eth.BlockID{
Number: i,
Hash: common.Hash{byte(i)},
})
require.Nil(t, err)
history, err := hdb.LoadHistory()
require.Nil(t, err)
expHistory := genExpHistory(i)
require.Equal(t, expHistory, history)
require.LessOrEqual(t, uint64(len(history.BlockIDs)), testMaxDepth+1)
}
}
go 1.18
use (
./op-batcher
./op-bindings
./op-node
./op-proposer
)
......@@ -21,13 +21,13 @@ var (
}
L2EthRpcFlag = cli.StringFlag{
Name: "l2-eth-rpc",
Usage: "HTTP provider URL for L2",
Usage: "HTTP provider URL for L2 execution engine",
Required: true,
EnvVar: "L2_ETH_RPC",
}
RollupRpcFlag = cli.StringFlag{
Name: "rollup-rpc",
Usage: "HTTP provider URL for the rollup node",
Usage: "HTTP provider URL for Rollup node",
Required: true,
EnvVar: "ROLLUP_RPC",
}
......@@ -43,6 +43,12 @@ var (
Required: true,
EnvVar: prefixEnvVar("MAX_L1_TX_SIZE_BYTES"),
}
ChannelTimeoutFlag = cli.Uint64Flag{
Name: "channel-timeout",
Usage: "The maximum amount of time to attempt completing an opened channel, as opposed to submitting L2 blocks into a new channel.",
Required: true,
EnvVar: prefixEnvVar("CHANNEL_TIMEOUT"),
}
PollIntervalFlag = cli.DurationFlag{
Name: "poll-interval",
Usage: "Delay between querying L2 for more transactions and " +
......@@ -86,19 +92,6 @@ var (
Required: true,
EnvVar: prefixEnvVar("SEQUENCER_HD_PATH"),
}
SequencerHistoryDBFilenameFlag = cli.StringFlag{
Name: "sequencer-history-db-filename",
Usage: "File name used to identify the latest L2 batches submitted " +
"by the sequencer",
Required: true,
EnvVar: prefixEnvVar("SEQUENCER_HISTORY_DB_FILENAME"),
}
SequencerGenesisHashFlag = cli.StringFlag{
Name: "sequencer-genesis-hash",
Usage: "Genesis hash of the L2 chain",
Required: true,
EnvVar: prefixEnvVar("SEQUENCER_GENESIS_HASH"),
}
SequencerBatchInboxAddressFlag = cli.StringFlag{
Name: "sequencer-batch-inbox-address",
Usage: "L1 Address to receive batch transactions",
......@@ -128,14 +121,13 @@ var requiredFlags = []cli.Flag{
RollupRpcFlag,
MinL1TxSizeBytesFlag,
MaxL1TxSizeBytesFlag,
ChannelTimeoutFlag,
PollIntervalFlag,
NumConfirmationsFlag,
SafeAbortNonceTooLowCountFlag,
ResubmissionTimeoutFlag,
MnemonicFlag,
SequencerHDPathFlag,
SequencerHistoryDBFilenameFlag,
SequencerGenesisHashFlag,
SequencerBatchInboxAddressFlag,
}
......
......@@ -3,161 +3,55 @@ module github.com/ethereum-optimism/optimism/op-batcher
go 1.18
require (
github.com/ethereum-optimism/optimism/op-node v0.0.0
github.com/ethereum-optimism/optimism/op-proposer v0.0.0
github.com/ethereum-optimism/optimism/op-node v0.3.0
github.com/ethereum-optimism/optimism/op-proposer v0.3.0
github.com/ethereum/go-ethereum v1.10.17
github.com/miguelmota/go-ethereum-hdwallet v0.1.1
github.com/stretchr/testify v1.7.0
github.com/urfave/cli v1.22.5
)
require (
github.com/VictoriaMetrics/fastcache v1.9.0 // indirect
github.com/benbjohnson/clock v1.1.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd v0.22.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327 // indirect
github.com/coreos/go-systemd/v22 v22.1.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/elastic/gosigar v0.12.0 // indirect
github.com/ethereum-optimism/optimism/op-bindings v0.0.0 // indirect
github.com/fjl/memsize v0.0.1 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/ethereum-optimism/optimism/op-bindings v0.3.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/godbus/dbus/v5 v5.0.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-bexpr v0.1.11 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.0 // indirect
github.com/huin/goupnp v1.0.3 // indirect
github.com/ipfs/go-cid v0.0.7 // indirect
github.com/ipfs/go-datastore v0.5.0 // indirect
github.com/ipfs/go-ds-leveldb v0.5.0 // indirect
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
github.com/ipfs/go-log v1.0.5 // indirect
github.com/ipfs/go-log/v2 v2.5.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/koron/go-ssdp v0.0.2 // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
github.com/libp2p/go-cidranger v1.1.0 // indirect
github.com/libp2p/go-conn-security-multistream v0.3.0 // indirect
github.com/libp2p/go-eventbus v0.2.1 // indirect
github.com/libp2p/go-flow-metrics v0.0.3 // indirect
github.com/libp2p/go-libp2p v0.18.1 // indirect
github.com/libp2p/go-libp2p-asn-util v0.1.0 // indirect
github.com/libp2p/go-libp2p-blankhost v0.3.0 // indirect
github.com/libp2p/go-libp2p-core v0.15.0 // indirect
github.com/libp2p/go-libp2p-discovery v0.6.0 // indirect
github.com/libp2p/go-libp2p-mplex v0.6.0 // indirect
github.com/libp2p/go-libp2p-nat v0.1.0 // indirect
github.com/libp2p/go-libp2p-noise v0.3.0 // indirect
github.com/libp2p/go-libp2p-peerstore v0.6.0 // indirect
github.com/libp2p/go-libp2p-pnet v0.2.0 // indirect
github.com/libp2p/go-libp2p-pubsub v0.6.1 // indirect
github.com/libp2p/go-libp2p-swarm v0.10.2 // indirect
github.com/libp2p/go-libp2p-testing v0.9.2 // indirect
github.com/libp2p/go-libp2p-tls v0.3.1 // indirect
github.com/libp2p/go-libp2p-transport-upgrader v0.7.1 // indirect
github.com/libp2p/go-libp2p-yamux v0.9.0 // indirect
github.com/libp2p/go-mplex v0.6.0 // indirect
github.com/libp2p/go-msgio v0.1.0 // indirect
github.com/libp2p/go-nat v0.1.0 // indirect
github.com/libp2p/go-netroute v0.2.0 // indirect
github.com/libp2p/go-openssl v0.0.7 // indirect
github.com/libp2p/go-reuseport v0.1.0 // indirect
github.com/libp2p/go-reuseport-transport v0.1.0 // indirect
github.com/libp2p/go-stream-muxer-multistream v0.4.0 // indirect
github.com/libp2p/go-tcp-transport v0.5.1 // indirect
github.com/libp2p/go-yamux/v3 v3.1.0 // indirect
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/miekg/dns v1.1.43 // indirect
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mitchellh/pointerstructure v1.2.1 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.0.3 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect
github.com/multiformats/go-multiaddr v0.5.0 // indirect
github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
github.com/multiformats/go-multibase v0.0.3 // indirect
github.com/multiformats/go-multicodec v0.4.1 // indirect
github.com/multiformats/go-multihash v0.0.15 // indirect
github.com/multiformats/go-multistream v0.2.2 // indirect
github.com/multiformats/go-varint v0.0.6 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/opencontainers/runtime-spec v1.0.2 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.35.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/tsdb v0.10.0 // indirect
github.com/raulk/clock v1.1.0 // indirect
github.com/raulk/go-watchdog v1.2.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 // indirect
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
google.golang.org/grpc v1.40.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/sys v0.0.0-20220701225701-179beb0bd1a1 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/urfave/cli.v1 v1.20.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
replace (
github.com/ethereum-optimism/optimism/op-bindings v0.0.0 => ../op-bindings
github.com/ethereum-optimism/optimism/op-node v0.0.0 => ../op-node
github.com/ethereum-optimism/optimism/op-proposer v0.0.0 => ../op-proposer
)
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220711171946-f579014dc46d
This source diff could not be displayed because it is too large. You can view the blob instead.
package sequencer
import (
"context"
"crypto/ecdsa"
"math/big"
"time"
"github.com/ethereum-optimism/optimism/op-batcher/db"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/node"
"github.com/ethereum-optimism/optimism/op-proposer/rollupclient"
"github.com/ethereum-optimism/optimism/op-proposer/txmgr"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
)
type Config struct {
Log log.Logger
Name string
L1Client *ethclient.Client
L2Client *ethclient.Client
RollupClient *rollupclient.RollupClient
MinL1TxSize uint64
MaxL1TxSize uint64
BatchInboxAddress common.Address
HistoryDB db.HistoryDatabase
ChainID *big.Int
PrivKey *ecdsa.PrivateKey
}
type Driver struct {
cfg Config
walletAddr common.Address
l log.Logger
currentBatch *node.BatchBundleResponse
}
func NewDriver(cfg Config) (*Driver, error) {
walletAddr := crypto.PubkeyToAddress(cfg.PrivKey.PublicKey)
return &Driver{
cfg: cfg,
walletAddr: walletAddr,
l: cfg.Log,
}, nil
}
// Name is an identifier used to prefix logs for a particular service.
func (d *Driver) Name() string {
return d.cfg.Name
}
// WalletAddr is the wallet address used to pay for transaction fees.
func (d *Driver) WalletAddr() common.Address {
return d.walletAddr
}
// GetBlockRange returns the start and end L2 block heights that need to be
// processed. Note that the end value is *exclusive*, therefore if the returned
// values are identical nothing needs to be processed.
func (d *Driver) GetBlockRange(
ctx context.Context,
) (*big.Int, *big.Int, error) {
// Clear prior batch, if any.
d.currentBatch = nil
history, err := d.cfg.HistoryDB.LoadHistory()
if err != nil {
return nil, nil, err
}
latestBlockID := history.LatestID()
ancestors := history.Ancestors()
d.l.Info("Fetching bundle",
"latest_number", latestBlockID.Number,
"lastest_hash", latestBlockID.Hash,
"num_ancestors", len(ancestors),
"min_tx_size", d.cfg.MinL1TxSize,
"max_tx_size", d.cfg.MaxL1TxSize)
batchResp, err := d.cfg.RollupClient.GetBatchBundle(
ctx,
&node.BatchBundleRequest{
L2History: ancestors,
MinSize: hexutil.Uint64(d.cfg.MinL1TxSize),
MaxSize: hexutil.Uint64(d.cfg.MaxL1TxSize),
},
)
if err != nil {
return nil, nil, err
}
Log log.Logger
Name string
// Bundle is not available yet, return the next expected block number.
if batchResp == nil {
start64 := latestBlockID.Number + 1
start := big.NewInt(int64(start64))
return start, start, nil
}
// API to submit txs to
L1Client *ethclient.Client
// There is nothing to be done if the rollup returns a last block hash equal
// to the previous block hash. Return identical start and end block heights
// to signal that there is no work to be done.
start := big.NewInt(int64(batchResp.PrevL2BlockNum) + 1)
if batchResp.LastL2BlockHash == batchResp.PrevL2BlockHash {
return start, start, nil
}
// API to hit for batch data
L2Client *ethclient.Client
if batchResp.PrevL2BlockHash != latestBlockID.Hash {
d.l.Warn("Reorg", "rpc_prev_block_hash", batchResp.PrevL2BlockHash,
"db_prev_block_hash", latestBlockID.Hash)
}
RollupNode *rollupclient.RollupClient
// If the bundle is empty, this implies that all blocks in the range were
// empty blocks. Simply commit the new head and return that there is no work
// to be done.
if len(batchResp.Bundle) == 0 {
err = d.cfg.HistoryDB.AppendEntry(eth.BlockID{
Number: uint64(batchResp.LastL2BlockNum),
Hash: batchResp.LastL2BlockHash,
})
if err != nil {
return nil, nil, err
}
// Limit the size of txs
MinL1TxSize uint64
MaxL1TxSize uint64
next := big.NewInt(int64(batchResp.LastL2BlockNum + 1))
return next, next, nil
}
d.currentBatch = batchResp
end := big.NewInt(int64(batchResp.LastL2BlockNum + 1))
return start, end, nil
}
// CraftTx transforms the L2 blocks between start and end into a transaction
// using the given nonce.
//
// NOTE: This method SHOULD NOT publish the resulting transaction.
func (d *Driver) CraftTx(
ctx context.Context,
start, end, nonce *big.Int,
) (*types.Transaction, error) {
gasTipCap, err := d.cfg.L1Client.SuggestGasTipCap(ctx)
if err != nil {
// TODO(conner): handle fallback
return nil, err
}
head, err := d.cfg.L1Client.HeaderByNumber(ctx, nil)
if err != nil {
return nil, err
}
gasFeeCap := txmgr.CalcGasFeeCap(head.BaseFee, gasTipCap)
rawTx := &types.DynamicFeeTx{
ChainID: d.cfg.ChainID,
Nonce: nonce.Uint64(),
To: &d.cfg.BatchInboxAddress,
GasTipCap: gasTipCap,
GasFeeCap: gasFeeCap,
Data: d.currentBatch.Bundle,
}
gas, err := core.IntrinsicGas(rawTx.Data, nil, false, true, true)
if err != nil {
return nil, err
}
rawTx.Gas = gas
return types.SignNewTx(
d.cfg.PrivKey, types.LatestSignerForChainID(d.cfg.ChainID), rawTx,
)
}
// UpdateGasPrice signs an otherwise identical txn to the one provided but with
// updated gas prices sampled from the existing network conditions.
//
// NOTE: Thie method SHOULD NOT publish the resulting transaction.
func (d *Driver) UpdateGasPrice(
ctx context.Context,
tx *types.Transaction,
) (*types.Transaction, error) {
gasTipCap, err := d.cfg.L1Client.SuggestGasTipCap(ctx)
if err != nil {
// TODO(conner): handle fallback
return nil, err
}
head, err := d.cfg.L1Client.HeaderByNumber(ctx, nil)
if err != nil {
return nil, err
}
gasFeeCap := txmgr.CalcGasFeeCap(head.BaseFee, gasTipCap)
rawTx := &types.DynamicFeeTx{
ChainID: d.cfg.ChainID,
Nonce: tx.Nonce(),
To: tx.To(),
GasTipCap: gasTipCap,
GasFeeCap: gasFeeCap,
Gas: tx.Gas(),
Data: tx.Data(),
}
// Where to send the batch txs to.
BatchInboxAddress common.Address
return types.SignNewTx(
d.cfg.PrivKey, types.LatestSignerForChainID(d.cfg.ChainID), rawTx,
)
}
// The batcher can decide to set it shorter than the actual timeout,
// since submitting continued channel data to L1 is not instantaneous.
// It's not worth it to work with nearly timed-out channels.
ChannelTimeout uint64
// SendTransaction injects a signed transaction into the pending pool for
// execution.
func (d *Driver) SendTransaction(
ctx context.Context,
tx *types.Transaction,
) error {
// Chain ID of the L1 chain to submit txs to.
ChainID *big.Int
err := d.cfg.HistoryDB.AppendEntry(eth.BlockID{
Number: uint64(d.currentBatch.LastL2BlockNum),
Hash: d.currentBatch.LastL2BlockHash,
})
if err != nil {
return err
}
// Private key to sign batch txs with
PrivKey *ecdsa.PrivateKey
return d.cfg.L1Client.SendTransaction(ctx, tx)
PollInterval time.Duration
}
......@@ -33,7 +33,7 @@ gas-price-oracle-bindings:
./gen_bindings.sh GasPriceOracle bindings
address-manager-bindings:
./gen_bindings.sh Lib_AddressManager bindings
./gen_bindings.sh AddressManager bindings
mkdir:
mkdir -p bin bindings
......
This diff is collapsed.
This diff is collapsed.
......@@ -2,4 +2,4 @@
// This file is a generated binding and any manual changes will be lost.
package bindings
var L1BlockDeployedBin = "0x608060405234801561001057600080fd5b506004361061007d5760003560e01c806364ca23ef1161005b57806364ca23ef146100bc5780638381f58a146100e9578063b80777ea146100fd578063e591b2821461011d57600080fd5b8063042c2f571461008257806309bd5a60146100975780635cf24969146100b3575b600080fd5b6100956100903660046102a6565b61015d565b005b6100a060025481565b6040519081526020015b60405180910390f35b6100a060015481565b6003546100d09067ffffffffffffffff1681565b60405167ffffffffffffffff90911681526020016100aa565b6000546100d09067ffffffffffffffff1681565b6000546100d09068010000000000000000900467ffffffffffffffff1681565b61013873deaddeaddeaddeaddeaddeaddeaddeaddead000181565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100aa565b3373deaddeaddeaddeaddeaddeaddeaddeaddead000114610204576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603b60248201527f4c31426c6f636b3a206f6e6c7920746865206465706f7369746f72206163636f60448201527f756e742063616e20736574204c3120626c6f636b2076616c7565730000000000606482015260840160405180910390fd5b6000805467ffffffffffffffff9687167fffffffffffffffffffffffffffffffff0000000000000000000000000000000090911617680100000000000000009587169590950294909417909355600191909155600255600380547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001691909216179055565b803567ffffffffffffffff811681146102a157600080fd5b919050565b600080600080600060a086880312156102be57600080fd5b6102c786610289565b94506102d560208701610289565b935060408601359250606086013591506102f160808701610289565b9050929550929590935056fea164736f6c634300080a000a"
var L1BlockDeployedBin = "0x608060405234801561001057600080fd5b50600436106100be5760003560e01c80638381f58a11610076578063c8b915311161005b578063c8b9153114610185578063e591b282146101ac578063f786becd146101ec57600080fd5b80638381f58a14610151578063b80777ea1461016557600080fd5b80635cf24969116100a75780635cf24969146100f457806364ca23ef146100fd5780636bf2606a1461012a57600080fd5b8063042c2f57146100c357806309bd5a60146100d8575b600080fd5b6100d66100d136600461035c565b610213565b005b6100e160025481565b6040519081526020015b60405180910390f35b6100e160015481565b6003546101119067ffffffffffffffff1681565b60405167ffffffffffffffff90911681526020016100eb565b6100e17f000000000000000000000000000000000000000000000000000000000000000081565b6000546101119067ffffffffffffffff1681565b6000546101119068010000000000000000900467ffffffffffffffff1681565b6100e17f000000000000000000000000000000000000000000000000000000000000000081565b6101c773deaddeaddeaddeaddeaddeaddeaddeaddead000181565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100eb565b6100e17f000000000000000000000000000000000000000000000000000000000000000081565b3373deaddeaddeaddeaddeaddeaddeaddeaddead0001146102ba576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603b60248201527f4c31426c6f636b3a206f6e6c7920746865206465706f7369746f72206163636f60448201527f756e742063616e20736574204c3120626c6f636b2076616c7565730000000000606482015260840160405180910390fd5b6000805467ffffffffffffffff9687167fffffffffffffffffffffffffffffffff0000000000000000000000000000000090911617680100000000000000009587169590950294909417909355600191909155600255600380547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001691909216179055565b803567ffffffffffffffff8116811461035757600080fd5b919050565b600080600080600060a0868803121561037457600080fd5b61037d8661033f565b945061038b6020870161033f565b935060408601359250606086013591506103a76080870161033f565b9050929550929590935056fea164736f6c634300080a000a"
This diff is collapsed.
This diff is collapsed.
......@@ -2,4 +2,4 @@
// This file is a generated binding and any manual changes will be lost.
package bindings
var L2ToL1MessagePasserDeployedBin = "0x6080604052600436106100435760003560e01c806344df8e701461006c57806382e3702d14610081578063affed0e0146100c6578063c2b3e5ac146100ea57600080fd5b366100675761006533620186a0604051806020016040528060008152506100f8565b005b600080fd5b34801561007857600080fd5b506100656101ae565b34801561008d57600080fd5b506100b161009c366004610260565b60006020819052908152604090205460ff1681565b60405190151581526020015b60405180910390f35b3480156100d257600080fd5b506100dc60015481565b6040519081526020016100bd565b6100656100f83660046102a8565b600061010a60015433863487876101e6565b6000818152602081905260409081902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600190811790915554905191925073ffffffffffffffffffffffffffffffffffffffff8616913391907f87bf7b546c8de873abb0db5b579ec131f8d0cf5b14f39933551cf9ced23a61369061019890349089908990610417565b60405180910390a4505060018054810190555050565b476101b881610225565b60405181907f7967de617a5ac1cc7eba2d6f37570a0135afa950d8bb77cdd35f0d0b4e85a16f90600090a250565b60008686868686866040516020016102039695949392919061043f565b6040516020818303038152906040528051906020012090509695505050505050565b8060405161023290610254565b6040518091039082f090508015801561024f573d6000803e3d6000fd5b505050565b60088061049783390190565b60006020828403121561027257600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156102bd57600080fd5b833573ffffffffffffffffffffffffffffffffffffffff811681146102e157600080fd5b925060208401359150604084013567ffffffffffffffff8082111561030557600080fd5b818601915086601f83011261031957600080fd5b81358181111561032b5761032b610279565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561037157610371610279565b8160405282815289602084870101111561038a57600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b6000815180845260005b818110156103d2576020818501810151868301820152016103b6565b818111156103e4576000602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b83815282602082015260606040820152600061043660608301846103ac565b95945050505050565b868152600073ffffffffffffffffffffffffffffffffffffffff808816602084015280871660408401525084606083015283608083015260c060a083015261048a60c08301846103ac565b9897505050505050505056fe608060405230fffea164736f6c634300080a000a"
var L2ToL1MessagePasserDeployedBin = "0x6080604052600436106100745760003560e01c8063affed0e01161004e578063affed0e014610139578063c2b3e5ac1461014f578063c8b9153114610162578063f786becd1461019657600080fd5b806344df8e701461009d5780636bf2606a146100b257806382e3702d146100f957600080fd5b366100985761009633620186a0604051806020016040528060008152506101ca565b005b600080fd5b3480156100a957600080fd5b50610096610280565b3480156100be57600080fd5b506100e67f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b34801561010557600080fd5b50610129610114366004610332565b60006020819052908152604090205460ff1681565b60405190151581526020016100f0565b34801561014557600080fd5b506100e660015481565b61009661015d36600461037a565b6101ca565b34801561016e57600080fd5b506100e67f000000000000000000000000000000000000000000000000000000000000000081565b3480156101a257600080fd5b506100e67f000000000000000000000000000000000000000000000000000000000000000081565b60006101dc60015433863487876102b8565b6000818152602081905260409081902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600190811790915554905191925073ffffffffffffffffffffffffffffffffffffffff8616913391907f87bf7b546c8de873abb0db5b579ec131f8d0cf5b14f39933551cf9ced23a61369061026a903490899089906104e9565b60405180910390a4505060018054810190555050565b4761028a816102f7565b60405181907f7967de617a5ac1cc7eba2d6f37570a0135afa950d8bb77cdd35f0d0b4e85a16f90600090a250565b60008686868686866040516020016102d596959493929190610511565b6040516020818303038152906040528051906020012090509695505050505050565b8060405161030490610326565b6040518091039082f0905080158015610321573d6000803e3d6000fd5b505050565b60088061056983390190565b60006020828403121561034457600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561038f57600080fd5b833573ffffffffffffffffffffffffffffffffffffffff811681146103b357600080fd5b925060208401359150604084013567ffffffffffffffff808211156103d757600080fd5b818601915086601f8301126103eb57600080fd5b8135818111156103fd576103fd61034b565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156104435761044361034b565b8160405282815289602084870101111561045c57600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b6000815180845260005b818110156104a457602081850181015186830182015201610488565b818111156104b6576000602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b838152826020820152606060408201526000610508606083018461047e565b95945050505050565b868152600073ffffffffffffffffffffffffffffffffffffffff808816602084015280871660408401525084606083015283608083015260c060a083015261055c60c083018461047e565b9897505050505050505056fe608060405230fffea164736f6c634300080a000a"
This diff is collapsed.
......@@ -2,25 +2,43 @@ module github.com/ethereum-optimism/optimism/op-bindings
go 1.18
require github.com/ethereum/go-ethereum v1.10.17
require (
github.com/ethereum/go-ethereum v1.10.17
github.com/stretchr/testify v1.7.0
)
require (
github.com/VictoriaMetrics/fastcache v1.9.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.0 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/tsdb v0.10.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 // indirect
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220711171946-f579014dc46d
This diff is collapsed.
......@@ -10,7 +10,7 @@ const (
L2CrossDomainMessenger = "0x4200000000000000000000000000000000000007"
L2StandardBridge = "0x4200000000000000000000000000000000000010"
SequencerFeeVault = "0x4200000000000000000000000000000000000011"
OptimismMintableTokenFactory = "0x4200000000000000000000000000000000000012"
OptimismMintableERC20Factory = "0x4200000000000000000000000000000000000012"
L1BlockNumber = "0x4200000000000000000000000000000000000013"
OVM_GasPriceOracle = "0x420000000000000000000000000000000000000F"
L1Block = "0x4200000000000000000000000000000000000015"
......@@ -25,7 +25,7 @@ var (
L2CrossDomainMessengerAddr = common.HexToAddress(L2CrossDomainMessenger)
L2StandardBridgeAddr = common.HexToAddress(L2StandardBridge)
SequencerFeeVaultAddr = common.HexToAddress(SequencerFeeVault)
OptimismMintableTokenFactoryAddr = common.HexToAddress(OptimismMintableTokenFactory)
OptimismMintableERC20FactoryAddr = common.HexToAddress(OptimismMintableERC20Factory)
L1BlockNumberAddr = common.HexToAddress(L1BlockNumber)
OVM_GasPriceOracleAddr = common.HexToAddress(OVM_GasPriceOracle)
L1BlockAddr = common.HexToAddress(L1Block)
......
package predeploys
import (
"testing"
"github.com/ethereum/go-ethereum/core"
"github.com/stretchr/testify/require"
)
func TestGethAddresses(t *testing.T) {
// We test if the addresses in geth match those in op-bindings, to avoid an import-cycle:
// we import geth in the monorepo, and do not want to import op-bindings into geth.
require.Equal(t, OVM_GasPriceOracleAddr, core.OVM_GasPriceOracleAddr)
require.Equal(t, L1BlockAddr, core.L1BlockAddr)
}
......@@ -3,15 +3,15 @@ module github.com/ethereum-optimism/optimism/op-e2e
go 1.18
require (
github.com/ethereum-optimism/optimism/op-batcher v0.0.0
github.com/ethereum-optimism/optimism/op-bindings v0.0.0
github.com/ethereum-optimism/optimism/op-node v0.0.0
github.com/ethereum-optimism/optimism/op-proposer v0.0.0
github.com/ethereum-optimism/optimism/op-batcher v0.3.0
github.com/ethereum-optimism/optimism/op-bindings v0.3.0
github.com/ethereum-optimism/optimism/op-node v0.3.0
github.com/ethereum-optimism/optimism/op-proposer v0.3.0
github.com/ethereum/go-ethereum v1.10.17
github.com/libp2p/go-libp2p v0.18.1
github.com/libp2p/go-libp2p-core v0.15.0
github.com/miguelmota/go-ethereum-hdwallet v0.1.1
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.0
)
require (
......@@ -24,8 +24,8 @@ require (
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327 // indirect
github.com/coreos/go-systemd/v22 v22.1.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
......@@ -38,7 +38,7 @@ require (
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/godbus/dbus/v5 v5.0.3 // indirect
github.com/godbus/dbus/v5 v5.0.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
......@@ -46,9 +46,9 @@ require (
github.com/google/gopacket v1.1.19 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-bexpr v0.1.11 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.0 // indirect
......@@ -103,7 +103,7 @@ require (
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/pointerstructure v1.2.1 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.0.3 // indirect
......@@ -121,9 +121,9 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.11.0 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.30.0 // indirect
github.com/prometheus/common v0.35.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/tsdb v0.10.0 // indirect
github.com/raulk/clock v1.1.0 // indirect
......@@ -144,27 +144,20 @@ require (
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
golang.org/x/sys v0.0.0-20220701225701-179beb0bd1a1 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect
google.golang.org/grpc v1.40.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
google.golang.org/grpc v1.46.2 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/urfave/cli.v1 v1.20.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
replace (
github.com/ethereum-optimism/optimism/op-batcher v0.0.0 => ../op-batcher
github.com/ethereum-optimism/optimism/op-bindings v0.0.0 => ../op-bindings
github.com/ethereum-optimism/optimism/op-node v0.0.0 => ../op-node
github.com/ethereum-optimism/optimism/op-proposer v0.0.0 => ../op-proposer
)
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220711171946-f579014dc46d
This diff is collapsed.
......@@ -3,9 +3,7 @@ package op_e2e
import (
"context"
"fmt"
"io/ioutil"
"math/big"
"os"
"strings"
"time"
......@@ -17,7 +15,6 @@ import (
"github.com/ethereum-optimism/optimism/op-node/p2p"
"github.com/ethereum-optimism/optimism/op-node/rollup"
l2os "github.com/ethereum-optimism/optimism/op-proposer"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
......@@ -108,17 +105,16 @@ type System struct {
wallet *hdwallet.Wallet
// Connections to running nodes
nodes map[string]*node.Node
backends map[string]*eth.Ethereum
Clients map[string]*ethclient.Client
RolupGenesis rollup.Genesis
rollupNodes map[string]*rollupNode.OpNode
l2OutputSubmitter *l2os.L2OutputSubmitter
sequencerHistoryDBFileName string
batchSubmitter *bss.BatchSubmitter
L2OOContractAddr common.Address
DepositContractAddr common.Address
Mocknet mocknet.Mocknet
nodes map[string]*node.Node
backends map[string]*eth.Ethereum
Clients map[string]*ethclient.Client
RolupGenesis rollup.Genesis
rollupNodes map[string]*rollupNode.OpNode
l2OutputSubmitter *l2os.L2OutputSubmitter
batchSubmitter *bss.BatchSubmitter
L2OOContractAddr common.Address
DepositContractAddr common.Address
Mocknet mocknet.Mocknet
}
func precompileAlloc() core.GenesisAlloc {
......@@ -154,9 +150,6 @@ func (sys *System) Close() {
if sys.batchSubmitter != nil {
sys.batchSubmitter.Stop()
}
if sys.sequencerHistoryDBFileName != "" {
_ = os.Remove(sys.sequencerHistoryDBFileName)
}
for _, node := range sys.rollupNodes {
node.Close()
......@@ -291,7 +284,6 @@ func (cfg SystemConfig) start() (*System, error) {
MergeForkBlock: common.Big0,
TerminalTotalDifficulty: common.Big0,
Optimism: &params.OptimismConfig{
Enabled: true,
BaseFeeRecipient: cfg.BaseFeeRecipient,
L1FeeRecipient: cfg.L1FeeRecipient,
},
......@@ -494,6 +486,11 @@ func (cfg SystemConfig) start() (*System, error) {
}
}
}
// Don't log state snapshots in test output
snapLog := log.New()
snapLog.SetHandler(log.DiscardHandler())
// Rollup nodes
for name, nodeConfig := range cfg.Nodes {
c := *nodeConfig // copy
......@@ -503,12 +500,12 @@ func (cfg SystemConfig) start() (*System, error) {
if p, ok := p2pNodes[name]; ok {
c.P2P = p
if c.Sequencer {
if c.Driver.SequencerEnabled {
c.P2PSigner = &p2p.PreparedSigner{Signer: p2p.NewLocalSigner(p2pSignerPrivKey)}
}
}
node, err := rollupNode.New(context.Background(), &c, cfg.Loggers[name], cfg.Loggers[name], "", metrics.NewMetrics(""))
node, err := rollupNode.New(context.Background(), &c, cfg.Loggers[name], snapLog, "", metrics.NewMetrics(""))
if err != nil {
didErrAfterStart = true
return nil, err
......@@ -562,7 +559,7 @@ func (cfg SystemConfig) start() (*System, error) {
LogTerminal: true,
Mnemonic: sys.cfg.Mnemonic,
L2OutputHDPath: sys.cfg.L2OutputHDPath,
}, "", cfg.ProposerLogger)
}, "", sys.cfg.Loggers["proposer"])
if err != nil {
return nil, fmt.Errorf("unable to setup l2 output submitter: %w", err)
}
......@@ -571,15 +568,6 @@ func (cfg SystemConfig) start() (*System, error) {
return nil, fmt.Errorf("unable to start l2 output submitter: %w", err)
}
sequencerHistoryDBFile, err := ioutil.TempFile("", "bss.*.json")
if err != nil {
return nil, fmt.Errorf("unable to create sequencer history db file: %w", err)
}
sys.sequencerHistoryDBFileName = sequencerHistoryDBFile.Name()
if err = sequencerHistoryDBFile.Close(); err != nil {
return nil, fmt.Errorf("unable to close sequencer history db file: %w", err)
}
// Batch Submitter
sys.batchSubmitter, err = bss.NewBatchSubmitter(bss.Config{
L1EthRpc: sys.nodes["l1"].WSEndpoint(),
......@@ -587,18 +575,17 @@ func (cfg SystemConfig) start() (*System, error) {
RollupRpc: rollupEndpoint,
MinL1TxSize: 1,
MaxL1TxSize: 120000,
ChannelTimeout: sys.cfg.RollupConfig.ChannelTimeout,
PollInterval: 50 * time.Millisecond,
NumConfirmations: 1,
ResubmissionTimeout: 5 * time.Second,
SafeAbortNonceTooLowCount: 3,
LogLevel: "info",
LogTerminal: true,
LogLevel: "info", // ignored if started in-process this way
LogTerminal: true, // ignored
Mnemonic: sys.cfg.Mnemonic,
SequencerHDPath: sys.cfg.BatchSubmitterHDPath,
SequencerHistoryDBFilename: sys.sequencerHistoryDBFileName,
SequencerGenesisHash: sys.RolupGenesis.L2.Hash.String(),
SequencerBatchInboxAddress: sys.cfg.RollupConfig.BatchInboxAddress.String(),
}, "", cfg.BatcherLogger)
}, sys.cfg.Loggers["batcher"])
if err != nil {
return nil, fmt.Errorf("failed to setup batch submitter: %w", err)
}
......
This diff is collapsed.
......@@ -2,15 +2,12 @@ FROM golang:1.18.0-alpine3.15 as builder
RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash
COPY ./op-node/go.mod /app/op-node/go.mod
COPY ./op-node/go.sum /app/op-node/go.sum
# build op-node with local monorepo go modules
COPY ./op-node/docker.go.work /app/go.work
COPY ./op-bindings /app/op-bindings
COPY ./op-node /app/op-node
WORKDIR /app/op-node
RUN go mod download -x
COPY ./op-node /app/op-node
RUN make op-node
......
......@@ -6,7 +6,17 @@
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/paginationjs/2.1.5/pagination.css" />
<style>
#snapshot-tables {
font-size: 0.6rem;
}
#snapshot-tables td {
padding: 0.2rem 0.2rem;
}
.tooltip div {
min-width: 40rem;
}
</style>
</head>
<body>
......
......@@ -20,6 +20,22 @@ async function fetchLogs() {
return await response.json();
}
function tooltipFormat(v) {
var out = ""
out += `<div>`
out += `<em>hash</em>: <code>${v["hash"]}</code><br/>`
out += `<em>num</em>: <code>${v["number"]}</code><br/>`
out += `<em>parent</em>: <code>${v["parentHash"]}</code><br/>`
out += `<em>time</em>: <code>${v["timestamp"]}</code><br/>`
if(v.hasOwnProperty("l1origin")) {
out += `<em>L1 hash</em>: <code>${v["l1origin"]["hash"]}</code><br/>`
out += `<em>L1 num</em>: <code>${v["l1origin"]["number"]}</code><br/>`
out += `<em>seq</em>: <code>${v["sequenceNumber"]}</code><br/>`
}
out += `</div>`
return out
}
async function pageTable() {
const logs = await fetchLogs();
if (logs.length === 0) {
......@@ -37,7 +53,7 @@ async function pageTable() {
$("#logs").append(paginationEl)
paginationEl.pagination({
dataSource: logs,
pageSize: 20,
pageSize: 40,
showGoInput: true,
showGoButton: true,
callback: (data, pagination) => {
......@@ -51,10 +67,10 @@ async function pageTable() {
<tr>
<th scope="col">Timestamp</th>
<th scope="col">L1Head</th>
<th scope="col">L1Current</th>
<th scope="col">L2Head</th>
<th scope="col">L2SafeHead</th>
<th scope="col">L2FinalizedHead</th>
<th scope="col">L1WindowBuf</th>
</tr>
</thead>
`;
......@@ -67,31 +83,29 @@ async function pageTable() {
// this column has reached its end
break
}
let windowBufEl = `<ul style="list-style-type:none">`
e.l1WindowBuf.forEach((x) => {
windowBufEl += `<li title=${JSON.stringify(x)} data-toggle="tooltip" style="background-color:${colorCode(x.hash)};">${prettyHex(x.hash)}</li>`
})
windowBufEl += "</ul>"
// outer stringify in title attribute escapes the content and adds the quotes for the html to be valid
// inner stringify in
// TODO: click to copy full hash
html += `<tr>
<td title="${e.event}" data-toggle="tooltip">
${e.t}
</td>
<td title=${JSON.stringify(e.l1Head)} data-toggle="tooltip" style="background-color:${colorCode(e.l1Head.hash)};">
<td title="${tooltipFormat(e.l1Head)}" data-bs-html="true" data-toggle="tooltip" style="background-color:${colorCode(e.l1Head.hash)};">
${prettyHex(e.l1Head.hash)}
</td>
<td title=${JSON.stringify(e.l2Head)} data-toggle="tooltip" style="background-color:${colorCode(e.l2Head.hash)};">
<td title="${tooltipFormat(e.l1Current)}" data-bs-html="true" data-toggle="tooltip" style="background-color:${colorCode(e.l1Current.hash)};">
${prettyHex(e.l1Current.hash)}
</td>
<td title="${tooltipFormat(e.l2Head)}" data-bs-html="true" data-toggle="tooltip" style="background-color:${colorCode(e.l2Head.hash)};">
${prettyHex(e.l2Head.hash)}
</td>
<td title=${JSON.stringify(e.l2SafeHead)} data-toggle="tooltip" style="background-color:${colorCode(e.l2SafeHead.hash)};">
<td title="${tooltipFormat(e.l2SafeHead)}" data-bs-html="true" data-toggle="tooltip" style="background-color:${colorCode(e.l2SafeHead.hash)};">
${prettyHex(e.l2SafeHead.hash)}
</td>
<td title=${JSON.stringify(e.l2FinalizedHead)} data-toggle="tooltip" style="background-color:${colorCode(e.l2FinalizedHead.hash)};">
<td title="${tooltipFormat(e.l2FinalizedHead)}" data-bs-html="true" data-toggle="tooltip" style="background-color:${colorCode(e.l2FinalizedHead.hash)};">
${prettyHex(e.l2FinalizedHead.hash)}
</td>
<td>${windowBufEl}</td>
</tr>`;
}
html += "</tbody>";
......
......@@ -38,12 +38,12 @@ var (
type SnapshotState struct {
Timestamp string `json:"t"`
EngineAddr string `json:"engine_addr"`
Event string `json:"event"`
L1Head eth.L1BlockRef `json:"l1Head"`
L2Head eth.L2BlockRef `json:"l2Head"`
L2SafeHead eth.L2BlockRef `json:"l2SafeHead"`
L2FinalizedHead eth.BlockID `json:"l2FinalizedHead"`
L1WindowBuf []eth.BlockID `json:"l1WindowBuf"`
Event string `json:"event"` // event name
L1Head eth.L1BlockRef `json:"l1Head"` // what we see as head on L1
L1Current eth.L1BlockRef `json:"l1Current"` // l1 block that the derivation is currently using
L2Head eth.L2BlockRef `json:"l2Head"` // l2 block that was last optimistically accepted (unsafe head)
L2SafeHead eth.L2BlockRef `json:"l2SafeHead"` // l2 block that was last derived
L2FinalizedHead eth.BlockID `json:"l2FinalizedHead"` // l2 block that is irreversible
}
func (e *SnapshotState) UnmarshalJSON(data []byte) error {
......@@ -52,10 +52,10 @@ func (e *SnapshotState) UnmarshalJSON(data []byte) error {
EngineAddr string `json:"engine_addr"`
Event string `json:"event"`
L1Head json.RawMessage `json:"l1Head"`
L1Current json.RawMessage `json:"l1Current"`
L2Head json.RawMessage `json:"l2Head"`
L2SafeHead json.RawMessage `json:"l2SafeHead"`
L2FinalizedHead json.RawMessage `json:"l2FinalizedHead"`
L1WindowBuf json.RawMessage `json:"l1WindowBuf"`
}{}
if err := json.Unmarshal(data, &t); err != nil {
return err
......@@ -72,6 +72,9 @@ func (e *SnapshotState) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(unquote(t.L1Head), &e.L1Head); err != nil {
return err
}
if err := json.Unmarshal(unquote(t.L1Current), &e.L1Current); err != nil {
return err
}
if err := json.Unmarshal(unquote(t.L2Head), &e.L2Head); err != nil {
return err
}
......@@ -81,12 +84,6 @@ func (e *SnapshotState) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(unquote(t.L2FinalizedHead), &e.L2FinalizedHead); err != nil {
return err
}
if err := json.Unmarshal(unquote(t.L1WindowBuf), &e.L1WindowBuf); err != nil {
return err
}
if e.L1WindowBuf == nil {
e.L1WindowBuf = make([]eth.BlockID, 0)
}
return nil
}
......
go 1.18
use (
./op-bindings
./op-node
)
package eth
import (
"math/big"
"github.com/ethereum/go-ethereum/common"
)
type L1Info interface {
Hash() common.Hash
ParentHash() common.Hash
Root() common.Hash // state-root
NumberU64() uint64
Time() uint64
// MixDigest field, reused for randomness after The Merge (Bellatrix hardfork)
MixDigest() common.Hash
BaseFee() *big.Int
ID() BlockID
BlockRef() L1BlockRef
ReceiptHash() common.Hash
}
package eth
import (
"fmt"
)
func ForkchoiceUpdateErr(payloadStatus PayloadStatusV1) error {
switch payloadStatus.Status {
case ExecutionSyncing:
return fmt.Errorf("updated forkchoice, but node is syncing")
case ExecutionAccepted, ExecutionInvalidTerminalBlock, ExecutionInvalidBlockHash:
// ACCEPTED, INVALID_TERMINAL_BLOCK, INVALID_BLOCK_HASH are only for execution
return fmt.Errorf("unexpected %s status, could not update forkchoice", payloadStatus.Status)
case ExecutionInvalid:
return fmt.Errorf("cannot update forkchoice, block is invalid")
case ExecutionValid:
return nil
default:
return fmt.Errorf("unknown forkchoice status: %q", string(payloadStatus.Status))
}
}
func NewPayloadErr(payload *ExecutionPayload, payloadStatus *PayloadStatusV1) error {
switch payloadStatus.Status {
case ExecutionValid:
return nil
case ExecutionSyncing:
return fmt.Errorf("failed to execute payload %s, node is syncing", payload.ID())
case ExecutionInvalid:
return fmt.Errorf("execution payload %s was INVALID! Latest valid hash is %s, ignoring bad block: %v", payload.ID(), payloadStatus.LatestValidHash, payloadStatus.ValidationError)
case ExecutionInvalidBlockHash:
return fmt.Errorf("execution payload %s has INVALID BLOCKHASH! %v", payload.BlockHash, payloadStatus.ValidationError)
case ExecutionInvalidTerminalBlock:
return fmt.Errorf("engine is misconfigured. Received invalid-terminal-block error while engine API should be active at genesis. err: %v", payloadStatus.ValidationError)
case ExecutionAccepted:
return fmt.Errorf("execution payload cannot be validated yet, latest valid hash is %s", payloadStatus.LatestValidHash)
default:
return fmt.Errorf("unknown execution status on %s: %q, ", payload.ID(), string(payloadStatus.Status))
}
}
......@@ -39,6 +39,12 @@ func (b Bytes32) String() string {
return hexutil.Encode(b[:])
}
// TerminalString implements log.TerminalStringer, formatting a string for console
// output during logging.
func (b Bytes32) TerminalString() string {
return fmt.Sprintf("%x..%x", b[:3], b[29:])
}
type Bytes256 [256]byte
func (b *Bytes256) UnmarshalJSON(text []byte) error {
......@@ -57,6 +63,12 @@ func (b Bytes256) String() string {
return hexutil.Encode(b[:])
}
// TerminalString implements log.TerminalStringer, formatting a string for console
// output during logging.
func (b Bytes256) TerminalString() string {
return fmt.Sprintf("%x..%x", b[:3], b[253:])
}
type Uint64Quantity = hexutil.Uint64
type BytesMax32 []byte
......@@ -219,10 +231,10 @@ const (
type PayloadStatusV1 struct {
// the result of the payload execution
Status ExecutePayloadStatus `json:"status"`
// the hash of the most recent valid block in the branch defined by payload and its ancestors
LatestValidHash common.Hash `json:"latestValidHash"`
// additional details on the result
ValidationError string `json:"validationError"`
// the hash of the most recent valid block in the branch defined by payload and its ancestors (optional field)
LatestValidHash *common.Hash `json:"latestValidHash,omitempty"`
// additional details on the result (optional field)
ValidationError *string `json:"validationError,omitempty"`
}
type ForkchoiceState struct {
......
......@@ -58,12 +58,25 @@ var (
Value: "",
Destination: new(string),
}
SequencingEnabledFlag = cli.BoolFlag{
Name: "sequencing.enabled",
Usage: "enable sequencing",
EnvVar: prefixEnvVar("SEQUENCING_ENABLED"),
VerifierL1Confs = cli.Uint64Flag{
Name: "verifier.l1-confs",
Usage: "Number of L1 blocks to keep distance from the L1 head before deriving L2 data from. Reorgs are supported, but may be slow to perform.",
EnvVar: prefixEnvVar("VERIFIER_L1_CONFS"),
Required: false,
Value: 0,
}
SequencerEnabledFlag = cli.BoolFlag{
Name: "sequencer.enabled",
Usage: "Enable sequencing of new L2 blocks. A separate batch submitter has to be deployed to publish the data for verifiers.",
EnvVar: prefixEnvVar("SEQUENCER_ENABLED"),
}
SequencerL1Confs = cli.Uint64Flag{
Name: "sequencer.l1-confs",
Usage: "Number of L1 blocks to keep distance from the L1 head as a sequencer for picking an L1 origin.",
EnvVar: prefixEnvVar("SEQUENCER_L1_CONFS"),
Required: false,
Value: 4,
}
LogLevelFlag = cli.StringFlag{
Name: "log.level",
Usage: "The lowest log level that will be output",
......@@ -117,7 +130,9 @@ var requiredFlags = []cli.Flag{
var optionalFlags = append([]cli.Flag{
L1TrustRPC,
L2EngineJWTSecret,
SequencingEnabledFlag,
VerifierL1Confs,
SequencerEnabledFlag,
SequencerL1Confs,
LogLevelFlag,
LogFormatFlag,
LogColorFlag,
......
......@@ -3,11 +3,11 @@ module github.com/ethereum-optimism/optimism/op-node
go 1.18
require (
github.com/ethereum-optimism/optimism/op-bindings v0.0.0
github.com/ethereum-optimism/optimism/op-bindings v0.3.0
github.com/ethereum/go-ethereum v1.10.17
github.com/golang/snappy v0.0.4
github.com/google/go-cmp v0.5.8
github.com/hashicorp/go-multierror v1.0.0
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/holiman/uint256 v1.2.0
github.com/ipfs/go-datastore v0.5.0
......@@ -26,7 +26,7 @@ require (
github.com/multiformats/go-multiaddr v0.5.0
github.com/multiformats/go-multiaddr-dns v0.3.1
github.com/prometheus/client_golang v1.12.2
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.0
github.com/urfave/cli v1.22.5
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
)
......@@ -41,8 +41,8 @@ require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cheekybits/genny v1.0.0 // indirect
github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327 // indirect
github.com/coreos/go-systemd/v22 v22.1.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
......@@ -52,19 +52,19 @@ require (
github.com/fjl/memsize v0.0.1 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/godbus/dbus/v5 v5.0.3 // indirect
github.com/godbus/dbus/v5 v5.0.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-bexpr v0.1.11 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/huin/goupnp v1.0.3 // indirect
......@@ -78,6 +78,7 @@ require (
github.com/klauspost/compress v1.13.6 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/koron/go-ssdp v0.0.2 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
github.com/libp2p/go-cidranger v1.1.0 // indirect
github.com/libp2p/go-conn-security-multistream v0.3.0 // indirect
......@@ -113,7 +114,7 @@ require (
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/pointerstructure v1.2.1 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.0.3 // indirect
......@@ -127,6 +128,7 @@ require (
github.com/nxadm/tail v1.4.8 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onsi/ginkgo v1.16.4 // indirect
github.com/onsi/gomega v1.19.0 // indirect
github.com/opencontainers/runtime-spec v1.0.2 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
......@@ -139,42 +141,39 @@ require (
github.com/raulk/go-watchdog v1.2.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
github.com/status-im/keycard-go v0.0.0-20211109104530-b0e0482ba91d // indirect
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/objx v0.4.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 // indirect
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 // indirect
golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
golang.org/x/sys v0.0.0-20220701225701-179beb0bd1a1 // indirect
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect
golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/grpc v1.40.0 // indirect
golang.org/x/tools v0.1.11 // indirect
google.golang.org/grpc v1.46.2 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/urfave/cli.v1 v1.20.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
replace github.com/ethereum-optimism/optimism/op-bindings v0.0.0 => ../op-bindings
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592
replace github.com/ethereum-optimism/optimism/op-proposer v0.0.0 => ../op-proposer
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220711171946-f579014dc46d
// For local debugging:
// replace github.com/ethereum/go-ethereum v1.10.17 => ../go-ethereum
This diff is collapsed.
......@@ -11,7 +11,6 @@ import (
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
......@@ -184,24 +183,24 @@ func (s *Source) blockCall(ctx context.Context, method string, id interface{}) (
return info, txs, nil
}
func (s *Source) InfoByHash(ctx context.Context, hash common.Hash) (derive.L1Info, error) {
func (s *Source) InfoByHash(ctx context.Context, hash common.Hash) (eth.L1Info, error) {
if header, ok := s.headersCache.Get(hash); ok {
return header.(*HeaderInfo), nil
}
return s.headerCall(ctx, "eth_getBlockByHash", hash)
}
func (s *Source) InfoByNumber(ctx context.Context, number uint64) (derive.L1Info, error) {
func (s *Source) InfoByNumber(ctx context.Context, number uint64) (eth.L1Info, error) {
// can't hit the cache when querying by number due to reorgs.
return s.headerCall(ctx, "eth_getBlockByNumber", hexutil.EncodeUint64(number))
}
func (s *Source) InfoHead(ctx context.Context) (derive.L1Info, error) {
func (s *Source) InfoHead(ctx context.Context) (eth.L1Info, error) {
// can't hit the cache when querying the head due to reorgs / changes.
return s.headerCall(ctx, "eth_getBlockByNumber", "latest")
}
func (s *Source) InfoAndTxsByHash(ctx context.Context, hash common.Hash) (derive.L1Info, types.Transactions, error) {
func (s *Source) InfoAndTxsByHash(ctx context.Context, hash common.Hash) (eth.L1Info, types.Transactions, error) {
if header, ok := s.headersCache.Get(hash); ok {
if txs, ok := s.transactionsCache.Get(hash); ok {
return header.(*HeaderInfo), txs.(types.Transactions), nil
......@@ -210,17 +209,17 @@ func (s *Source) InfoAndTxsByHash(ctx context.Context, hash common.Hash) (derive
return s.blockCall(ctx, "eth_getBlockByHash", hash)
}
func (s *Source) InfoAndTxsByNumber(ctx context.Context, number uint64) (derive.L1Info, types.Transactions, error) {
func (s *Source) InfoAndTxsByNumber(ctx context.Context, number uint64) (eth.L1Info, types.Transactions, error) {
// can't hit the cache when querying by number due to reorgs.
return s.blockCall(ctx, "eth_getBlockByNumber", hexutil.EncodeUint64(number))
}
func (s *Source) InfoAndTxsHead(ctx context.Context) (derive.L1Info, types.Transactions, error) {
func (s *Source) InfoAndTxsHead(ctx context.Context) (eth.L1Info, types.Transactions, error) {
// can't hit the cache when querying the head due to reorgs / changes.
return s.blockCall(ctx, "eth_getBlockByNumber", "latest")
}
func (s *Source) Fetch(ctx context.Context, blockHash common.Hash) (derive.L1Info, types.Transactions, types.Receipts, error) {
func (s *Source) Fetch(ctx context.Context, blockHash common.Hash) (eth.L1Info, types.Transactions, types.Receipts, error) {
if blockHash == (common.Hash{}) {
return nil, nil, nil, ethereum.NotFound
}
......
......@@ -6,7 +6,6 @@ import (
"math/big"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/trie"
......@@ -35,7 +34,7 @@ type HeaderInfo struct {
receiptHash common.Hash
}
var _ derive.L1Info = (*HeaderInfo)(nil)
var _ eth.L1Info = (*HeaderInfo)(nil)
func (info *HeaderInfo) Hash() common.Hash {
return info.hash
......
This diff is collapsed.
......@@ -113,7 +113,8 @@ func BlockToBatch(config *rollup.Config, block *types.Block) (*derive.BatchData,
return nil, fmt.Errorf("invalid L1 info deposit tx in block: %v", err)
}
return &derive.BatchData{BatchV1: derive.BatchV1{
Epoch: rollup.Epoch(l1Info.Number), // the L1 block number equals the L2 epoch.
EpochNum: rollup.Epoch(l1Info.Number), // the L1 block number equals the L2 epoch.
EpochHash: l1Info.BlockHash,
Timestamp: block.Time(),
Transactions: opaqueTxs,
}}, nil
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment