Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2b74b98
feat: Adds depcheck to CI workflow
noahlitvin Jan 6, 2022
c9fd6ec
l2geth: parse fees config
tynes Dec 22, 2021
1da1600
ops: allow configurable fees
tynes Dec 22, 2021
67fc72d
ops: document how to turn off L2 fees for development
tynes Jan 11, 2022
c34e039
chore(deps): bump follow-redirects from 1.14.3 to 1.14.7
dependabot[bot] Jan 14, 2022
6e3c393
chore(deps-dev): bump shelljs from 0.8.4 to 0.8.5
dependabot[bot] Jan 15, 2022
66481ca
l2geth: forward tx to sequencer
tuxcanfly Jan 14, 2022
ab8223d
feat: add flag for sequencer client http url
tuxcanfly Jan 18, 2022
7c439ed
fix: dial sequencer client with timeout
tuxcanfly Jan 18, 2022
6f2e29d
fix (docker): pass sequencer client http from env
tuxcanfly Jan 18, 2022
5c96d27
Merge pull request #1989 from noahlitvin/feat/depcheck
tynes Jan 18, 2022
92337f8
Merge pull request #2013 from ethereum-optimism/dependabot/npm_and_ya…
tynes Jan 18, 2022
ab40732
Merge pull request #2009 from ethereum-optimism/dependabot/npm_and_ya…
tynes Jan 18, 2022
e67e850
Merge pull request #2000 from ethereum-optimism/fix/geth-enforce-fees
tynes Jan 18, 2022
805a42c
test: add integration test for sequencer fwd
tuxcanfly Jan 19, 2022
9d9bbc9
Merge pull request #2011 from tuxcanfly/tux/replica-fwd
tynes Jan 19, 2022
d4bf299
feat: regenerate receipt json for optimism fields
annieke Jan 19, 2022
ae30643
Merge pull request #2032 from ethereum-optimism/annie/regen-receipt-o…
tynes Jan 19, 2022
8be69ca
chore: add changeset for l2geth
tynes Jan 19, 2022
d4e5de5
Merge pull request #2035 from ethereum-optimism/fix/add-l2geth-rpc-pr…
tynes Jan 19, 2022
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
5 changes: 5 additions & 0 deletions .changeset/big-pants-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/l2geth': patch
---

Add support to fully unmarshal Receipts with Optimism fields
5 changes: 5 additions & 0 deletions .changeset/dull-ladybugs-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/l2geth': patch
---

Add changeset for https://github.com/ethereum-optimism/optimism/pull/2011 - replicas forward write requests to the sequencer via a configured parameter `--sequencer.clienthttp` or `SEQUENCER_CLIENT_HTTP`
5 changes: 5 additions & 0 deletions .changeset/fluffy-teachers-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/l2geth': patch
---

Correctly parse fee enforcement via config to allow turning off L2 fees for development
60 changes: 60 additions & 0 deletions .github/workflows/ts-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,66 @@ jobs:
verbose: true
flags: sdk

depcheck:
name: Check for unused dependencies
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Fetch history
run: git fetch

- name: Setup node
uses: actions/setup-node@v1
with:
node-version: '16.x'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install Dependencies
# only install dependencies if there was a change in the deps
# if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install

- name: Check packages/batch-submitter
working-directory: ./packages/batch-submitter
run: npx depcheck

- name: Check packages/contracts
working-directory: ./packages/contracts
run: npx depcheck

- name: Check packages/core-utils
working-directory: ./packages/core-utils
run: npx depcheck

- name: Check packages/data-transport-layer
working-directory: ./packages/data-transport-layer
run: npx depcheck

- name: Check packages/message-relayer
working-directory: ./packages/message-relayer
run: npx depcheck

- name: Check packages/sdk
working-directory: ./packages/sdk
run: npx depcheck

- name: Check integration-tests
working-directory: ./integration-tests
run: npx depcheck

lint:
name: Linting
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/.depcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ignores: [
"@openzeppelin/contracts",
"@types/mocha",
"@types/rimraf",
"@uniswap/v3-core",
"mocha",
"typescript",
]
27 changes: 27 additions & 0 deletions integration-tests/test/replica.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,32 @@ describe('Replica Tests', () => {
expect(sequencerBlock.stateRoot).to.deep.eq(replicaBlock.stateRoot)
expect(sequencerBlock.hash).to.deep.eq(replicaBlock.hash)
})

