native: implement HF-based update
A part of #3213. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
83fdcc8568
commit
d62fad1268
19 changed files with 416 additions and 105 deletions
|
@ -32,17 +32,25 @@ func Call(ic *interop.Context) error {
|
|||
return fmt.Errorf("native contract %s (version %d) not found", curr.StringLE(), version)
|
||||
}
|
||||
var (
|
||||
meta = c.Metadata()
|
||||
activeIn = c.ActiveIn()
|
||||
genericMeta = c.Metadata()
|
||||
activeIn = c.ActiveIn()
|
||||
)
|
||||
if activeIn != nil {
|
||||
height, ok := ic.Hardforks[activeIn.String()]
|
||||
// Persisting block must not be taken into account, native contract can be called
|
||||
// only AFTER its initialization block persist, thus, can't use ic.IsHardforkEnabled.
|
||||
if !ok || ic.BlockHeight() < height {
|
||||
return fmt.Errorf("native contract %s is active after hardfork %s", meta.Name, activeIn.String())
|
||||
return fmt.Errorf("native contract %s is active after hardfork %s", genericMeta.Name, activeIn.String())
|
||||
}
|
||||
}
|
||||
var current config.Hardfork
|
||||
for _, hf := range config.Hardforks {
|
||||
if !ic.IsHardforkEnabled(hf) {
|
||||
break
|
||||
}
|
||||
current = hf
|
||||
}
|
||||
meta := genericMeta.HFSpecificContractMD(¤t)
|
||||
m, ok := meta.GetMethodByOffset(ic.VM.Context().IP())
|
||||
if !ok {
|
||||
return fmt.Errorf("method not found")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue