Skip to content

Commit d8ad01e

Browse files
PlasmaPowerhkalodner
authored andcommitted
Let arbitrum handle more of tx publishing
1 parent 61bec6e commit d8ad01e

File tree

2 files changed

+6
-29
lines changed

2 files changed

+6
-29
lines changed

arbitrum/arbos_interface.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
package arbitrum
22

33
import (
4-
"github.com/ethereum/go-ethereum/core/state"
54
"github.com/ethereum/go-ethereum/core/types"
65
)
76

8-
type ArbosWrapper interface {
9-
BuildBlock(force bool) (*types.Block, types.Receipts, *state.StateDB)
10-
11-
EnqueueSequencerTx(tx *types.Transaction) error
7+
type TransactionPublisher interface {
8+
PublishTransaction(tx *types.Transaction) error
129
}

arbitrum/backend.go

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
type Backend struct {
16-
arbos ArbosWrapper
16+
publisher TransactionPublisher
1717
blockChain *core.BlockChain
1818
stack *node.Node
1919
chainId *big.Int
@@ -29,9 +29,9 @@ type Backend struct {
2929
chanNewBlock chan struct{} //create new L2 block unless empty
3030
}
3131

32-
func NewBackend(stack *node.Node, config *ethconfig.Config, ethDatabase ethdb.Database, blockChain *core.BlockChain, chainId *big.Int, arbos ArbosWrapper) (*Backend, error) {
32+
func NewBackend(stack *node.Node, config *ethconfig.Config, ethDatabase ethdb.Database, blockChain *core.BlockChain, chainId *big.Int, publisher TransactionPublisher) (*Backend, error) {
3333
backend := &Backend{
34-
arbos: arbos,
34+
publisher: publisher,
3535
blockChain: blockChain,
3636
stack: stack,
3737
chainId: chainId,
@@ -42,7 +42,6 @@ func NewBackend(stack *node.Node, config *ethconfig.Config, ethDatabase ethdb.Da
4242
chanNewBlock: make(chan struct{}, 1),
4343
}
4444
stack.RegisterLifecycle(backend)
45-
go backend.segmentQueueRoutine()
4645

4746
createRegisterAPIBackend(backend)
4847
return backend, nil
@@ -53,12 +52,7 @@ func (b *Backend) APIBackend() *APIBackend {
5352
}
5453

5554
func (b *Backend) EnqueueL2Message(tx *types.Transaction) error {
56-
b.chanTxs <- tx
57-
return nil
58-
}
59-
60-
func (b *Backend) CloseBlock() {
61-
b.chanNewBlock <- struct{}{}
55+
return b.publisher.PublishTransaction(tx)
6256
}
6357

6458
func (b *Backend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription {
@@ -76,20 +70,6 @@ func (b *Backend) enqueueBlock(block *types.Block, reciepts types.Receipts, stat
7670
b.blockChain.WriteBlockWithState(block, reciepts, logs, state, true)
7771
}
7872

79-
func (b *Backend) segmentQueueRoutine() {
80-
for {
81-
select {
82-
case tx := <-b.chanTxs:
83-
b.txFeed.Send(core.NewTxsEvent{Txs: []*types.Transaction{tx}})
84-
b.arbos.EnqueueSequencerTx(tx)
85-
case <-b.chanNewBlock:
86-
b.enqueueBlock(b.arbos.BuildBlock(true))
87-
case <-b.chanClose:
88-
return
89-
}
90-
}
91-
}
92-
9373
//TODO: this is used when registering backend as lifecycle in stack
9474
func (b *Backend) Start() error {
9575
return nil

0 commit comments

Comments
 (0)