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

l2geth: forward tx to sequencer

parent 3174f034
......@@ -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"
......@@ -1649,18 +1650,30 @@ 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
// Forward tx to sequencer if config is set
// TODO: add forwarding config
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
txMeta := types.NewTransactionMeta(nil, 0, nil, types.QueueOriginSequencer, nil, nil, encodedTx)
tx.SetTransactionMeta(txMeta)
......
......@@ -155,6 +155,7 @@ services:
replica:
depends_on:
- dtl
- l2geth
deploy:
replicas: 1
build:
......@@ -165,6 +166,7 @@ services:
- ./envs/geth.env
environment:
ETH1_HTTP: http://l1_chain:8545
L2_URL: http://l2geth:8545
ROLLUP_STATE_DUMP_PATH: http://deployer:8081/state-dump.latest.json
ROLLUP_CLIENT_HTTP: http://dtl:7878
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