mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-30 09:33:36 +00:00
core: calculate prices of Neo.Crypt.*
opcodes correctly
This commit is contained in:
parent
ce6bacd51a
commit
540ac23ca8
2 changed files with 10 additions and 3 deletions
|
@ -8,10 +8,14 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/crypto"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
)
|
||||
|
||||
// ECDSAVerifyPrice is a gas price of a single verification.
|
||||
const ECDSAVerifyPrice = 1000000
|
||||
|
||||
// ECDSAVerify checks ECDSA signature.
|
||||
func ECDSAVerify(ic *interop.Context, v *vm.VM) error {
|
||||
msg := getMessage(ic, v.Estack().Pop().Item())
|
||||
|
@ -35,6 +39,9 @@ func ECDSACheckMultisig(ic *interop.Context, v *vm.VM) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("wrong parameters: %s", err.Error())
|
||||
}
|
||||
if !v.AddGas(util.Fixed8(ECDSAVerifyPrice * len(pkeys))) {
|
||||
return errors.New("gas limit exceeded")
|
||||
}
|
||||
sigs, err := v.Estack().PopSigElements()
|
||||
if err != nil {
|
||||
return fmt.Errorf("wrong parameters: %s", err.Error())
|
||||
|
|
|
@ -138,9 +138,9 @@ var systemInterops = []interop.Function{
|
|||
}
|
||||
|
||||
var neoInterops = []interop.Function{
|
||||
{Name: "Neo.Crypto.ECDsaVerify", Func: crypto.ECDSAVerify, Price: 1},
|
||||
{Name: "Neo.Crypto.ECDsaCheckMultiSig", Func: crypto.ECDSACheckMultisig, Price: 1},
|
||||
{Name: "Neo.Crypto.SHA256", Func: crypto.Sha256, Price: 1},
|
||||
{Name: "Neo.Crypto.ECDsaVerify", Func: crypto.ECDSAVerify, Price: crypto.ECDSAVerifyPrice},
|
||||
{Name: "Neo.Crypto.ECDsaCheckMultiSig", Func: crypto.ECDSACheckMultisig, Price: 0},
|
||||
{Name: "Neo.Crypto.SHA256", Func: crypto.Sha256, Price: 1000000},
|
||||
{Name: "Neo.Native.Deploy", Func: native.Deploy, Price: 1,
|
||||
AllowedTriggers: trigger.Application, RequiredFlags: smartcontract.AllowModifyStates},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue