Use MassCommitment instead of Mass

This commit is contained in:
Ori Newman 2025-01-18 16:03:33 +02:00
parent baa7d1a15f
commit 998d0ce33c
5 changed files with 241 additions and 343 deletions

View File

@ -2,9 +2,10 @@ package appmessage
import ( import (
"encoding/hex" "encoding/hex"
"github.com/pkg/errors"
"math/big" "math/big"
"github.com/pkg/errors"
"github.com/kaspanet/kaspad/domain/consensus/utils/blockheader" "github.com/kaspanet/kaspad/domain/consensus/utils/blockheader"
"github.com/kaspanet/kaspad/domain/consensus/utils/hashes" "github.com/kaspanet/kaspad/domain/consensus/utils/hashes"
"github.com/kaspanet/kaspad/domain/consensus/utils/utxo" "github.com/kaspanet/kaspad/domain/consensus/utils/utxo"
@ -219,7 +220,7 @@ func RPCTransactionToDomainTransaction(rpcTransaction *RPCTransaction) (*externa
LockTime: rpcTransaction.LockTime, LockTime: rpcTransaction.LockTime,
SubnetworkID: *subnetworkID, SubnetworkID: *subnetworkID,
Gas: rpcTransaction.Gas, Gas: rpcTransaction.Gas,
Mass: rpcTransaction.Mass, // BPS10 add mass MassCommitment: rpcTransaction.Mass,
Payload: payload, Payload: payload,
}, nil }, nil
} }
@ -288,7 +289,7 @@ func DomainTransactionToRPCTransaction(transaction *externalapi.DomainTransactio
LockTime: transaction.LockTime, LockTime: transaction.LockTime,
SubnetworkID: subnetworkID, SubnetworkID: subnetworkID,
Gas: transaction.Gas, Gas: transaction.Gas,
Mass: transaction.Mass, // <<< BPS10 add mass Mass: transaction.MassCommitment,
Payload: payload, Payload: payload,
} }
} }

View File

