diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index b5271b4b4..c9d1a26d5 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -1123,7 +1123,7 @@ func (bc *Blockchain) isHardforkEnabled(hf *config.Hardfork, blockHeight uint32) hfs := bc.config.Hardforks if hf != nil { start, ok := hfs[hf.String()] - if !ok || start < blockHeight { + if !ok || start > blockHeight { return false } } diff --git a/pkg/core/interop/context.go b/pkg/core/interop/context.go index ddfeb11e9..c72adbeff 100644 --- a/pkg/core/interop/context.go +++ b/pkg/core/interop/context.go @@ -256,10 +256,10 @@ func (c *ContractMD) HFSpecificContractMD(hf *config.Hardfork) *HFSpecificContra } md, ok := c.mdCache[key] if !ok { - panic(fmt.Errorf("native contract descriptor cache is not initialized: contract %s, hardfork %s", c.Hash.StringLE(), key)) + panic(fmt.Errorf("native contract descriptor cache is not initialized: contract %s, hardfork %s", c.Name, key)) } if md == nil { - panic(fmt.Errorf("native contract descriptor cache is nil: contract %s, hardfork %s", c.Hash.StringLE(), key)) + panic(fmt.Errorf("native contract descriptor cache is nil: contract %s, hardfork %s", c.Name, key)) } return md } diff --git a/pkg/core/native/management.go b/pkg/core/native/management.go index 54640a866..0bd36c138 100644 --- a/pkg/core/native/management.go +++ b/pkg/core/native/management.go @@ -619,8 +619,6 @@ func (m *Management) OnPersist(ic *interop.Context) error { for _, hf := range config.Hardforks { if _, ok := activeHFs[hf]; ok && ic.IsHardforkActivation(hf) { isUpdate = true - activation := hf // avoid loop variable pointer exporting. - activeIn = &activation // reuse ActiveIn variable for the initialization hardfork. // Break immediately since native Initialize should be called starting from the first hardfork in a raw // (if there are multiple hardforks with the same enabling height). break @@ -635,6 +633,10 @@ func (m *Management) OnPersist(ic *interop.Context) error { currentActiveHFs = append(currentActiveHFs, hf) } } + // activeIn is not included into the activeHFs list. + if activeIn != nil && activeIn.Cmp(latestHF) > 0 { + latestHF = *activeIn + } if !(isDeploy || isUpdate) { continue } @@ -677,7 +679,7 @@ func (m *Management) OnPersist(ic *interop.Context) error { // The rest of activating hardforks also require initialization. for _, hf := range currentActiveHFs { if err := native.Initialize(ic, &hf, hfSpecificMD); err != nil { - return fmt.Errorf("initializing %s native contract at HF %d: %w", md.Name, activeIn, err) + return fmt.Errorf("initializing %s native contract at HF %s: %w", md.Name, hf, err) } }