Skip to content

Commit 33a912e

Browse files
authored
fix(bridge): compatible with DynamicFeeTxType not supported chain (#280)
Co-authored-by: colinlyguo <[email protected]>
1 parent e48e76a commit 33a912e

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

bridge/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"escalate_multiple_num": 11,
1616
"escalate_multiple_den": 10,
1717
"max_gas_price": 10000000000,
18-
"tx_type": "AccessListTx",
18+
"tx_type": "LegacyTx",
1919
"min_balance": 100000000000000000000
2020
},
2121
"message_sender_private_keys": [
@@ -38,7 +38,7 @@
3838
"escalate_multiple_num": 11,
3939
"escalate_multiple_den": 10,
4040
"max_gas_price": 10000000000,
41-
"tx_type": "DynamicFeeTx",
41+
"tx_type": "LegacyTx",
4242
"min_balance": 100000000000000000000
4343
},
4444
"message_sender_private_keys": [

bridge/sender/sender.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ func NewSender(ctx context.Context, config *config.SenderConfig, privs []*ecdsa.
120120
return nil, err
121121
}
122122

123+
var baseFeePerGas uint64
124+
if config.TxType == DynamicFeeTxType {
125+
if header.BaseFee != nil {
126+
baseFeePerGas = header.BaseFee.Uint64()
127+
} else {
128+
return nil, errors.New("DynamicFeeTxType not supported, header.BaseFee nil")
129+
}
130+
}
131+
123132
sender := &Sender{
124133
ctx: ctx,
125134
config: config,
@@ -128,7 +137,7 @@ func NewSender(ctx context.Context, config *config.SenderConfig, privs []*ecdsa.
128137
auths: auths,
129138
confirmCh: make(chan *Confirmation, 128),
130139
blockNumber: header.Number.Uint64(),
131-
baseFeePerGas: header.BaseFee.Uint64(),
140+
baseFeePerGas: baseFeePerGas,
132141
pendingTxs: sync.Map{},
133142
stopCh: make(chan struct{}),
134143
}
@@ -356,7 +365,13 @@ func (s *Sender) resubmitTransaction(feeData *FeeData, auth *bind.TransactOpts,
356365
func (s *Sender) CheckPendingTransaction(header *types.Header) {
357366
number := header.Number.Uint64()
358367
atomic.StoreUint64(&s.blockNumber, number)
359-
atomic.StoreUint64(&s.baseFeePerGas, header.BaseFee.Uint64())
368+
if s.config.TxType == DynamicFeeTxType {
369+
if header.BaseFee != nil {
370+
atomic.StoreUint64(&s.baseFeePerGas, header.BaseFee.Uint64())
371+
} else {
372+
log.Error("DynamicFeeTxType not supported, header.BaseFee nil")
373+
}
374+
}
360375
s.pendingTxs.Range(func(key, value interface{}) bool {
361376
// ignore empty id, since we use empty id to occupy pending task
362377
if value == nil || reflect.ValueOf(value).IsNil() {

common/docker/l2geth/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM scrolltech/l2geth:prealpha-v4.2
1+
FROM scrolltech/l2geth:prealpha-v5.1
22

33
RUN mkdir -p /l2geth/keystore
44

common/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"runtime/debug"
66
)
77

8-
var tag = "prealpha-v11.18"
8+
var tag = "prealpha-v11.19"
99

1010
var commit = func() string {
1111
if info, ok := debug.ReadBuildInfo(); ok {

tests/integration-test/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func runSender(t *testing.T, endpoint string) *sender.Sender {
122122
Confirmations: 0,
123123
EscalateMultipleNum: 11,
124124
EscalateMultipleDen: 10,
125-
TxType: "DynamicFeeTx",
125+
TxType: "LegacyTx",
126126
}, []*ecdsa.PrivateKey{priv})
127127
assert.NoError(t, err)
128128
return newSender

0 commit comments

Comments
 (0)