在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
版权属于:区块链中文技术社区 / 转载原创者
本文链接:https://bcskill.com/index.php/archives/2006.html
相关技术文章仅限于相关区块链底层技术研究,禁止用于非法用途,后果自负!本站严格遵守一切相关法律政策!