Commit 66481ca9 authored by Javed Khan's avatar Javed Khan

l2geth: forward tx to sequencer

parent 3174f034
...@@ -40,6 +40,7 @@ import ( ...@@ -40,6 +40,7 @@ import (
"github.com/ethereum-optimism/optimism/l2geth/core/types" "github.com/ethereum-optimism/optimism/l2geth/core/types"
"github.com/ethereum-optimism/optimism/l2geth/core/vm" "github.com/ethereum-optimism/optimism/l2geth/core/vm"
"github.com/ethereum-optimism/optimism/l2geth/crypto" "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/log"
"github.com/ethereum-optimism/optimism/l2geth/p2p" "github.com/ethereum-optimism/optimism/l2geth/p2p"
"github.com/ethereum-optimism/optimism/l2geth/params" "github.com/ethereum-optimism/optimism/l2geth/params"
...@@ -1649,18 +1650,30 @@ func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args Sen ...@@ -1649,18 +1650,30 @@ func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args Sen
// SendRawTransaction will add the signed transaction to the transaction pool. // SendRawTransaction will add the signed transaction to the transaction pool.
// The sender is responsible for signing the transaction and using the correct nonce. // 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) { func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) {
if s.b.IsVerifier() { tx := new(types.Transaction)
return common.Hash{}, errors.New("Cannot send raw transaction in verifier mode") if err := rlp.DecodeBytes(encodedTx, tx); err != nil {
return common.Hash{}, err
} }
if s.b.IsSyncing() { if s.b.IsSyncing() {
return common.Hash{}, errors.New("Cannot send raw transaction while syncing") return common.Hash{}, errors.New("Cannot send raw transaction while syncing")
} }
tx := new(types.Transaction) // Forward tx to sequencer if config is set
if err := rlp.DecodeBytes(encodedTx, tx); err != nil { // TODO: add forwarding config
return common.Hash{}, err if s.b.IsVerifier() {
// TODO: replace with env var L2_URL
client, err := ethclient.Dial("http://l2geth:8545")
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 // L1Timestamp and L1BlockNumber will be set right before execution
txMeta := types.NewTransactionMeta(nil, 0, nil, types.QueueOriginSequencer, nil, nil, encodedTx) txMeta := types.NewTransactionMeta(nil, 0, nil, types.QueueOriginSequencer, nil, nil, encodedTx)
tx.SetTransactionMeta(txMeta) tx.SetTransactionMeta(txMeta)
......
...@@ -155,6 +155,7 @@ services: ...@@ -155,6 +155,7 @@ services:
replica: replica:
depends_on: depends_on:
- dtl - dtl
- l2geth
deploy: deploy:
replicas: 1 replicas: 1
build: build:
...@@ -165,6 +166,7 @@ services: ...@@ -165,6 +166,7 @@ services:
- ./envs/geth.env - ./envs/geth.env
environment: environment:
ETH1_HTTP: http://l1_chain:8545 ETH1_HTTP: http://l1_chain:8545
L2_URL: http://l2geth:8545
ROLLUP_STATE_DUMP_PATH: http://deployer:8081/state-dump.latest.json ROLLUP_STATE_DUMP_PATH: http://deployer:8081/state-dump.latest.json
ROLLUP_CLIENT_HTTP: http://dtl:7878 ROLLUP_CLIENT_HTTP: http://dtl:7878
ROLLUP_BACKEND: 'l2' ROLLUP_BACKEND: 'l2'
......
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