[NOD-1259] Do not panic on non-protocol errors from RPC (#863)

* [NOD-1259] All rule-errors should be protocol-errors

* [NOD-1259] Handle submitting of coinbase transactions properly

* Revert "[NOD-1259] All rule-errors should be protocol-errors"

This reverts commit 2fd30c185640fcee62030f72ed14654570a1d7c7.

* [NOD-1259] Don't panic on non-protocol errors in ProtocolManager.AddTransaction/AddBlock

* [NOD-1259] Implement subnetworkid.IsBuiltInOrNative and use where appropriate
This commit is contained in:
Svarog 2020-08-12 12:29:58 +03:00 committed by Ori Newman
parent 32c5cfeaf5
commit 48d498e820
2 changed files with 2149 additions and 7 deletions

2143
blockdag/dag.go Normal file

File diff suppressed because it is too large Load Diff

View File

@ -7,14 +7,16 @@ package blockdag
import (
"fmt"
"github.com/kaspanet/go-secp256k1"
"github.com/kaspanet/kaspad/util/mstime"
"github.com/pkg/errors"
"math"
"sort"
"github.com/kaspanet/kaspad/domain/dagconfig"
"github.com/kaspanet/kaspad/domain/txscript"
"github.com/kaspanet/kaspad/network/domainmessage"
"github.com/kaspanet/kaspad/util/mstime"
"github.com/pkg/errors"
"github.com/kaspanet/kaspad/domainmessage"
"github.com/kaspanet/kaspad/util"
"github.com/kaspanet/kaspad/util/daghash"
"github.com/kaspanet/kaspad/util/subnetworkid"
@ -265,10 +267,7 @@ func checkTransactionPayloadHash(tx *util.Tx) error {
func checkGasInBuiltInOrNativeTransactions(tx *util.Tx) error {
// Transactions in native, registry and coinbase subnetworks must have Gas = 0
msgTx := tx.MsgTx()
if (msgTx.SubnetworkID.IsEqual(subnetworkid.SubnetworkIDNative) ||
msgTx.SubnetworkID.IsBuiltIn()) &&
msgTx.Gas > 0 {
if msgTx.SubnetworkID.IsBuiltInOrNative() && msgTx.Gas > 0 {
return ruleError(ErrInvalidGas, "transaction in the native or "+
"registry subnetworks has gas > 0 ")
}