Compare commits

...

19 Commits

Author SHA1 Message Date
cbitensky
a5df278855 Updating changelog.txt 2021-07-05 11:50:43 +03:00
cbitensky
de0bdfcd33
Make use of maxBlocks instead of maxBlueScoreDifference in antiPastHashesBetween (#1774) 2021-07-01 11:33:22 +03:00
tal
eaf4180082 Update to version 0.10.4 2021-06-06 14:54:41 +03:00
Ori Newman
5ef24ae37e Merge branch 'v0.10.3-dev' of github.com:kaspanet/kaspad into v0.10.3-dev 2021-05-31 18:24:19 +03:00
stasatdaglabs
83e631548f Implement NotifyVirtualDaaScoreChanged (#1737)
* Add notifyVirtualDaaScoreChanged to protowire.

* Add notifyVirtualDaaScoreChanged to the rest of kaspad.

* Add notifyVirtualDaaScoreChanged to the rest of kaspad.

* Test the DAA score notification in TestVirtualSelectedParentBlueScore.

* Rename TestVirtualSelectedParentBlueScore to TestVirtualSelectedParentBlueScoreAndVirtualDAAScore.
2021-05-31 18:13:44 +03:00
stasatdaglabs
0adfb2dfbb
Implement NotifyVirtualDaaScoreChanged (#1737)
* Add notifyVirtualDaaScoreChanged to protowire.

* Add notifyVirtualDaaScoreChanged to the rest of kaspad.

* Add notifyVirtualDaaScoreChanged to the rest of kaspad.

* Test the DAA score notification in TestVirtualSelectedParentBlueScore.

* Rename TestVirtualSelectedParentBlueScore to TestVirtualSelectedParentBlueScoreAndVirtualDAAScore.
2021-05-31 18:11:08 +03:00
stasatdaglabs
4461f56ca3 Update to version 0.10.3 2021-05-18 13:54:33 +03:00
Ori Newman
a18f2f8802
Fix overflow when checking coinbase maturity and don't ban peers that send transactions with immature spend (#1722)
* Fix overflow when checking coinbase maturity and don't ban peers that send transactions with immature spend

* Fix tests

Co-authored-by: Svarog <feanorr@gmail.com>
2021-05-14 13:02:50 +03:00
Ori Newman
04dc1947ff
Fix calcTxSequenceLockFromReferencedUTXOEntries for loop break condition (#1723)
Co-authored-by: Svarog <feanorr@gmail.com>
2021-05-14 12:49:53 +03:00
Ori Newman
36c56f73bf
Add VirtualDaaScore to GetBlockDagInfo (#1719)
Co-authored-by: Svarog <feanorr@gmail.com>
2021-05-14 12:36:20 +03:00
Ori Newman
b76ca41109
serializeAddress should always serialize as IPv6, since it assumes the IP size is 16 bytes (#1720) 2021-05-13 17:42:59 +03:00
Ori Newman
50fd86e287
Fix getBlock and getBlocks RPC commands to return blocks and transactions properly (#1716)
* Fix getBlock RPC command to return transactions

* Fix getBlocks RPC command to return transactions and blocks

* Add GetBlockEvenIfHeaderOnly and use it for getBlock and getBlocks

* Implement GetBlockEvenIfHeaderOnly for fakeRelayInvsContext

* Use less nested code
2021-05-13 15:45:03 +03:00
stasatdaglabs
79cf0d64d0 Update to version 0.10.2 2021-05-09 14:33:47 +03:00
Ori Newman
b405ea50e5
Calculate virtual's acceptance data and multiset after importing a new pruning point (#1700) 2021-05-05 18:13:00 +03:00
Ori Newman
ccfe8a45dd Create v0.10.1 2021-05-05 17:09:30 +03:00
stasatdaglabs
9dd8136e4b
Add v0.10.0 to the changelog. (#1692) 2021-04-26 15:01:02 +03:00
stasatdaglabs
eb1703b948
Fix the mempool-limits stability test (#1690)
* Add -v to the `go test` command.

* Generate a new keypair for mempool-limits.

* Set mempool-limits to time out only after 24 hours.
2021-04-25 16:27:47 +03:00
stasatdaglabs
a6da3251d0
Generalize stability-tests/docker/Dockerfile. (#1685) 2021-04-21 12:53:37 +03:00
stasatdaglabs
bf198948c4
Update the testnet version to testnet-5. (#1683) 2021-04-20 14:35:41 +03:00
50 changed files with 1523 additions and 691 deletions

View File

@ -137,6 +137,9 @@ const (
CmdPruningPointUTXOSetOverrideNotificationMessage CmdPruningPointUTXOSetOverrideNotificationMessage
CmdStopNotifyingPruningPointUTXOSetOverrideRequestMessage CmdStopNotifyingPruningPointUTXOSetOverrideRequestMessage
CmdStopNotifyingPruningPointUTXOSetOverrideResponseMessage CmdStopNotifyingPruningPointUTXOSetOverrideResponseMessage
CmdNotifyVirtualDaaScoreChangedRequestMessage
CmdNotifyVirtualDaaScoreChangedResponseMessage
CmdVirtualDaaScoreChangedNotificationMessage
) )
// ProtocolMessageCommandToString maps all MessageCommands to their string representation // ProtocolMessageCommandToString maps all MessageCommands to their string representation
@ -248,6 +251,9 @@ var RPCMessageCommandToString = map[MessageCommand]string{
CmdPruningPointUTXOSetOverrideNotificationMessage: "PruningPointUTXOSetOverrideNotification", CmdPruningPointUTXOSetOverrideNotificationMessage: "PruningPointUTXOSetOverrideNotification",
CmdStopNotifyingPruningPointUTXOSetOverrideRequestMessage: "StopNotifyingPruningPointUTXOSetOverrideRequest", CmdStopNotifyingPruningPointUTXOSetOverrideRequestMessage: "StopNotifyingPruningPointUTXOSetOverrideRequest",
CmdStopNotifyingPruningPointUTXOSetOverrideResponseMessage: "StopNotifyingPruningPointUTXOSetOverrideResponse", CmdStopNotifyingPruningPointUTXOSetOverrideResponseMessage: "StopNotifyingPruningPointUTXOSetOverrideResponse",
CmdNotifyVirtualDaaScoreChangedRequestMessage: "NotifyVirtualDaaScoreChangedRequest",
CmdNotifyVirtualDaaScoreChangedResponseMessage: "NotifyVirtualDaaScoreChangedResponse",
CmdVirtualDaaScoreChangedNotificationMessage: "VirtualDaaScoreChangedNotification",
} }
// Message is an interface that describes a kaspa message. A type that // Message is an interface that describes a kaspa message. A type that

View File

@ -28,6 +28,7 @@ type GetBlockDAGInfoResponseMessage struct {
Difficulty float64 Difficulty float64
PastMedianTime int64 PastMedianTime int64
PruningPointHash string PruningPointHash string
VirtualDAAScore uint64
Error *RPCError Error *RPCError
} }

View File

@ -0,0 +1,55 @@
package appmessage
// NotifyVirtualDaaScoreChangedRequestMessage is an appmessage corresponding to
// its respective RPC message
type NotifyVirtualDaaScoreChangedRequestMessage struct {
baseMessage
}
// Command returns the protocol command string for the message
func (msg *NotifyVirtualDaaScoreChangedRequestMessage) Command() MessageCommand {
return CmdNotifyVirtualDaaScoreChangedRequestMessage
}
// NewNotifyVirtualDaaScoreChangedRequestMessage returns a instance of the message
func NewNotifyVirtualDaaScoreChangedRequestMessage() *NotifyVirtualDaaScoreChangedRequestMessage {
return &NotifyVirtualDaaScoreChangedRequestMessage{}
}
// NotifyVirtualDaaScoreChangedResponseMessage is an appmessage corresponding to
// its respective RPC message
type NotifyVirtualDaaScoreChangedResponseMessage struct {
baseMessage
Error *RPCError
}
// Command returns the protocol command string for the message
func (msg *NotifyVirtualDaaScoreChangedResponseMessage) Command() MessageCommand {
return CmdNotifyVirtualDaaScoreChangedResponseMessage
}
// NewNotifyVirtualDaaScoreChangedResponseMessage returns a instance of the message
func NewNotifyVirtualDaaScoreChangedResponseMessage() *NotifyVirtualDaaScoreChangedResponseMessage {
return &NotifyVirtualDaaScoreChangedResponseMessage{}
}
// VirtualDaaScoreChangedNotificationMessage is an appmessage corresponding to
// its respective RPC message
type VirtualDaaScoreChangedNotificationMessage struct {
baseMessage
VirtualDaaScore uint64
}
// Command returns the protocol command string for the message
func (msg *VirtualDaaScoreChangedNotificationMessage) Command() MessageCommand {
return CmdVirtualDaaScoreChangedNotificationMessage
}
// NewVirtualDaaScoreChangedNotificationMessage returns a instance of the message
func NewVirtualDaaScoreChangedNotificationMessage(
virtualDaaScore uint64) *VirtualDaaScoreChangedNotificationMessage {
return &VirtualDaaScoreChangedNotificationMessage{
VirtualDaaScore: virtualDaaScore,
}
}

View File

@ -49,8 +49,9 @@ func (flow *handleRequestHeadersFlow) start() error {
// GetHashesBetween is a relatively heavy operation so we limit it // GetHashesBetween is a relatively heavy operation so we limit it
// in order to avoid locking the consensus for too long // in order to avoid locking the consensus for too long
const maxBlueScoreDifference = 1 << 10 // maxBlocks MUST be >= MergeSetSizeLimit + 1
blockHashes, _, err := flow.Domain().Consensus().GetHashesBetween(lowHash, highHash, maxBlueScoreDifference) const maxBlocks = 1 << 10
blockHashes, _, err := flow.Domain().Consensus().GetHashesBetween(lowHash, highHash, maxBlocks)
if err != nil { if err != nil {
return err return err
} }

View File

@ -130,6 +130,10 @@ type fakeRelayInvsContext struct {
rwLock sync.RWMutex rwLock sync.RWMutex
} }
func (f *fakeRelayInvsContext) GetBlockEvenIfHeaderOnly(blockHash *externalapi.DomainHash) (*externalapi.DomainBlock, error) {
panic("implement me")
}
func (f *fakeRelayInvsContext) GetBlockRelations(blockHash *externalapi.DomainHash) ([]*externalapi.DomainHash, *externalapi.DomainHash, []*externalapi.DomainHash, error) { func (f *fakeRelayInvsContext) GetBlockRelations(blockHash *externalapi.DomainHash) ([]*externalapi.DomainHash, *externalapi.DomainHash, []*externalapi.DomainHash, error) {
panic(errors.Errorf("called unimplemented function from test '%s'", f.testName)) panic(errors.Errorf("called unimplemented function from test '%s'", f.testName))
} }
@ -182,7 +186,7 @@ func (f *fakeRelayInvsContext) GetBlockAcceptanceData(blockHash *externalapi.Dom
panic(errors.Errorf("called unimplemented function from test '%s'", f.testName)) panic(errors.Errorf("called unimplemented function from test '%s'", f.testName))
} }
func (f *fakeRelayInvsContext) GetHashesBetween(lowHash, highHash *externalapi.DomainHash, maxBlueScoreDifference uint64) (hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) { func (f *fakeRelayInvsContext) GetHashesBetween(lowHash, highHash *externalapi.DomainHash, maxBlocks uint64) (hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) {
panic(errors.Errorf("called unimplemented function from test '%s'", f.testName)) panic(errors.Errorf("called unimplemented function from test '%s'", f.testName))
} }

View File

@ -64,6 +64,11 @@ func (m *Manager) NotifyBlockAddedToDAG(block *externalapi.DomainBlock, blockIns
return err return err
} }
err = m.notifyVirtualDaaScoreChanged()
if err != nil {
return err
}
err = m.notifyVirtualSelectedParentChainChanged(blockInsertionResult) err = m.notifyVirtualSelectedParentChainChanged(blockInsertionResult)
if err != nil { if err != nil {
return err return err
@ -153,6 +158,19 @@ func (m *Manager) notifyVirtualSelectedParentBlueScoreChanged() error {
return m.context.NotificationManager.NotifyVirtualSelectedParentBlueScoreChanged(notification) return m.context.NotificationManager.NotifyVirtualSelectedParentBlueScoreChanged(notification)
} }
func (m *Manager) notifyVirtualDaaScoreChanged() error {
onEnd := logger.LogAndMeasureExecutionTime(log, "RPCManager.NotifyVirtualDaaScoreChanged")
defer onEnd()
virtualInfo, err := m.context.Domain.Consensus().GetVirtualInfo()
if err != nil {
return err
}
notification := appmessage.NewVirtualDaaScoreChangedNotificationMessage(virtualInfo.DAAScore)
return m.context.NotificationManager.NotifyVirtualDaaScoreChanged(notification)
}
func (m *Manager) notifyVirtualSelectedParentChainChanged(blockInsertionResult *externalapi.BlockInsertionResult) error { func (m *Manager) notifyVirtualSelectedParentChainChanged(blockInsertionResult *externalapi.BlockInsertionResult) error {
onEnd := logger.LogAndMeasureExecutionTime(log, "RPCManager.NotifyVirtualSelectedParentChainChanged") onEnd := logger.LogAndMeasureExecutionTime(log, "RPCManager.NotifyVirtualSelectedParentChainChanged")
defer onEnd() defer onEnd()

View File

@ -44,6 +44,7 @@ var handlers = map[appmessage.MessageCommand]handler{
appmessage.CmdGetInfoRequestMessage: rpchandlers.HandleGetInfo, appmessage.CmdGetInfoRequestMessage: rpchandlers.HandleGetInfo,
appmessage.CmdNotifyPruningPointUTXOSetOverrideRequestMessage: rpchandlers.HandleNotifyPruningPointUTXOSetOverrideRequest, appmessage.CmdNotifyPruningPointUTXOSetOverrideRequestMessage: rpchandlers.HandleNotifyPruningPointUTXOSetOverrideRequest,
appmessage.CmdStopNotifyingPruningPointUTXOSetOverrideRequestMessage: rpchandlers.HandleStopNotifyingPruningPointUTXOSetOverrideRequest, appmessage.CmdStopNotifyingPruningPointUTXOSetOverrideRequestMessage: rpchandlers.HandleStopNotifyingPruningPointUTXOSetOverrideRequest,
appmessage.CmdNotifyVirtualDaaScoreChangedRequestMessage: rpchandlers.HandleNotifyVirtualDaaScoreChanged,
} }
func (m *Manager) routerInitializer(router *router.Router, netConnection *netadapter.NetConnection) { func (m *Manager) routerInitializer(router *router.Router, netConnection *netadapter.NetConnection) {

View File

@ -30,6 +30,7 @@ type NotificationListener struct {
propagateFinalityConflictResolvedNotifications bool propagateFinalityConflictResolvedNotifications bool
propagateUTXOsChangedNotifications bool propagateUTXOsChangedNotifications bool
propagateVirtualSelectedParentBlueScoreChangedNotifications bool propagateVirtualSelectedParentBlueScoreChangedNotifications bool
propagateVirtualDaaScoreChangedNotifications bool
propagatePruningPointUTXOSetOverrideNotifications bool propagatePruningPointUTXOSetOverrideNotifications bool
propagateUTXOsChangedNotificationAddresses map[utxoindex.ScriptPublicKeyString]*UTXOsChangedNotificationAddress propagateUTXOsChangedNotificationAddresses map[utxoindex.ScriptPublicKeyString]*UTXOsChangedNotificationAddress
@ -181,6 +182,25 @@ func (nm *NotificationManager) NotifyVirtualSelectedParentBlueScoreChanged(
return nil return nil
} }
// NotifyVirtualDaaScoreChanged notifies the notification manager that the DAG's
// virtual DAA score has changed
func (nm *NotificationManager) NotifyVirtualDaaScoreChanged(
notification *appmessage.VirtualDaaScoreChangedNotificationMessage) error {
nm.RLock()
defer nm.RUnlock()
for router, listener := range nm.listeners {
if listener.propagateVirtualDaaScoreChangedNotifications {
err := router.OutgoingRoute().Enqueue(notification)
if err != nil {
return err
}
}
}
return nil
}
// NotifyPruningPointUTXOSetOverride notifies the notification manager that the UTXO index // NotifyPruningPointUTXOSetOverride notifies the notification manager that the UTXO index
// reset due to pruning point change via IBD. // reset due to pruning point change via IBD.
func (nm *NotificationManager) NotifyPruningPointUTXOSetOverride() error { func (nm *NotificationManager) NotifyPruningPointUTXOSetOverride() error {
@ -308,6 +328,12 @@ func (nl *NotificationListener) PropagateVirtualSelectedParentBlueScoreChangedNo
nl.propagateVirtualSelectedParentBlueScoreChangedNotifications = true nl.propagateVirtualSelectedParentBlueScoreChangedNotifications = true
} }
// PropagateVirtualDaaScoreChangedNotifications instructs the listener to send
// virtual DAA score notifications to the remote listener
func (nl *NotificationListener) PropagateVirtualDaaScoreChangedNotifications() {
nl.propagateVirtualDaaScoreChangedNotifications = true
}
// PropagatePruningPointUTXOSetOverrideNotifications instructs the listener to send pruning point UTXO set override notifications // PropagatePruningPointUTXOSetOverrideNotifications instructs the listener to send pruning point UTXO set override notifications
// to the remote listener. // to the remote listener.
func (nl *NotificationListener) PropagatePruningPointUTXOSetOverrideNotifications() { func (nl *NotificationListener) PropagatePruningPointUTXOSetOverrideNotifications() {

View File

@ -80,7 +80,7 @@ func (ctx *Context) PopulateBlockWithVerboseData(block *appmessage.RPCBlock, dom
// Get the block if we didn't receive it previously // Get the block if we didn't receive it previously
if domainBlock == nil { if domainBlock == nil {
domainBlock, err = ctx.Domain.Consensus().GetBlock(blockHash) domainBlock, err = ctx.Domain.Consensus().GetBlockEvenIfHeaderOnly(blockHash)
if err != nil { if err != nil {
return err return err
} }

View File

@ -20,18 +20,22 @@ func HandleGetBlock(context *rpccontext.Context, _ *router.Router, request appme
return errorMessage, nil return errorMessage, nil
} }
header, err := context.Domain.Consensus().GetBlockHeader(hash) block, err := context.Domain.Consensus().GetBlockEvenIfHeaderOnly(hash)
if err != nil { if err != nil {
errorMessage := &appmessage.GetBlockResponseMessage{} errorMessage := &appmessage.GetBlockResponseMessage{}
errorMessage.Error = appmessage.RPCErrorf("Block %s not found", hash) errorMessage.Error = appmessage.RPCErrorf("Block %s not found", hash)
return errorMessage, nil return errorMessage, nil
} }
block := &externalapi.DomainBlock{Header: header}
response := appmessage.NewGetBlockResponseMessage() response := appmessage.NewGetBlockResponseMessage()
response.Block = appmessage.DomainBlockToRPCBlock(block)
err = context.PopulateBlockWithVerboseData(response.Block, header, nil, getBlockRequest.IncludeTransactionVerboseData) if getBlockRequest.IncludeTransactionVerboseData {
response.Block = appmessage.DomainBlockToRPCBlock(block)
} else {
response.Block = appmessage.DomainBlockToRPCBlock(&externalapi.DomainBlock{Header: block.Header})
}
err = context.PopulateBlockWithVerboseData(response.Block, block.Header, block, getBlockRequest.IncludeTransactionVerboseData)
if err != nil { if err != nil {
if errors.Is(err, rpccontext.ErrBuildBlockVerboseDataInvalidBlock) { if errors.Is(err, rpccontext.ErrBuildBlockVerboseDataInvalidBlock) {
errorMessage := &appmessage.GetBlockResponseMessage{} errorMessage := &appmessage.GetBlockResponseMessage{}

View File

@ -35,6 +35,7 @@ func HandleGetBlockDAGInfo(context *rpccontext.Context, _ *router.Router, _ appm
response.VirtualParentHashes = hashes.ToStrings(virtualInfo.ParentHashes) response.VirtualParentHashes = hashes.ToStrings(virtualInfo.ParentHashes)
response.Difficulty = context.GetDifficultyRatio(virtualInfo.Bits, context.Config.ActiveNetParams) response.Difficulty = context.GetDifficultyRatio(virtualInfo.Bits, context.Config.ActiveNetParams)
response.PastMedianTime = virtualInfo.PastMedianTime response.PastMedianTime = virtualInfo.PastMedianTime
response.VirtualDAAScore = virtualInfo.DAAScore
pruningPoint, err := context.Domain.Consensus().PruningPoint() pruningPoint, err := context.Domain.Consensus().PruningPoint()
if err != nil { if err != nil {

View File

@ -8,12 +8,6 @@ import (
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
) )
const (
// maxBlocksInGetBlocksResponse is the max amount of blocks that are
// allowed in a GetBlocksResult.
maxBlocksInGetBlocksResponse = 1000
)
// HandleGetBlocks handles the respectively named RPC command // HandleGetBlocks handles the respectively named RPC command
func HandleGetBlocks(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) { func HandleGetBlocks(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) {
getBlocksRequest := request.(*appmessage.GetBlocksRequestMessage) getBlocksRequest := request.(*appmessage.GetBlocksRequestMessage)
@ -55,7 +49,11 @@ func HandleGetBlocks(context *rpccontext.Context, _ *router.Router, request appm
if err != nil { if err != nil {
return nil, err return nil, err
} }
blockHashes, highHash, err := context.Domain.Consensus().GetHashesBetween(lowHash, virtualSelectedParent, maxBlocksInGetBlocksResponse)
// We use +1 because lowHash is also returned
// maxBlocks MUST be >= MergeSetSizeLimit + 1
maxBlocks := context.Config.NetParams().MergeSetSizeLimit + 1
blockHashes, highHash, err := context.Domain.Consensus().GetHashesBetween(lowHash, virtualSelectedParent, maxBlocks)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -74,29 +72,28 @@ func HandleGetBlocks(context *rpccontext.Context, _ *router.Router, request appm
blockHashes = append(blockHashes, virtualSelectedParentAnticone...) blockHashes = append(blockHashes, virtualSelectedParentAnticone...)
} }
// Both GetHashesBetween and Anticone might return more then the allowed number of blocks, so
// trim any extra blocks.
if len(blockHashes) > maxBlocksInGetBlocksResponse {
blockHashes = blockHashes[:maxBlocksInGetBlocksResponse]
}
// Prepare the response // Prepare the response
response := appmessage.NewGetBlocksResponseMessage() response := appmessage.NewGetBlocksResponseMessage()
response.BlockHashes = hashes.ToStrings(blockHashes) response.BlockHashes = hashes.ToStrings(blockHashes)
if getBlocksRequest.IncludeBlocks { if getBlocksRequest.IncludeBlocks {
blocks := make([]*appmessage.RPCBlock, len(blockHashes)) rpcBlocks := make([]*appmessage.RPCBlock, len(blockHashes))
for i, blockHash := range blockHashes { for i, blockHash := range blockHashes {
blockHeader, err := context.Domain.Consensus().GetBlockHeader(blockHash) block, err := context.Domain.Consensus().GetBlockEvenIfHeaderOnly(blockHash)
if err != nil { if err != nil {
return nil, err return nil, err
} }
block := &externalapi.DomainBlock{Header: blockHeader}
blocks[i] = appmessage.DomainBlockToRPCBlock(block) if getBlocksRequest.IncludeTransactionVerboseData {
err = context.PopulateBlockWithVerboseData(blocks[i], blockHeader, nil, getBlocksRequest.IncludeTransactionVerboseData) rpcBlocks[i] = appmessage.DomainBlockToRPCBlock(block)
} else {
rpcBlocks[i] = appmessage.DomainBlockToRPCBlock(&externalapi.DomainBlock{Header: block.Header})
}
err = context.PopulateBlockWithVerboseData(rpcBlocks[i], block.Header, nil, getBlocksRequest.IncludeTransactionVerboseData)
if err != nil { if err != nil {
return nil, err return nil, err
} }
} }
response.Blocks = rpcBlocks
} }
return response, nil return response, nil

View File

@ -0,0 +1,19 @@
package rpchandlers
import (
"github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
)
// HandleNotifyVirtualDaaScoreChanged handles the respectively named RPC command
func HandleNotifyVirtualDaaScoreChanged(context *rpccontext.Context, router *router.Router, _ appmessage.Message) (appmessage.Message, error) {
listener, err := context.NotificationManager.Listener(router)
if err != nil {
return nil, err
}
listener.PropagateVirtualDaaScoreChangedNotifications()
response := appmessage.NewNotifyVirtualDaaScoreChangedResponseMessage()
return response, nil
}

View File

@ -1,11 +1,104 @@
Kaspad v0.10.4 - 2021-07-05
===========================
* Make use of maxBlocks instead of maxBlueScoreDifference in antiPastHashesBetween (#1774)
Kaspad v0.10.3 - 2021-06-06
===========================
Non-breaking changes:
* Implement NotifyVirtualDaaScoreChanged (#1737)
Kaspad v0.10.2 - 2021-05-18
===========================
Non-breaking changes:
* Fix getBlock and getBlocks RPC commands to return blocks and transactions properly (#1716)
* serializeAddress should always serialize as IPv6, since it assumes the IP size is 16 bytes (#1720)
* Add VirtualDaaScore to GetBlockDagInfo (#1719)
* Fix calcTxSequenceLockFromReferencedUTXOEntries for loop break condition (#1723)
* Fix overflow when checking coinbase maturity and don't ban peers that send transactions with immature spend (#1722)
Kaspad v0.10.1 - 2021-05-11
===========================
* Calculate virtual's acceptance data and multiset after importing a new pruning point (#1700)
Kaspad v0.10.0 - 2021-04-26
===========================
Major changes include:
* Implementing a signature hashing scheme similar to BIP-143
* Replacing HASH160 with BLAKE2B
* Replacing ECMH with MuHash
* Removing RIPEMD160 and SHA1 from the codebase entirely
* Making P2PKH transactions non-standard
* Vastly enhancing the CLI wallet
* Restructuring kaspad's app/home directory
* Modifying block and transaction types in the RPC to be easier to consume clientside
A partial list of the more-important commits is as follows:
* Fix data race in GetBlockChildren (#1579)
* Remove payload hash (#1583)
* Add the mempool size to getInfo RPC command (#1584)
* Change the difficulty to be calculated based on the same block instead of its selected parent (#1591)
* Adjust the difficulty in the first difficultyAdjustmentWindowSize blocks (#1592)
* Adding DAA score (#1596)
* Use DAA score where needed (#1602)
* Remove the Services field from NetAddress. (#1610)
* Fix getBlocks to not add the anticone when some blocks were filtered by GetHashesBetween (#1611)
* Restructure the default ~/.kaspad directory layout (#1613)
* Replace the HomeDir flag with a AppDir flag (#1615)
* Implement BIP-143-like sighash (#1598)
* Change --datadir to --appdir and remove symmetrical connection in stability tests (#1617)
* Use BLAKE2B instead of HASH160, and get rid of any usage of RIPEMD160 and SHA1 (#1618)
* Replace ECMH with Muhash (#1624)
* Add support for multiple staging areas (#1633)
* Make sure the ghostdagDataStore cache is at least DifficultyAdjustmentBlockWindow sized (#1635)
* Resolve each block status in it's own staging area (#1634)
* Add mass limit to mempool (#1627)
* In RPC, use RPCTransactions and RPCBlocks instead of TransactionMessages and BlockMessages (#1609)
* Use go-secp256k1 v0.0.5 (#1640)
* Add a show-address subcommand to kaspawallet (#1653)
* Replace p2pkh with p2pk (#1650)
* Implement importing private keys into the wallet (#1655)
* Add dump unencrypted data sub command to the wallet (#1661)
* Add ECDSA support (#1657)
* Add OpCheckMultiSigECDSA (#1663)
* Add ECDSA support to the wallet (#1664)
* Make moving the pruning point faster (#1660)
* Implement new mechanism for updating UTXO Diffs (#1671)
Kaspad v0.9.2 - 2021-03-31
===========================
* Increase the route capacity of InvTransaction messages. (#1603) (#1637)
Kaspad v0.9.1 - 2021-03-14
===========================
* Testnet network reset
Kaspad v0.9.0 - 2021-03-04
===========================
* Merge big subdags in pick virtual parents (#1574)
* Write in the reject message the tx rejection reason (#1573)
* Add nil checks for protowire (#1570)
* Increase getBlocks limit to 1000 (#1572)
* Return RPC error if getBlock's lowHash doesn't exist (#1569)
* Add default dns-seeder to testnet (#1568)
* Fix utxoindex deserialization (#1566)
* Add pruning point hash to GetBlockDagInfo response (#1565)
* Use EmitUnpopulated so that kaspactl prints all fields, even the default ones (#1561)
* Stop logging an error whenever an RPC/P2P connection is canceled (#1562)
* Cleanup the logger and make it asynchronous (#1524)
* Close all iterators (#1542)
* Add childrenHashes to GetBlock/s RPC commands (#1560)
* Add ScriptPublicKey.Version to RPC (#1559)
* Fix the target block rate to create less bursty mining (#1554)
Kaspad v0.8.10 - 2021-02-25 Kaspad v0.8.10 - 2021-02-25
=========================== ===========================
[*] Fix bug where invalid mempool transactions were not removed (#1551) * Fix bug where invalid mempool transactions were not removed (#1551)
[*] Add RPC reconnection to the miner (#1552) * Add RPC reconnection to the miner (#1552)
[*] Remove virtual diff parents - only selectedTip is virtualDiffParent now (#1550) * Remove virtual diff parents - only selectedTip is virtualDiffParent now (#1550)
[*] Fix UTXO index (#1548) * Fix UTXO index (#1548)
[*] Prevent fast failing (#1545) * Prevent fast failing (#1545)
[*] Increase the sleep time in kaspaminer when the node is not synced (#1544) * Increase the sleep time in kaspaminer when the node is not synced (#1544)
[*] Disallow header only blocks on RPC, relay and when requesting IBD full blocks (#1537) * Disallow header only blocks on RPC, relay and when requesting IBD full blocks (#1537)
[*] Make templateManager hold a DomainBlock and isSynced bool instead of a GetBlockTemplateResponseMessage (#1538) * Make templateManager hold a DomainBlock and isSynced bool instead of a GetBlockTemplateResponseMessage (#1538)

View File

@ -28,15 +28,14 @@ func balance(conf *balanceConfig) error {
if err != nil { if err != nil {
return err return err
} }
virtualSelectedParentBlueScoreResponse, err := client.GetVirtualSelectedParentBlueScore() blockDAGInfo, err := client.GetBlockDAGInfo()
if err != nil { if err != nil {
return err return err
} }
virtualSelectedParentBlueScore := virtualSelectedParentBlueScoreResponse.BlueScore
var availableBalance, pendingBalance uint64 var availableBalance, pendingBalance uint64
for _, entry := range getUTXOsByAddressesResponse.Entries { for _, entry := range getUTXOsByAddressesResponse.Entries {
if isUTXOSpendable(entry, virtualSelectedParentBlueScore, conf.ActiveNetParams.BlockCoinbaseMaturity) { if isUTXOSpendable(entry, blockDAGInfo.VirtualDAAScore, conf.ActiveNetParams.BlockCoinbaseMaturity) {
availableBalance += entry.UTXOEntry.Amount availableBalance += entry.UTXOEntry.Amount
} else { } else {
pendingBalance += entry.UTXOEntry.Amount pendingBalance += entry.UTXOEntry.Amount

View File

@ -8,13 +8,12 @@ import (
"os" "os"
) )
func isUTXOSpendable(entry *appmessage.UTXOsByAddressesEntry, virtualSelectedParentBlueScore uint64, coinbaseMaturity uint64) bool { func isUTXOSpendable(entry *appmessage.UTXOsByAddressesEntry, virtualDAAScore uint64, coinbaseMaturity uint64) bool {
if !entry.UTXOEntry.IsCoinbase { if !entry.UTXOEntry.IsCoinbase {
return true return true
} }
blockBlueScore := entry.UTXOEntry.BlockDAAScore blockBlueScore := entry.UTXOEntry.BlockDAAScore
// TODO: Check for a better alternative than virtualSelectedParentBlueScore return blockBlueScore+coinbaseMaturity < virtualDAAScore
return blockBlueScore+coinbaseMaturity < virtualSelectedParentBlueScore
} }
func printErrorAndExit(err error) { func printErrorAndExit(err error) {

View File

@ -96,15 +96,15 @@ func fetchSpendableUTXOs(params *dagconfig.Params, client *rpcclient.RPCClient,
if err != nil { if err != nil {
return nil, err return nil, err
} }
virtualSelectedParentBlueScoreResponse, err := client.GetVirtualSelectedParentBlueScore()
blockDAGInfo, err := client.GetBlockDAGInfo()
if err != nil { if err != nil {
return nil, err return nil, err
} }
virtualSelectedParentBlueScore := virtualSelectedParentBlueScoreResponse.BlueScore
spendableUTXOs := make([]*appmessage.UTXOsByAddressesEntry, 0) spendableUTXOs := make([]*appmessage.UTXOsByAddressesEntry, 0)
for _, entry := range getUTXOsByAddressesResponse.Entries { for _, entry := range getUTXOsByAddressesResponse.Entries {
if !isUTXOSpendable(entry, virtualSelectedParentBlueScore, params.BlockCoinbaseMaturity) { if !isUTXOSpendable(entry, blockDAGInfo.VirtualDAAScore, params.BlockCoinbaseMaturity) {
continue continue
} }
spendableUTXOs = append(spendableUTXOs, entry) spendableUTXOs = append(spendableUTXOs, entry)

View File

@ -112,6 +112,30 @@ func (s *consensus) GetBlock(blockHash *externalapi.DomainHash) (*externalapi.Do
return block, nil return block, nil
} }
func (s *consensus) GetBlockEvenIfHeaderOnly(blockHash *externalapi.DomainHash) (*externalapi.DomainBlock, error) {
s.lock.Lock()
defer s.lock.Unlock()
stagingArea := model.NewStagingArea()
block, err := s.blockStore.Block(s.databaseContext, stagingArea, blockHash)
if err == nil {
return block, nil
}
if !errors.Is(err, database.ErrNotFound) {
return nil, err
}
header, err := s.blockHeaderStore.BlockHeader(s.databaseContext, stagingArea, blockHash)
if err != nil {
if errors.Is(err, database.ErrNotFound) {
return nil, errors.Wrapf(err, "block %s does not exist", blockHash)
}
return nil, err
}
return &externalapi.DomainBlock{Header: header}, nil
}
func (s *consensus) GetBlockHeader(blockHash *externalapi.DomainHash) (externalapi.BlockHeader, error) { func (s *consensus) GetBlockHeader(blockHash *externalapi.DomainHash) (externalapi.BlockHeader, error) {
s.lock.Lock() s.lock.Lock()
defer s.lock.Unlock() defer s.lock.Unlock()
@ -202,7 +226,7 @@ func (s *consensus) GetBlockAcceptanceData(blockHash *externalapi.DomainHash) (e
return s.acceptanceDataStore.Get(s.databaseContext, stagingArea, blockHash) return s.acceptanceDataStore.Get(s.databaseContext, stagingArea, blockHash)
} }
func (s *consensus) GetHashesBetween(lowHash, highHash *externalapi.DomainHash, maxBlueScoreDifference uint64) ( func (s *consensus) GetHashesBetween(lowHash, highHash *externalapi.DomainHash, maxBlocks uint64) (
hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) { hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) {
s.lock.Lock() s.lock.Lock()
@ -219,7 +243,7 @@ func (s *consensus) GetHashesBetween(lowHash, highHash *externalapi.DomainHash,
return nil, nil, err return nil, nil, err
} }
return s.syncManager.GetHashesBetween(stagingArea, lowHash, highHash, maxBlueScoreDifference) return s.syncManager.GetHashesBetween(stagingArea, lowHash, highHash, maxBlocks)
} }
func (s *consensus) GetMissingBlockBodyHashes(highHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) { func (s *consensus) GetMissingBlockBodyHashes(highHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) {
@ -363,11 +387,17 @@ func (s *consensus) GetVirtualInfo() (*externalapi.VirtualInfo, error) {
return nil, err return nil, err
} }
daaScore, err := s.daaBlocksStore.DAAScore(s.databaseContext, stagingArea, model.VirtualBlockHash)
if err != nil {
return nil, err
}
return &externalapi.VirtualInfo{ return &externalapi.VirtualInfo{
ParentHashes: blockRelations.Parents, ParentHashes: blockRelations.Parents,
Bits: bits, Bits: bits,
PastMedianTime: pastMedianTime, PastMedianTime: pastMedianTime,
BlueScore: virtualGHOSTDAGData.BlueScore(), BlueScore: virtualGHOSTDAGData.BlueScore(),
DAAScore: daaScore,
}, nil }, nil
} }

View File

@ -314,6 +314,7 @@ func (f *factory) NewConsensus(config *Config, db infrastructuredatabase.Databas
syncManager := syncmanager.New( syncManager := syncmanager.New(
dbManager, dbManager,
genesisHash, genesisHash,
config.MergeSetSizeLimit,
dagTraversalManager, dagTraversalManager,
dagTopologyManager, dagTopologyManager,
ghostdagManager, ghostdagManager,

View File

@ -7,12 +7,13 @@ type Consensus interface {
ValidateTransactionAndPopulateWithConsensusData(transaction *DomainTransaction) error ValidateTransactionAndPopulateWithConsensusData(transaction *DomainTransaction) error
GetBlock(blockHash *DomainHash) (*DomainBlock, error) GetBlock(blockHash *DomainHash) (*DomainBlock, error)
GetBlockEvenIfHeaderOnly(blockHash *DomainHash) (*DomainBlock, error)
GetBlockHeader(blockHash *DomainHash) (BlockHeader, error) GetBlockHeader(blockHash *DomainHash) (BlockHeader, error)
GetBlockInfo(blockHash *DomainHash) (*BlockInfo, error) GetBlockInfo(blockHash *DomainHash) (*BlockInfo, error)
GetBlockRelations(blockHash *DomainHash) (parents []*DomainHash, selectedParent *DomainHash, children []*DomainHash, err error) GetBlockRelations(blockHash *DomainHash) (parents []*DomainHash, selectedParent *DomainHash, children []*DomainHash, err error)
GetBlockAcceptanceData(blockHash *DomainHash) (AcceptanceData, error) GetBlockAcceptanceData(blockHash *DomainHash) (AcceptanceData, error)
GetHashesBetween(lowHash, highHash *DomainHash, maxBlueScoreDifference uint64) (hashes []*DomainHash, actualHighHash *DomainHash, err error) GetHashesBetween(lowHash, highHash *DomainHash, maxBlocks uint64) (hashes []*DomainHash, actualHighHash *DomainHash, err error)
GetMissingBlockBodyHashes(highHash *DomainHash) ([]*DomainHash, error) GetMissingBlockBodyHashes(highHash *DomainHash) ([]*DomainHash, error)
GetPruningPointUTXOs(expectedPruningPointHash *DomainHash, fromOutpoint *DomainOutpoint, limit int) ([]*OutpointAndUTXOEntryPair, error) GetPruningPointUTXOs(expectedPruningPointHash *DomainHash, fromOutpoint *DomainOutpoint, limit int) ([]*OutpointAndUTXOEntryPair, error)
GetVirtualUTXOs(expectedVirtualParents []*DomainHash, fromOutpoint *DomainOutpoint, limit int) ([]*OutpointAndUTXOEntryPair, error) GetVirtualUTXOs(expectedVirtualParents []*DomainHash, fromOutpoint *DomainOutpoint, limit int) ([]*OutpointAndUTXOEntryPair, error)

View File

@ -6,4 +6,5 @@ type VirtualInfo struct {
Bits uint32 Bits uint32
PastMedianTime int64 PastMedianTime int64
BlueScore uint64 BlueScore uint64
DAAScore uint64
} }

View File

@ -4,7 +4,7 @@ import "github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
// SyncManager exposes functions to support sync between kaspad nodes // SyncManager exposes functions to support sync between kaspad nodes
type SyncManager interface { type SyncManager interface {
GetHashesBetween(stagingArea *StagingArea, lowHash, highHash *externalapi.DomainHash, maxBlueScoreDifference uint64) ( GetHashesBetween(stagingArea *StagingArea, lowHash, highHash *externalapi.DomainHash, maxBlocks uint64) (
hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error)
GetMissingBlockBodyHashes(stagingArea *StagingArea, highHash *externalapi.DomainHash) ( GetMissingBlockBodyHashes(stagingArea *StagingArea, highHash *externalapi.DomainHash) (
[]*externalapi.DomainHash, error) []*externalapi.DomainHash, error)

View File

@ -59,6 +59,22 @@ func (bp *blockProcessor) setBlockStatusAfterBlockValidation(
return nil return nil
} }
func (bp *blockProcessor) updateVirtualAcceptanceDataAfterImportingPruningPoint(stagingArea *model.StagingArea) error {
_, virtualAcceptanceData, virtualMultiset, err :=
bp.consensusStateManager.CalculatePastUTXOAndAcceptanceData(stagingArea, model.VirtualBlockHash)
if err != nil {
return err
}
log.Debugf("Staging virtual acceptance data after importing the pruning point")
bp.acceptanceDataStore.Stage(stagingArea, model.VirtualBlockHash, virtualAcceptanceData)
log.Debugf("Staging virtual multiset after importing the pruning point")
bp.multisetStore.Stage(stagingArea, model.VirtualBlockHash, virtualMultiset)
return nil
}
func (bp *blockProcessor) validateAndInsertBlock(stagingArea *model.StagingArea, block *externalapi.DomainBlock, func (bp *blockProcessor) validateAndInsertBlock(stagingArea *model.StagingArea, block *externalapi.DomainBlock,
isPruningPoint bool) (*externalapi.BlockInsertionResult, error) { isPruningPoint bool) (*externalapi.BlockInsertionResult, error) {
@ -102,6 +118,11 @@ func (bp *blockProcessor) validateAndInsertBlock(stagingArea *model.StagingArea,
if err != nil { if err != nil {
return nil, err return nil, err
} }
} else {
err := bp.updateVirtualAcceptanceDataAfterImportingPruningPoint(stagingArea)
if err != nil {
return nil, err
}
} }
} }

View File

@ -132,37 +132,37 @@ func TestBlockWindow(t *testing.T) {
{ {
parents: []string{"H", "F"}, parents: []string{"H", "F"},
id: "I", id: "I",
expectedWindow: []string{"F", "D", "H", "C", "G", "B"}, expectedWindow: []string{"F", "D", "C", "H", "G", "B"},
}, },
{ {
parents: []string{"I"}, parents: []string{"I"},
id: "J", id: "J",
expectedWindow: []string{"I", "F", "D", "H", "C", "G", "B"}, expectedWindow: []string{"I", "F", "D", "C", "H", "G", "B"},
}, },
{ {
parents: []string{"J"}, parents: []string{"J"},
id: "K", id: "K",
expectedWindow: []string{"J", "I", "F", "D", "H", "C", "G", "B"}, expectedWindow: []string{"J", "I", "F", "D", "C", "H", "G", "B"},
}, },
{ {
parents: []string{"K"}, parents: []string{"K"},
id: "L", id: "L",
expectedWindow: []string{"K", "J", "I", "F", "D", "H", "C", "G", "B"}, expectedWindow: []string{"K", "J", "I", "F", "D", "C", "H", "G", "B"},
}, },
{ {
parents: []string{"L"}, parents: []string{"L"},
id: "M", id: "M",
expectedWindow: []string{"L", "K", "J", "I", "F", "D", "H", "C", "G", "B"}, expectedWindow: []string{"L", "K", "J", "I", "F", "D", "C", "H", "G", "B"},
}, },
{ {
parents: []string{"M"}, parents: []string{"M"},
id: "N", id: "N",
expectedWindow: []string{"M", "L", "K", "J", "I", "F", "D", "H", "C", "G"}, expectedWindow: []string{"M", "L", "K", "J", "I", "F", "D", "C", "H", "G"},
}, },
{ {
parents: []string{"N"}, parents: []string{"N"},
id: "O", id: "O",
expectedWindow: []string{"N", "M", "L", "K", "J", "I", "F", "D", "H", "C"}, expectedWindow: []string{"N", "M", "L", "K", "J", "I", "F", "D", "C", "H"},
}, },
}, },
dagconfig.DevnetParams.Name: { dagconfig.DevnetParams.Name: {

View File

@ -7,11 +7,19 @@ import (
) )
// antiPastHashesBetween returns the hashes of the blocks between the // antiPastHashesBetween returns the hashes of the blocks between the
// lowHash's antiPast and highHash's antiPast, or up to // lowHash's antiPast and highHash's antiPast, or up to `maxBlocks`, if non-zero.
// `maxBlueScoreDifference`, if non-zero.
// The result excludes lowHash and includes highHash. If lowHash == highHash, returns nothing. // The result excludes lowHash and includes highHash. If lowHash == highHash, returns nothing.
// If maxBlocks != 0 then maxBlocks MUST be >= MergeSetSizeLimit + 1
// because it returns blocks with MergeSet granularity,
// so if MergeSet > maxBlocks, function will return nothing
func (sm *syncManager) antiPastHashesBetween(stagingArea *model.StagingArea, lowHash, highHash *externalapi.DomainHash, func (sm *syncManager) antiPastHashesBetween(stagingArea *model.StagingArea, lowHash, highHash *externalapi.DomainHash,
maxBlueScoreDifference uint64) (hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) { maxBlocks uint64) (hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) {
// Sanity check, for debugging only
if maxBlocks != 0 && maxBlocks < sm.mergeSetSizeLimit+1 {
return nil, nil,
errors.Errorf("maxBlocks (%d) MUST be >= MergeSetSizeLimit + 1 (%d)", maxBlocks, sm.mergeSetSizeLimit+1)
}
// If lowHash is not in the selectedParentChain of highHash - SelectedChildIterator will fail. // If lowHash is not in the selectedParentChain of highHash - SelectedChildIterator will fail.
// Therefore, we traverse down lowHash's selectedParentChain until we reach a block that is in // Therefore, we traverse down lowHash's selectedParentChain until we reach a block that is in
@ -36,23 +44,6 @@ func (sm *syncManager) antiPastHashesBetween(stagingArea *model.StagingArea, low
lowBlockGHOSTDAGData.BlueScore(), highBlockGHOSTDAGData.BlueScore()) lowBlockGHOSTDAGData.BlueScore(), highBlockGHOSTDAGData.BlueScore())
} }
if maxBlueScoreDifference != 0 {
// In order to get no more then maxBlueScoreDifference
// blocks from the future of the lowHash (including itself),
// we iterate the selected parent chain of the highNode and
// stop once we reach
// highBlockBlueScore-lowBlockBlueScore+1 <= maxBlueScoreDifference.
// That stop point becomes the new highHash.
// Using blueScore as an approximation is considered to be
// fairly accurate because we presume that most DAG blocks are
// blue.
highHash, err = sm.findHighHashAccordingToMaxBlueScoreDifference(stagingArea,
lowHash, highHash, maxBlueScoreDifference, highBlockGHOSTDAGData, lowBlockGHOSTDAGData)
if err != nil {
return nil, nil, err
}
}
// Collect all hashes by concatenating the merge-sets of all blocks between highHash and lowHash // Collect all hashes by concatenating the merge-sets of all blocks between highHash and lowHash
blockHashes := []*externalapi.DomainHash{} blockHashes := []*externalapi.DomainHash{}
iterator, err := sm.dagTraversalManager.SelectedChildIterator(stagingArea, highHash, lowHash) iterator, err := sm.dagTraversalManager.SelectedChildIterator(stagingArea, highHash, lowHash)
@ -76,6 +67,12 @@ func (sm *syncManager) antiPastHashesBetween(stagingArea *model.StagingArea, low
return nil, nil, err return nil, nil, err
} }
if maxBlocks != 0 && uint64(len(blockHashes)+len(sortedMergeSet)) > maxBlocks {
break
}
highHash = current
// append to blockHashes all blocks in sortedMergeSet which are not in the past of originalLowHash // append to blockHashes all blocks in sortedMergeSet which are not in the past of originalLowHash
for _, blockHash := range sortedMergeSet { for _, blockHash := range sortedMergeSet {
isInPastOfOriginalLowHash, err := sm.dagTopologyManager.IsAncestorOf(stagingArea, blockHash, originalLowHash) isInPastOfOriginalLowHash, err := sm.dagTopologyManager.IsAncestorOf(stagingArea, blockHash, originalLowHash)
@ -136,37 +133,6 @@ func (sm *syncManager) getSortedMergeSet(stagingArea *model.StagingArea, current
return sortedMergeSet, nil return sortedMergeSet, nil
} }
func (sm *syncManager) findHighHashAccordingToMaxBlueScoreDifference(stagingArea *model.StagingArea,
lowHash *externalapi.DomainHash, highHash *externalapi.DomainHash, maxBlueScoreDifference uint64,
highBlockGHOSTDAGData *model.BlockGHOSTDAGData, lowBlockGHOSTDAGData *model.BlockGHOSTDAGData) (
*externalapi.DomainHash, error) {
if highBlockGHOSTDAGData.BlueScore()-lowBlockGHOSTDAGData.BlueScore() <= maxBlueScoreDifference {
return highHash, nil
}
iterator, err := sm.dagTraversalManager.SelectedChildIterator(stagingArea, highHash, lowHash)
if err != nil {
return nil, err
}
defer iterator.Close()
for ok := iterator.First(); ok; ok = iterator.Next() {
highHashCandidate, err := iterator.Get()
if err != nil {
return nil, err
}
highBlockGHOSTDAGData, err = sm.ghostdagDataStore.Get(sm.databaseContext, stagingArea, highHashCandidate)
if err != nil {
return nil, err
}
if highBlockGHOSTDAGData.BlueScore()-lowBlockGHOSTDAGData.BlueScore() > maxBlueScoreDifference {
break
}
highHash = highHashCandidate
}
return highHash, nil
}
func (sm *syncManager) findLowHashInHighHashSelectedParentChain(stagingArea *model.StagingArea, func (sm *syncManager) findLowHashInHighHashSelectedParentChain(stagingArea *model.StagingArea,
lowHash *externalapi.DomainHash, highHash *externalapi.DomainHash) (*externalapi.DomainHash, error) { lowHash *externalapi.DomainHash, highHash *externalapi.DomainHash) (*externalapi.DomainHash, error) {
for { for {

View File

@ -21,12 +21,15 @@ type syncManager struct {
blockStore model.BlockStore blockStore model.BlockStore
pruningStore model.PruningStore pruningStore model.PruningStore
headersSelectedChainStore model.HeadersSelectedChainStore headersSelectedChainStore model.HeadersSelectedChainStore
mergeSetSizeLimit uint64
} }
// New instantiates a new SyncManager // New instantiates a new SyncManager
func New( func New(
databaseContext model.DBReader, databaseContext model.DBReader,
genesisBlockHash *externalapi.DomainHash, genesisBlockHash *externalapi.DomainHash,
mergeSetSizeLimit uint64,
dagTraversalManager model.DAGTraversalManager, dagTraversalManager model.DAGTraversalManager,
dagTopologyManager model.DAGTopologyManager, dagTopologyManager model.DAGTopologyManager,
ghostdagManager model.GHOSTDAGManager, ghostdagManager model.GHOSTDAGManager,
@ -58,12 +61,12 @@ func New(
} }
func (sm *syncManager) GetHashesBetween(stagingArea *model.StagingArea, lowHash, highHash *externalapi.DomainHash, func (sm *syncManager) GetHashesBetween(stagingArea *model.StagingArea, lowHash, highHash *externalapi.DomainHash,
maxBlueScoreDifference uint64) (hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) { maxBlocks uint64) (hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) {
onEnd := logger.LogAndMeasureExecutionTime(log, "GetHashesBetween") onEnd := logger.LogAndMeasureExecutionTime(log, "GetHashesBetween")
defer onEnd() defer onEnd()
return sm.antiPastHashesBetween(stagingArea, lowHash, highHash, maxBlueScoreDifference) return sm.antiPastHashesBetween(stagingArea, lowHash, highHash, maxBlocks)
} }
func (sm *syncManager) GetMissingBlockBodyHashes(stagingArea *model.StagingArea, highHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) { func (sm *syncManager) GetMissingBlockBodyHashes(stagingArea *model.StagingArea, highHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) {

View File

@ -68,8 +68,7 @@ func (v *transactionValidator) checkTransactionCoinbaseMaturity(stagingArea *mod
missingOutpoints = append(missingOutpoints, &input.PreviousOutpoint) missingOutpoints = append(missingOutpoints, &input.PreviousOutpoint)
} else if utxoEntry.IsCoinbase() { } else if utxoEntry.IsCoinbase() {
originDAAScore := utxoEntry.BlockDAAScore() originDAAScore := utxoEntry.BlockDAAScore()
daaScoreSincePrev := povDAAScore - originDAAScore if originDAAScore+v.blockCoinbaseMaturity > povDAAScore {
if daaScoreSincePrev < v.blockCoinbaseMaturity {
return errors.Wrapf(ruleerrors.ErrImmatureSpend, "tried to spend coinbase "+ return errors.Wrapf(ruleerrors.ErrImmatureSpend, "tried to spend coinbase "+
"transaction output %s from DAA score %d "+ "transaction output %s from DAA score %d "+
"to DAA score %d before required maturity "+ "to DAA score %d before required maturity "+
@ -266,7 +265,7 @@ func (v *transactionValidator) calcTxSequenceLockFromReferencedUTXOEntries(stagi
baseHash := povBlockHash baseHash := povBlockHash
for { for {
selectedParentDAAScore, err := v.daaBlocksStore.DAAScore(v.databaseContext, stagingArea, povBlockHash) selectedParentDAAScore, err := v.daaBlocksStore.DAAScore(v.databaseContext, stagingArea, baseHash)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -78,7 +78,17 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
true, true,
uint64(5)), uint64(5)),
} }
txInputWithMaxSequence := externalapi.DomainTransactionInput{ immatureInput := externalapi.DomainTransactionInput{
PreviousOutpoint: prevOutPoint,
SignatureScript: []byte{},
Sequence: constants.MaxTxInSequenceNum,
UTXOEntry: utxo.NewUTXOEntry(
100_000_000, // 1 KAS
scriptPublicKey,
true,
uint64(6)),
}
txInputWithSequenceLockTimeIsSeconds := externalapi.DomainTransactionInput{
PreviousOutpoint: prevOutPoint, PreviousOutpoint: prevOutPoint,
SignatureScript: []byte{}, SignatureScript: []byte{},
Sequence: constants.SequenceLockTimeIsSeconds, Sequence: constants.SequenceLockTimeIsSeconds,
@ -110,7 +120,7 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
validTx := externalapi.DomainTransaction{ validTx := externalapi.DomainTransaction{
Version: constants.MaxTransactionVersion, Version: constants.MaxTransactionVersion,
Inputs: []*externalapi.DomainTransactionInput{&txInputWithMaxSequence}, Inputs: []*externalapi.DomainTransactionInput{&txInputWithSequenceLockTimeIsSeconds},
Outputs: []*externalapi.DomainTransactionOutput{&txOut}, Outputs: []*externalapi.DomainTransactionOutput{&txOut},
SubnetworkID: subnetworks.SubnetworkIDRegistry, SubnetworkID: subnetworks.SubnetworkIDRegistry,
Gas: 0, Gas: 0,
@ -127,7 +137,7 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
txWithImmatureCoinbase := externalapi.DomainTransaction{ txWithImmatureCoinbase := externalapi.DomainTransaction{
Version: constants.MaxTransactionVersion, Version: constants.MaxTransactionVersion,
Inputs: []*externalapi.DomainTransactionInput{&txInput}, Inputs: []*externalapi.DomainTransactionInput{&immatureInput},
Outputs: []*externalapi.DomainTransactionOutput{&txOut}, Outputs: []*externalapi.DomainTransactionOutput{&txOut},
SubnetworkID: subnetworks.SubnetworkIDRegistry, SubnetworkID: subnetworks.SubnetworkIDRegistry,
Gas: 0, Gas: 0,
@ -158,7 +168,15 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
povBlockHash := externalapi.NewDomainHashFromByteArray(&[32]byte{0x01}) povBlockHash := externalapi.NewDomainHashFromByteArray(&[32]byte{0x01})
tc.DAABlocksStore().StageDAAScore(stagingArea, povBlockHash, consensusConfig.BlockCoinbaseMaturity+txInput.UTXOEntry.BlockDAAScore()) tc.DAABlocksStore().StageDAAScore(stagingArea, povBlockHash, consensusConfig.BlockCoinbaseMaturity+txInput.UTXOEntry.BlockDAAScore())
tc.DAABlocksStore().StageDAAScore(stagingArea, povBlockHash, 10)
// Just use some stub ghostdag data
tc.GHOSTDAGDataStore().Stage(stagingArea, povBlockHash, model.NewBlockGHOSTDAGData(
0,
nil,
consensusConfig.GenesisHash,
nil,
nil,
nil))
tests := []struct { tests := []struct {
name string name string
@ -171,7 +189,7 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
{ {
name: "Valid transaction", name: "Valid transaction",
tx: &validTx, tx: &validTx,
povBlockHash: model.VirtualBlockHash, povBlockHash: povBlockHash,
selectedParentMedianTime: 1, selectedParentMedianTime: 1,
isValid: true, isValid: true,
expectedError: nil, expectedError: nil,
@ -189,7 +207,7 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
{ // The total inputs amount is bigger than the allowed maximum (constants.MaxSompi) { // The total inputs amount is bigger than the allowed maximum (constants.MaxSompi)
name: "checkTransactionInputAmounts", name: "checkTransactionInputAmounts",
tx: &txWithLargeAmount, tx: &txWithLargeAmount,
povBlockHash: model.VirtualBlockHash, povBlockHash: povBlockHash,
selectedParentMedianTime: 1, selectedParentMedianTime: 1,
isValid: false, isValid: false,
expectedError: ruleerrors.ErrBadTxOutValue, expectedError: ruleerrors.ErrBadTxOutValue,
@ -197,7 +215,7 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
{ // The total SompiIn (sum of inputs amount) is smaller than the total SompiOut (sum of outputs value) and hence invalid. { // The total SompiIn (sum of inputs amount) is smaller than the total SompiOut (sum of outputs value) and hence invalid.
name: "checkTransactionOutputAmounts", name: "checkTransactionOutputAmounts",
tx: &txWithBigValue, tx: &txWithBigValue,
povBlockHash: model.VirtualBlockHash, povBlockHash: povBlockHash,
selectedParentMedianTime: 1, selectedParentMedianTime: 1,
isValid: false, isValid: false,
expectedError: ruleerrors.ErrSpendTooHigh, expectedError: ruleerrors.ErrSpendTooHigh,
@ -205,15 +223,15 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
{ // the selectedParentMedianTime is negative and hence invalid. { // the selectedParentMedianTime is negative and hence invalid.
name: "checkTransactionSequenceLock", name: "checkTransactionSequenceLock",
tx: &validTx, tx: &validTx,
povBlockHash: model.VirtualBlockHash, povBlockHash: povBlockHash,
selectedParentMedianTime: -1, selectedParentMedianTime: -1,
isValid: false, isValid: false,
expectedError: ruleerrors.ErrUnfinalizedTx, expectedError: ruleerrors.ErrUnfinalizedTx,
}, },
{ // The SignatureScript (in the txInput) is empty and hence invalid. { // The SignatureScript (in the immatureInput) is empty and hence invalid.
name: "checkTransactionScripts", name: "checkTransactionScripts",
tx: &txWithInvalidSignature, tx: &txWithInvalidSignature,
povBlockHash: model.VirtualBlockHash, povBlockHash: povBlockHash,
selectedParentMedianTime: 1, selectedParentMedianTime: 1,
isValid: false, isValid: false,
expectedError: ruleerrors.ErrScriptValidation, expectedError: ruleerrors.ErrScriptValidation,
@ -226,7 +244,7 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
if test.isValid { if test.isValid {
if err != nil { if err != nil {
t.Fatalf("Unexpected error on TestValidateTransactionInContextAndPopulateMassAndFee"+ t.Fatalf("Unexpected error on TestValidateTransactionInContextAndPopulateMassAndFee"+
" on test '%v': %v", test.name, err) " on test '%v': %+v", test.name, err)
} }
} else { } else {
if err == nil || !errors.Is(err, test.expectedError) { if err == nil || !errors.Is(err, test.expectedError) {

View File

@ -177,10 +177,10 @@ var testnetGenesisCoinbaseTx = transactionhelper.NewSubnetworkTransaction(0,
// testnetGenesisHash is the hash of the first block in the block DAG for the test // testnetGenesisHash is the hash of the first block in the block DAG for the test
// network (genesis block). // network (genesis block).
var testnetGenesisHash = externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{ var testnetGenesisHash = externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{
0x8f, 0x83, 0xf5, 0x33, 0x77, 0xa4, 0x80, 0xa7, 0xac, 0x23, 0xff, 0xc3, 0x85, 0xd3, 0x88, 0x99,
0x93, 0xf3, 0x17, 0xee, 0x3e, 0x8f, 0xf5, 0xaf, 0xfd, 0xb8, 0x83, 0x30, 0x80, 0x3a, 0x3d, 0xbf,
0x16, 0x6d, 0x87, 0x1d, 0x54, 0xfd, 0xe7, 0x79, 0xf7, 0x9b, 0x96, 0x9e, 0x4c, 0xd5, 0x1b, 0xf0,
0xa2, 0xab, 0x6f, 0xc3, 0x76, 0x60, 0xc3, 0x64, 0x0e, 0x77, 0xb6, 0x87, 0x70, 0xaa, 0x4e, 0x1f,
}) })
// testnetGenesisMerkleRoot is the hash of the first transaction in the genesis block // testnetGenesisMerkleRoot is the hash of the first transaction in the genesis block
@ -201,9 +201,9 @@ var testnetGenesisBlock = externalapi.DomainBlock{
testnetGenesisMerkleRoot, testnetGenesisMerkleRoot,
&externalapi.DomainHash{}, &externalapi.DomainHash{},
externalapi.NewDomainHashFromByteArray(muhash.EmptyMuHashHash.AsArray()), externalapi.NewDomainHashFromByteArray(muhash.EmptyMuHashHash.AsArray()),
0x177bfd44a10, 0x178547bee50,
0x1e7fffff, 0x1e7fffff,
0x64d74, 0x2de70,
), ),
Transactions: []*externalapi.DomainTransaction{testnetGenesisCoinbaseTx}, Transactions: []*externalapi.DomainTransaction{testnetGenesisCoinbaseTx},
} }

View File

@ -256,11 +256,11 @@ var MainnetParams = Params{
// TestnetParams defines the network parameters for the test Kaspa network. // TestnetParams defines the network parameters for the test Kaspa network.
var TestnetParams = Params{ var TestnetParams = Params{
K: defaultGHOSTDAGK, K: defaultGHOSTDAGK,
Name: "kaspa-testnet-2", Name: "kaspa-testnet-5",
Net: appmessage.Testnet, Net: appmessage.Testnet,
RPCPort: "16210", RPCPort: "16210",
DefaultPort: "16211", DefaultPort: "16211",
DNSSeeds: []string{"testnet-2-dnsseed.daglabs-dev.com"}, DNSSeeds: []string{"testnet-5-dnsseed.daglabs-dev.com"},
// DAG parameters // DAG parameters
GenesisBlock: &testnetGenesisBlock, GenesisBlock: &testnetGenesisBlock,

View File

@ -49,6 +49,7 @@ const (
RejectInsufficientFee RejectCode = 0x42 RejectInsufficientFee RejectCode = 0x42
RejectFinality RejectCode = 0x43 RejectFinality RejectCode = 0x43
RejectDifficulty RejectCode = 0x44 RejectDifficulty RejectCode = 0x44
RejectImmatureSpend RejectCode = 0x45
) )
// Map of reject codes back strings for pretty printing. // Map of reject codes back strings for pretty printing.
@ -63,6 +64,7 @@ var rejectCodeStrings = map[RejectCode]string{
RejectFinality: "REJECT_FINALITY", RejectFinality: "REJECT_FINALITY",
RejectDifficulty: "REJECT_DIFFICULTY", RejectDifficulty: "REJECT_DIFFICULTY",
RejectNotRequested: "REJECT_NOTREQUESTED", RejectNotRequested: "REJECT_NOTREQUESTED",
RejectImmatureSpend: "REJECT_IMMATURESPEND",
} }
// String returns the RejectCode in human-readable form. // String returns the RejectCode in human-readable form.

View File

@ -720,6 +720,9 @@ func (mp *mempool) maybeAcceptTransaction(tx *consensusexternalapi.DomainTransac
if errors.As(err, &missingOutpoints) { if errors.As(err, &missingOutpoints) {
return missingOutpoints.MissingOutpoints, nil, nil return missingOutpoints.MissingOutpoints, nil, nil
} }
if errors.Is(err, ruleerrors.ErrImmatureSpend) {
return nil, nil, txRuleError(RejectImmatureSpend, "one of the transaction inputs spends an immature UTXO")
}
if errors.As(err, &ruleerrors.RuleError{}) { if errors.As(err, &ruleerrors.RuleError{}) {
return nil, nil, newRuleError(err) return nil, nil, newRuleError(err)
} }

View File

@ -1,6 +1,7 @@
package miningmanager_test package miningmanager_test
import ( import (
"github.com/kaspanet/kaspad/domain/miningmanager/mempool"
"strings" "strings"
"testing" "testing"
@ -70,11 +71,35 @@ func TestValidateAndInsertTransaction(t *testing.T) {
}) })
} }
func TestImmatureSpend(t *testing.T) {
testutils.ForAllNets(t, true, func(t *testing.T, consensusConfig *consensus.Config) {
factory := consensus.NewFactory()
tc, teardown, err := factory.NewTestConsensus(consensusConfig, "TestValidateAndInsertTransaction")
if err != nil {
t.Fatalf("Error setting up TestConsensus: %+v", err)
}
defer teardown(false)
miningFactory := miningmanager.NewFactory()
miningManager := miningFactory.NewMiningManager(tc, &consensusConfig.Params)
tx := createTransactionWithUTXOEntry(t, 0)
err = miningManager.ValidateAndInsertTransaction(tx, false)
txRuleError := &mempool.TxRuleError{}
if !errors.As(err, txRuleError) || txRuleError.RejectCode != mempool.RejectImmatureSpend {
t.Fatalf("Unexpected error %+v", err)
}
transactionsFromMempool := miningManager.AllTransactions()
if contains(tx, transactionsFromMempool) {
t.Fatalf("Mempool contains a transaction with immature coinbase")
}
})
}
// TestInsertDoubleTransactionsToMempool verifies that an attempt to insert a transaction // TestInsertDoubleTransactionsToMempool verifies that an attempt to insert a transaction
// more than once into the mempool will result in raising an appropriate error. // more than once into the mempool will result in raising an appropriate error.
func TestInsertDoubleTransactionsToMempool(t *testing.T) { func TestInsertDoubleTransactionsToMempool(t *testing.T) {
testutils.ForAllNets(t, true, func(t *testing.T, consensusConfig *consensus.Config) { testutils.ForAllNets(t, true, func(t *testing.T, consensusConfig *consensus.Config) {
consensusConfig.BlockCoinbaseMaturity = 0
factory := consensus.NewFactory() factory := consensus.NewFactory()
tc, teardown, err := factory.NewTestConsensus(consensusConfig, "TestInsertDoubleTransactionsToMempool") tc, teardown, err := factory.NewTestConsensus(consensusConfig, "TestInsertDoubleTransactionsToMempool")
if err != nil { if err != nil {
@ -99,7 +124,7 @@ func TestInsertDoubleTransactionsToMempool(t *testing.T) {
// TestHandleNewBlockTransactions verifies that all the transactions in the block were successfully removed from the mempool. // TestHandleNewBlockTransactions verifies that all the transactions in the block were successfully removed from the mempool.
func TestHandleNewBlockTransactions(t *testing.T) { func TestHandleNewBlockTransactions(t *testing.T) {
testutils.ForAllNets(t, true, func(t *testing.T, consensusConfig *consensus.Config) { testutils.ForAllNets(t, true, func(t *testing.T, consensusConfig *consensus.Config) {
consensusConfig.BlockCoinbaseMaturity = 0
factory := consensus.NewFactory() factory := consensus.NewFactory()
tc, teardown, err := factory.NewTestConsensus(consensusConfig, "TestHandleNewBlockTransactions") tc, teardown, err := factory.NewTestConsensus(consensusConfig, "TestHandleNewBlockTransactions")
if err != nil { if err != nil {
@ -165,7 +190,7 @@ func domainBlocksToBlockIds(blocks []*externalapi.DomainTransaction) []*external
// will be removed from the mempool. // will be removed from the mempool.
func TestDoubleSpends(t *testing.T) { func TestDoubleSpends(t *testing.T) {
testutils.ForAllNets(t, true, func(t *testing.T, consensusConfig *consensus.Config) { testutils.ForAllNets(t, true, func(t *testing.T, consensusConfig *consensus.Config) {
consensusConfig.BlockCoinbaseMaturity = 0
factory := consensus.NewFactory() factory := consensus.NewFactory()
tc, teardown, err := factory.NewTestConsensus(consensusConfig, "TestDoubleSpends") tc, teardown, err := factory.NewTestConsensus(consensusConfig, "TestDoubleSpends")
if err != nil { if err != nil {
@ -309,7 +334,7 @@ func createTransactionWithUTXOEntry(t *testing.T, i int) *externalapi.DomainTran
100000000, // 1 KAS 100000000, // 1 KAS
scriptPublicKey, scriptPublicKey,
true, true,
uint64(5)), uint64(0)),
} }
txOut := externalapi.DomainTransactionOutput{ txOut := externalapi.DomainTransactionOutput{
Value: 10000, Value: 10000,

View File

@ -243,7 +243,7 @@ func (as *addressStore) serializeAddress(address *address) []byte {
serializedSize := 16 + 2 + 8 + 8 // ipv6 + port + timestamp + connectionFailedCount serializedSize := 16 + 2 + 8 + 8 // ipv6 + port + timestamp + connectionFailedCount
serializedNetAddress := make([]byte, serializedSize) serializedNetAddress := make([]byte, serializedSize)
copy(serializedNetAddress[:], address.netAddress.IP[:]) copy(serializedNetAddress[:], address.netAddress.IP.To16()[:])
binary.LittleEndian.PutUint16(serializedNetAddress[16:], address.netAddress.Port) binary.LittleEndian.PutUint16(serializedNetAddress[16:], address.netAddress.Port)
binary.LittleEndian.PutUint64(serializedNetAddress[18:], uint64(address.netAddress.Timestamp.UnixMilliseconds())) binary.LittleEndian.PutUint64(serializedNetAddress[18:], uint64(address.netAddress.Timestamp.UnixMilliseconds()))
binary.LittleEndian.PutUint64(serializedNetAddress[26:], uint64(address.connectionFailedCount)) binary.LittleEndian.PutUint64(serializedNetAddress[26:], uint64(address.connectionFailedCount))

View File

@ -1,13 +1,12 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.25.0 // protoc-gen-go v1.26.0
// protoc v3.12.3 // protoc v3.12.3
// source: messages.proto // source: messages.proto
package protowire package protowire
import ( import (
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect" reflect "reflect"
@ -21,10 +20,6 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type KaspadMessage struct { type KaspadMessage struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -134,6 +129,9 @@ type KaspadMessage struct {
// *KaspadMessage_PruningPointUTXOSetOverrideNotification // *KaspadMessage_PruningPointUTXOSetOverrideNotification
// *KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest // *KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest
// *KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse // *KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse
// *KaspadMessage_NotifyVirtualDaaScoreChangedRequest
// *KaspadMessage_NotifyVirtualDaaScoreChangedResponse
// *KaspadMessage_VirtualDaaScoreChangedNotification
Payload isKaspadMessage_Payload `protobuf_oneof:"payload"` Payload isKaspadMessage_Payload `protobuf_oneof:"payload"`
} }
@ -897,6 +895,27 @@ func (x *KaspadMessage) GetStopNotifyingPruningPointUTXOSetOverrideResponse() *S
return nil return nil
} }
func (x *KaspadMessage) GetNotifyVirtualDaaScoreChangedRequest() *NotifyVirtualDaaScoreChangedRequestMessage {
if x, ok := x.GetPayload().(*KaspadMessage_NotifyVirtualDaaScoreChangedRequest); ok {
return x.NotifyVirtualDaaScoreChangedRequest
}
return nil
}
func (x *KaspadMessage) GetNotifyVirtualDaaScoreChangedResponse() *NotifyVirtualDaaScoreChangedResponseMessage {
if x, ok := x.GetPayload().(*KaspadMessage_NotifyVirtualDaaScoreChangedResponse); ok {
return x.NotifyVirtualDaaScoreChangedResponse
}
return nil
}
func (x *KaspadMessage) GetVirtualDaaScoreChangedNotification() *VirtualDaaScoreChangedNotificationMessage {
if x, ok := x.GetPayload().(*KaspadMessage_VirtualDaaScoreChangedNotification); ok {
return x.VirtualDaaScoreChangedNotification
}
return nil
}
type isKaspadMessage_Payload interface { type isKaspadMessage_Payload interface {
isKaspadMessage_Payload() isKaspadMessage_Payload()
} }
@ -1313,6 +1332,18 @@ type KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse struct {
StopNotifyingPruningPointUTXOSetOverrideResponse *StopNotifyingPruningPointUTXOSetOverrideResponseMessage `protobuf:"bytes,1071,opt,name=stopNotifyingPruningPointUTXOSetOverrideResponse,proto3,oneof"` StopNotifyingPruningPointUTXOSetOverrideResponse *StopNotifyingPruningPointUTXOSetOverrideResponseMessage `protobuf:"bytes,1071,opt,name=stopNotifyingPruningPointUTXOSetOverrideResponse,proto3,oneof"`
} }
type KaspadMessage_NotifyVirtualDaaScoreChangedRequest struct {
NotifyVirtualDaaScoreChangedRequest *NotifyVirtualDaaScoreChangedRequestMessage `protobuf:"bytes,1072,opt,name=notifyVirtualDaaScoreChangedRequest,proto3,oneof"`
}
type KaspadMessage_NotifyVirtualDaaScoreChangedResponse struct {
NotifyVirtualDaaScoreChangedResponse *NotifyVirtualDaaScoreChangedResponseMessage `protobuf:"bytes,1073,opt,name=notifyVirtualDaaScoreChangedResponse,proto3,oneof"`
}
type KaspadMessage_VirtualDaaScoreChangedNotification struct {
VirtualDaaScoreChangedNotification *VirtualDaaScoreChangedNotificationMessage `protobuf:"bytes,1074,opt,name=virtualDaaScoreChangedNotification,proto3,oneof"`
}
func (*KaspadMessage_Addresses) isKaspadMessage_Payload() {} func (*KaspadMessage_Addresses) isKaspadMessage_Payload() {}
func (*KaspadMessage_Block) isKaspadMessage_Payload() {} func (*KaspadMessage_Block) isKaspadMessage_Payload() {}
@ -1519,13 +1550,19 @@ func (*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest) isKaspadMe
func (*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse) isKaspadMessage_Payload() {} func (*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse) isKaspadMessage_Payload() {}
func (*KaspadMessage_NotifyVirtualDaaScoreChangedRequest) isKaspadMessage_Payload() {}
func (*KaspadMessage_NotifyVirtualDaaScoreChangedResponse) isKaspadMessage_Payload() {}
func (*KaspadMessage_VirtualDaaScoreChangedNotification) isKaspadMessage_Payload() {}
var File_messages_proto protoreflect.FileDescriptor var File_messages_proto protoreflect.FileDescriptor
var file_messages_proto_rawDesc = []byte{ var file_messages_proto_rawDesc = []byte{
0x0a, 0x0e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x0a, 0x0e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x1a, 0x09, 0x70, 0x32, 0x70, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x1a, 0x09, 0x70, 0x32, 0x70,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x09, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x09, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x22, 0xa4, 0x55, 0x0a, 0x0d, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x6f, 0x22, 0xcb, 0x58, 0x0a, 0x0d, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x12, 0x3b, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3b, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69,
0x72, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x4d, 0x65, 0x73, 0x73, 0x72, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x4d, 0x65, 0x73, 0x73,
@ -2206,21 +2243,48 @@ var file_messages_proto_rawDesc = []byte{
0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x30, 0x73, 0x74, 0x6f, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x30, 0x73, 0x74, 0x6f,
0x70, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, 0x70, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e,
0x67, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x55, 0x54, 0x58, 0x4f, 0x53, 0x65, 0x74, 0x4f, 0x76, 0x65, 0x67, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x55, 0x54, 0x58, 0x4f, 0x53, 0x65, 0x74, 0x4f, 0x76, 0x65,
0x72, 0x72, 0x69, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x09, 0x0a, 0x72, 0x72, 0x69, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x8a, 0x01,
0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x32, 0x50, 0x0a, 0x03, 0x50, 0x32, 0x50, 0x12, 0x0a, 0x23, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x56, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x44,
0x49, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x61, 0x61, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x52, 0x65,
0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0xb0, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x70,
0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x56,
0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x68,
0x73, 0x61, 0x67, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x32, 0x50, 0x0a, 0x03, 0x52, 0x50, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73,
0x43, 0x12, 0x49, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x23, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x56, 0x69, 0x72,
0x61, 0x6d, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x61, 0x6e,
0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x18, 0x2e, 0x70, 0x67, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x8d, 0x01, 0x0a, 0x24, 0x6e,
0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x56, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53,
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x26, 0x5a, 0x24, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x6e, 0x73, 0x65, 0x18, 0xb1, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x70, 0x72, 0x6f,
0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x56, 0x69, 0x72,
0x77, 0x69, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x61, 0x6e,
0x67, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x48, 0x00, 0x52, 0x24, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x56, 0x69, 0x72, 0x74,
0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67,
0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x87, 0x01, 0x0a, 0x22, 0x76,
0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x68,
0x61, 0x6e, 0x67, 0x65, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x18, 0xb2, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x77, 0x69, 0x72, 0x65, 0x2e, 0x56, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53,
0x63, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66,
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00,
0x52, 0x22, 0x76, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53, 0x63, 0x6f, 0x72,
0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 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, 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, 0x32, 0x50, 0x0a, 0x03, 0x52, 0x50, 0x43, 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, 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 ( var (
@ -2340,6 +2404,9 @@ var file_messages_proto_goTypes = []interface{}{
(*PruningPointUTXOSetOverrideNotificationMessage)(nil), // 100: protowire.PruningPointUTXOSetOverrideNotificationMessage (*PruningPointUTXOSetOverrideNotificationMessage)(nil), // 100: protowire.PruningPointUTXOSetOverrideNotificationMessage
(*StopNotifyingPruningPointUTXOSetOverrideRequestMessage)(nil), // 101: protowire.StopNotifyingPruningPointUTXOSetOverrideRequestMessage (*StopNotifyingPruningPointUTXOSetOverrideRequestMessage)(nil), // 101: protowire.StopNotifyingPruningPointUTXOSetOverrideRequestMessage
(*StopNotifyingPruningPointUTXOSetOverrideResponseMessage)(nil), // 102: protowire.StopNotifyingPruningPointUTXOSetOverrideResponseMessage (*StopNotifyingPruningPointUTXOSetOverrideResponseMessage)(nil), // 102: protowire.StopNotifyingPruningPointUTXOSetOverrideResponseMessage
(*NotifyVirtualDaaScoreChangedRequestMessage)(nil), // 103: protowire.NotifyVirtualDaaScoreChangedRequestMessage
(*NotifyVirtualDaaScoreChangedResponseMessage)(nil), // 104: protowire.NotifyVirtualDaaScoreChangedResponseMessage
(*VirtualDaaScoreChangedNotificationMessage)(nil), // 105: protowire.VirtualDaaScoreChangedNotificationMessage
} }
var file_messages_proto_depIdxs = []int32{ var file_messages_proto_depIdxs = []int32{
1, // 0: protowire.KaspadMessage.addresses:type_name -> protowire.AddressesMessage 1, // 0: protowire.KaspadMessage.addresses:type_name -> protowire.AddressesMessage
@ -2445,15 +2512,18 @@ var file_messages_proto_depIdxs = []int32{
100, // 100: protowire.KaspadMessage.pruningPointUTXOSetOverrideNotification:type_name -> protowire.PruningPointUTXOSetOverrideNotificationMessage 100, // 100: protowire.KaspadMessage.pruningPointUTXOSetOverrideNotification:type_name -> protowire.PruningPointUTXOSetOverrideNotificationMessage
101, // 101: protowire.KaspadMessage.stopNotifyingPruningPointUTXOSetOverrideRequest:type_name -> protowire.StopNotifyingPruningPointUTXOSetOverrideRequestMessage 101, // 101: protowire.KaspadMessage.stopNotifyingPruningPointUTXOSetOverrideRequest:type_name -> protowire.StopNotifyingPruningPointUTXOSetOverrideRequestMessage
102, // 102: protowire.KaspadMessage.stopNotifyingPruningPointUTXOSetOverrideResponse:type_name -> protowire.StopNotifyingPruningPointUTXOSetOverrideResponseMessage 102, // 102: protowire.KaspadMessage.stopNotifyingPruningPointUTXOSetOverrideResponse:type_name -> protowire.StopNotifyingPruningPointUTXOSetOverrideResponseMessage
0, // 103: protowire.P2P.MessageStream:input_type -> protowire.KaspadMessage 103, // 103: protowire.KaspadMessage.notifyVirtualDaaScoreChangedRequest:type_name -> protowire.NotifyVirtualDaaScoreChangedRequestMessage
0, // 104: protowire.RPC.MessageStream:input_type -> protowire.KaspadMessage 104, // 104: protowire.KaspadMessage.notifyVirtualDaaScoreChangedResponse:type_name -> protowire.NotifyVirtualDaaScoreChangedResponseMessage
0, // 105: protowire.P2P.MessageStream:output_type -> protowire.KaspadMessage 105, // 105: protowire.KaspadMessage.virtualDaaScoreChangedNotification:type_name -> protowire.VirtualDaaScoreChangedNotificationMessage
0, // 106: protowire.RPC.MessageStream:output_type -> protowire.KaspadMessage 0, // 106: protowire.P2P.MessageStream:input_type -> protowire.KaspadMessage
105, // [105:107] is the sub-list for method output_type 0, // 107: protowire.RPC.MessageStream:input_type -> protowire.KaspadMessage
103, // [103:105] is the sub-list for method input_type 0, // 108: protowire.P2P.MessageStream:output_type -> protowire.KaspadMessage
103, // [103:103] is the sub-list for extension type_name 0, // 109: protowire.RPC.MessageStream:output_type -> protowire.KaspadMessage
103, // [103:103] is the sub-list for extension extendee 108, // [108:110] is the sub-list for method output_type
0, // [0:103] is the sub-list for field type_name 106, // [106:108] is the sub-list for method input_type
106, // [106:106] is the sub-list for extension type_name
106, // [106:106] is the sub-list for extension extendee
0, // [0:106] is the sub-list for field type_name
} }
func init() { file_messages_proto_init() } func init() { file_messages_proto_init() }
@ -2581,6 +2651,9 @@ func file_messages_proto_init() {
(*KaspadMessage_PruningPointUTXOSetOverrideNotification)(nil), (*KaspadMessage_PruningPointUTXOSetOverrideNotification)(nil),
(*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest)(nil), (*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest)(nil),
(*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse)(nil), (*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse)(nil),
(*KaspadMessage_NotifyVirtualDaaScoreChangedRequest)(nil),
(*KaspadMessage_NotifyVirtualDaaScoreChangedResponse)(nil),
(*KaspadMessage_VirtualDaaScoreChangedNotification)(nil),
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{

View File

@ -112,6 +112,9 @@ message KaspadMessage {
PruningPointUTXOSetOverrideNotificationMessage pruningPointUTXOSetOverrideNotification = 1069; PruningPointUTXOSetOverrideNotificationMessage pruningPointUTXOSetOverrideNotification = 1069;
StopNotifyingPruningPointUTXOSetOverrideRequestMessage stopNotifyingPruningPointUTXOSetOverrideRequest = 1070; StopNotifyingPruningPointUTXOSetOverrideRequestMessage stopNotifyingPruningPointUTXOSetOverrideRequest = 1070;
StopNotifyingPruningPointUTXOSetOverrideResponseMessage stopNotifyingPruningPointUTXOSetOverrideResponse = 1071; StopNotifyingPruningPointUTXOSetOverrideResponseMessage stopNotifyingPruningPointUTXOSetOverrideResponse = 1071;
NotifyVirtualDaaScoreChangedRequestMessage notifyVirtualDaaScoreChangedRequest = 1072;
NotifyVirtualDaaScoreChangedResponseMessage notifyVirtualDaaScoreChangedResponse = 1073;
VirtualDaaScoreChangedNotificationMessage virtualDaaScoreChangedNotification = 1074;
} }
} }

View File

@ -11,7 +11,8 @@ import (
// This is a compile-time assertion to ensure that this generated file // This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against. // is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6 // Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// P2PClient is the client API for P2P service. // P2PClient is the client API for P2P service.
// //
@ -29,7 +30,7 @@ func NewP2PClient(cc grpc.ClientConnInterface) P2PClient {
} }
func (c *p2PClient) MessageStream(ctx context.Context, opts ...grpc.CallOption) (P2P_MessageStreamClient, error) { func (c *p2PClient) MessageStream(ctx context.Context, opts ...grpc.CallOption) (P2P_MessageStreamClient, error) {
stream, err := c.cc.NewStream(ctx, &_P2P_serviceDesc.Streams[0], "/protowire.P2P/MessageStream", opts...) stream, err := c.cc.NewStream(ctx, &P2P_ServiceDesc.Streams[0], "/protowire.P2P/MessageStream", opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -71,13 +72,20 @@ type P2PServer interface {
type UnimplementedP2PServer struct { type UnimplementedP2PServer struct {
} }
func (*UnimplementedP2PServer) MessageStream(P2P_MessageStreamServer) error { func (UnimplementedP2PServer) MessageStream(P2P_MessageStreamServer) error {
return status.Errorf(codes.Unimplemented, "method MessageStream not implemented") return status.Errorf(codes.Unimplemented, "method MessageStream not implemented")
} }
func (*UnimplementedP2PServer) mustEmbedUnimplementedP2PServer() {} func (UnimplementedP2PServer) mustEmbedUnimplementedP2PServer() {}
func RegisterP2PServer(s *grpc.Server, srv P2PServer) { // UnsafeP2PServer may be embedded to opt out of forward compatibility for this service.
s.RegisterService(&_P2P_serviceDesc, srv) // Use of this interface is not recommended, as added methods to P2PServer will
// result in compilation errors.
type UnsafeP2PServer interface {
mustEmbedUnimplementedP2PServer()
}
func RegisterP2PServer(s grpc.ServiceRegistrar, srv P2PServer) {
s.RegisterService(&P2P_ServiceDesc, srv)
} }
func _P2P_MessageStream_Handler(srv interface{}, stream grpc.ServerStream) error { func _P2P_MessageStream_Handler(srv interface{}, stream grpc.ServerStream) error {
@ -106,7 +114,10 @@ func (x *p2PMessageStreamServer) Recv() (*KaspadMessage, error) {
return m, nil return m, nil
} }
var _P2P_serviceDesc = grpc.ServiceDesc{ // P2P_ServiceDesc is the grpc.ServiceDesc for P2P service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var P2P_ServiceDesc = grpc.ServiceDesc{
ServiceName: "protowire.P2P", ServiceName: "protowire.P2P",
HandlerType: (*P2PServer)(nil), HandlerType: (*P2PServer)(nil),
Methods: []grpc.MethodDesc{}, Methods: []grpc.MethodDesc{},
@ -137,7 +148,7 @@ func NewRPCClient(cc grpc.ClientConnInterface) RPCClient {
} }
func (c *rPCClient) MessageStream(ctx context.Context, opts ...grpc.CallOption) (RPC_MessageStreamClient, error) { func (c *rPCClient) MessageStream(ctx context.Context, opts ...grpc.CallOption) (RPC_MessageStreamClient, error) {
stream, err := c.cc.NewStream(ctx, &_RPC_serviceDesc.Streams[0], "/protowire.RPC/MessageStream", opts...) stream, err := c.cc.NewStream(ctx, &RPC_ServiceDesc.Streams[0], "/protowire.RPC/MessageStream", opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -179,13 +190,20 @@ type RPCServer interface {
type UnimplementedRPCServer struct { type UnimplementedRPCServer struct {
} }
func (*UnimplementedRPCServer) MessageStream(RPC_MessageStreamServer) error { func (UnimplementedRPCServer) MessageStream(RPC_MessageStreamServer) error {
return status.Errorf(codes.Unimplemented, "method MessageStream not implemented") return status.Errorf(codes.Unimplemented, "method MessageStream not implemented")
} }
func (*UnimplementedRPCServer) mustEmbedUnimplementedRPCServer() {} func (UnimplementedRPCServer) mustEmbedUnimplementedRPCServer() {}
func RegisterRPCServer(s *grpc.Server, srv RPCServer) { // UnsafeRPCServer may be embedded to opt out of forward compatibility for this service.
s.RegisterService(&_RPC_serviceDesc, srv) // Use of this interface is not recommended, as added methods to RPCServer will
// result in compilation errors.
type UnsafeRPCServer interface {
mustEmbedUnimplementedRPCServer()
}
func RegisterRPCServer(s grpc.ServiceRegistrar, srv RPCServer) {
s.RegisterService(&RPC_ServiceDesc, srv)
} }
func _RPC_MessageStream_Handler(srv interface{}, stream grpc.ServerStream) error { func _RPC_MessageStream_Handler(srv interface{}, stream grpc.ServerStream) error {
@ -214,7 +232,10 @@ func (x *rPCMessageStreamServer) Recv() (*KaspadMessage, error) {
return m, nil return m, nil
} }
var _RPC_serviceDesc = grpc.ServiceDesc{ // RPC_ServiceDesc is the grpc.ServiceDesc for RPC service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var RPC_ServiceDesc = grpc.ServiceDesc{
ServiceName: "protowire.RPC", ServiceName: "protowire.RPC",
HandlerType: (*RPCServer)(nil), HandlerType: (*RPCServer)(nil),
Methods: []grpc.MethodDesc{}, Methods: []grpc.MethodDesc{},

View File

@ -1,13 +1,12 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.25.0 // protoc-gen-go v1.26.0
// protoc v3.12.3 // protoc v3.12.3
// source: p2p.proto // source: p2p.proto
package protowire package protowire
import ( import (
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect" reflect "reflect"
@ -21,10 +20,6 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type RequestAddressesMessage struct { type RequestAddressesMessage struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache

View File

@ -5,11 +5,21 @@
- [rpc.proto](#rpc.proto) - [rpc.proto](#rpc.proto)
- [RPCError](#protowire.RPCError) - [RPCError](#protowire.RPCError)
- [RpcBlock](#protowire.RpcBlock)
- [RpcBlockHeader](#protowire.RpcBlockHeader)
- [RpcBlockVerboseData](#protowire.RpcBlockVerboseData)
- [RpcTransaction](#protowire.RpcTransaction)
- [RpcTransactionInput](#protowire.RpcTransactionInput)
- [RpcScriptPublicKey](#protowire.RpcScriptPublicKey)
- [RpcTransactionOutput](#protowire.RpcTransactionOutput)
- [RpcOutpoint](#protowire.RpcOutpoint)
- [RpcUtxoEntry](#protowire.RpcUtxoEntry)
- [RpcTransactionVerboseData](#protowire.RpcTransactionVerboseData)
- [RpcTransactionInputVerboseData](#protowire.RpcTransactionInputVerboseData)
- [RpcTransactionOutputVerboseData](#protowire.RpcTransactionOutputVerboseData)
- [GetCurrentNetworkRequestMessage](#protowire.GetCurrentNetworkRequestMessage) - [GetCurrentNetworkRequestMessage](#protowire.GetCurrentNetworkRequestMessage)
- [GetCurrentNetworkResponseMessage](#protowire.GetCurrentNetworkResponseMessage) - [GetCurrentNetworkResponseMessage](#protowire.GetCurrentNetworkResponseMessage)
- [SubmitBlockRequestMessage](#protowire.SubmitBlockRequestMessage) - [SubmitBlockRequestMessage](#protowire.SubmitBlockRequestMessage)
- [RpcBlock](#protowire.RpcBlock)
- [RpcBlockHeader](#protowire.RpcBlockHeader)
- [SubmitBlockResponseMessage](#protowire.SubmitBlockResponseMessage) - [SubmitBlockResponseMessage](#protowire.SubmitBlockResponseMessage)
- [GetBlockTemplateRequestMessage](#protowire.GetBlockTemplateRequestMessage) - [GetBlockTemplateRequestMessage](#protowire.GetBlockTemplateRequestMessage)
- [GetBlockTemplateResponseMessage](#protowire.GetBlockTemplateResponseMessage) - [GetBlockTemplateResponseMessage](#protowire.GetBlockTemplateResponseMessage)
@ -40,10 +50,6 @@
- [AcceptedBlock](#protowire.AcceptedBlock) - [AcceptedBlock](#protowire.AcceptedBlock)
- [GetBlockRequestMessage](#protowire.GetBlockRequestMessage) - [GetBlockRequestMessage](#protowire.GetBlockRequestMessage)
- [GetBlockResponseMessage](#protowire.GetBlockResponseMessage) - [GetBlockResponseMessage](#protowire.GetBlockResponseMessage)
- [BlockVerboseData](#protowire.BlockVerboseData)
- [TransactionVerboseData](#protowire.TransactionVerboseData)
- [TransactionVerboseInput](#protowire.TransactionVerboseInput)
- [TransactionVerboseOutput](#protowire.TransactionVerboseOutput)
- [GetSubnetworkRequestMessage](#protowire.GetSubnetworkRequestMessage) - [GetSubnetworkRequestMessage](#protowire.GetSubnetworkRequestMessage)
- [GetSubnetworkResponseMessage](#protowire.GetSubnetworkResponseMessage) - [GetSubnetworkResponseMessage](#protowire.GetSubnetworkResponseMessage)
- [GetVirtualSelectedParentChainFromBlockRequestMessage](#protowire.GetVirtualSelectedParentChainFromBlockRequestMessage) - [GetVirtualSelectedParentChainFromBlockRequestMessage](#protowire.GetVirtualSelectedParentChainFromBlockRequestMessage)
@ -70,12 +76,6 @@
- [UtxosByAddressesEntry](#protowire.UtxosByAddressesEntry) - [UtxosByAddressesEntry](#protowire.UtxosByAddressesEntry)
- [StopNotifyingUtxosChangedRequestMessage](#protowire.StopNotifyingUtxosChangedRequestMessage) - [StopNotifyingUtxosChangedRequestMessage](#protowire.StopNotifyingUtxosChangedRequestMessage)
- [StopNotifyingUtxosChangedResponseMessage](#protowire.StopNotifyingUtxosChangedResponseMessage) - [StopNotifyingUtxosChangedResponseMessage](#protowire.StopNotifyingUtxosChangedResponseMessage)
- [RpcTransaction](#protowire.RpcTransaction)
- [RpcTransactionInput](#protowire.RpcTransactionInput)
- [RpcScriptPublicKey](#protowire.RpcScriptPublicKey)
- [RpcTransactionOutput](#protowire.RpcTransactionOutput)
- [RpcOutpoint](#protowire.RpcOutpoint)
- [RpcUtxoEntry](#protowire.RpcUtxoEntry)
- [GetUtxosByAddressesRequestMessage](#protowire.GetUtxosByAddressesRequestMessage) - [GetUtxosByAddressesRequestMessage](#protowire.GetUtxosByAddressesRequestMessage)
- [GetUtxosByAddressesResponseMessage](#protowire.GetUtxosByAddressesResponseMessage) - [GetUtxosByAddressesResponseMessage](#protowire.GetUtxosByAddressesResponseMessage)
- [GetVirtualSelectedParentBlueScoreRequestMessage](#protowire.GetVirtualSelectedParentBlueScoreRequestMessage) - [GetVirtualSelectedParentBlueScoreRequestMessage](#protowire.GetVirtualSelectedParentBlueScoreRequestMessage)
@ -83,6 +83,9 @@
- [NotifyVirtualSelectedParentBlueScoreChangedRequestMessage](#protowire.NotifyVirtualSelectedParentBlueScoreChangedRequestMessage) - [NotifyVirtualSelectedParentBlueScoreChangedRequestMessage](#protowire.NotifyVirtualSelectedParentBlueScoreChangedRequestMessage)
- [NotifyVirtualSelectedParentBlueScoreChangedResponseMessage](#protowire.NotifyVirtualSelectedParentBlueScoreChangedResponseMessage) - [NotifyVirtualSelectedParentBlueScoreChangedResponseMessage](#protowire.NotifyVirtualSelectedParentBlueScoreChangedResponseMessage)
- [VirtualSelectedParentBlueScoreChangedNotificationMessage](#protowire.VirtualSelectedParentBlueScoreChangedNotificationMessage) - [VirtualSelectedParentBlueScoreChangedNotificationMessage](#protowire.VirtualSelectedParentBlueScoreChangedNotificationMessage)
- [NotifyVirtualDaaScoreChangedRequestMessage](#protowire.NotifyVirtualDaaScoreChangedRequestMessage)
- [NotifyVirtualDaaScoreChangedResponseMessage](#protowire.NotifyVirtualDaaScoreChangedResponseMessage)
- [VirtualDaaScoreChangedNotificationMessage](#protowire.VirtualDaaScoreChangedNotificationMessage)
- [NotifyPruningPointUTXOSetOverrideRequestMessage](#protowire.NotifyPruningPointUTXOSetOverrideRequestMessage) - [NotifyPruningPointUTXOSetOverrideRequestMessage](#protowire.NotifyPruningPointUTXOSetOverrideRequestMessage)
- [NotifyPruningPointUTXOSetOverrideResponseMessage](#protowire.NotifyPruningPointUTXOSetOverrideResponseMessage) - [NotifyPruningPointUTXOSetOverrideResponseMessage](#protowire.NotifyPruningPointUTXOSetOverrideResponseMessage)
- [PruningPointUTXOSetOverrideNotificationMessage](#protowire.PruningPointUTXOSetOverrideNotificationMessage) - [PruningPointUTXOSetOverrideNotificationMessage](#protowire.PruningPointUTXOSetOverrideNotificationMessage)
@ -132,6 +135,218 @@ Receivers of any ResponseMessage are expected to check whether its error field i
<a name="protowire.RpcBlock"></a>
### RpcBlock
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| header | [RpcBlockHeader](#protowire.RpcBlockHeader) | | |
| transactions | [RpcTransaction](#protowire.RpcTransaction) | repeated | |
| verboseData | [RpcBlockVerboseData](#protowire.RpcBlockVerboseData) | | |
<a name="protowire.RpcBlockHeader"></a>
### RpcBlockHeader
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| version | [uint32](#uint32) | | |
| parentHashes | [string](#string) | repeated | |
| hashMerkleRoot | [string](#string) | | |
| acceptedIdMerkleRoot | [string](#string) | | |
| utxoCommitment | [string](#string) | | |
| timestamp | [int64](#int64) | | |
| bits | [uint32](#uint32) | | |
| nonce | [uint64](#uint64) | | |
<a name="protowire.RpcBlockVerboseData"></a>
### RpcBlockVerboseData
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| hash | [string](#string) | | |
| difficulty | [double](#double) | | |
| selectedParentHash | [string](#string) | | |
| transactionIds | [string](#string) | repeated | |
| isHeaderOnly | [bool](#bool) | | |
| blueScore | [uint64](#uint64) | | |
| childrenHashes | [string](#string) | repeated | |
<a name="protowire.RpcTransaction"></a>
### RpcTransaction
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| version | [uint32](#uint32) | | |
| inputs | [RpcTransactionInput](#protowire.RpcTransactionInput) | repeated | |
| outputs | [RpcTransactionOutput](#protowire.RpcTransactionOutput) | repeated | |
| lockTime | [uint64](#uint64) | | |
| subnetworkId | [string](#string) | | |
| gas | [uint64](#uint64) | | |
| payload | [string](#string) | | |
| verboseData | [RpcTransactionVerboseData](#protowire.RpcTransactionVerboseData) | | |
<a name="protowire.RpcTransactionInput"></a>
### RpcTransactionInput
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| previousOutpoint | [RpcOutpoint](#protowire.RpcOutpoint) | | |
| signatureScript | [string](#string) | | |
| sequence | [uint64](#uint64) | | |
| verboseData | [RpcTransactionInputVerboseData](#protowire.RpcTransactionInputVerboseData) | | |
<a name="protowire.RpcScriptPublicKey"></a>
### RpcScriptPublicKey
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| version | [uint32](#uint32) | | |
| scriptPublicKey | [string](#string) | | |
<a name="protowire.RpcTransactionOutput"></a>
### RpcTransactionOutput
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| amount | [uint64](#uint64) | | |
| scriptPublicKey | [RpcScriptPublicKey](#protowire.RpcScriptPublicKey) | | |
| verboseData | [RpcTransactionOutputVerboseData](#protowire.RpcTransactionOutputVerboseData) | | |
<a name="protowire.RpcOutpoint"></a>
### RpcOutpoint
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| transactionId | [string](#string) | | |
| index | [uint32](#uint32) | | |
<a name="protowire.RpcUtxoEntry"></a>
### RpcUtxoEntry
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| amount | [uint64](#uint64) | | |
| scriptPublicKey | [RpcScriptPublicKey](#protowire.RpcScriptPublicKey) | | |
| blockDaaScore | [uint64](#uint64) | | |
| isCoinbase | [bool](#bool) | | |
<a name="protowire.RpcTransactionVerboseData"></a>
### RpcTransactionVerboseData
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| transactionId | [string](#string) | | |
| hash | [string](#string) | | |
| size | [uint64](#uint64) | | |
| blockHash | [string](#string) | | |
| blockTime | [uint64](#uint64) | | |
<a name="protowire.RpcTransactionInputVerboseData"></a>
### RpcTransactionInputVerboseData
<a name="protowire.RpcTransactionOutputVerboseData"></a>
### RpcTransactionOutputVerboseData
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| scriptPublicKeyType | [string](#string) | | |
| scriptPublicKeyAddress | [string](#string) | | |
<a name="protowire.GetCurrentNetworkRequestMessage"></a> <a name="protowire.GetCurrentNetworkRequestMessage"></a>
### GetCurrentNetworkRequestMessage ### GetCurrentNetworkRequestMessage
@ -163,44 +378,27 @@ Possible networks are: Mainnet, Testnet, Simnet, Devnet
<a name="protowire.SubmitBlockRequestMessage"></a> <a name="protowire.SubmitBlockRequestMessage"></a>
### SubmitBlockRequestMessage ### SubmitBlockRequestMessage
SubmitBlockRequestMessage requests to submit a block into the DAG.
SubmitBlockRequestMessage requests to submit a block into the DAG. Blocks are generally expected to have been generated Blocks are generally expected to have been generated using the getBlockTemplate call.
using the getBlockTemplate call.
See: GetBlockTemplateRequestMessage See: GetBlockTemplateRequestMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| block | [RpcBlock](#protowire.RpcBlock) | | | | block | [RpcBlock](#protowire.RpcBlock) | | |
<a name="protowire.RpcBlock"></a>
### RpcBlock
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| header | [RpcBlockHeader](#protowire.RpcBlockHeader) | | |
| transactions | [RpcTransaction](#protowire.RpcTransaction) | repeated | |
<a name="protowire.RpcBlockHeader"></a>
### RpcBlockHeader
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| version | [uint32](#uint32) | | |
| parentHashes | [string](#string) | repeated | |
| hashMerkleRoot | [string](#string) | | |
| acceptedIdMerkleRoot | [string](#string) | | |
| utxoCommitment | [string](#string) | | |
| timestamp | [int64](#int64) | | |
| bits | [uint32](#uint32) | | |
| nonce | [uint64](#uint64) | | |
<a name="protowire.SubmitBlockResponseMessage"></a> <a name="protowire.SubmitBlockResponseMessage"></a>
### SubmitBlockResponseMessage ### SubmitBlockResponseMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| rejectReason | [SubmitBlockResponseMessage.RejectReason](#protowire.SubmitBlockResponseMessage.RejectReason) | | | | rejectReason | [SubmitBlockResponseMessage.RejectReason](#protowire.SubmitBlockResponseMessage.RejectReason) | | |
@ -284,7 +482,7 @@ See: NotifyBlockAddedRequestMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| blockVerboseData | [BlockVerboseData](#protowire.BlockVerboseData) | | | | block | [RpcBlock](#protowire.RpcBlock) | | |
@ -429,7 +627,7 @@ currently in the mempool.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| fee | [uint64](#uint64) | | | | fee | [uint64](#uint64) | | |
| transactionVerboseData | [TransactionVerboseData](#protowire.TransactionVerboseData) | | | | transaction | [RpcTransaction](#protowire.RpcTransaction) | | |
@ -651,78 +849,8 @@ GetBlockRequestMessage requests information about a specific block
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| blockHash | [string](#string) | | |
| blockVerboseData | [BlockVerboseData](#protowire.BlockVerboseData) | | |
| error | [RPCError](#protowire.RPCError) | | |
<a name="protowire.BlockVerboseData"></a>
### BlockVerboseData
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| hash | [string](#string) | | |
| block | [RpcBlock](#protowire.RpcBlock) | | | | block | [RpcBlock](#protowire.RpcBlock) | | |
| transactionVerboseData | [TransactionVerboseData](#protowire.TransactionVerboseData) | repeated | | | error | [RPCError](#protowire.RPCError) | | |
| difficulty | [double](#double) | | |
| childrenHashes | [string](#string) | repeated | |
| selectedParentHash | [string](#string) | | |
| transactionIDs | [string](#string) | repeated | |
| isHeaderOnly | [bool](#bool) | | |
| blueScore | [uint64](#uint64) | | |
<a name="protowire.TransactionVerboseData"></a>
### TransactionVerboseData
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| txId | [string](#string) | | |
| hash | [string](#string) | | |
| size | [uint64](#uint64) | | |
| transactionVerboseInputs | [TransactionVerboseInput](#protowire.TransactionVerboseInput) | repeated | |
| transactionVerboseOutputs | [TransactionVerboseOutput](#protowire.TransactionVerboseOutput) | repeated | |
| blockHash | [string](#string) | | |
| blockTime | [uint64](#uint64) | | |
| transaction | [RpcTransaction](#protowire.RpcTransaction) | | |
<a name="protowire.TransactionVerboseInput"></a>
### TransactionVerboseInput
<a name="protowire.TransactionVerboseOutput"></a>
### TransactionVerboseOutput
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| scriptPublicKeyType | [string](#string) | | |
| scriptPublicKeyAddress | [string](#string) | | |
@ -805,7 +933,7 @@ kaspad&#39;s current virtual.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| lowHash | [string](#string) | | | | lowHash | [string](#string) | | |
| includeBlockVerboseData | [bool](#bool) | | | | includeBlocks | [bool](#bool) | | |
| includeTransactionVerboseData | [bool](#bool) | | | | includeTransactionVerboseData | [bool](#bool) | | |
@ -822,7 +950,7 @@ kaspad&#39;s current virtual.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| blockHashes | [string](#string) | repeated | | | blockHashes | [string](#string) | repeated | |
| blockVerboseData | [BlockVerboseData](#protowire.BlockVerboseData) | repeated | | | blocks | [RpcBlock](#protowire.RpcBlock) | repeated | |
| error | [RPCError](#protowire.RPCError) | | | | error | [RPCError](#protowire.RPCError) | | |
@ -885,6 +1013,7 @@ of this kaspad&#39;s DAG.
| pastMedianTime | [int64](#int64) | | | | pastMedianTime | [int64](#int64) | | |
| virtualParentHashes | [string](#string) | repeated | | | virtualParentHashes | [string](#string) | repeated | |
| pruningPointHash | [string](#string) | | | | pruningPointHash | [string](#string) | | |
| virtualDaaScore | [uint64](#uint64) | | |
| error | [RPCError](#protowire.RPCError) | | | | error | [RPCError](#protowire.RPCError) | | |
@ -1141,110 +1270,6 @@ See: UtxosChangedNotificationMessage
<a name="protowire.RpcTransaction"></a>
### RpcTransaction
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| version | [uint32](#uint32) | | |
| inputs | [RpcTransactionInput](#protowire.RpcTransactionInput) | repeated | |
| outputs | [RpcTransactionOutput](#protowire.RpcTransactionOutput) | repeated | |
| lockTime | [uint64](#uint64) | | |
| subnetworkId | [string](#string) | | |
| gas | [uint64](#uint64) | | |
| payload | [string](#string) | | |
<a name="protowire.RpcTransactionInput"></a>
### RpcTransactionInput
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| previousOutpoint | [RpcOutpoint](#protowire.RpcOutpoint) | | |
| signatureScript | [string](#string) | | |
| sequence | [uint64](#uint64) | | |
<a name="protowire.RpcScriptPublicKey"></a>
### RpcScriptPublicKey
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| version | [uint32](#uint32) | | |
| scriptPublicKey | [string](#string) | | |
<a name="protowire.RpcTransactionOutput"></a>
### RpcTransactionOutput
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| amount | [uint64](#uint64) | | |
| scriptPublicKey | [RpcScriptPublicKey](#protowire.RpcScriptPublicKey) | | |
<a name="protowire.RpcOutpoint"></a>
### RpcOutpoint
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| transactionId | [string](#string) | | |
| index | [uint32](#uint32) | | |
<a name="protowire.RpcUtxoEntry"></a>
### RpcUtxoEntry
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| amount | [uint64](#uint64) | | |
| scriptPublicKey | [RpcScriptPublicKey](#protowire.RpcScriptPublicKey) | | |
| blockDaaScore | [uint64](#uint64) | | |
| isCoinbase | [bool](#bool) | | |
<a name="protowire.GetUtxosByAddressesRequestMessage"></a> <a name="protowire.GetUtxosByAddressesRequestMessage"></a>
### GetUtxosByAddressesRequestMessage ### GetUtxosByAddressesRequestMessage
@ -1351,6 +1376,52 @@ See NotifyVirtualSelectedParentBlueScoreChangedRequestMessage
<a name="protowire.NotifyVirtualDaaScoreChangedRequestMessage"></a>
### NotifyVirtualDaaScoreChangedRequestMessage
NotifyVirtualDaaScoreChangedRequestMessage registers this connection for
virtualDaaScoreChanged notifications.
See: VirtualDaaScoreChangedNotificationMessage
<a name="protowire.NotifyVirtualDaaScoreChangedResponseMessage"></a>
### NotifyVirtualDaaScoreChangedResponseMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| error | [RPCError](#protowire.RPCError) | | |
<a name="protowire.VirtualDaaScoreChangedNotificationMessage"></a>
### VirtualDaaScoreChangedNotificationMessage
VirtualDaaScoreChangedNotificationMessage is sent whenever the DAA score
of the virtual changes.
See NotifyVirtualDaaScoreChangedRequestMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| virtualDaaScore | [uint64](#uint64) | | |
<a name="protowire.NotifyPruningPointUTXOSetOverrideRequestMessage"></a> <a name="protowire.NotifyPruningPointUTXOSetOverrideRequestMessage"></a>
### NotifyPruningPointUTXOSetOverrideRequestMessage ### NotifyPruningPointUTXOSetOverrideRequestMessage

View File

@ -395,6 +395,7 @@ message GetBlockDagInfoResponseMessage{
int64 pastMedianTime = 6; int64 pastMedianTime = 6;
repeated string virtualParentHashes = 7; repeated string virtualParentHashes = 7;
string pruningPointHash = 8; string pruningPointHash = 8;
uint64 virtualDaaScore = 9;
RPCError error = 1000; RPCError error = 1000;
} }
@ -527,6 +528,25 @@ message VirtualSelectedParentBlueScoreChangedNotificationMessage {
uint64 virtualSelectedParentBlueScore = 1; uint64 virtualSelectedParentBlueScore = 1;
} }
// NotifyVirtualDaaScoreChangedRequestMessage registers this connection for
// virtualDaaScoreChanged notifications.
//
// See: VirtualDaaScoreChangedNotificationMessage
message NotifyVirtualDaaScoreChangedRequestMessage {
}
message NotifyVirtualDaaScoreChangedResponseMessage {
RPCError error = 1000;
}
// VirtualDaaScoreChangedNotificationMessage is sent whenever the DAA score
// of the virtual changes.
//
// See NotifyVirtualDaaScoreChangedRequestMessage
message VirtualDaaScoreChangedNotificationMessage {
uint64 virtualDaaScore = 1;
}
// NotifyPruningPointUTXOSetOverrideRequestMessage registers this connection for // NotifyPruningPointUTXOSetOverrideRequestMessage registers this connection for
// pruning point UTXO set override notifications. // pruning point UTXO set override notifications.
// //

View File

@ -45,6 +45,7 @@ func (x *GetBlockDagInfoResponseMessage) toAppMessage() (appmessage.Message, err
Difficulty: x.Difficulty, Difficulty: x.Difficulty,
PastMedianTime: x.PastMedianTime, PastMedianTime: x.PastMedianTime,
PruningPointHash: x.PruningPointHash, PruningPointHash: x.PruningPointHash,
VirtualDAAScore: x.VirtualDaaScore,
Error: rpcErr, Error: rpcErr,
}, nil }, nil
} }
@ -63,6 +64,7 @@ func (x *KaspadMessage_GetBlockDagInfoResponse) fromAppMessage(message *appmessa
Difficulty: message.Difficulty, Difficulty: message.Difficulty,
PastMedianTime: message.PastMedianTime, PastMedianTime: message.PastMedianTime,
PruningPointHash: message.PruningPointHash, PruningPointHash: message.PruningPointHash,
VirtualDaaScore: message.VirtualDAAScore,
Error: err, Error: err,
} }
return nil return nil

View File

@ -0,0 +1,73 @@
package protowire
import (
"github.com/kaspanet/kaspad/app/appmessage"
"github.com/pkg/errors"
)
func (x *KaspadMessage_NotifyVirtualDaaScoreChangedRequest) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualDaaScoreChangedRequest is nil")
}
return &appmessage.NotifyVirtualDaaScoreChangedRequestMessage{}, nil
}
func (x *KaspadMessage_NotifyVirtualDaaScoreChangedRequest) fromAppMessage(_ *appmessage.NotifyVirtualDaaScoreChangedRequestMessage) error {
x.NotifyVirtualDaaScoreChangedRequest = &NotifyVirtualDaaScoreChangedRequestMessage{}
return nil
}
func (x *KaspadMessage_NotifyVirtualDaaScoreChangedResponse) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualDaaScoreChangedResponse is nil")
}
return x.NotifyVirtualDaaScoreChangedResponse.toAppMessage()
}
func (x *KaspadMessage_NotifyVirtualDaaScoreChangedResponse) fromAppMessage(message *appmessage.NotifyVirtualDaaScoreChangedResponseMessage) error {
var err *RPCError
if message.Error != nil {
err = &RPCError{Message: message.Error.Message}
}
x.NotifyVirtualDaaScoreChangedResponse = &NotifyVirtualDaaScoreChangedResponseMessage{
Error: err,
}
return nil
}
func (x *NotifyVirtualDaaScoreChangedResponseMessage) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "NotifyVirtualDaaScoreChangedResponseMessage is nil")
}
rpcErr, err := x.Error.toAppMessage()
// Error is an optional field
if err != nil && !errors.Is(err, errorNil) {
return nil, err
}
return &appmessage.NotifyVirtualDaaScoreChangedResponseMessage{
Error: rpcErr,
}, nil
}
func (x *KaspadMessage_VirtualDaaScoreChangedNotification) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_VirtualDaaScoreChangedNotification is nil")
}
return x.VirtualDaaScoreChangedNotification.toAppMessage()
}
func (x *KaspadMessage_VirtualDaaScoreChangedNotification) fromAppMessage(message *appmessage.VirtualDaaScoreChangedNotificationMessage) error {
x.VirtualDaaScoreChangedNotification = &VirtualDaaScoreChangedNotificationMessage{
VirtualDaaScore: message.VirtualDaaScore,
}
return nil
}
func (x *VirtualDaaScoreChangedNotificationMessage) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "VirtualDaaScoreChangedNotificationMessage is nil")
}
return &appmessage.VirtualDaaScoreChangedNotificationMessage{
VirtualDaaScore: x.VirtualDaaScore,
}, nil
}

View File

@ -779,6 +779,27 @@ func toRPCPayload(message appmessage.Message) (isKaspadMessage_Payload, error) {
return nil, err return nil, err
} }
return payload, nil return payload, nil
case *appmessage.NotifyVirtualDaaScoreChangedRequestMessage:
payload := new(KaspadMessage_NotifyVirtualDaaScoreChangedRequest)
err := payload.fromAppMessage(message)
if err != nil {
return nil, err
}
return payload, nil
case *appmessage.NotifyVirtualDaaScoreChangedResponseMessage:
payload := new(KaspadMessage_NotifyVirtualDaaScoreChangedResponse)
err := payload.fromAppMessage(message)
if err != nil {
return nil, err
}
return payload, nil
case *appmessage.VirtualDaaScoreChangedNotificationMessage:
payload := new(KaspadMessage_VirtualDaaScoreChangedNotification)
err := payload.fromAppMessage(message)
if err != nil {
return nil, err
}
return payload, nil
default: default:
return nil, nil return nil, nil
} }

View File

@ -0,0 +1,41 @@
package rpcclient
import (
"github.com/kaspanet/kaspad/app/appmessage"
routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
"github.com/pkg/errors"
)
// RegisterForVirtualDaaScoreChangedNotifications sends an RPC request respective to the function's
// name and returns the RPC server's response. Additionally, it starts listening for the appropriate notification
// using the given handler function
func (c *RPCClient) RegisterForVirtualDaaScoreChangedNotifications(
onVirtualDaaScoreChanged func(notification *appmessage.VirtualDaaScoreChangedNotificationMessage)) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyVirtualDaaScoreChangedRequestMessage())
if err != nil {
return err
}
response, err := c.route(appmessage.CmdNotifyVirtualDaaScoreChangedResponseMessage).DequeueWithTimeout(c.timeout)
if err != nil {
return err
}
notifyVirtualDaaScoreChangedResponse := response.(*appmessage.NotifyVirtualDaaScoreChangedResponseMessage)
if notifyVirtualDaaScoreChangedResponse.Error != nil {
return c.convertRPCError(notifyVirtualDaaScoreChangedResponse.Error)
}
spawn("RegisterForVirtualDaaScoreChangedNotifications", func() {
for {
notification, err := c.route(appmessage.CmdVirtualDaaScoreChangedNotificationMessage).Dequeue()
if err != nil {
if errors.Is(err, routerpkg.ErrRouteClosed) {
break
}
panic(err)
}
VirtualDaaScoreChangedNotification := notification.(*appmessage.VirtualDaaScoreChangedNotificationMessage)
onVirtualDaaScoreChanged(VirtualDaaScoreChangedNotification)
}
})
return nil
}

View File

@ -1,26 +1,29 @@
ARG KASPAD_VERSION ARG KASPAD_IMAGE
ARG KASPAMINER_IMAGE
FROM 578712463641.dkr.ecr.eu-central-1.amazonaws.com/kaspad-release-candidate:$KASPAD_VERSION as kaspad FROM ${KASPAD_IMAGE} as kaspad
FROM 578712463641.dkr.ecr.eu-central-1.amazonaws.com/kaspaminer-release-candidate:$KASPAD_VERSION as kaspaminer FROM ${KASPAMINER_IMAGE} as kaspaminer
FROM golang:1.16-alpine FROM golang:1.16-alpine
RUN mkdir -p /go/src/github.com/kaspanet/kaspad
WORKDIR /go/src/github.com/kaspanet/kaspad
RUN apk add bash build-base git RUN apk add bash build-base git
ARG KASPAD_VERSION COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
COPY --from=kaspad /app/ /app/ COPY --from=kaspad /app/ /app/
COPY --from=kaspaminer /app/ /app/ COPY --from=kaspaminer /app/ /app/
ENV PATH="/app:${PATH}" ENV PATH="/app:${PATH}"
COPY . /tests WORKDIR /go/src/github.com/kaspanet/kaspad/stability-tests
WORKDIR /tests
RUN git ls-remote https://github.com/kaspanet/kaspad.git $KASPAD_VERSION | awk '{print $1;}' > /tmp/kaspad_git_commit
RUN go mod edit -dropreplace github.com/kaspanet/kaspad
RUN go mod edit -replace github.com/kaspanet/kaspad=github.com/kaspanet/kaspad@`cat /tmp/kaspad_git_commit` ;
RUN go mod download
RUN go install ./... RUN go install ./...

View File

@ -10,7 +10,7 @@ KASPAD_PID=$!
sleep 1 sleep 1
RUN_STABILITY_TESTS=true go test ../ -- --rpc-address=127.0.0.1:"${KASPAD_RPC_PORT}" --profile=7000 RUN_STABILITY_TESTS=true go test ../ -v -timeout 86400s -- --rpc-address=127.0.0.1:"${KASPAD_RPC_PORT}" --profile=7000
TEST_EXIT_CODE=$? TEST_EXIT_CODE=$?
kill $KASPAD_PID kill $KASPAD_PID

View File

@ -20,8 +20,8 @@ import (
) )
const ( const (
payAddress = "kaspasim:qr79e37hxdgkn4xjjmfxvqvayc5gsmsql2660d08u9ej9vnc8lzcywr265u64" payAddress = "kaspasim:qzuax2jhawd354e54thhpd9m9wg03pdzwjlpr4vtq3k7xrpumhhtwa2hkr3ep"
payAddressPrivateKey = "0ec5d7308f65717f3f0c3e4d962d73056c1c255a16593b3989589281b51ad5bc" payAddressPrivateKey = "05d8f681e954a550395ee2297fc1a14f6e801f554c0b9d48cd7165a7ea72ff77"
fundingCoinbaseTransactionAmount = 1000 fundingCoinbaseTransactionAmount = 1000
outputsPerTransaction = 3 outputsPerTransaction = 3
transactionFee = 1000 transactionFee = 1000

View File

@ -5,7 +5,7 @@ import (
"testing" "testing"
) )
func TestVirtualSelectedParentBlueScore(t *testing.T) { func TestVirtualSelectedParentBlueScoreAndVirtualDAAScore(t *testing.T) {
// Setup a single kaspad instance // Setup a single kaspad instance
harnessParams := &harnessParams{ harnessParams := &harnessParams{
p2pAddress: p2pAddress1, p2pAddress: p2pAddress1,
@ -38,15 +38,30 @@ func TestVirtualSelectedParentBlueScore(t *testing.T) {
"blue score change notifications: %s", err) "blue score change notifications: %s", err)
} }
// Register to virtual DAA score changes
onVirtualDaaScoreChangedChan := make(chan *appmessage.VirtualDaaScoreChangedNotificationMessage)
err = kaspad.rpcClient.RegisterForVirtualDaaScoreChangedNotifications(
func(notification *appmessage.VirtualDaaScoreChangedNotificationMessage) {
onVirtualDaaScoreChangedChan <- notification
})
if err != nil {
t.Fatalf("Failed to register for virtual DAA score change notifications: %s", err)
}
// Mine some blocks and make sure that the notifications // Mine some blocks and make sure that the notifications
// report correct blue score values // report correct values
const blockAmountToMine = 100 const blockAmountToMine = 100
for i := 0; i < blockAmountToMine; i++ { for i := 0; i < blockAmountToMine; i++ {
mineNextBlock(t, kaspad) mineNextBlock(t, kaspad)
notification := <-onVirtualSelectedParentBlueScoreChangedChan blueScoreChangedNotification := <-onVirtualSelectedParentBlueScoreChangedChan
if notification.VirtualSelectedParentBlueScore != 1+uint64(i) { if blueScoreChangedNotification.VirtualSelectedParentBlueScore != 1+uint64(i) {
t.Fatalf("Unexpected virtual selected parent blue score. Want: %d, got: %d", t.Fatalf("Unexpected virtual selected parent blue score. Want: %d, got: %d",
1+uint64(i), notification.VirtualSelectedParentBlueScore) 1+uint64(i), blueScoreChangedNotification.VirtualSelectedParentBlueScore)
}
daaScoreChangedNotification := <-onVirtualDaaScoreChangedChan
if daaScoreChangedNotification.VirtualDaaScore > 1+uint64(i) {
t.Fatalf("Unexpected virtual DAA score. Want: %d, got: %d",
1+uint64(i), daaScoreChangedNotification.VirtualDaaScore)
} }
} }

View File

@ -11,7 +11,7 @@ const validCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrs
const ( const (
appMajor uint = 0 appMajor uint = 0
appMinor uint = 10 appMinor uint = 10
appPatch uint = 0 appPatch uint = 4
) )
// appBuild is defined as a variable so it can be overridden during the build // appBuild is defined as a variable so it can be overridden during the build