polygon cdk Aggregator使用SequencerPrivateKey的时机
在Aggregator中有如下配置,需要配置Sequencer的私钥
[Aggregator.SequencerPrivateKey]
Path = "/etc/cdk/sequencer.keystore"
Password = "password"
查看链代码
if !cfg.SyncModeOnlyEnabled && cfg.SettlementBackend == AggLayer {
aggLayerClient = agglayer.NewAggLayerClient(cfg.AggLayerURL)
sequencerPrivateKey, err = cdkcommon.NewKeyFromKeystore(cfg.SequencerPrivateKey)
if err != nil {
return nil, err
}
}
以下条件时被设置
- cfg.SyncModeOnlyEnabled == false
- cfg.SettlementBackend == AggLayer
查看SequencerPrivateKey使用逻辑
func (a *Aggregator) settleWithAggLayer(
ctx context.Context,
proof *state.Proof,
inputs ethmanTypes.FinalProofInputs) bool {
proofStrNo0x := strings.TrimPrefix(inputs.FinalProof.Proof, "0x")
proofBytes := common.Hex2Bytes(proofStrNo0x)
tx := agglayer.Tx{
LastVerifiedBatch: cdkTypes.ArgUint64(proof.BatchNumber - 1),
NewVerifiedBatch: cdkTypes.ArgUint64(proof.BatchNumberFinal),
ZKP: agglayer.ZKP{
NewStateRoot: common.BytesToHash(inputs.NewStateRoot),
NewLocalExitRoot: common.BytesToHash(inputs.NewLocalExitRoot),
Proof: cdkTypes.ArgBytes(proofBytes),
},
RollupID: a.etherman.GetRollupId(),
}
signedTx, err := tx.Sign(a.sequencerPrivateKey)
if err != nil {
a.logger.Errorf("failed to sign tx: %v", err)
a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof)
return false
}
switch a.cfg.SettlementBackend {
case AggLayer:
if success := a.settleWithAggLayer(ctx, proof, inputs); !success {
continue
}
default:
if success := a.settleDirect(ctx, proof, inputs); !success {
continue
}
}
SettlementBackend 配置选项
- agglayer
- l1 (默认)
总结
当使用agglayer结算时,才需要设置SequencerPrivateKey,所以独立部署时Aggregator不需要配置Aggregator.SequencerPrivateKey
当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »