Skip to content

Commit abf89e4

Browse files
author
Tural Devrishev
committed
vm: add dynamic opcode pricing
Close #4043. Signed-off-by: Tural Devrishev <tural@nspcc.ru>
1 parent 48a0ae4 commit abf89e4

11 files changed

Lines changed: 681 additions & 72 deletions

File tree

pkg/core/blockchain_neotest_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2497,7 +2497,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
24972497
notaryServiceFeePerKey + // fee for Notary attribute
24982498
vm.PicoGasToDatoshi(fee.Opcode(bc.GetBaseExecFee(), // Notary verification script
24992499
opcode.PUSHDATA1, opcode.RET, // invocation script
2500-
opcode.PUSH0, opcode.SYSCALL, opcode.RET)) + // Neo.Native.Call
2500+
opcode.PUSH0, opcode.SYSCALL, opcode.RET)/vm.OpcodePriceMultiplier) + // Neo.Native.Call
25012501
vm.PicoGasToDatoshi(nativeprices.NotaryVerificationPrice*bc.GetBaseExecFee()) // Notary witness verification price
25022502
tx.Scripts = []transaction.Witness{
25032503
{

pkg/core/fee/calculate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ func Calculate(base int64, script []byte) (int64, int) {
1919
)
2020
if scparser.IsSignatureContract(script) {
2121
size += 67 + io.GetVarSize(script)
22-
netFee += Opcode(base, opcode.PUSHDATA1, opcode.PUSHDATA1) + base*ECDSAVerifyPrice
22+
netFee += Opcode(base, opcode.PUSHDATA1, opcode.PUSHDATA1)/factor + base*ECDSAVerifyPrice
2323
} else if m, pubs, ok := scparser.ParseMultiSigContract(script); ok {
2424
n := len(pubs)
2525
sizeInv := 66 * m
2626
size += io.GetVarSize(sizeInv) + sizeInv + io.GetVarSize(script)
27-
netFee += calculateMultisig(base, m) + calculateMultisig(base, n)
27+
netFee += (calculateMultisig(base, m) + calculateMultisig(base, n)) / factor
2828
netFee += base * ECDSAVerifyPrice * int64(n)
2929
} /*else {
3030
// We can support more contract types in the future.

0 commit comments

Comments
 (0)