mirror of
https://github.com/kaspanet/kaspad.git
synced 2026-02-22 11:39:15 +00:00
Compare commits
8 Commits
v0.6.1-dev
...
v0.6.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffe153efa7 | ||
|
|
91f4ed9825 | ||
|
|
aa9556aa59 | ||
|
|
91f0fe5740 | ||
|
|
b0fecc9f87 | ||
|
|
53cccd405f | ||
|
|
5b84184921 | ||
|
|
af1df425a2 |
@@ -168,6 +168,7 @@ func setupIndexes(cfg *config.Config) (blockdag.IndexManager, *indexers.Acceptan
|
||||
var acceptanceIndex *indexers.AcceptanceIndex
|
||||
if cfg.AcceptanceIndex {
|
||||
log.Info("acceptance index is enabled")
|
||||
acceptanceIndex = indexers.NewAcceptanceIndex()
|
||||
indexes = append(indexes, acceptanceIndex)
|
||||
}
|
||||
|
||||
|
||||
@@ -881,7 +881,7 @@ func (dag *BlockDAG) validateGasLimit(block *util.Block) error {
|
||||
|
||||
// In native and Built-In subnetworks all txs must have Gas = 0, and that was already validated in checkTransactionSanity
|
||||
// Therefore - no need to check them here.
|
||||
if msgTx.SubnetworkID.IsEqual(subnetworkid.SubnetworkIDNative) || msgTx.SubnetworkID.IsBuiltIn() {
|
||||
if msgTx.SubnetworkID.IsBuiltInOrNative() {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
// block given its bluest parent.
|
||||
func (dag *BlockDAG) requiredDifficulty(bluestParent *blockNode, newBlockTime mstime.Time) uint32 {
|
||||
// Genesis block.
|
||||
if bluestParent == nil || bluestParent.blueScore < dag.difficultyAdjustmentWindowSize+1 {
|
||||
if dag.Params.DisableDifficultyAdjustment || bluestParent == nil || bluestParent.blueScore < dag.difficultyAdjustmentWindowSize+1 {
|
||||
return dag.powMaxBits
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ func TestCalcWork(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDifficulty(t *testing.T) {
|
||||
params := dagconfig.SimnetParams
|
||||
params := dagconfig.MainnetParams
|
||||
params.K = 1
|
||||
params.DifficultyAdjustmentWindowSize = 264
|
||||
dag, teardownFunc, err := DAGSetup("TestDifficulty", true, Config{
|
||||
|
||||
@@ -6,11 +6,12 @@ package blockdag
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/kaspanet/kaspad/util/mstime"
|
||||
"math"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/kaspanet/kaspad/util/mstime"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/kaspanet/kaspad/dagconfig"
|
||||
@@ -212,10 +213,7 @@ func CheckTransactionSanity(tx *util.Tx, subnetworkID *subnetworkid.SubnetworkID
|
||||
}
|
||||
|
||||
// Transactions in native, registry and coinbase subnetworks must have Gas = 0
|
||||
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 ")
|
||||
}
|
||||
|
||||
@@ -178,6 +178,9 @@ type Params struct {
|
||||
|
||||
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
||||
EnableNonNativeSubnetworks bool
|
||||
|
||||
// DisableDifficultyAdjustment determine whether to use difficulty
|
||||
DisableDifficultyAdjustment bool
|
||||
}
|
||||
|
||||
// NormalizeRPCServerAddress returns addr with the current network default
|
||||
@@ -189,7 +192,7 @@ func (p *Params) NormalizeRPCServerAddress(addr string) (string, error) {
|
||||
// MainnetParams defines the network parameters for the main Kaspa network.
|
||||
var MainnetParams = Params{
|
||||
K: ghostdagK,
|
||||
Name: "mainnet",
|
||||
Name: "kaspa-mainnet",
|
||||
Net: domainmessage.Mainnet,
|
||||
RPCPort: "16110",
|
||||
DefaultPort: "16111",
|
||||
@@ -235,6 +238,8 @@ var MainnetParams = Params{
|
||||
|
||||
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
||||
EnableNonNativeSubnetworks: false,
|
||||
|
||||
DisableDifficultyAdjustment: false,
|
||||
}
|
||||
|
||||
// RegressionNetParams defines the network parameters for the regression test
|
||||
@@ -242,7 +247,7 @@ var MainnetParams = Params{
|
||||
// 3), this network is sometimes simply called "testnet".
|
||||
var RegressionNetParams = Params{
|
||||
K: ghostdagK,
|
||||
Name: "regtest",
|
||||
Name: "kaspa-regtest",
|
||||
Net: domainmessage.Regtest,
|
||||
RPCPort: "16210",
|
||||
DefaultPort: "16211",
|
||||
@@ -288,12 +293,14 @@ var RegressionNetParams = Params{
|
||||
|
||||
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
||||
EnableNonNativeSubnetworks: false,
|
||||
|
||||
DisableDifficultyAdjustment: false,
|
||||
}
|
||||
|
||||
// TestnetParams defines the network parameters for the test Kaspa network.
|
||||
var TestnetParams = Params{
|
||||
K: ghostdagK,
|
||||
Name: "testnet",
|
||||
Name: "kaspa-testnet",
|
||||
Net: domainmessage.Testnet,
|
||||
RPCPort: "16210",
|
||||
DefaultPort: "16211",
|
||||
@@ -339,6 +346,8 @@ var TestnetParams = Params{
|
||||
|
||||
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
||||
EnableNonNativeSubnetworks: false,
|
||||
|
||||
DisableDifficultyAdjustment: false,
|
||||
}
|
||||
|
||||
// SimnetParams defines the network parameters for the simulation test Kaspa
|
||||
@@ -350,7 +359,7 @@ var TestnetParams = Params{
|
||||
// just turn into another public testnet.
|
||||
var SimnetParams = Params{
|
||||
K: ghostdagK,
|
||||
Name: "simnet",
|
||||
Name: "kaspa-simnet",
|
||||
Net: domainmessage.Simnet,
|
||||
RPCPort: "16510",
|
||||
DefaultPort: "16511",
|
||||
@@ -394,12 +403,14 @@ var SimnetParams = Params{
|
||||
|
||||
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
||||
EnableNonNativeSubnetworks: false,
|
||||
|
||||
DisableDifficultyAdjustment: true,
|
||||
}
|
||||
|
||||
// DevnetParams defines the network parameters for the development Kaspa network.
|
||||
var DevnetParams = Params{
|
||||
K: ghostdagK,
|
||||
Name: "devnet",
|
||||
Name: "kaspa-devnet",
|
||||
Net: domainmessage.Devnet,
|
||||
RPCPort: "16610",
|
||||
DefaultPort: "16611",
|
||||
@@ -445,6 +456,8 @@ var DevnetParams = Params{
|
||||
|
||||
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
||||
EnableNonNativeSubnetworks: false,
|
||||
|
||||
DisableDifficultyAdjustment: false,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
24
domainmessage/base_message.go
Normal file
24
domainmessage/base_message.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package domainmessage
|
||||
|
||||
import "time"
|
||||
|
||||
type baseMessage struct {
|
||||
messageNumber uint64
|
||||
receivedAt time.Time
|
||||
}
|
||||
|
||||
func (b *baseMessage) MessageNumber() uint64 {
|
||||
return b.messageNumber
|
||||
}
|
||||
|
||||
func (b *baseMessage) SetMessageNumber(messageNumber uint64) {
|
||||
b.messageNumber = messageNumber
|
||||
}
|
||||
|
||||
func (b *baseMessage) ReceivedAt() time.Time {
|
||||
return b.receivedAt
|
||||
}
|
||||
|
||||
func (b *baseMessage) SetReceivedAt(receivedAt time.Time) {
|
||||
b.receivedAt = receivedAt
|
||||
}
|
||||
@@ -6,6 +6,7 @@ package domainmessage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// MaxMessagePayload is the maximum bytes a message can be regardless of other
|
||||
@@ -79,4 +80,8 @@ var MessageCommandToString = map[MessageCommand]string{
|
||||
// are used directly in the protocol encoded message.
|
||||
type Message interface {
|
||||
Command() MessageCommand
|
||||
MessageNumber() uint64
|
||||
SetMessageNumber(index uint64)
|
||||
ReceivedAt() time.Time
|
||||
SetReceivedAt(receivedAt time.Time)
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ const MaxAddressesPerMsg = 1000
|
||||
// Use the AddAddress function to build up the list of known addresses when
|
||||
// sending an Addresses message to another peer.
|
||||
type MsgAddresses struct {
|
||||
baseMessage
|
||||
IncludeAllSubnetworks bool
|
||||
SubnetworkID *subnetworkid.SubnetworkID
|
||||
AddrList []*NetAddress
|
||||
|
||||
@@ -42,6 +42,7 @@ type TxLoc struct {
|
||||
// block message. It is used to deliver block and transaction information in
|
||||
// response to a getdata message (MsgGetData) for a given block hash.
|
||||
type MsgBlock struct {
|
||||
baseMessage
|
||||
Header BlockHeader
|
||||
Transactions []*MsgTx
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ const MaxBlockLocatorsPerMsg = 500
|
||||
// locator message. It is used to find the blockLocator of a peer that is
|
||||
// syncing with you.
|
||||
type MsgBlockLocator struct {
|
||||
baseMessage
|
||||
BlockLocatorHashes []*daghash.Hash
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ package domainmessage
|
||||
// syncer sent all the requested blocks.
|
||||
//
|
||||
// This message has no payload.
|
||||
type MsgDoneIBDBlocks struct{}
|
||||
type MsgDoneIBDBlocks struct {
|
||||
baseMessage
|
||||
}
|
||||
|
||||
// Command returns the protocol command string for the message. This is part
|
||||
// of the Message interface implementation.
|
||||
|
||||
@@ -8,6 +8,7 @@ package domainmessage
|
||||
// ibdblock message. It is used to deliver block and transaction information in
|
||||
// response to a RequestIBDBlocks message (MsgRequestIBDBlocks).
|
||||
type MsgIBDBlock struct {
|
||||
baseMessage
|
||||
*MsgBlock
|
||||
}
|
||||
|
||||
@@ -26,5 +27,5 @@ func (msg *MsgIBDBlock) MaxPayloadLength(pver uint32) uint32 {
|
||||
// NewMsgIBDBlock returns a new kaspa ibdblock message that conforms to the
|
||||
// Message interface. See MsgIBDBlock for details.
|
||||
func NewMsgIBDBlock(msgBlock *MsgBlock) *MsgIBDBlock {
|
||||
return &MsgIBDBlock{msgBlock}
|
||||
return &MsgIBDBlock{MsgBlock: msgBlock}
|
||||
}
|
||||
|
||||
@@ -77,8 +77,8 @@ func TestIBDBlockEncoding(t *testing.T) {
|
||||
}{
|
||||
// Latest protocol version.
|
||||
{
|
||||
&MsgIBDBlock{&blockOne},
|
||||
&MsgIBDBlock{&blockOne},
|
||||
&MsgIBDBlock{MsgBlock: &blockOne},
|
||||
&MsgIBDBlock{MsgBlock: &blockOne},
|
||||
blockOneBytes,
|
||||
blockOneTxLocs,
|
||||
ProtocolVersion,
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
// block inventory message. It is used to notify the network about new block
|
||||
// by sending their hash, and let the receiving node decide if it needs it.
|
||||
type MsgInvRelayBlock struct {
|
||||
baseMessage
|
||||
Hash *daghash.Hash
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ const MaxInvPerTxInvMsg = MaxInvPerMsg
|
||||
// TxInv message. It is used to notify the network about new transactions
|
||||
// by sending their ID, and let the receiving node decide if it needs it.
|
||||
type MsgInvTransaction struct {
|
||||
baseMessage
|
||||
TxIDs []*daghash.TxID
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ package domainmessage
|
||||
// The payload for this message just consists of a nonce used for identifying
|
||||
// it later.
|
||||
type MsgPing struct {
|
||||
baseMessage
|
||||
// Unique value associated with message that is used to identify
|
||||
// specific ping message.
|
||||
Nonce uint64
|
||||
|
||||
@@ -10,6 +10,7 @@ package domainmessage
|
||||
//
|
||||
// This message was not added until protocol versions AFTER BIP0031Version.
|
||||
type MsgPong struct {
|
||||
baseMessage
|
||||
// Unique value associated with message that is used to identify
|
||||
// specific ping message.
|
||||
Nonce uint64
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
//
|
||||
// This message has no payload.
|
||||
type MsgRequestAddresses struct {
|
||||
baseMessage
|
||||
IncludeAllSubnetworks bool
|
||||
SubnetworkID *subnetworkid.SubnetworkID
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
// and low hash.
|
||||
// The locator is returned via a locator message (MsgBlockLocator).
|
||||
type MsgRequestBlockLocator struct {
|
||||
baseMessage
|
||||
HighHash *daghash.Hash
|
||||
LowHash *daghash.Hash
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
// RequestIBDBlocks message. It is used to request a list of blocks starting after the
|
||||
// low hash and until the high hash.
|
||||
type MsgRequestIBDBlocks struct {
|
||||
baseMessage
|
||||
LowHash *daghash.Hash
|
||||
HighHash *daghash.Hash
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ package domainmessage
|
||||
// more blocks.
|
||||
//
|
||||
// This message has no payload.
|
||||
type MsgRequestNextIBDBlocks struct{}
|
||||
type MsgRequestNextIBDBlocks struct {
|
||||
baseMessage
|
||||
}
|
||||
|
||||
// Command returns the protocol command string for the message. This is part
|
||||
// of the Message interface implementation.
|
||||
|
||||
@@ -12,6 +12,7 @@ const MsgRequestRelayBlocksHashes = MaxInvPerMsg
|
||||
// RequestRelayBlocks message. It is used to request blocks as part of the block
|
||||
// relay protocol.
|
||||
type MsgRequestRelayBlocks struct {
|
||||
baseMessage
|
||||
Hashes []*daghash.Hash
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ package domainmessage
|
||||
// RequestSelectedTip message. It is used to request the selected tip of another peer.
|
||||
//
|
||||
// This message has no payload.
|
||||
type MsgRequestSelectedTip struct{}
|
||||
type MsgRequestSelectedTip struct {
|
||||
baseMessage
|
||||
}
|
||||
|
||||
// Command returns the protocol command string for the message. This is part
|
||||
// of the Message interface implementation.
|
||||
|
||||
@@ -12,6 +12,7 @@ const MaxInvPerRequestTransactionsMsg = MaxInvPerMsg
|
||||
// RequestTransactions message. It is used to request transactions as part of the
|
||||
// transactions relay protocol.
|
||||
type MsgRequestTransactions struct {
|
||||
baseMessage
|
||||
IDs []*daghash.TxID
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
// selectedtip message. It is used to answer getseltip messages and tell
|
||||
// the asking peer what is the selected tip of this peer.
|
||||
type MsgSelectedTip struct {
|
||||
baseMessage
|
||||
// The selected tip hash of the generator of the message.
|
||||
SelectedTipHash *daghash.Hash
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
// MsgTransactionNotFound defines a kaspa TransactionNotFound message which is sent in response to
|
||||
// a RequestTransactions message if any of the requested data in not available on the peer.
|
||||
type MsgTransactionNotFound struct {
|
||||
baseMessage
|
||||
ID *daghash.TxID
|
||||
}
|
||||
|
||||
|
||||
@@ -268,6 +268,7 @@ func NewTxOut(value uint64, scriptPubKey []byte) *TxOut {
|
||||
// Use the AddTxIn and AddTxOut functions to build up the list of transaction
|
||||
// inputs and outputs.
|
||||
type MsgTx struct {
|
||||
baseMessage
|
||||
Version int32
|
||||
TxIn []*TxIn
|
||||
TxOut []*TxOut
|
||||
|
||||
@@ -9,7 +9,9 @@ package domainmessage
|
||||
// to negotiate parameters. It implements the Message interface.
|
||||
//
|
||||
// This message has no payload.
|
||||
type MsgVerAck struct{}
|
||||
type MsgVerAck struct {
|
||||
baseMessage
|
||||
}
|
||||
|
||||
// Command returns the protocol command string for the message. This is part
|
||||
// of the Message interface implementation.
|
||||
|
||||
@@ -31,9 +31,13 @@ var DefaultUserAgent = fmt.Sprintf("/kaspad:%s/", version.Version())
|
||||
// message (MsgVerAck). This exchange must take place before any further
|
||||
// communication is allowed to proceed.
|
||||
type MsgVersion struct {
|
||||
baseMessage
|
||||
// Version of the protocol the node is using.
|
||||
ProtocolVersion uint32
|
||||
|
||||
// The peer's network (mainnet, testnet, etc.)
|
||||
Network string
|
||||
|
||||
// Bitfield which identifies the enabled services.
|
||||
Services ServiceFlag
|
||||
|
||||
@@ -81,13 +85,14 @@ func (msg *MsgVersion) Command() MessageCommand {
|
||||
// NewMsgVersion returns a new kaspa version message that conforms to the
|
||||
// Message interface using the passed parameters and defaults for the remaining
|
||||
// fields.
|
||||
func NewMsgVersion(addr *NetAddress, id *id.ID,
|
||||
func NewMsgVersion(addr *NetAddress, id *id.ID, network string,
|
||||
selectedTipHash *daghash.Hash, subnetworkID *subnetworkid.SubnetworkID) *MsgVersion {
|
||||
|
||||
// Limit the timestamp to one millisecond precision since the protocol
|
||||
// doesn't support better.
|
||||
return &MsgVersion{
|
||||
ProtocolVersion: ProtocolVersion,
|
||||
Network: network,
|
||||
Services: 0,
|
||||
Timestamp: mstime.Now(),
|
||||
Address: addr,
|
||||
|
||||
@@ -6,7 +6,7 @@ package domainmessage
|
||||
|
||||
import (
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
id "github.com/kaspanet/kaspad/netadapter/id"
|
||||
"github.com/kaspanet/kaspad/netadapter/id"
|
||||
"github.com/kaspanet/kaspad/util/daghash"
|
||||
"net"
|
||||
"reflect"
|
||||
@@ -27,7 +27,7 @@ func TestVersion(t *testing.T) {
|
||||
}
|
||||
|
||||
// Ensure we get the correct data back out.
|
||||
msg := NewMsgVersion(me, generatedID, selectedTipHash, nil)
|
||||
msg := NewMsgVersion(me, generatedID, "mainnet", selectedTipHash, nil)
|
||||
if msg.ProtocolVersion != pver {
|
||||
t.Errorf("NewMsgVersion: wrong protocol version - got %v, want %v",
|
||||
msg.ProtocolVersion, pver)
|
||||
|
||||
3
go.mod
3
go.mod
@@ -7,7 +7,7 @@ require (
|
||||
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792
|
||||
github.com/btcsuite/winsvc v1.0.0
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
github.com/golang/protobuf v1.4.1
|
||||
github.com/golang/protobuf v1.4.2
|
||||
github.com/golang/snappy v0.0.1 // indirect
|
||||
github.com/jessevdk/go-flags v1.4.0
|
||||
github.com/jrick/logrotate v1.0.0
|
||||
@@ -19,6 +19,7 @@ require (
|
||||
golang.org/x/sys v0.0.0-20190426135247-a129542de9ae // indirect
|
||||
golang.org/x/text v0.3.2 // indirect
|
||||
google.golang.org/grpc v1.30.0
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v0.0.0-20200805213715-b2f0b7930d06 // indirect
|
||||
google.golang.org/protobuf v1.25.0
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
||||
gopkg.in/yaml.v2 v2.2.2 // indirect
|
||||
|
||||
6
go.sum
6
go.sum
@@ -30,6 +30,8 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
||||
@@ -116,12 +118,16 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE=
|
||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.0 h1:T7P4R73V3SSDPhH7WW7ATbfViLtmamH0DKrP3f9AuDI=
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v0.0.0-20200805213715-b2f0b7930d06 h1:WOtSnnKPfWsgy//E8PUhDnNAj3o/3YqA6IAEKaj913o=
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v0.0.0-20200805213715-b2f0b7930d06/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
|
||||
@@ -851,7 +851,7 @@ func (mp *TxPool) maybeAcceptTransaction(tx *util.Tx, rejectDupOrphans bool) ([]
|
||||
|
||||
// Check that transaction does not overuse GAS
|
||||
msgTx := tx.MsgTx()
|
||||
if !msgTx.SubnetworkID.IsEqual(subnetworkid.SubnetworkIDNative) && !msgTx.SubnetworkID.IsEqual(subnetworkid.SubnetworkIDRegistry) {
|
||||
if !msgTx.SubnetworkID.IsBuiltInOrNative() {
|
||||
gasLimit, err := mp.cfg.DAG.GasLimit(&msgTx.SubnetworkID)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
||||
@@ -156,7 +156,7 @@ func (g *BlkTmplGenerator) collectCandidatesTxs(sourceTxs []*TxDesc) []*candidat
|
||||
}
|
||||
|
||||
gasLimit := uint64(0)
|
||||
if !tx.MsgTx().SubnetworkID.IsEqual(subnetworkid.SubnetworkIDNative) && !tx.MsgTx().SubnetworkID.IsBuiltIn() {
|
||||
if !tx.MsgTx().SubnetworkID.IsBuiltInOrNative() {
|
||||
subnetworkID := tx.MsgTx().SubnetworkID
|
||||
gasLimit, err = g.dag.GasLimit(&subnetworkID)
|
||||
if err != nil {
|
||||
@@ -202,8 +202,7 @@ func (g *BlkTmplGenerator) calcTxValue(tx *util.Tx, fee uint64) (float64, error)
|
||||
massLimit := g.policy.BlockMaxMass
|
||||
|
||||
msgTx := tx.MsgTx()
|
||||
if msgTx.SubnetworkID.IsEqual(subnetworkid.SubnetworkIDNative) ||
|
||||
msgTx.SubnetworkID.IsBuiltIn() {
|
||||
if msgTx.SubnetworkID.IsBuiltInOrNative() {
|
||||
return float64(fee) / (float64(mass) / float64(massLimit)), nil
|
||||
}
|
||||
|
||||
@@ -266,7 +265,7 @@ func (g *BlkTmplGenerator) populateTemplateFromCandidates(candidateTxs []*candid
|
||||
|
||||
// Enforce maximum gas per subnetwork per block. Also check
|
||||
// for overflow.
|
||||
if !tx.MsgTx().SubnetworkID.IsEqual(subnetworkid.SubnetworkIDNative) && !tx.MsgTx().SubnetworkID.IsBuiltIn() {
|
||||
if !tx.MsgTx().SubnetworkID.IsBuiltInOrNative() {
|
||||
subnetworkID := tx.MsgTx().SubnetworkID
|
||||
gasUsage, ok := gasUsageMap[subnetworkID]
|
||||
if !ok {
|
||||
|
||||
@@ -2,6 +2,7 @@ package grpcserver
|
||||
|
||||
import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
routerpkg "github.com/kaspanet/kaspad/netadapter/router"
|
||||
"github.com/pkg/errors"
|
||||
@@ -61,6 +62,7 @@ func (c *gRPCConnection) sendLoop() error {
|
||||
}
|
||||
|
||||
func (c *gRPCConnection) receiveLoop() error {
|
||||
messageNumber := uint64(0)
|
||||
for c.IsConnected() {
|
||||
protoMessage, err := c.stream.Recv()
|
||||
if err != nil {
|
||||
@@ -75,10 +77,17 @@ func (c *gRPCConnection) receiveLoop() error {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugf("incoming '%s' message from %s", message.Command(), c)
|
||||
log.Tracef("incoming '%s' message from %s: %s", message.Command(), c, logger.NewLogClosure(func() string {
|
||||
return spew.Sdump(message)
|
||||
}))
|
||||
messageNumber++
|
||||
message.SetMessageNumber(messageNumber)
|
||||
message.SetReceivedAt(time.Now())
|
||||
|
||||
log.Debugf("incoming '%s' message from %s (message number %d)", message.Command(), c,
|
||||
message.MessageNumber())
|
||||
|
||||
log.Tracef("incoming '%s' message from %s (message number %d): %s", message.Command(),
|
||||
c, message.MessageNumber(), logger.NewLogClosure(func() string {
|
||||
return spew.Sdump(message)
|
||||
}))
|
||||
|
||||
err = c.router.EnqueueIncomingMessage(message)
|
||||
if err != nil {
|
||||
|
||||
@@ -22,11 +22,13 @@ type gRPCServer struct {
|
||||
server *grpc.Server
|
||||
}
|
||||
|
||||
const maxMessageSize = 1024 * 1024 * 10 // 10MB
|
||||
|
||||
// NewGRPCServer creates and starts a gRPC server, listening on the
|
||||
// provided addresses/ports
|
||||
func NewGRPCServer(listeningAddrs []string) (server.Server, error) {
|
||||
s := &gRPCServer{
|
||||
server: grpc.NewServer(),
|
||||
server: grpc.NewServer(grpc.MaxRecvMsgSize(maxMessageSize), grpc.MaxSendMsgSize(maxMessageSize)),
|
||||
listeningAddrs: listeningAddrs,
|
||||
}
|
||||
protowire.RegisterP2PServer(s.server, newP2PServer(s))
|
||||
@@ -42,6 +44,8 @@ func (s *gRPCServer) Start() error {
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("P2P server started with maxMessageSize %d", maxMessageSize)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
7
netadapter/server/grpcserver/protowire/README.md
Normal file
7
netadapter/server/grpcserver/protowire/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
protowire
|
||||
=========
|
||||
|
||||
1. Download and place in your PATH: https://github.com/protocolbuffers/protobuf/releases/download/v3.12.3/protoc-3.12.3-linux-x86_64.zip
|
||||
2. `go get github.com/golang/protobuf/protoc-gen-go`
|
||||
3. `go get google.golang.org/grpc/cmd/protoc-gen-go-grpc`
|
||||
4. In the protowire directory: `go generate .`
|
||||
@@ -34,6 +34,7 @@ func (x *KaspadMessage_Version) toDomainMessage() (domainmessage.Message, error)
|
||||
|
||||
return &domainmessage.MsgVersion{
|
||||
ProtocolVersion: x.Version.ProtocolVersion,
|
||||
Network: x.Version.Network,
|
||||
Services: domainmessage.ServiceFlag(x.Version.Services),
|
||||
Timestamp: mstime.UnixMilliseconds(x.Version.Timestamp),
|
||||
Address: address,
|
||||
@@ -64,6 +65,7 @@ func (x *KaspadMessage_Version) fromDomainMessage(msgVersion *domainmessage.MsgV
|
||||
|
||||
x.Version = &VersionMessage{
|
||||
ProtocolVersion: msgVersion.ProtocolVersion,
|
||||
Network: msgVersion.Network,
|
||||
Services: uint64(msgVersion.Services),
|
||||
Timestamp: msgVersion.Timestamp.UnixMilliseconds(),
|
||||
Address: address,
|
||||
|
||||
@@ -1854,6 +1854,7 @@ type VersionMessage struct {
|
||||
SelectedTipHash *Hash `protobuf:"bytes,7,opt,name=selectedTipHash,proto3" json:"selectedTipHash,omitempty"`
|
||||
DisableRelayTx bool `protobuf:"varint,8,opt,name=disableRelayTx,proto3" json:"disableRelayTx,omitempty"`
|
||||
SubnetworkID *SubnetworkID `protobuf:"bytes,9,opt,name=subnetworkID,proto3" json:"subnetworkID,omitempty"`
|
||||
Network string `protobuf:"bytes,10,opt,name=network,proto3" json:"network,omitempty"`
|
||||
}
|
||||
|
||||
func (x *VersionMessage) Reset() {
|
||||
@@ -1951,6 +1952,13 @@ func (x *VersionMessage) GetSubnetworkID() *SubnetworkID {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *VersionMessage) GetNetwork() string {
|
||||
if x != nil {
|
||||
return x.Network
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_messages_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_messages_proto_rawDesc = []byte{
|
||||
@@ -2214,7 +2222,7 @@ var file_messages_proto_rawDesc = []byte{
|
||||
0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x48, 0x61,
|
||||
0x73, 0x68, 0x52, 0x0f, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x54, 0x69, 0x70, 0x48,
|
||||
0x61, 0x73, 0x68, 0x22, 0x0f, 0x0a, 0x0d, 0x56, 0x65, 0x72, 0x61, 0x63, 0x6b, 0x4d, 0x65, 0x73,
|
||||
0x73, 0x61, 0x67, 0x65, 0x22, 0xf3, 0x02, 0x0a, 0x0e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x73, 0x61, 0x67, 0x65, 0x22, 0x8d, 0x03, 0x0a, 0x0e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x63, 0x6f, 0x6c, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d,
|
||||
0x52, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f,
|
||||
@@ -2237,15 +2245,17 @@ var file_messages_proto_rawDesc = []byte{
|
||||
0x0c, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x44, 0x18, 0x09, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e,
|
||||
0x53, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x44, 0x52, 0x0c, 0x73, 0x75,
|
||||
0x62, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x44, 0x32, 0x50, 0x0a, 0x03, 0x50, 0x32,
|
||||
0x50, 0x12, 0x49, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x72, 0x65,
|
||||
0x61, 0x6d, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b,
|
||||
0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x18, 0x2e, 0x70,
|
||||
0x62, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65,
|
||||
0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74,
|
||||
0x77, 0x6f, 0x72, 0x6b, 0x32, 0x50, 0x0a, 0x03, 0x50, 0x32, 0x50, 0x12, 0x49, 0x0a, 0x0d, 0x4d,
|
||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d,
|
||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x26, 0x5a, 0x24,
|
||||
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61,
|
||||
0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x77, 0x69, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69,
|
||||
0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
||||
0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
|
||||
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61,
|
||||
0x73, 0x70, 0x61, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -209,6 +209,7 @@ message VersionMessage{
|
||||
Hash selectedTipHash = 7;
|
||||
bool disableRelayTx = 8;
|
||||
SubnetworkID subnetworkID = 9;
|
||||
string network = 10;
|
||||
}
|
||||
// VersionMessage end
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package standalone
|
||||
|
||||
import (
|
||||
"github.com/kaspanet/kaspad/util/mstime"
|
||||
"sync"
|
||||
|
||||
"github.com/kaspanet/kaspad/netadapter/id"
|
||||
"github.com/kaspanet/kaspad/util/mstime"
|
||||
|
||||
"github.com/kaspanet/kaspad/protocol/common"
|
||||
|
||||
"github.com/kaspanet/kaspad/domainmessage"
|
||||
@@ -20,6 +19,7 @@ import (
|
||||
// MinimalNetAdapter allows tests and other tools to use a simple network adapter without implementing
|
||||
// all the required supporting structures.
|
||||
type MinimalNetAdapter struct {
|
||||
cfg *config.Config
|
||||
lock sync.Mutex
|
||||
netAdapter *netadapter.NetAdapter
|
||||
routesChan <-chan *Routes
|
||||
@@ -41,6 +41,7 @@ func NewMinimalNetAdapter(cfg *config.Config) (*MinimalNetAdapter, error) {
|
||||
}
|
||||
|
||||
return &MinimalNetAdapter{
|
||||
cfg: cfg,
|
||||
lock: sync.Mutex{},
|
||||
netAdapter: netAdapter,
|
||||
routesChan: routesChan,
|
||||
@@ -61,13 +62,13 @@ func (mna *MinimalNetAdapter) Connect(address string) (*Routes, error) {
|
||||
}
|
||||
|
||||
routes := <-mna.routesChan
|
||||
err = handleHandshake(routes, mna.netAdapter.ID())
|
||||
err = mna.handleHandshake(routes, mna.netAdapter.ID())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Error in handshake")
|
||||
}
|
||||
|
||||
spawn("netAdapterMock-handlePingPong", func() {
|
||||
err := handlePingPong(routes)
|
||||
err := mna.handlePingPong(routes)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "Error from ping-pong"))
|
||||
}
|
||||
@@ -79,7 +80,7 @@ func (mna *MinimalNetAdapter) Connect(address string) (*Routes, error) {
|
||||
// handlePingPong makes sure that we are not disconnected due to not responding to pings.
|
||||
// However, it only responds to pings, not sending its own, to conform to the minimal-ness
|
||||
// of MinimalNetAdapter
|
||||
func handlePingPong(routes *Routes) error {
|
||||
func (*MinimalNetAdapter) handlePingPong(routes *Routes) error {
|
||||
for {
|
||||
message, err := routes.pingRoute.Dequeue()
|
||||
if err != nil {
|
||||
@@ -98,7 +99,7 @@ func handlePingPong(routes *Routes) error {
|
||||
}
|
||||
}
|
||||
|
||||
func handleHandshake(routes *Routes, ourID *id.ID) error {
|
||||
func (mna *MinimalNetAdapter) handleHandshake(routes *Routes, ourID *id.ID) error {
|
||||
msg, err := routes.handshakeRoute.DequeueWithTimeout(common.DefaultTimeout)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -111,6 +112,7 @@ func handleHandshake(routes *Routes, ourID *id.ID) error {
|
||||
|
||||
err = routes.OutgoingRoute.Enqueue(&domainmessage.MsgVersion{
|
||||
ProtocolVersion: versionMessage.ProtocolVersion,
|
||||
Network: mna.cfg.ActiveNetParams.Name,
|
||||
Services: versionMessage.Services,
|
||||
Timestamp: mstime.Now(),
|
||||
Address: nil,
|
||||
|
||||
@@ -55,6 +55,11 @@ func (flow *receiveVersionFlow) start() (*domainmessage.NetAddress, error) {
|
||||
return nil, protocolerrors.New(true, "connected to self")
|
||||
}
|
||||
|
||||
// Disconnect and ban peers from a different network
|
||||
if msgVersion.Network != flow.Config().ActiveNetParams.Name {
|
||||
return nil, protocolerrors.Errorf(true, "wrong network")
|
||||
}
|
||||
|
||||
// Notify and disconnect clients that have a protocol version that is
|
||||
// too old.
|
||||
//
|
||||
|
||||
@@ -49,7 +49,8 @@ func (flow *sendVersionFlow) start() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
msg := domainmessage.NewMsgVersion(localAddress, flow.NetAdapter().ID(), selectedTipHash, subnetworkID)
|
||||
msg := domainmessage.NewMsgVersion(localAddress, flow.NetAdapter().ID(),
|
||||
flow.Config().ActiveNetParams.Name, selectedTipHash, subnetworkID)
|
||||
msg.AddUserAgent(userAgentName, userAgentVersion, flow.Config().UserAgentComments...)
|
||||
|
||||
// Advertise the services flag
|
||||
|
||||
@@ -11,9 +11,7 @@ import (
|
||||
"github.com/kaspanet/kaspad/netadapter"
|
||||
"github.com/kaspanet/kaspad/protocol/flowcontext"
|
||||
peerpkg "github.com/kaspanet/kaspad/protocol/peer"
|
||||
"github.com/kaspanet/kaspad/protocol/protocolerrors"
|
||||
"github.com/kaspanet/kaspad/util"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Manager manages the p2p protocol
|
||||
@@ -56,30 +54,12 @@ func (m *Manager) IBDPeer() *peerpkg.Peer {
|
||||
|
||||
// AddTransaction adds transaction to the mempool and propagates it.
|
||||
func (m *Manager) AddTransaction(tx *util.Tx) error {
|
||||
err := m.context.AddTransaction(tx)
|
||||
if err != nil {
|
||||
if protocolErr := &(protocolerrors.ProtocolError{}); errors.As(err, &protocolErr) {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO(libp2p): Remove panic once RPC is integrated into protocol architecture
|
||||
panic(err)
|
||||
}
|
||||
return nil
|
||||
return m.context.AddTransaction(tx)
|
||||
}
|
||||
|
||||
// AddBlock adds the given block to the DAG and propagates it.
|
||||
func (m *Manager) AddBlock(block *util.Block, flags blockdag.BehaviorFlags) error {
|
||||
err := m.context.AddBlock(block, flags)
|
||||
if err != nil {
|
||||
if protocolErr := &(protocolerrors.ProtocolError{}); errors.As(err, &protocolErr) {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO(libp2p): Remove panic once RPC is integrated into protocol architecture
|
||||
panic(err)
|
||||
}
|
||||
return nil
|
||||
return m.context.AddBlock(block, flags)
|
||||
}
|
||||
|
||||
func (m *Manager) runFlows(flows []*flow, peer *peerpkg.Peer, errChan <-chan error) error {
|
||||
|
||||
@@ -15,8 +15,7 @@ func handleGetSubnetwork(s *Server, cmd interface{}, closeChan <-chan struct{})
|
||||
}
|
||||
|
||||
var gasLimit *uint64
|
||||
if !subnetworkID.IsEqual(subnetworkid.SubnetworkIDNative) &&
|
||||
!subnetworkID.IsBuiltIn() {
|
||||
if !subnetworkID.IsBuiltInOrNative() {
|
||||
limit, err := s.dag.GasLimit(subnetworkID)
|
||||
if err != nil {
|
||||
return nil, &model.RPCError{
|
||||
|
||||
@@ -7,8 +7,9 @@ package subnetworkid
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"github.com/pkg/errors"
|
||||
"math/big"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// IDLength of array used to store the subnetwork ID. See SubnetworkID.
|
||||
@@ -196,6 +197,12 @@ func (id *SubnetworkID) IsBuiltIn() bool {
|
||||
return id.IsEqual(SubnetworkIDCoinbase) || id.IsEqual(SubnetworkIDRegistry)
|
||||
}
|
||||
|
||||
// IsBuiltInOrNative returns true if the subnetwork is the native or a built in subnetwork,
|
||||
// see IsBuiltIn for further details
|
||||
func (id *SubnetworkID) IsBuiltInOrNative() bool {
|
||||
return id.IsEqual(SubnetworkIDNative) || id.IsBuiltIn()
|
||||
}
|
||||
|
||||
// Less returns true iff id a is less than id b
|
||||
func Less(a *SubnetworkID, b *SubnetworkID) bool {
|
||||
return a.Cmp(b) < 0
|
||||
|
||||
@@ -11,7 +11,7 @@ const validCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrs
|
||||
const (
|
||||
appMajor uint = 0
|
||||
appMinor uint = 6
|
||||
appPatch uint = 1
|
||||
appPatch uint = 2
|
||||
)
|
||||
|
||||
// appBuild is defined as a variable so it can be overridden during the build
|
||||
|
||||
Reference in New Issue
Block a user