diff --git a/core/validator.go b/core/validator.go index 7b17b34..28ec27f 100644 --- a/core/validator.go +++ b/core/validator.go @@ -40,6 +40,7 @@ func (v Validator) ID() common.Address { // Equals checks whether the validator is the same as another validator func (v Validator) Equals(x Validator) bool { + logger.Debugf("v.Equals(x) check, v.Addr: %v, x.Addr: %v, v.Stake: %v, x.Stake: %v\n", v.Address.Hex(), x.Address.Hex(), v.Stake, x.Stake) if v.Address != x.Address { return false } diff --git a/interchain/witness/metachain_witness.go b/interchain/witness/metachain_witness.go index 16e533b..82f826f 100644 --- a/interchain/witness/metachain_witness.go +++ b/interchain/witness/metachain_witness.go @@ -570,9 +570,10 @@ func (mw *MetachainWitness) updateValidatorSetCache(dynasty *big.Int) (*score.Va mw.cacheMutex.Lock() defer mw.cacheMutex.Unlock() - queryBlockHeight := big.NewInt(1).Mul(dynasty, big.NewInt(1).SetInt64(scom.NumMainchainBlocksPerDynasty)) - queryBlockHeight = big.NewInt(0).Add(queryBlockHeight, big.NewInt(1)) // increment by one to make sure the query block height falls into the dynasty - vs, err := mw.chainRegistrarOnMainchain.GetValidatorSet(nil, mw.subchainID, queryBlockHeight) + // queryBlockHeight := big.NewInt(1).Mul(dynasty, big.NewInt(1).SetInt64(scom.NumMainchainBlocksPerDynasty)) + // queryBlockHeight = big.NewInt(0).Add(queryBlockHeight, big.NewInt(1)) // increment by one to make sure the query block height falls into the dynasty + // vs, err := mw.chainRegistrarOnMainchain.GetValidatorSet(nil, mw.subchainID, queryBlockHeight) + vs, err := mw.chainRegistrarOnMainchain.GetValidatorSet(nil, mw.subchainID, dynasty) validatorAddrs := vs.Validators validatorStakes := vs.ShareAmounts @@ -592,6 +593,8 @@ func (mw *MetachainWitness) updateValidatorSetCache(dynasty *big.Int) (*score.Va mw.validatorSetCache[dynasty.String()] = validatorSet + logger.Debugf("updateValidatorSetCache, dynasty = %v, validatorSet = %v", dynasty.String(), validatorSet.String()) + return validatorSet, nil } diff --git a/ledger/execution/tx_validator_set_update.go b/ledger/execution/tx_validator_set_update.go index 00ca6cc..6e4c765 100644 --- a/ledger/execution/tx_validator_set_update.go +++ b/ledger/execution/tx_validator_set_update.go @@ -114,6 +114,10 @@ func (exec *SubchainValidatorSetUpdateTxExecutor) process(chainID string, view * return common.Hash{}, result.UndecidedWith(result.Info{"newDynasty": newDynasty, "err": err}) } + logger.Debugf("newDynasty: %v", newDynasty) + logger.Debugf("newValidatorSet : %v", newValidatorSet.String()) + logger.Debugf("witnessedValidatorSet: %v", witnessedValidatorSet.String()) + if !newValidatorSet.Equals(witnessedValidatorSet) { return common.Hash{}, result.Error("validator set mismatch: %v vs %v", *newValidatorSet, *witnessedValidatorSet) }