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

@ -105,7 +105,6 @@ func newPolicy(p2pSigExtensionsEnabled bool) *Policy {
ContractMD: *interop.NewContractMD(nativenames.Policy, policyContractID),
p2pSigExtensionsEnabled: p2pSigExtensionsEnabled,
}
defer p.UpdateHash()
desc := newDescriptor("getFeePerByte", smartcontract.IntegerType)
md := newMethodAndPrice(p.getFeePerByte, 1<<15, callflag.ReadStates)
@ -169,7 +168,11 @@ func (p *Policy) Metadata() *interop.ContractMD {
}
// Initialize initializes Policy native contract and implements the Contract interface.
func (p *Policy) Initialize(ic *interop.Context) error {
func (p *Policy) Initialize(ic *interop.Context, hf *config.Hardfork) error {
if hf != p.ActiveIn() {
return nil
}
setIntWithKey(p.ID, ic.DAO, feePerByteKey, defaultFeePerByte)
setIntWithKey(p.ID, ic.DAO, execFeeFactorKey, defaultExecFeeFactor)
setIntWithKey(p.ID, ic.DAO, storagePriceKey, DefaultStoragePrice)