mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 13:41:37 +00:00
vm: fix caller's script hash returned from VM
Regular CALLs don't update it, only Contract.Call does. Fixes the following mismatch on preview2 testnet: file BlockStorage_100000/dump-block-49000.json: block 48644, changes number mismatch: 6 vs 4
This commit is contained in:
parent
d5c9449a43
commit
a77357227a
2 changed files with 6 additions and 1 deletions
|
@ -41,6 +41,9 @@ type Context struct {
|
|||
// Script hash of the prog.
|
||||
scriptHash util.Uint160
|
||||
|
||||
// Caller's contract script hash.
|
||||
callingScriptHash util.Uint160
|
||||
|
||||
// Call flags this context was created with.
|
||||
callFlag smartcontract.CallFlag
|
||||
}
|
||||
|
|
|
@ -276,9 +276,11 @@ func (v *VM) LoadScriptWithFlags(b []byte, f smartcontract.CallFlag) {
|
|||
// given script hash directly into the Context to avoid its recalculations. It's
|
||||
// up to user of this function to make sure the script and hash match each other.
|
||||
func (v *VM) LoadScriptWithHash(b []byte, hash util.Uint160, f smartcontract.CallFlag) {
|
||||
shash := v.GetCurrentScriptHash()
|
||||
v.LoadScriptWithFlags(b, f)
|
||||
ctx := v.Context()
|
||||
ctx.scriptHash = hash
|
||||
ctx.callingScriptHash = shash
|
||||
}
|
||||
|
||||
// Context returns the current executed context. Nil if there is no context,
|
||||
|
@ -1607,7 +1609,7 @@ func (v *VM) bytesToPublicKey(b []byte) *keys.PublicKey {
|
|||
|
||||
// GetCallingScriptHash implements ScriptHashGetter interface
|
||||
func (v *VM) GetCallingScriptHash() util.Uint160 {
|
||||
return v.getContextScriptHash(1)
|
||||
return v.Context().callingScriptHash
|
||||
}
|
||||
|
||||
// GetEntryScriptHash implements ScriptHashGetter interface
|
||||
|
|
Loading…
Reference in a new issue