mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-23 13:38:35 +00:00
core: adjust System.Runtime.CheckWitness interop
Part of #1055. It should have `AllowStates` flag. Also removed unreachable code: we can't have such situation when script container is not a transaction in the scope of `CheckWitness` method because: 1. Blocks have their own implementation of CheckWitness for internal usage (it's (bc *Blockchain) verifyHeaderWitnesses method). 2. For the outside calls of System.Runtime.CheckWitness interop (e.g. calls from smart-contract) script container is always a transaction.
This commit is contained in:
parent
c9ef7425ac
commit
8fed383523
2 changed files with 3 additions and 12 deletions
|
@ -19,17 +19,7 @@ func CheckHashedWitness(ic *interop.Context, hash util.Uint160) (bool, error) {
|
|||
return checkScope(ic.DAO, tx, ic.ScriptGetter, hash)
|
||||
}
|
||||
|
||||
// only for non-Transaction types (Block, etc.)
|
||||
hashes, err := ic.Chain.GetScriptHashesForVerifying(ic.Tx)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "failed to get script hashes")
|
||||
}
|
||||
for _, v := range hashes {
|
||||
if hash.Equals(v) {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
return false, errors.New("script container is not a transaction")
|
||||
}
|
||||
|
||||
func checkScope(d dao.DAO, tx *transaction.Transaction, v vm.ScriptHashGetter, hash util.Uint160) (bool, error) {
|
||||
|
|
|
@ -110,7 +110,8 @@ var systemInterops = []interop.Function{
|
|||
{Name: "System.Iterator.Values", Func: iterator.Values, Price: 400},
|
||||
{Name: "System.Json.Deserialize", Func: json.Deserialize, Price: 500000},
|
||||
{Name: "System.Json.Serialize", Func: json.Serialize, Price: 100000},
|
||||
{Name: "System.Runtime.CheckWitness", Func: runtime.CheckWitness, Price: 30000},
|
||||
{Name: "System.Runtime.CheckWitness", Func: runtime.CheckWitness, Price: 30000,
|
||||
RequiredFlags: smartcontract.AllowStates},
|
||||
{Name: "System.Runtime.GasLeft", Func: runtime.GasLeft, Price: 400},
|
||||
{Name: "System.Runtime.GetCallingScriptHash", Func: engineGetCallingScriptHash, Price: 400},
|
||||
{Name: "System.Runtime.GetEntryScriptHash", Func: engineGetEntryScriptHash, Price: 400},
|
||||
|
|
Loading…
Reference in a new issue