From ae6edf0601537d9d00df08026901c4ff4d908207 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 4 Mar 2020 13:27:22 +0300 Subject: [PATCH] core: add a check for fractional gas in invocation TXes It's not allowed in C# code and that's reasonable as it's a sysfee essentially that can only be integer. --- pkg/core/blockchain.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 160e51db2..4a1fdbc0c 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -1283,7 +1283,8 @@ func (bc *Blockchain) verifyTx(t *transaction.Transaction, block *block.Block) e } } - if t.Type == transaction.ClaimType { + switch t.Type { + case transaction.ClaimType: claim := t.Data.(*transaction.ClaimTX) if transaction.HaveDuplicateInputs(claim.Claims) { return errors.New("duplicate claims") @@ -1294,6 +1295,11 @@ func (bc *Blockchain) verifyTx(t *transaction.Transaction, block *block.Block) e if err := bc.verifyClaims(t); err != nil { return err } + case transaction.InvocationType: + inv := t.Data.(*transaction.InvocationTX) + if inv.Gas.FractionalValue() != 0 { + return errors.New("invocation gas can only be integer") + } } return bc.verifyTxWitnesses(t, block)