it('should forward tx to sequencer', async () => {
const tx = {
...defaultTransactionFactory(),
nonce: await env.l2Wallet.getTransactionCount(),
gasPrice: await gasPriceForL2(env),
}
const signed = await env.l2Wallet.signTransaction(tx)
const result = await env.replicaProvider.sendTransaction(signed)

let receipt: TransactionReceipt
while (!receipt) {
receipt = await env.replicaProvider.getTransactionReceipt(result.hash)
await sleep(200)
}

const sequencerBlock = (await env.l2Provider.getBlock(
result.blockNumber
)) as any

const replicaBlock = (await env.replicaProvider.getBlock(
result.blockNumber
)) as any

expect(sequencerBlock.stateRoot).to.deep.eq(replicaBlock.stateRoot)
expect(sequencerBlock.hash).to.deep.eq(replicaBlock.hash)
})
})
})
1 change: 1 addition & 0 deletions l2geth/cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ var (
utils.RollupEnforceFeesFlag,
utils.RollupFeeThresholdDownFlag,
utils.RollupFeeThresholdUpFlag,
utils.SequencerClientHttpFlag,
}

rpcFlags = []cli.Flag{
Expand Down
1 change: 1 addition & 0 deletions l2geth/cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var AppHelpFlagGroups = []flagGroup{
utils.RollupEnforceFeesFlag,
utils.RollupFeeThresholdDownFlag,
utils.RollupFeeThresholdUpFlag,
utils.SequencerClientHttpFlag,
},
},
{
Expand Down
10 changes: 9 additions & 1 deletion l2geth/cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,11 @@ var (
Usage: "Allow txs with fees above the current fee up to this amount, must be > 1",
EnvVar: "ROLLUP_FEE_THRESHOLD_UP",
}
SequencerClientHttpFlag = cli.StringFlag{
Name: "sequencer.clienthttp",
Usage: "HTTP endpoint for the sequencer client",
EnvVar: "SEQUENCER_CLIENT_HTTP",
}
)

// MakeDataDir retrieves the currently requested data directory, terminating
Expand Down Expand Up @@ -1127,7 +1132,7 @@ func setRollup(ctx *cli.Context, cfg *rollup.Config) {
cfg.Backend = backend
}
if ctx.GlobalIsSet(RollupEnforceFeesFlag.Name) {
cfg.EnforceFees = true
cfg.EnforceFees = ctx.GlobalBool(RollupEnforceFeesFlag.Name)
}
if ctx.GlobalIsSet(RollupFeeThresholdDownFlag.Name) {
val := ctx.GlobalFloat64(RollupFeeThresholdDownFlag.Name)
Expand All @@ -1137,6 +1142,9 @@ func setRollup(ctx *cli.Context, cfg *rollup.Config) {
val := ctx.GlobalFloat64(RollupFeeThresholdUpFlag.Name)
cfg.FeeThresholdUp = new(big.Float).SetFloat64(val)
}
if ctx.GlobalIsSet(SequencerClientHttpFlag.Name) {
cfg.SequencerClientHttp = ctx.GlobalString(SequencerClientHttpFlag.Name)
}
}

// setLes configures the les server and ultra light client settings from the command line flags.
Expand Down
24 changes: 12 additions & 12 deletions l2geth/core/types/gen_receipt_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions l2geth/core/types/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ type receiptMarshaling struct {
GasUsed hexutil.Uint64
BlockNumber *hexutil.Big
TransactionIndex hexutil.Uint
L1GasPrice *hexutil.Big
L1GasUsed *hexutil.Big
L1Fee *hexutil.Big
}

// receiptRLP is the consensus encoding of a receipt.
Expand Down
4 changes: 4 additions & 0 deletions l2geth/eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ func (b *EthAPIBackend) IngestTransactions(txs []*types.Transaction) error {
return nil
}

func (b *EthAPIBackend) SequencerClientHttp() string {
return b.eth.config.Rollup.SequencerClientHttp
}

