Merge pull request #2001 from rlan35/staking_pangaea

Fix shard state epoch number after staking
pull/2007/head
Rongjian Lan 5 years ago committed by GitHub
commit c79e8a8687
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      core/blockchain.go
  2. 3
      internal/utils/utils.go

@ -1159,6 +1159,12 @@ func (bc *BlockChain) WriteBlockWithState(
if len(header.ShardState()) > 0 {
// Write shard state for the new epoch
epoch := new(big.Int).Add(header.Epoch(), common.Big1)
shardState, err := block.Header().GetShardState()
if err == nil && shardState.Epoch != nil && bc.chainConfig.IsStaking(shardState.Epoch) {
// After staking, the epoch will be decided by the epoch in the shard state.
epoch = new(big.Int).Set(shardState.Epoch)
}
newShardState, err := bc.WriteShardStateBytes(batch, epoch, header.ShardState())
if err != nil {
header.Logger(utils.Logger()).Warn().Err(err).Msg("cannot store shard state")

@ -95,8 +95,9 @@ func GetAddressFromBlsPubKeyBytes(pubKeyBytes []byte) common.Address {
if err == nil {
addrBytes := pubKey.GetAddress()
addr.SetBytes(addrBytes[:])
} else {
Logger().Err(err).Msg("Failed to get address of bls key")
}
Logger().Err(err).Msg("Failed to get address of bls key")
return addr
}

Loading…
Cancel
Save