fix(bridge): compatible with DynamicFeeTxType not supported chain (#280)

Co-authored-by: colinlyguo <colinlyguo@gmail.com>
This commit is contained in:
colin
2023-02-06 13:47:34 +08:00
committed by GitHub
parent e48e76acdf
commit 33a912e7c1
5 changed files with 22 additions and 7 deletions

View File

@@ -15,7 +15,7 @@
"escalate_multiple_num": 11,
"escalate_multiple_den": 10,
"max_gas_price": 10000000000,
"tx_type": "AccessListTx",
"tx_type": "LegacyTx",
"min_balance": 100000000000000000000
},
"message_sender_private_keys": [
@@ -38,7 +38,7 @@
"escalate_multiple_num": 11,
"escalate_multiple_den": 10,
"max_gas_price": 10000000000,
"tx_type": "DynamicFeeTx",
"tx_type": "LegacyTx",
"min_balance": 100000000000000000000
},
"message_sender_private_keys": [

View File

@@ -120,6 +120,15 @@ func NewSender(ctx context.Context, config *config.SenderConfig, privs []*ecdsa.
return nil, err
}
var baseFeePerGas uint64
if config.TxType == DynamicFeeTxType {
if header.BaseFee != nil {
baseFeePerGas = header.BaseFee.Uint64()
} else {
return nil, errors.New("DynamicFeeTxType not supported, header.BaseFee nil")
}
}
sender := &Sender{
ctx: ctx,
config: config,
@@ -128,7 +137,7 @@ func NewSender(ctx context.Context, config *config.SenderConfig, privs []*ecdsa.
auths: auths,
confirmCh: make(chan *Confirmation, 128),
blockNumber: header.Number.Uint64(),
baseFeePerGas: header.BaseFee.Uint64(),
baseFeePerGas: baseFeePerGas,
pendingTxs: sync.Map{},
stopCh: make(chan struct{}),
}
@@ -356,7 +365,13 @@ func (s *Sender) resubmitTransaction(feeData *FeeData, auth *bind.TransactOpts,
func (s *Sender) CheckPendingTransaction(header *types.Header) {
number := header.Number.Uint64()
atomic.StoreUint64(&s.blockNumber, number)
atomic.StoreUint64(&s.baseFeePerGas, header.BaseFee.Uint64())
if s.config.TxType == DynamicFeeTxType {
if header.BaseFee != nil {
atomic.StoreUint64(&s.baseFeePerGas, header.BaseFee.Uint64())
} else {
log.Error("DynamicFeeTxType not supported, header.BaseFee nil")
}
}
s.pendingTxs.Range(func(key, value interface{}) bool {
// ignore empty id, since we use empty id to occupy pending task
if value == nil || reflect.ValueOf(value).IsNil() {

View File

@@ -1,4 +1,4 @@
FROM scrolltech/l2geth:prealpha-v4.2
FROM scrolltech/l2geth:prealpha-v5.1
RUN mkdir -p /l2geth/keystore

View File

@@ -5,7 +5,7 @@ import (
"runtime/debug"
)
var tag = "prealpha-v11.18"
var tag = "prealpha-v11.19"
var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {

View File

@@ -122,7 +122,7 @@ func runSender(t *testing.T, endpoint string) *sender.Sender {
Confirmations: 0,
EscalateMultipleNum: 11,
EscalateMultipleDen: 10,
TxType: "DynamicFeeTx",
TxType: "LegacyTx",
}, []*ecdsa.PrivateKey{priv})
assert.NoError(t, err)
return newSender