Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jieyilong committed Mar 21, 2023
1 parent 3bf17c9 commit 7a9432a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ledger/execution/tx_validator_set_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,17 @@ func (exec *SubchainValidatorSetUpdateTxExecutor) process(chainID string, view *
return common.Hash{}, result.Error(fmt.Sprintf("new dynasty needs to be strictly larger than the current dynasty (new: %v, current: %v)", newDynasty, currentDynasty))
}

if currentDynasty.Cmp(common.Big0) == 0 {
// special handling: currentDynasty is 0 means the node just loaded the genesis snapshot, we should trust the initial ValidatorSet specified by the snapshot
registrationMainchainHeight, err := exec.metachainWitness.GetSubchainRegistrationHeight()
if err != nil {
logger.Warnf("Failed to get subchain registration height: %v", err)
return common.Hash{}, result.UndecidedWith(result.Info{"newDynasty": newDynasty, "err": err})
}
registrationDynasty := scom.CalculateDynasty(registrationMainchainHeight)

if currentDynasty.Cmp(common.Big0) == 0 && newDynasty.Cmp(registrationDynasty) == 0 {
// special handling: currentDynasty == 0 and newDynasty == registrationDynasty means the node just loaded the genesis snapshot,
// and the only purpose of the validatorSetUpdateTx is to update the dynasty in the StoreView. In this case,
// We should trust the initial ValidatorSet specified by the snapshot
validatorSetSpecifiedInTheSnapshot := view.GetValidatorSet()

logger.Debugf("currentDynasty: %v", currentDynasty)
Expand Down

0 comments on commit 7a9432a

Please sign in to comment.