native: implement HF-based update

A part of #3213.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
Anna Shaleva 2024-03-27 20:48:14 +03:00
parent 83fdcc8568
commit d62fad1268
19 changed files with 416 additions and 105 deletions

View file

@ -106,7 +106,6 @@ func newDesignate(p2pSigExtensionsEnabled bool, initialNodeRoles map[noderoles.R
s := &Designate{ContractMD: *interop.NewContractMD(nativenames.Designation, designateContractID)}
s.p2pSigExtensionsEnabled = p2pSigExtensionsEnabled
s.initialNodeRoles = initialNodeRoles
defer s.UpdateHash()
desc := newDescriptor("getDesignatedByRole", smartcontract.ArrayType,
manifest.NewParameter("role", smartcontract.IntegerType),
@ -120,9 +119,11 @@ func newDesignate(p2pSigExtensionsEnabled bool, initialNodeRoles map[noderoles.R
md = newMethodAndPrice(s.designateAsRole, 1<<15, callflag.States|callflag.AllowNotify)
s.AddMethod(md, desc)
s.AddEvent(DesignationEventName,
eDesc := newEventDescriptor(DesignationEventName,
manifest.NewParameter("Role", smartcontract.IntegerType),
manifest.NewParameter("BlockIndex", smartcontract.IntegerType))
eMD := newEvent(eDesc)
s.AddEvent(eMD)
return s
}
@ -130,7 +131,11 @@ func newDesignate(p2pSigExtensionsEnabled bool, initialNodeRoles map[noderoles.R
// Initialize initializes Designation contract. It is called once at native Management's OnPersist
// at the genesis block, and we can't properly fill the cache at this point, as there are no roles
// data in the storage.
func (s *Designate) Initialize(ic *interop.Context) error {
func (s *Designate) Initialize(ic *interop.Context, hf *config.Hardfork) error {
if hf != s.ActiveIn() {
return nil
}
cache := &DesignationCache{}
ic.DAO.SetCache(s.ID, cache)