@ -20,6 +20,7 @@ type DomainTransaction struct {
Fee uint64 Fee uint64
Mass uint64 Mass uint64
MassCommitment uint64
// ID is a field that is used to cache the transaction ID. // ID is a field that is used to cache the transaction ID.
// Always use consensushashing.TransactionID instead of accessing this field directly // Always use consensushashing.TransactionID instead of accessing this field directly

View File

@ -27,7 +27,7 @@ func TransactionHash(tx *externalapi.DomainTransaction) *externalapi.DomainHash
// Encode the header and hash everything prior to the number of // Encode the header and hash everything prior to the number of
// transactions. // transactions.
writer := hashes.NewTransactionHashWriter() writer := hashes.NewTransactionHashWriter()
err := serializeTransaction(writer, tx, txEncodingFull) err := serializeTransaction(writer, tx, txEncodingFull, true)
if err != nil { if err != nil {
// It seems like this could only happen if the writer returned an error. // It seems like this could only happen if the writer returned an error.
// and this writer should never return an error (no allocations or possible failures) // and this writer should never return an error (no allocations or possible failures)
@ -52,7 +52,7 @@ func TransactionID(tx *externalapi.DomainTransaction) *externalapi.DomainTransac
encodingFlags = txEncodingExcludeSignatureScript encodingFlags = txEncodingExcludeSignatureScript
} }
writer := hashes.NewTransactionIDWriter() writer := hashes.NewTransactionIDWriter()
err := serializeTransaction(writer, tx, encodingFlags) err := serializeTransaction(writer, tx, encodingFlags, false)
if err != nil { if err != nil {
// this writer never return errors (no allocations or possible failures) so errors can only come from validity checks, // this writer never return errors (no allocations or possible failures) so errors can only come from validity checks,
// and we assume we never construct malformed transactions. // and we assume we never construct malformed transactions.
@ -74,7 +74,7 @@ func TransactionIDs(txs []*externalapi.DomainTransaction) []*externalapi.DomainT
return txIDs return txIDs
} }
func serializeTransaction(w io.Writer, tx *externalapi.DomainTransaction, encodingFlags txEncoding) error { func serializeTransaction(w io.Writer, tx *externalapi.DomainTransaction, encodingFlags txEncoding, includeMass bool) error {
err := binaryserializer.PutUint16(w, tx.Version) err := binaryserializer.PutUint16(w, tx.Version)
if err != nil { if err != nil {
return err return err
@ -126,12 +126,13 @@ func serializeTransaction(w io.Writer, tx *externalapi.DomainTransaction, encodi
return err return err
} }
if tx.Mass > 0 { // Only serialize Mass if it's not zero if includeMass {
if tx.MassCommitment > 0 { // For backward compatibility, serialize MassCommitment only if it's not zero
err = binaryserializer.PutUint64(w, tx.Mass) err = binaryserializer.PutUint64(w, tx.Mass)
if err != nil { if err != nil {
return err return err
} }
}
} }
return nil return nil

View File

@ -8,9 +8,7 @@ message RequestAddressesMessage{
SubnetworkId subnetworkId = 2; SubnetworkId subnetworkId = 2;
} }
message AddressesMessage{ message AddressesMessage { repeated NetAddress addressList = 1; }
repeated NetAddress addressList = 1;
}
message NetAddress { message NetAddress {
int64 timestamp = 1; int64 timestamp = 1;
@ -18,9 +16,7 @@ message NetAddress{
uint32 port = 4; uint32 port = 4;
} }
message SubnetworkId{ message SubnetworkId { bytes bytes = 1; }
bytes bytes = 1;
}
message TransactionMessage { message TransactionMessage {
uint32 version = 1; uint32 version = 1;
@ -30,7 +26,7 @@ message TransactionMessage{
SubnetworkId subnetworkId = 5; SubnetworkId subnetworkId = 5;
uint64 gas = 6; uint64 gas = 6;
bytes payload = 8; bytes payload = 8;
uint64 mass = 9; // <<< BPS10 - Add mass to TransactionMessage uint64 mass = 9;
} }
message TransactionInput { message TransactionInput {
@ -45,9 +41,7 @@ message Outpoint{
uint32 index = 2; uint32 index = 2;
} }
message TransactionId{ message TransactionId { bytes bytes = 1; }
bytes bytes = 1;
}
message ScriptPublicKey { message ScriptPublicKey {
bytes script = 1; bytes script = 1;
uint32 version = 2; uint32 version = 2;
@ -78,64 +72,41 @@ message BlockHeader{
uint64 blueScore = 13; uint64 blueScore = 13;
} }
message BlockLevelParents { message BlockLevelParents { repeated Hash parentHashes = 1; }
repeated Hash parentHashes = 1;
}
message Hash{ message Hash { bytes bytes = 1; }
bytes bytes = 1;
}
message RequestBlockLocatorMessage { message RequestBlockLocatorMessage {
Hash highHash = 1; Hash highHash = 1;
uint32 limit = 2; uint32 limit = 2;
} }
message BlockLocatorMessage{ message BlockLocatorMessage { repeated Hash hashes = 1; }
repeated Hash hashes = 1;
}
message RequestHeadersMessage { message RequestHeadersMessage {
Hash lowHash = 1; Hash lowHash = 1;
Hash highHash = 2; Hash highHash = 2;
} }
message RequestNextHeadersMessage{ message RequestNextHeadersMessage {}
}
message DoneHeadersMessage{ message DoneHeadersMessage {}
}
message RequestRelayBlocksMessage{ message RequestRelayBlocksMessage { repeated Hash hashes = 1; }
repeated Hash hashes = 1;
}
message RequestTransactionsMessage { message RequestTransactionsMessage { repeated TransactionId ids = 1; }
repeated TransactionId ids = 1;
}
message TransactionNotFoundMessage{ message TransactionNotFoundMessage { TransactionId id = 1; }
TransactionId id = 1;
}
message InvRelayBlockMessage{ message InvRelayBlockMessage { Hash hash = 1; }
Hash hash = 1;
}
message InvTransactionsMessage{ message InvTransactionsMessage { repeated TransactionId ids = 1; }
repeated TransactionId ids = 1;
}
message PingMessage{ message PingMessage { uint64 nonce = 1; }
uint64 nonce = 1;
}
message PongMessage{ message PongMessage { uint64 nonce = 1; }
uint64 nonce = 1;
}
message VerackMessage{ message VerackMessage {}
}
message VersionMessage { message VersionMessage {
uint32 protocolVersion = 1; uint32 protocolVersion = 1;
@ -149,13 +120,9 @@ message VersionMessage{
string network = 10; string network = 10;
} }
message RejectMessage{ message RejectMessage { string reason = 1; }
string reason = 1;
}
message RequestPruningPointUTXOSetMessage{ message RequestPruningPointUTXOSetMessage { Hash pruningPointHash = 1; }
Hash pruningPointHash = 1;
}
message PruningPointUtxoSetChunkMessage { message PruningPointUtxoSetChunkMessage {
repeated OutpointAndUtxoEntryPair outpointAndUtxoEntryPairs = 1; repeated OutpointAndUtxoEntryPair outpointAndUtxoEntryPairs = 1;
@ -173,18 +140,13 @@ message UtxoEntry {
bool isCoinbase = 4; bool isCoinbase = 4;
} }
message RequestNextPruningPointUtxoSetChunkMessage { message RequestNextPruningPointUtxoSetChunkMessage {}
}
message DonePruningPointUtxoSetChunksMessage { message DonePruningPointUtxoSetChunksMessage {}
}
message RequestIBDBlocksMessage{ message RequestIBDBlocksMessage { repeated Hash hashes = 1; }
repeated Hash hashes = 1;
}
message UnexpectedPruningPointMessage{ message UnexpectedPruningPointMessage {}
}
message IbdBlockLocatorMessage { message IbdBlockLocatorMessage {
Hash targetHash = 1; Hash targetHash = 1;
@ -196,31 +158,22 @@ message RequestIBDChainBlockLocatorMessage{
Hash highHash = 2; Hash highHash = 2;
} }
message IbdChainBlockLocatorMessage { message IbdChainBlockLocatorMessage { repeated Hash blockLocatorHashes = 1; }
repeated Hash blockLocatorHashes = 1;
}
message RequestAnticoneMessage { message RequestAnticoneMessage {
Hash blockHash = 1; Hash blockHash = 1;
Hash contextHash = 2; Hash contextHash = 2;
} }
message IbdBlockLocatorHighestHashMessage { message IbdBlockLocatorHighestHashMessage { Hash highestHash = 1; }
Hash highestHash = 1;
}
message IbdBlockLocatorHighestHashNotFoundMessage { message IbdBlockLocatorHighestHashNotFoundMessage {}
}
message BlockHeadersMessage { message BlockHeadersMessage { repeated BlockHeader blockHeaders = 1; }
repeated BlockHeader blockHeaders = 1;
}
message RequestPruningPointAndItsAnticoneMessage { message RequestPruningPointAndItsAnticoneMessage {}
}
message RequestNextPruningPointAndItsAnticoneBlocksMessage{ message RequestNextPruningPointAndItsAnticoneBlocksMessage {}
}
message BlockWithTrustedDataMessage { message BlockWithTrustedDataMessage {
BlockMessage block = 1; BlockMessage block = 1;
@ -258,26 +211,19 @@ message BluesAnticoneSizes {
uint32 anticoneSize = 2; uint32 anticoneSize = 2;
} }
message DoneBlocksWithTrustedDataMessage { message DoneBlocksWithTrustedDataMessage {}
}
message PruningPointsMessage { message PruningPointsMessage { repeated BlockHeader headers = 1; }
repeated BlockHeader headers = 1;
}
message RequestPruningPointProofMessage { message RequestPruningPointProofMessage {}
}
message PruningPointProofMessage { message PruningPointProofMessage {
repeated PruningPointProofHeaderArray headers = 1; repeated PruningPointProofHeaderArray headers = 1;
} }
message PruningPointProofHeaderArray { message PruningPointProofHeaderArray { repeated BlockHeader headers = 1; }
repeated BlockHeader headers = 1;
}
message ReadyMessage { message ReadyMessage {}
}
message BlockWithTrustedDataV4Message { message BlockWithTrustedDataV4Message {
BlockMessage block = 1; BlockMessage block = 1;

View File

@ -1,11 +1,14 @@
// RPC-related types. Request messages, response messages, and dependant types. // RPC-related types. Request messages, response messages, and dependant types.
// //
// Clients are expected to build RequestMessages and wrap them in KaspadMessage. (see messages.proto) // Clients are expected to build RequestMessages and wrap them in KaspadMessage.
// (see messages.proto)
// //
// Having received a RequestMessage, (wrapped in a KaspadMessage) the RPC server will respond with a // Having received a RequestMessage, (wrapped in a KaspadMessage) the RPC server
// ResponseMessage (likewise wrapped in a KaspadMessage) respective to the original RequestMessage. // will respond with a ResponseMessage (likewise wrapped in a KaspadMessage)
// respective to the original RequestMessage.
// //
// **IMPORTANT:** This API is a work in progress and is subject to break between versions. // **IMPORTANT:** This API is a work in progress and is subject to break between
// versions.
// //
syntax = "proto3"; syntax = "proto3";
package protowire; package protowire;
@ -14,10 +17,9 @@ option go_package = "github.com/kaspanet/kaspad/protowire";
// RPCError represents a generic non-internal error. // RPCError represents a generic non-internal error.
// //
// Receivers of any ResponseMessage are expected to check whether its error field is not null. // Receivers of any ResponseMessage are expected to check whether its error
message RPCError{ // field is not null.
string message = 1; message RPCError { string message = 1; }
}
message RpcBlock { message RpcBlock {
RpcBlockHeader header = 1; RpcBlockHeader header = 1;
@ -40,9 +42,7 @@ message RpcBlockHeader {
uint64 blueScore = 13; uint64 blueScore = 13;
} }
message RpcBlockLevelParents { message RpcBlockLevelParents { repeated string parentHashes = 1; }
repeated string parentHashes = 1;
}
message RpcBlockVerboseData { message RpcBlockVerboseData {
string hash = 1; string hash = 1;
@ -66,7 +66,7 @@ message RpcTransaction {
uint64 gas = 6; uint64 gas = 6;
string payload = 8; string payload = 8;
RpcTransactionVerboseData verboseData = 9; RpcTransactionVerboseData verboseData = 9;
uint64 mass = 10; // <<< BPS10 - Add mass to RpcTransaction uint64 mass = 10;
} }
message RpcTransactionInput { message RpcTransactionInput {
@ -108,19 +108,18 @@ message RpcTransactionVerboseData{
uint64 blockTime = 14; uint64 blockTime = 14;
} }
message RpcTransactionInputVerboseData{ message RpcTransactionInputVerboseData {}
}
message RpcTransactionOutputVerboseData { message RpcTransactionOutputVerboseData {
string scriptPublicKeyType = 5; string scriptPublicKeyType = 5;
string scriptPublicKeyAddress = 6; string scriptPublicKeyAddress = 6;
} }
// GetCurrentNetworkRequestMessage requests the network kaspad is currently running against. // GetCurrentNetworkRequestMessage requests the network kaspad is currently
// running against.
// //
// Possible networks are: Mainnet, Testnet, Simnet, Devnet // Possible networks are: Mainnet, Testnet, Simnet, Devnet
message GetCurrentNetworkRequestMessage{ message GetCurrentNetworkRequestMessage {}
}
message GetCurrentNetworkResponseMessage { message GetCurrentNetworkResponseMessage {
string currentNetwork = 1; string currentNetwork = 1;
@ -128,7 +127,8 @@ message GetCurrentNetworkResponseMessage{
} }
// 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 using the getBlockTemplate call. // Blocks are generally expected to have been generated using the
// getBlockTemplate call.
// //
// See: GetBlockTemplateRequestMessage // See: GetBlockTemplateRequestMessage
message SubmitBlockRequestMessage { message SubmitBlockRequestMessage {
@ -147,7 +147,8 @@ message SubmitBlockResponseMessage{
} }
// GetBlockTemplateRequestMessage requests a current block template. // GetBlockTemplateRequestMessage requests a current block template.
// Callers are expected to solve the block template and submit it using the submitBlock call // Callers are expected to solve the block template and submit it using the
// submitBlock call
// //
// See: SubmitBlockRequestMessage // See: SubmitBlockRequestMessage
message GetBlockTemplateRequestMessage { message GetBlockTemplateRequestMessage {
@ -160,36 +161,32 @@ message GetBlockTemplateResponseMessage{
RpcBlock block = 3; RpcBlock block = 3;
// Whether kaspad thinks that it's synced. // Whether kaspad thinks that it's synced.
// Callers are discouraged (but not forbidden) from solving blocks when kaspad is not synced. // Callers are discouraged (but not forbidden) from solving blocks when kaspad
// That is because when kaspad isn't in sync with the rest of the network there's a high // is not synced. That is because when kaspad isn't in sync with the rest of
// chance the block will never be accepted, thus the solving effort would have been wasted. // the network there's a high chance the block will never be accepted, thus
// the solving effort would have been wasted.
bool isSynced = 2; bool isSynced = 2;
RPCError error = 1000; RPCError error = 1000;
} }
// NotifyBlockAddedRequestMessage registers this connection for blockAdded notifications. // NotifyBlockAddedRequestMessage registers this connection for blockAdded
// notifications.
// //
// See: BlockAddedNotificationMessage // See: BlockAddedNotificationMessage
message NotifyBlockAddedRequestMessage{ message NotifyBlockAddedRequestMessage {}
}
message NotifyBlockAddedResponseMessage{ message NotifyBlockAddedResponseMessage { RPCError error = 1000; }
RPCError error = 1000;
}
// BlockAddedNotificationMessage is sent whenever a blocks has been added (NOT accepted) // BlockAddedNotificationMessage is sent whenever a blocks has been added (NOT
// into the DAG. // accepted) into the DAG.
// //
// See: NotifyBlockAddedRequestMessage // See: NotifyBlockAddedRequestMessage
message BlockAddedNotificationMessage{ message BlockAddedNotificationMessage { RpcBlock block = 3; }
RpcBlock block = 3;
}
// GetPeerAddressesRequestMessage requests the list of known kaspad addresses in the // GetPeerAddressesRequestMessage requests the list of known kaspad addresses in
// current network. (mainnet, testnet, etc.) // the current network. (mainnet, testnet, etc.)
message GetPeerAddressesRequestMessage{ message GetPeerAddressesRequestMessage {}
}
message GetPeerAddressesResponseMessage { message GetPeerAddressesResponseMessage {
repeated GetPeerAddressesKnownAddressMessage addresses = 1; repeated GetPeerAddressesKnownAddressMessage addresses = 1;
@ -197,22 +194,19 @@ message GetPeerAddressesResponseMessage{
RPCError error = 1000; RPCError error = 1000;
} }
message GetPeerAddressesKnownAddressMessage { message GetPeerAddressesKnownAddressMessage { string Addr = 1; }
string Addr = 1;
}
// GetSelectedTipHashRequestMessage requests the hash of the current virtual's // GetSelectedTipHashRequestMessage requests the hash of the current virtual's
// selected parent. // selected parent.
message GetSelectedTipHashRequestMessage{ message GetSelectedTipHashRequestMessage {}
}
message GetSelectedTipHashResponseMessage { message GetSelectedTipHashResponseMessage {
string selectedTipHash = 1; string selectedTipHash = 1;
RPCError error = 1000; RPCError error = 1000;
} }
// GetMempoolEntryRequestMessage requests information about a specific transaction // GetMempoolEntryRequestMessage requests information about a specific
// in the mempool. // transaction in the mempool.
message GetMempoolEntryRequestMessage { message GetMempoolEntryRequestMessage {
// The transaction's TransactionID. // The transaction's TransactionID.
string txId = 1; string txId = 1;
@ -226,8 +220,8 @@ message GetMempoolEntryResponseMessage{
RPCError error = 1000; RPCError error = 1000;
} }
// GetMempoolEntriesRequestMessage requests information about all the transactions // GetMempoolEntriesRequestMessage requests information about all the
// currently in the mempool. // transactions currently in the mempool.
message GetMempoolEntriesRequestMessage { message GetMempoolEntriesRequestMessage {
bool includeOrphanPool = 1; bool includeOrphanPool = 1;
bool filterTransactionPool = 2; bool filterTransactionPool = 2;
@ -245,10 +239,9 @@ message MempoolEntry{
bool isOrphan = 4; bool isOrphan = 4;
} }
// GetConnectedPeerInfoRequestMessage requests information about all the p2p peers // GetConnectedPeerInfoRequestMessage requests information about all the p2p
// currently connected to this kaspad. // peers currently connected to this kaspad.
message GetConnectedPeerInfoRequestMessage{ message GetConnectedPeerInfoRequestMessage {}
}
message GetConnectedPeerInfoResponseMessage { message GetConnectedPeerInfoResponseMessage {
repeated GetConnectedPeerInfoMessage infos = 1; repeated GetConnectedPeerInfoMessage infos = 1;
@ -286,9 +279,7 @@ message AddPeerRequestMessage{
bool isPermanent = 2; bool isPermanent = 2;
} }
message AddPeerResponseMessage{ message AddPeerResponseMessage { RPCError error = 1000; }
RPCError error = 1000;
}
// SubmitTransactionRequestMessage submits a transaction to the mempool // SubmitTransactionRequestMessage submits a transaction to the mempool
message SubmitTransactionRequestMessage { message SubmitTransactionRequestMessage {
@ -303,7 +294,8 @@ message SubmitTransactionResponseMessage{
RPCError error = 1000; RPCError error = 1000;
} }
// NotifyVirtualSelectedParentChainChangedRequestMessage registers this connection for virtualSelectedParentChainChanged notifications. // NotifyVirtualSelectedParentChainChangedRequestMessage registers this
// connection for virtualSelectedParentChainChanged notifications.
// //
// See: VirtualSelectedParentChainChangedNotificationMessage // See: VirtualSelectedParentChainChangedNotificationMessage
message NotifyVirtualSelectedParentChainChangedRequestMessage { message NotifyVirtualSelectedParentChainChangedRequestMessage {
@ -314,8 +306,8 @@ message NotifyVirtualSelectedParentChainChangedResponseMessage{
RPCError error = 1000; RPCError error = 1000;
} }
// VirtualSelectedParentChainChangedNotificationMessage is sent whenever the DAG's selected parent // VirtualSelectedParentChainChangedNotificationMessage is sent whenever the
// chain had changed. // DAG's selected parent chain had changed.
// //
// See: NotifyVirtualSelectedParentChainChangedRequestMessage // See: NotifyVirtualSelectedParentChainChangedRequestMessage
message VirtualSelectedParentChainChangedNotificationMessage { message VirtualSelectedParentChainChangedNotificationMessage {
@ -325,7 +317,8 @@ message VirtualSelectedParentChainChangedNotificationMessage{
// The chain blocks that were added, in low-to-high order // The chain blocks that were added, in low-to-high order
repeated string addedChainBlockHashes = 3; repeated string addedChainBlockHashes = 3;
// Will be filled only if `includeAcceptedTransactionIds = true` in the notify request. // Will be filled only if `includeAcceptedTransactionIds = true` in the notify
// request.
repeated AcceptedTransactionIds acceptedTransactionIds = 2; repeated AcceptedTransactionIds acceptedTransactionIds = 2;
} }
@ -346,17 +339,15 @@ message GetBlockResponseMessage{
// GetSubnetworkRequestMessage requests information about a specific subnetwork // GetSubnetworkRequestMessage requests information about a specific subnetwork
// //
// Currently unimplemented // Currently unimplemented
message GetSubnetworkRequestMessage{ message GetSubnetworkRequestMessage { string subnetworkId = 1; }
string subnetworkId = 1;
}
message GetSubnetworkResponseMessage { message GetSubnetworkResponseMessage {
uint64 gasLimit = 1; uint64 gasLimit = 1;
RPCError error = 1000; RPCError error = 1000;
} }
// GetVirtualSelectedParentChainFromBlockRequestMessage requests the virtual selected // GetVirtualSelectedParentChainFromBlockRequestMessage requests the virtual
// parent chain from some startHash to this kaspad's current virtual // selected parent chain from some startHash to this kaspad's current virtual
message GetVirtualSelectedParentChainFromBlockRequestMessage { message GetVirtualSelectedParentChainFromBlockRequestMessage {
string startHash = 1; string startHash = 1;
bool includeAcceptedTransactionIds = 2; bool includeAcceptedTransactionIds = 2;
@ -375,14 +366,15 @@ message GetVirtualSelectedParentChainFromBlockResponseMessage{
repeated string addedChainBlockHashes = 3; repeated string addedChainBlockHashes = 3;
// The transactions accepted by each block in addedChainBlockHashes. // The transactions accepted by each block in addedChainBlockHashes.
// Will be filled only if `includeAcceptedTransactionIds = true` in the request. // Will be filled only if `includeAcceptedTransactionIds = true` in the
// request.
repeated AcceptedTransactionIds acceptedTransactionIds = 2; repeated AcceptedTransactionIds acceptedTransactionIds = 2;
RPCError error = 1000; RPCError error = 1000;
} }
// GetBlocksRequestMessage requests blocks between a certain block lowHash up to this // GetBlocksRequestMessage requests blocks between a certain block lowHash up to
// kaspad's current virtual. // this kaspad's current virtual.
message GetBlocksRequestMessage { message GetBlocksRequestMessage {
string lowHash = 1; string lowHash = 1;
bool includeBlocks = 2; bool includeBlocks = 2;
@ -395,10 +387,9 @@ message GetBlocksResponseMessage{
RPCError error = 1000; RPCError error = 1000;
} }
// GetBlockCountRequestMessage requests the current number of blocks in this kaspad. // GetBlockCountRequestMessage requests the current number of blocks in this
// Note that this number may decrease as pruning occurs. // kaspad. Note that this number may decrease as pruning occurs.
message GetBlockCountRequestMessage{ message GetBlockCountRequestMessage {}
}
message GetBlockCountResponseMessage { message GetBlockCountResponseMessage {
uint64 blockCount = 1; uint64 blockCount = 1;
@ -406,10 +397,9 @@ message GetBlockCountResponseMessage{
RPCError error = 1000; RPCError error = 1000;
} }
// GetBlockDagInfoRequestMessage requests general information about the current state // GetBlockDagInfoRequestMessage requests general information about the current
// of this kaspad's DAG. // state of this kaspad's DAG.
message GetBlockDagInfoRequestMessage{ message GetBlockDagInfoRequestMessage {}
}
message GetBlockDagInfoResponseMessage { message GetBlockDagInfoResponseMessage {
string networkName = 1; string networkName = 1;
@ -424,36 +414,24 @@ message GetBlockDagInfoResponseMessage{
RPCError error = 1000; RPCError error = 1000;
} }
message ResolveFinalityConflictRequestMessage{ message ResolveFinalityConflictRequestMessage { string finalityBlockHash = 1; }
string finalityBlockHash = 1;
}
message ResolveFinalityConflictResponseMessage{ message ResolveFinalityConflictResponseMessage { RPCError error = 1000; }
RPCError error = 1000;
}
message NotifyFinalityConflictsRequestMessage{ message NotifyFinalityConflictsRequestMessage {}
}
message NotifyFinalityConflictsResponseMessage{ message NotifyFinalityConflictsResponseMessage { RPCError error = 1000; }
RPCError error = 1000;
}
message FinalityConflictNotificationMessage{ message FinalityConflictNotificationMessage { string violatingBlockHash = 1; }
string violatingBlockHash = 1;
}
message FinalityConflictResolvedNotificationMessage { message FinalityConflictResolvedNotificationMessage {
string finalityBlockHash = 1; string finalityBlockHash = 1;
} }
// ShutDownRequestMessage shuts down this kaspad. // ShutDownRequestMessage shuts down this kaspad.
message ShutDownRequestMessage{ message ShutDownRequestMessage {}
}
message ShutDownResponseMessage{ message ShutDownResponseMessage { RPCError error = 1000; }
RPCError error = 1000;
}
// GetHeadersRequestMessage requests headers between the given startHash and the // GetHeadersRequestMessage requests headers between the given startHash and the
// current virtual, up to the given limit. // current virtual, up to the given limit.
@ -468,8 +446,8 @@ message GetHeadersResponseMessage{
RPCError error = 1000; RPCError error = 1000;
} }
// NotifyUtxosChangedRequestMessage registers this connection for utxoChanged notifications // NotifyUtxosChangedRequestMessage registers this connection for utxoChanged
// for the given addresses. // notifications for the given addresses.
// //
// This call is only available when this kaspad was started with `--utxoindex` // This call is only available when this kaspad was started with `--utxoindex`
// //
@ -478,11 +456,10 @@ message NotifyUtxosChangedRequestMessage {
repeated string addresses = 1; // Leave empty to get all updates repeated string addresses = 1; // Leave empty to get all updates
} }
message NotifyUtxosChangedResponseMessage { message NotifyUtxosChangedResponseMessage { RPCError error = 1000; }
RPCError error = 1000;
}
// UtxosChangedNotificationMessage is sent whenever the UTXO index had been updated. // UtxosChangedNotificationMessage is sent whenever the UTXO index had been
// updated.
// //
// See: NotifyUtxosChangedRequestMessage // See: NotifyUtxosChangedRequestMessage
message UtxosChangedNotificationMessage { message UtxosChangedNotificationMessage {
@ -496,8 +473,8 @@ message UtxosByAddressesEntry {
RpcUtxoEntry utxoEntry = 3; RpcUtxoEntry utxoEntry = 3;
} }
// StopNotifyingUtxosChangedRequestMessage unregisters this connection for utxoChanged notifications // StopNotifyingUtxosChangedRequestMessage unregisters this connection for
// for the given addresses. // utxoChanged notifications for the given addresses.
// //
// This call is only available when this kaspad was started with `--utxoindex` // This call is only available when this kaspad was started with `--utxoindex`
// //
@ -506,16 +483,13 @@ message StopNotifyingUtxosChangedRequestMessage {
repeated string addresses = 1; repeated string addresses = 1;
} }
message StopNotifyingUtxosChangedResponseMessage { message StopNotifyingUtxosChangedResponseMessage { RPCError error = 1000; }
RPCError error = 1000;
}
// GetUtxosByAddressesRequestMessage requests all current UTXOs for the given kaspad addresses // GetUtxosByAddressesRequestMessage requests all current UTXOs for the given
// kaspad addresses
// //
// This call is only available when this kaspad was started with `--utxoindex` // This call is only available when this kaspad was started with `--utxoindex`
message GetUtxosByAddressesRequestMessage { message GetUtxosByAddressesRequestMessage { repeated string addresses = 1; }
repeated string addresses = 1;
}
message GetUtxosByAddressesResponseMessage { message GetUtxosByAddressesResponseMessage {
repeated UtxosByAddressesEntry entries = 1; repeated UtxosByAddressesEntry entries = 1;
@ -523,12 +497,11 @@ message GetUtxosByAddressesResponseMessage {
RPCError error = 1000; RPCError error = 1000;
} }
// GetBalanceByAddressRequest returns the total balance in unspent transactions towards a given address // GetBalanceByAddressRequest returns the total balance in unspent transactions
// towards a given address
// //
// This call is only available when this kaspad was started with `--utxoindex` // This call is only available when this kaspad was started with `--utxoindex`
message GetBalanceByAddressRequestMessage { message GetBalanceByAddressRequestMessage { string address = 1; }
string address = 1;
}
message GetBalanceByAddressResponseMessage { message GetBalanceByAddressResponseMessage {
uint64 balance = 1; uint64 balance = 1;
@ -536,9 +509,7 @@ message GetBalanceByAddressResponseMessage {
RPCError error = 1000; RPCError error = 1000;
} }
message GetBalancesByAddressesRequestMessage { message GetBalancesByAddressesRequestMessage { repeated string addresses = 1; }
repeated string addresses = 1;
}
message BalancesByAddressEntry { message BalancesByAddressEntry {
string address = 1; string address = 1;
@ -553,10 +524,9 @@ message GetBalancesByAddressesResponseMessage {
RPCError error = 1000; RPCError error = 1000;
} }
// GetVirtualSelectedParentBlueScoreRequestMessage requests the blue score of the current selected parent // GetVirtualSelectedParentBlueScoreRequestMessage requests the blue score of
// of the virtual block. // the current selected parent of the virtual block.
message GetVirtualSelectedParentBlueScoreRequestMessage { message GetVirtualSelectedParentBlueScoreRequestMessage {}
}
message GetVirtualSelectedParentBlueScoreResponseMessage { message GetVirtualSelectedParentBlueScoreResponseMessage {
uint64 blueScore = 1; uint64 blueScore = 1;
@ -564,19 +534,18 @@ message GetVirtualSelectedParentBlueScoreResponseMessage {
RPCError error = 1000; RPCError error = 1000;
} }
// NotifyVirtualSelectedParentBlueScoreChangedRequestMessage registers this connection for // NotifyVirtualSelectedParentBlueScoreChangedRequestMessage registers this
// virtualSelectedParentBlueScoreChanged notifications. // connection for virtualSelectedParentBlueScoreChanged notifications.
// //
// See: VirtualSelectedParentBlueScoreChangedNotificationMessage // See: VirtualSelectedParentBlueScoreChangedNotificationMessage
message NotifyVirtualSelectedParentBlueScoreChangedRequestMessage { message NotifyVirtualSelectedParentBlueScoreChangedRequestMessage {}
}
message NotifyVirtualSelectedParentBlueScoreChangedResponseMessage { message NotifyVirtualSelectedParentBlueScoreChangedResponseMessage {
RPCError error = 1000; RPCError error = 1000;
} }
// VirtualSelectedParentBlueScoreChangedNotificationMessage is sent whenever the blue score // VirtualSelectedParentBlueScoreChangedNotificationMessage is sent whenever the
// of the virtual's selected parent changes. // blue score of the virtual's selected parent changes.
// //
// See NotifyVirtualSelectedParentBlueScoreChangedRequestMessage // See NotifyVirtualSelectedParentBlueScoreChangedRequestMessage
message VirtualSelectedParentBlueScoreChangedNotificationMessage { message VirtualSelectedParentBlueScoreChangedNotificationMessage {
@ -587,12 +556,9 @@ message VirtualSelectedParentBlueScoreChangedNotificationMessage {
// virtualDaaScoreChanged notifications. // virtualDaaScoreChanged notifications.
// //
// See: VirtualDaaScoreChangedNotificationMessage // See: VirtualDaaScoreChangedNotificationMessage
message NotifyVirtualDaaScoreChangedRequestMessage { message NotifyVirtualDaaScoreChangedRequestMessage {}
}
message NotifyVirtualDaaScoreChangedResponseMessage { message NotifyVirtualDaaScoreChangedResponseMessage { RPCError error = 1000; }
RPCError error = 1000;
}
// VirtualDaaScoreChangedNotificationMessage is sent whenever the DAA score // VirtualDaaScoreChangedNotificationMessage is sent whenever the DAA score
// of the virtual changes. // of the virtual changes.
@ -608,55 +574,42 @@ message VirtualDaaScoreChangedNotificationMessage {
// This call is only available when this kaspad was started with `--utxoindex` // This call is only available when this kaspad was started with `--utxoindex`
// //
// See: NotifyPruningPointUTXOSetOverrideResponseMessage // See: NotifyPruningPointUTXOSetOverrideResponseMessage
message NotifyPruningPointUTXOSetOverrideRequestMessage { message NotifyPruningPointUTXOSetOverrideRequestMessage {}
}
message NotifyPruningPointUTXOSetOverrideResponseMessage { message NotifyPruningPointUTXOSetOverrideResponseMessage {
RPCError error = 1000; RPCError error = 1000;
} }
// PruningPointUTXOSetOverrideNotificationMessage is sent whenever the UTXO index // PruningPointUTXOSetOverrideNotificationMessage is sent whenever the UTXO
// resets due to pruning point change via IBD. // index resets due to pruning point change via IBD.
// //
// See NotifyPruningPointUTXOSetOverrideRequestMessage // See NotifyPruningPointUTXOSetOverrideRequestMessage
message PruningPointUTXOSetOverrideNotificationMessage { message PruningPointUTXOSetOverrideNotificationMessage {}
}
// StopNotifyingPruningPointUTXOSetOverrideRequestMessage unregisters this connection for // StopNotifyingPruningPointUTXOSetOverrideRequestMessage unregisters this
// pruning point UTXO set override notifications. // connection for pruning point UTXO set override notifications.
// //
// This call is only available when this kaspad was started with `--utxoindex` // This call is only available when this kaspad was started with `--utxoindex`
// //
// See: PruningPointUTXOSetOverrideNotificationMessage // See: PruningPointUTXOSetOverrideNotificationMessage
message StopNotifyingPruningPointUTXOSetOverrideRequestMessage { message StopNotifyingPruningPointUTXOSetOverrideRequestMessage {}
}
message StopNotifyingPruningPointUTXOSetOverrideResponseMessage { message StopNotifyingPruningPointUTXOSetOverrideResponseMessage {
RPCError error = 1000; RPCError error = 1000;
} }
// BanRequestMessage bans the given ip. // BanRequestMessage bans the given ip.
message BanRequestMessage{ message BanRequestMessage { string ip = 1; }
string ip = 1;
}
message BanResponseMessage{ message BanResponseMessage { RPCError error = 1000; }
RPCError error = 1000;
}
// UnbanRequestMessage unbans the given ip. // UnbanRequestMessage unbans the given ip.
message UnbanRequestMessage{ message UnbanRequestMessage { string ip = 1; }
string ip = 1;
}
message UnbanResponseMessage{ message UnbanResponseMessage { RPCError error = 1000; }
RPCError error = 1000;
}
// GetInfoRequestMessage returns info about the node. // GetInfoRequestMessage returns info about the node.
message GetInfoRequestMessage{ message GetInfoRequestMessage {}
}
message GetInfoResponseMessage { message GetInfoResponseMessage {
string p2pId = 1; string p2pId = 1;
@ -681,19 +634,15 @@ message EstimateNetworkHashesPerSecondResponseMessage{
// NewBlockTemplate notifications. // NewBlockTemplate notifications.
// //
// See: NewBlockTemplateNotificationMessage // See: NewBlockTemplateNotificationMessage
message NotifyNewBlockTemplateRequestMessage { message NotifyNewBlockTemplateRequestMessage {}
}
message NotifyNewBlockTemplateResponseMessage { message NotifyNewBlockTemplateResponseMessage { RPCError error = 1000; }
RPCError error = 1000;
}
// NewBlockTemplateNotificationMessage is sent whenever a new updated block template is // NewBlockTemplateNotificationMessage is sent whenever a new updated block
// available for miners. // template is available for miners.
// //
// See NotifyNewBlockTemplateRequestMessage // See NotifyNewBlockTemplateRequestMessage
message NewBlockTemplateNotificationMessage { message NewBlockTemplateNotificationMessage {}
}
message MempoolEntryByAddress { message MempoolEntryByAddress {
string address = 1; string address = 1;
@ -713,18 +662,18 @@ message GetMempoolEntriesByAddressesResponseMessage{
RPCError error = 1000; RPCError error = 1000;
} }
message GetCoinSupplyRequestMessage{ message GetCoinSupplyRequestMessage {}
}
message GetCoinSupplyResponseMessage { message GetCoinSupplyResponseMessage {
uint64 maxSompi = 1; // note: this is a hard coded maxSupply, actual maxSupply is expected to deviate by upto -5%, but cannot be measured exactly. uint64 maxSompi =
1; // note: this is a hard coded maxSupply, actual maxSupply is expected
// to deviate by upto -5%, but cannot be measured exactly.
uint64 circulatingSompi = 2; uint64 circulatingSompi = 2;
RPCError error = 1000; RPCError error = 1000;
} }
message PingRequestMessage{ message PingRequestMessage {}
}
message PingResponseMessage { RPCError error = 1000; } message PingResponseMessage { RPCError error = 1000; }