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

@ -3,26 +3,22 @@ package protowire;
option go_package = "github.com/kaspanet/kaspad/protowire"; option go_package = "github.com/kaspanet/kaspad/protowire";
message RequestAddressesMessage{ message RequestAddressesMessage {
bool includeAllSubnetworks = 1; bool includeAllSubnetworks = 1;
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;
bytes ip = 3; bytes ip = 3;
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;
repeated TransactionInput inputs = 2; repeated TransactionInput inputs = 2;
repeated TransactionOutput outputs = 3; repeated TransactionOutput outputs = 3;
@ -30,40 +26,38 @@ 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 {
Outpoint previousOutpoint = 1; Outpoint previousOutpoint = 1;
bytes signatureScript = 2; bytes signatureScript = 2;
uint64 sequence = 3; uint64 sequence = 3;
uint32 sigOpCount = 4; uint32 sigOpCount = 4;
} }
message Outpoint{ message Outpoint {
TransactionId transactionId = 1; TransactionId transactionId = 1;
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;
} }
message TransactionOutput{ message TransactionOutput {
uint64 value = 1; uint64 value = 1;
ScriptPublicKey scriptPublicKey = 2; ScriptPublicKey scriptPublicKey = 2;
} }
message BlockMessage{ message BlockMessage {
BlockHeader header = 1; BlockHeader header = 1;
repeated TransactionMessage transactions = 2; repeated TransactionMessage transactions = 2;
} }
message BlockHeader{ message BlockHeader {
uint32 version = 1; uint32 version = 1;
repeated BlockLevelParents parents = 12; repeated BlockLevelParents parents = 12;
Hash hashMerkleRoot = 3; Hash hashMerkleRoot = 3;
@ -78,66 +72,43 @@ 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;
uint64 services = 2; uint64 services = 2;
int64 timestamp = 3; int64 timestamp = 3;
@ -149,19 +120,15 @@ 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;
} }
message OutpointAndUtxoEntryPair{ message OutpointAndUtxoEntryPair {
Outpoint outpoint = 1; Outpoint outpoint = 1;
UtxoEntry utxoEntry = 2; UtxoEntry utxoEntry = 2;
} }
@ -173,54 +140,40 @@ 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;
repeated Hash blockLocatorHashes = 2; repeated Hash blockLocatorHashes = 2;
} }
message RequestIBDChainBlockLocatorMessage{ message RequestIBDChainBlockLocatorMessage {
Hash lowHash = 1; Hash lowHash = 1;
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,11 +42,9 @@ 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;
double difficulty = 11; double difficulty = 11;
string selectedParentHash = 13; string selectedParentHash = 13;
@ -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 {
@ -100,7 +100,7 @@ message RpcUtxoEntry {
bool isCoinbase = 4; bool isCoinbase = 4;
} }
message RpcTransactionVerboseData{ message RpcTransactionVerboseData {
string transactionId = 1; string transactionId = 1;
string hash = 2; string hash = 2;
uint64 mass = 4; uint64 mass = 4;
@ -108,35 +108,35 @@ 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;
RPCError error = 1000; RPCError error = 1000;
} }
// 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 {
RpcBlock block = 2; RpcBlock block = 2;
bool allowNonDAABlocks = 3; bool allowNonDAABlocks = 3;
} }
message SubmitBlockResponseMessage{ message SubmitBlockResponseMessage {
enum RejectReason { enum RejectReason {
NONE = 0; NONE = 0;
BLOCK_INVALID = 1; BLOCK_INVALID = 1;
@ -147,115 +147,108 @@ 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 {
// Which kaspa address should the coinbase block reward transaction pay into // Which kaspa address should the coinbase block reward transaction pay into
string payAddress = 1; string payAddress = 1;
string extraData = 2; string extraData = 2;
} }
message GetBlockTemplateResponseMessage{ 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;
repeated GetPeerAddressesKnownAddressMessage bannedAddresses = 2; repeated GetPeerAddressesKnownAddressMessage bannedAddresses = 2;
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;
bool includeOrphanPool = 2; bool includeOrphanPool = 2;
bool filterTransactionPool = 3; bool filterTransactionPool = 3;
} }
message GetMempoolEntryResponseMessage{ message GetMempoolEntryResponseMessage {
MempoolEntry entry = 1; MempoolEntry entry = 1;
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;
} }
message GetMempoolEntriesResponseMessage{ message GetMempoolEntriesResponseMessage {
repeated MempoolEntry entries = 1; repeated MempoolEntry entries = 1;
RPCError error = 1000; RPCError error = 1000;
} }
message MempoolEntry{ message MempoolEntry {
uint64 fee = 1; uint64 fee = 1;
RpcTransaction transaction = 3; RpcTransaction transaction = 3;
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;
RPCError error = 1000; RPCError error = 1000;
} }
message GetConnectedPeerInfoMessage{ message GetConnectedPeerInfoMessage {
string id = 1; string id = 1;
string address = 2; string address = 2;
@ -279,58 +272,58 @@ message GetConnectedPeerInfoMessage{
// AddPeerRequestMessage adds a peer to kaspad's outgoing connection list. // AddPeerRequestMessage adds a peer to kaspad's outgoing connection list.
// This will, in most cases, result in kaspad connecting to said peer. // This will, in most cases, result in kaspad connecting to said peer.
message AddPeerRequestMessage{ message AddPeerRequestMessage {
string address = 1; string address = 1;
// Whether to keep attempting to connect to this peer after disconnection // Whether to keep attempting to connect to this peer after disconnection
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 {
RpcTransaction transaction = 1; RpcTransaction transaction = 1;
bool allowOrphan = 2; bool allowOrphan = 2;
} }
message SubmitTransactionResponseMessage{ message SubmitTransactionResponseMessage {
// The transaction ID of the submitted transaction // The transaction ID of the submitted transaction
string transactionId = 1; string transactionId = 1;
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 {
bool includeAcceptedTransactionIds = 1; bool includeAcceptedTransactionIds = 1;
} }
message NotifyVirtualSelectedParentChainChangedResponseMessage{ 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 {
// The chain blocks that were removed, in high-to-low order // The chain blocks that were removed, in high-to-low order
repeated string removedChainBlockHashes = 1; repeated string removedChainBlockHashes = 1;
// 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;
} }
// GetBlockRequestMessage requests information about a specific block // GetBlockRequestMessage requests information about a specific block
message GetBlockRequestMessage{ message GetBlockRequestMessage {
// The hash of the requested block // The hash of the requested block
string hash = 1; string hash = 1;
@ -338,7 +331,7 @@ message GetBlockRequestMessage{
bool includeTransactions = 3; bool includeTransactions = 3;
} }
message GetBlockResponseMessage{ message GetBlockResponseMessage {
RpcBlock block = 3; RpcBlock block = 3;
RPCError error = 1000; RPCError error = 1000;
} }
@ -346,28 +339,26 @@ 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;
} }
message AcceptedTransactionIds{ message AcceptedTransactionIds {
string acceptingBlockHash = 1; string acceptingBlockHash = 1;
repeated string acceptedTransactionIds = 2; repeated string acceptedTransactionIds = 2;
} }
message GetVirtualSelectedParentChainFromBlockResponseMessage{ message GetVirtualSelectedParentChainFromBlockResponseMessage {
// The chain blocks that were removed, in high-to-low order // The chain blocks that were removed, in high-to-low order
repeated string removedChainBlockHashes = 1; repeated string removedChainBlockHashes = 1;
@ -375,43 +366,42 @@ 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;
bool includeTransactions = 3; bool includeTransactions = 3;
} }
message GetBlocksResponseMessage{ message GetBlocksResponseMessage {
repeated string blockHashes = 4; repeated string blockHashes = 4;
repeated RpcBlock blocks = 3; repeated RpcBlock blocks = 3;
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;
uint64 headerCount = 2; uint64 headerCount = 2;
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;
uint64 blockCount = 2; uint64 blockCount = 2;
uint64 headerCount = 3; uint64 headerCount = 3;
@ -424,52 +414,40 @@ 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.
message GetHeadersRequestMessage{ message GetHeadersRequestMessage {
string startHash = 1; string startHash = 1;
uint64 limit = 2; uint64 limit = 2;
bool isAscending = 3; bool isAscending = 3;
} }
message GetHeadersResponseMessage{ message GetHeadersResponseMessage {
repeated string headers = 1; repeated string headers = 1;
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,11 +509,9 @@ 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;
uint64 balance = 2; uint64 balance = 2;
@ -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,57 +574,44 @@ 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;
uint64 mempoolSize = 2; uint64 mempoolSize = 2;
string serverVersion = 3; string serverVersion = 3;
@ -667,12 +620,12 @@ message GetInfoResponseMessage{
RPCError error = 1000; RPCError error = 1000;
} }
message EstimateNetworkHashesPerSecondRequestMessage{ message EstimateNetworkHashesPerSecondRequestMessage {
uint32 windowSize = 1; uint32 windowSize = 1;
string startHash = 2; string startHash = 2;
} }
message EstimateNetworkHashesPerSecondResponseMessage{ message EstimateNetworkHashesPerSecondResponseMessage {
uint64 networkHashesPerSecond = 1; uint64 networkHashesPerSecond = 1;
RPCError error = 1000; RPCError error = 1000;
} }
@ -681,50 +634,46 @@ 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;
repeated MempoolEntry sending = 2; repeated MempoolEntry sending = 2;
repeated MempoolEntry receiving = 3; repeated MempoolEntry receiving = 3;
} }
message GetMempoolEntriesByAddressesRequestMessage{ message GetMempoolEntriesByAddressesRequestMessage {
repeated string addresses = 1; repeated string addresses = 1;
bool includeOrphanPool = 2; bool includeOrphanPool = 2;
bool filterTransactionPool = 3; bool filterTransactionPool = 3;
} }
message GetMempoolEntriesByAddressesResponseMessage{ message GetMempoolEntriesByAddressesResponseMessage {
repeated MempoolEntryByAddress entries = 1; repeated MempoolEntryByAddress entries = 1;
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; }
@ -853,7 +802,7 @@ message GetDaaScoreTimestampEstimateRequestMessage {
repeated uint64 daaScores = 1; repeated uint64 daaScores = 1;
} }
message GetDaaScoreTimestampEstimateResponseMessage{ message GetDaaScoreTimestampEstimateResponseMessage {
repeated uint64 timestamps = 1; repeated uint64 timestamps = 1;
RPCError error = 1000; RPCError error = 1000;
} }