diff --git a/consensus/forks/meerevmfork.go b/consensus/forks/meerevmfork.go index 0b56a560..d4ae17fb 100644 --- a/consensus/forks/meerevmfork.go +++ b/consensus/forks/meerevmfork.go @@ -82,3 +82,10 @@ func IsMeerEVMUTXOHeight(mainHeight int64) bool { } return mainHeight >= MeerEVMUTXOUnlockMainHeight } + +func IsBeforeMeerEVMForkHeight(mainHeight int64) bool { + if params.ActiveNetParams.Net != protocol.MainNet { + return false + } + return mainHeight < MeerEVMForkMainHeight +} diff --git a/core/blockchain/api.go b/core/blockchain/api.go index a7ec25d7..e94fb3db 100644 --- a/core/blockchain/api.go +++ b/core/blockchain/api.go @@ -477,6 +477,8 @@ func (api *PublicBlockAPI) GetStateRoot(order int64, verbose *bool) (interface{} } else { if order > mainOrder { return nil, fmt.Errorf("Order is too big") + } else if order < 0 { + return nil, fmt.Errorf("Order is too small") } } vb := false diff --git a/core/blockchain/blockindex.go b/core/blockchain/blockindex.go index fc2fab7b..7dcc164d 100644 --- a/core/blockchain/blockindex.go +++ b/core/blockchain/blockindex.go @@ -198,11 +198,14 @@ func (b *BlockChain) GetMeerBlock(order uint) (interface{}, error) { } number := uint64(0) for i := uint(order); i > 0; i-- { - bh := b.bd.GetBlockHashByOrder(i) - if bh == nil { + ib := b.bd.GetBlockByOrder(i) + if ib == nil { return nil, fmt.Errorf("No meer block number:%d", i) } - num := b.VMService().GetBlockID(bh) + if forks.IsBeforeMeerEVMForkHeight(int64(ib.GetHeight())) { + break + } + num := b.VMService().GetBlockID(ib.GetHash()) if num != 0 { number = num break