error getting sequences: error no leaves on L1InfoTree yet and GetInitL1InfoRootMap
错误
启动sequence-sender时报以下错误
2024-11-15T11:11:46.117Z ERROR sequencesender/sequencesender.go:312 error getting sequences: error no leaves on L1InfoTree yet and GetInitL1InfoRootMap fails: %!w(<nil>) {"pid": 39, "version": "v0.4.0-beta5", "module": "sequence-sender"}
github.com/0xPolygon/cdk/sequencesender.(*SequenceSender).tryToSendSequence
/go/src/github.com/0xPolygon/cdk/sequencesender/sequencesender.go:312
github.com/0xPolygon/cdk/sequencesender.(*SequenceSender).sequenceSending
/go/src/github.com/0xPolygon/cdk/sequencesender/sequencesender.go:243
相关代码
// Returns CounterL1InfoRoot to use for this batch
func (t *TxBuilderBananaBase) GetCounterL1InfoRoot(ctx context.Context, highestL1IndexInBatch uint32) (uint32, error) {
header, err := t.ethClient.HeaderByNumber(ctx, t.blockFinality)
if err != nil {
return 0, fmt.Errorf("error calling HeaderByNumber, with block finality %d: %w", t.blockFinality.Int64(), err)
}
var resL1InfoCounter uint32
info, err := t.l1InfoTree.GetLatestInfoUntilBlock(ctx, header.Number.Uint64())
if err == nil {
resL1InfoCounter = info.L1InfoTreeIndex + 1
}
if errors.Is(err, l1infotreesync.ErrNotFound) {
// There are no L1 Info tree leaves yet, so we can try to use L1InfoRootMap event
l1infotreeInitial, err := t.l1InfoTree.GetInitL1InfoRootMap(ctx)
if l1infotreeInitial == nil || err != nil {
return 0, fmt.Errorf("error no leaves on L1InfoTree yet and GetInitL1InfoRootMap fails: %w", err)
}
// We use this leaf as first one
resL1InfoCounter = l1infotreeInitial.LeafCount
} else if err != nil {
return 0, fmt.Errorf("error calling GetLatestInfoUntilBlock with block num %d: %w", header.Number.Uint64(), err)
}
分析
l1InfoTree.GetInitL1InfoRootMap 没有获取到数据
GetInitL1InfoRootMap 通过事件InitL1InfoRootMap
进行写入的
if event.InitL1InfoRootMap != nil {
log.Debugf("handle InitL1InfoRootMap event %s", event.InitL1InfoRootMap.String())
err = processEventInitL1InfoRootMap(tx, block.Num, event.InitL1InfoRootMap)
if err != nil {
err = fmt.Errorf("initL1InfoRootMap. Err: %w", err)
log.Errorf("error processing InitL1InfoRootMap: %v", err)
return err
}
}
对应合约PolygonZkEVMGlobalExitRootV2.sol->emit InitL1InfoRootMap
function initialize() external virtual initializer {
// Get the current historic root
bytes32 currentL1InfoRoot = getRoot();
// Store L1InfoRoot
l1InfoRootMap[uint32(depositCount)] = currentL1InfoRoot;
emit InitL1InfoRootMap(uint32(depositCount), currentL1InfoRoot);
}
继续排查,看链是否代码没有执行对应逻辑
l1infotreesync/processor.go
func (p *processor) ProcessBlock(ctx context.Context, block sync.Block) error {
...
if event.InitL1InfoRootMap != nil {
log.Debugf("handle InitL1InfoRootMap event %s", event.InitL1InfoRootMap.String())
err = processEventInitL1InfoRootMap(tx, block.Num, event.InitL1InfoRootMap)
if err != nil {
err = fmt.Errorf("initL1InfoRootMap. Err: %w", err)
log.Errorf("error processing InitL1InfoRootMap: %v", err)
return err
}
}
func (d *EVMDriver) handleNewBlock(ctx context.Context, b EVMBlock) {
...
err := d.processor.ProcessBlock(ctx, blockToProcess)
2024-11-16T01:17:02.244Z DEBUG sync/evmdriver.go:100 handleNewBlock blockNum: 7085616 blockHash: 0x72c30608c656bfd164e1e5836db12d6b36ad2f7ddbd5e26557ea18fcdce98d94 {"pid": 40, "version": "v0.4.0-beta5", "syncer": "l1infotreesync"}
2024-11-16T01:17:02.244Z INFO l1infotreesync/processor.go:343 block 7085616 processed with 0 events {"pid": 40, "version": "v0.4.0-beta5"}
执行逻辑中已经包含 event.InitL1InfoRootMap
继续排查
排查两个角度
- 合约中并未发出
- 区块高度有错误
由于事件是由合约PolygonZkEVMGlobalExitRootV2.sol发出,对应的合约地址为deploy_output.json->polygonZkEVMGlobalExitRootAddress
查看当前地址
https://sepolia.etherscan.io/tx/0xc3b16bdaa7054689230e976e20badcb65c92ad2a623ea89b1b33147a1fc0f227#eventlog
高度:7085224
合约event.InitL1InfoRootMap
已发出,排除问题1
继续看下配置的高度deploy_output.json->deploymentRollupManagerBlockNumber
https://sepolia.etherscan.io/tx/0x03f41442db2e20f2551436df6ec607be307c89e7b05fe32fc462fceb225ce24a
高度:7085226
问题汇总
当前高度没有包含PolygonZkEVMGlobalExitRootV2->initialize 高度,所以导致事件event.InitL1InfoRootMap
没有扫描到,从而导致GetInitL1InfoRootMap数据没有本地存储,最终导致sequence-sender报错
解决方式
查询deploy_output.json->polygonZkEVMGlobalExitRootAddress合约地址交易对应的高度,并更新到sequence-sender配置
L1InfoTreeSync->InitialBlock
https://sepolia.etherscan.io/address/0xEEc7988853B40B65FaBB3E9A3393E093D5710515
当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »