Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 9b315a1

Browse files
authored
Add mined l1blocknumber to MonitoredTxResult. Undo forkid10 and forkid11 changes (#3734) (#3758)
1 parent 07c3182 commit 9b315a1

File tree

3 files changed

+13
-24
lines changed

3 files changed

+13
-24
lines changed

ethtxmanager/ethtxmanager.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,10 @@ func (c *Client) buildResult(ctx context.Context, mTx monitoredTx) (MonitoredTxR
213213
}
214214

215215
result := MonitoredTxResult{
216-
ID: mTx.id,
217-
Status: mTx.status,
218-
Txs: txs,
216+
ID: mTx.id,
217+
Status: mTx.status,
218+
BlockNumber: mTx.blockNumber,
219+
Txs: txs,
219220
}
220221

221222
return result, nil

ethtxmanager/monitoredtx.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,10 @@ func (mTx *monitoredTx) blockNumberU64Ptr() *uint64 {
182182

183183
// MonitoredTxResult represents the result of a execution of a monitored tx
184184
type MonitoredTxResult struct {
185-
ID string
186-
Status MonitoredTxStatus
187-
Txs map[common.Hash]TxResult
185+
ID string
186+
Status MonitoredTxStatus
187+
BlockNumber *big.Int
188+
Txs map[common.Hash]TxResult
188189
}
189190

190191
// TxResult represents the result of a execution of a ethereum transaction in the block chain

sequencesender/sequencesender.go

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/0xPolygonHermez/zkevm-node/event"
1313
"github.com/0xPolygonHermez/zkevm-node/log"
1414
"github.com/0xPolygonHermez/zkevm-node/state"
15-
"github.com/ethereum/go-ethereum/common"
1615
ethTypes "github.com/ethereum/go-ethereum/core/types"
1716
"github.com/jackc/pgx/v4"
1817
)
@@ -97,33 +96,21 @@ func (s *SequenceSender) tryToSendSequence(ctx context.Context) {
9796
s.ethTxManager.ProcessPendingMonitoredTxs(ctx, ethTxManagerOwner, func(result ethtxmanager.MonitoredTxResult, dbTx pgx.Tx) {
9897
if result.Status == ethtxmanager.MonitoredTxStatusConfirmed {
9998
if len(result.Txs) > 0 {
100-
var txL1BlockNumber uint64
101-
var txHash common.Hash
102-
receiptFound := false
103-
for _, tx := range result.Txs {
104-
if tx.Receipt != nil {
105-
txL1BlockNumber = tx.Receipt.BlockNumber.Uint64()
106-
txHash = tx.Tx.Hash()
107-
receiptFound = true
108-
break
109-
}
110-
}
111-
112-
if !receiptFound {
113-
s.halt(ctx, fmt.Errorf("monitored tx %s for sequence [%d-%d] is confirmed but doesn't have a receipt", result.ID, s.lastSequenceInitialBatch, s.lastSequenceEndBatch))
99+
if result.BlockNumber == nil {
100+
s.halt(ctx, fmt.Errorf("monitored tx %s for sequence [%d-%d] is confirmed but doesn't have L1 block number where tx was mined", result.ID, s.lastSequenceInitialBatch, s.lastSequenceEndBatch))
114101
}
115102

116103
// wait L1 confirmation blocks
117-
log.Infof("waiting %d L1 block confirmations for sequence [%d-%d], L1 block: %d, tx: %s",
118-
s.cfg.SequenceL1BlockConfirmations, s.lastSequenceInitialBatch, s.lastSequenceEndBatch, txL1BlockNumber, txHash)
104+
log.Infof("waiting %d L1 block confirmations for sequence [%d-%d], L1 block: %d",
105+
s.cfg.SequenceL1BlockConfirmations, s.lastSequenceInitialBatch, s.lastSequenceEndBatch, result.BlockNumber)
119106
for {
120107
lastL1BlockHeader, err := s.etherman.GetLatestBlockHeader(ctx)
121108
if err != nil {
122109
log.Errorf("failed to get last L1 block number, err: %v", err)
123110
} else {
124111
lastL1BlockNumber := lastL1BlockHeader.Number.Uint64()
125112

126-
if lastL1BlockNumber >= txL1BlockNumber+s.cfg.SequenceL1BlockConfirmations {
113+
if lastL1BlockNumber >= result.BlockNumber.Uint64()+s.cfg.SequenceL1BlockConfirmations {
127114
log.Infof("continuing, last L1 block: %d", lastL1BlockNumber)
128115
break
129116
}

0 commit comments

Comments
 (0)