func (b *EthAPIBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) {
// Pending block is only known by the miner
if number == rpc.PendingBlockNumber {
Expand Down
38 changes: 33 additions & 5 deletions l2geth/internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/ethereum-optimism/optimism/l2geth/core/types"
"github.com/ethereum-optimism/optimism/l2geth/core/vm"
"github.com/ethereum-optimism/optimism/l2geth/crypto"
"github.com/ethereum-optimism/optimism/l2geth/ethclient"
"github.com/ethereum-optimism/optimism/l2geth/log"
"github.com/ethereum-optimism/optimism/l2geth/p2p"
"github.com/ethereum-optimism/optimism/l2geth/params"
Expand All @@ -51,6 +52,12 @@ import (

var errOVMUnsupported = errors.New("OVM: Unsupported RPC Method")

const (
// defaultDialTimeout is default duration the service will wait on
// startup to make a connection to either the L1 or L2 backends.
defaultDialTimeout = 5 * time.Second
)

// PublicEthereumAPI provides an API to access Ethereum related information.
// It offers only methods that operate on public data that is freely available to anyone.
type PublicEthereumAPI struct {
Expand Down Expand Up @@ -1289,6 +1296,18 @@ func newRPCTransactionFromBlockHash(b *types.Block, hash common.Hash) *RPCTransa
return nil
}

// dialSequencerClientWithTimeout attempts to dial the Sequencer using the
// provided URL. If the dial doesn't complete within defaultDialTimeout
// seconds, this method will return an error.
func dialSequencerClientWithTimeout(ctx context.Context, url string) (
*ethclient.Client, error) {

ctxt, cancel := context.WithTimeout(ctx, defaultDialTimeout)
defer cancel()

return ethclient.DialContext(ctxt, url)
}

// PublicTransactionPoolAPI exposes methods for the RPC interface
type PublicTransactionPoolAPI struct {
b Backend
Expand Down Expand Up @@ -1649,18 +1668,27 @@ func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args Sen
// SendRawTransaction will add the signed transaction to the transaction pool.
// The sender is responsible for signing the transaction and using the correct nonce.
func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) {
if s.b.IsVerifier() {
return common.Hash{}, errors.New("Cannot send raw transaction in verifier mode")
tx := new(types.Transaction)
if err := rlp.DecodeBytes(encodedTx, tx); err != nil {
return common.Hash{}, err
}

if s.b.IsSyncing() {
return common.Hash{}, errors.New("Cannot send raw transaction while syncing")
}

tx := new(types.Transaction)
if err := rlp.DecodeBytes(encodedTx, tx); err != nil {
return common.Hash{}, err
if s.b.IsVerifier() {
client, err := dialSequencerClientWithTimeout(ctx, s.b.SequencerClientHttp())
if err != nil {
return common.Hash{}, err
}
err = client.SendTransaction(context.Background(), tx)
if err != nil {
return common.Hash{}, err
}
return tx.Hash(), nil
}

// L1Timestamp and L1BlockNumber will be set right before execution
txMeta := types.NewTransactionMeta(nil, 0, nil, types.QueueOriginSequencer, nil, nil, encodedTx)
tx.SetTransactionMeta(txMeta)
Expand Down
1 change: 1 addition & 0 deletions l2geth/internal/ethapi/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ type Backend interface {
SuggestL2GasPrice(context.Context) (*big.Int, error)
SetL2GasPrice(context.Context, *big.Int) error
IngestTransactions([]*types.Transaction) error
SequencerClientHttp() string
}

func GetAPIs(apiBackend Backend) []rpc.API {
Expand Down
4 changes: 4 additions & 0 deletions l2geth/les/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ func (b *LesApiBackend) IngestTransactions([]*types.Transaction) error {
panic("not implemented")
}

func (b *LesApiBackend) SequencerClientHttp() string {
return b.eth.config.Rollup.SequencerClientHttp
}

func (b *LesApiBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) {
if number == rpc.LatestBlockNumber || number == rpc.PendingBlockNumber {
return b.eth.blockchain.CurrentHeader(), nil
Expand Down
2 changes: 2 additions & 0 deletions l2geth/rollup/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ type Config struct {
// quoted and the transaction being executed
FeeThresholdDown *big.Float
FeeThresholdUp *big.Float
// HTTP endpoint of the sequencer
SequencerClientHttp string
}
9 changes: 9 additions & 0 deletions ops/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ A Makefile has been provided for convience. The following targets are available.
- make up-metrics
- make down-metrics

## Turning off L2 Fee Enforcement

Fees can be turned off at runtime by setting the environment variable
`ROLLUP_ENFORCE_FEES` to `false`.

```bash
ROLLUP_ENFORCE_FEES=false docker-compose up
```

## Using the Go Batch Submitter

The existing Typescript batch submitter is in the process of being reimplemented
Expand Down
6 changes: 6 additions & 0 deletions ops/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ services:
# no need to keep this secret, only used internally to sign blocks
BLOCK_SIGNER_KEY: "6587ae678cf4fc9a33000cdbf9f35226b71dcc6a4684a31203241f9bcfd55d27"
BLOCK_SIGNER_ADDRESS: "0x00000398232E2064F896018496b4b44b3D62751F"

ROLLUP_ENFORCE_FEES: ${ROLLUP_ENFORCE_FEES:-true}
ROLLUP_FEE_THRESHOLD_DOWN: 0.9
ROLLUP_FEE_THRESHOLD_UP: 1.1
ports:
- ${L2GETH_HTTP_PORT:-8545}:8545
- ${L2GETH_WS_PORT:-8546}:8546
Expand Down Expand Up @@ -155,6 +159,7 @@ services:
replica:
depends_on:
- dtl
- l2geth
deploy:
replicas: 1
build:
Expand All @@ -165,6 +170,7 @@ services:
- ./envs/geth.env
environment:
ETH1_HTTP: http://l1_chain:8545
SEQUENCER_CLIENT_HTTP: http://l2geth:8545
ROLLUP_STATE_DUMP_PATH: http://deployer:8081/state-dump.latest.json
ROLLUP_CLIENT_HTTP: http://dtl:7878
ROLLUP_BACKEND: 'l2'
Expand Down
Loading