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 (
"encoding/hex"
"github.com/pkg/errors"
"math/big"
"github.com/pkg/errors"
"github.com/kaspanet/kaspad/domain/consensus/utils/blockheader"
"github.com/kaspanet/kaspad/domain/consensus/utils/hashes"
"github.com/kaspanet/kaspad/domain/consensus/utils/utxo"
@ -213,14 +214,14 @@ func RPCTransactionToDomainTransaction(rpcTransaction *RPCTransaction) (*externa
}
return &externalapi.DomainTransaction{
Version: rpcTransaction.Version,
Inputs: inputs,
Outputs: outputs,
LockTime: rpcTransaction.LockTime,
SubnetworkID: *subnetworkID,
Gas: rpcTransaction.Gas,
Mass: rpcTransaction.Mass, // BPS10 add mass
Payload: payload,
Version: rpcTransaction.Version,
Inputs: inputs,
Outputs: outputs,
LockTime: rpcTransaction.LockTime,
SubnetworkID: *subnetworkID,
Gas: rpcTransaction.Gas,
MassCommitment: rpcTransaction.Mass,
Payload: payload,
}, nil
}
@ -288,7 +289,7 @@ func DomainTransactionToRPCTransaction(transaction *externalapi.DomainTransactio
LockTime: transaction.LockTime,
SubnetworkID: subnetworkID,
Gas: transaction.Gas,
Mass: transaction.Mass, // <<< BPS10 add mass
Mass: transaction.MassCommitment,
Payload: payload,
}
}

View File

@ -18,8 +18,9 @@ type DomainTransaction struct {
Gas uint64
Payload []byte
Fee uint64
Mass uint64
Fee uint64
Mass uint64
MassCommitment uint64
// ID is a field that is used to cache the transaction ID.
// 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
// transactions.
writer := hashes.NewTransactionHashWriter()
err := serializeTransaction(writer, tx, txEncodingFull)
err := serializeTransaction(writer, tx, txEncodingFull, true)
if err != nil {
// 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)
@ -52,7 +52,7 @@ func TransactionID(tx *externalapi.DomainTransaction) *externalapi.DomainTransac
encodingFlags = txEncodingExcludeSignatureScript
}
writer := hashes.NewTransactionIDWriter()
err := serializeTransaction(writer, tx, encodingFlags)
err := serializeTransaction(writer, tx, encodingFlags, false)
if err != nil {
// 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.
@ -74,7 +74,7 @@ func TransactionIDs(txs []*externalapi.DomainTransaction) []*externalapi.DomainT
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)
if err != nil {
return err
@ -126,12 +126,13 @@ func serializeTransaction(w io.Writer, tx *externalapi.DomainTransaction, encodi
return err
}
if tx.Mass > 0 { // Only serialize Mass if it's not zero
err = binaryserializer.PutUint64(w, tx.Mass)
if err != nil {
return err
if includeMass {
if tx.MassCommitment > 0 { // For backward compatibility, serialize MassCommitment only if it's not zero
err = binaryserializer.PutUint64(w, tx.Mass)
if err != nil {
return err
}
}
}
return nil

View File

@ -3,26 +3,22 @@ package protowire;
option go_package = "github.com/kaspanet/kaspad/protowire";
message RequestAddressesMessage{
message RequestAddressesMessage {
bool includeAllSubnetworks = 1;
SubnetworkId subnetworkId = 2;
}
message AddressesMessage{
repeated NetAddress addressList = 1;
}
message AddressesMessage { repeated NetAddress addressList = 1; }
message NetAddress{
message NetAddress {
int64 timestamp = 1;
bytes ip = 3;
uint32 port = 4;
}
message SubnetworkId{
bytes bytes = 1;
}
message SubnetworkId { bytes bytes = 1; }
message TransactionMessage{
message TransactionMessage {
uint32 version = 1;
repeated TransactionInput inputs = 2;
repeated TransactionOutput outputs = 3;
@ -30,40 +26,38 @@ message TransactionMessage{
SubnetworkId subnetworkId = 5;
uint64 gas = 6;
bytes payload = 8;
uint64 mass = 9; // <<< BPS10 - Add mass to TransactionMessage
uint64 mass = 9;
}
message TransactionInput{
message TransactionInput {
Outpoint previousOutpoint = 1;
bytes signatureScript = 2;
uint64 sequence = 3;
uint32 sigOpCount = 4;
}
message Outpoint{
message Outpoint {
TransactionId transactionId = 1;
uint32 index = 2;
}
message TransactionId{
bytes bytes = 1;
}
message TransactionId { bytes bytes = 1; }
message ScriptPublicKey {
bytes script = 1;
uint32 version = 2;
}
message TransactionOutput{
message TransactionOutput {
uint64 value = 1;
ScriptPublicKey scriptPublicKey = 2;
}
message BlockMessage{
message BlockMessage {
BlockHeader header = 1;
repeated TransactionMessage transactions = 2;
}
message BlockHeader{
message BlockHeader {
uint32 version = 1;
repeated BlockLevelParents parents = 12;
Hash hashMerkleRoot = 3;
@ -78,66 +72,43 @@ message BlockHeader{
uint64 blueScore = 13;
}
message BlockLevelParents {
repeated Hash parentHashes = 1;
}
message BlockLevelParents { repeated Hash parentHashes = 1; }
message Hash{
bytes bytes = 1;
}
message Hash { bytes bytes = 1; }
message RequestBlockLocatorMessage{
message RequestBlockLocatorMessage {
Hash highHash = 1;
uint32 limit = 2;
}
message BlockLocatorMessage{
repeated Hash hashes = 1;
}
message BlockLocatorMessage { repeated Hash hashes = 1; }
message RequestHeadersMessage{
message RequestHeadersMessage {
Hash lowHash = 1;
Hash highHash = 2;
}
message RequestNextHeadersMessage{
}
message RequestNextHeadersMessage {}
message DoneHeadersMessage{
}
message DoneHeadersMessage {}
message RequestRelayBlocksMessage{
repeated Hash hashes = 1;
}
message RequestRelayBlocksMessage { repeated Hash hashes = 1; }
message RequestTransactionsMessage {
repeated TransactionId ids = 1;
}
message RequestTransactionsMessage { repeated TransactionId ids = 1; }
message TransactionNotFoundMessage{
TransactionId id = 1;
}
message TransactionNotFoundMessage { TransactionId id = 1; }
message InvRelayBlockMessage{
Hash hash = 1;
}
message InvRelayBlockMessage { Hash hash = 1; }
message InvTransactionsMessage{
repeated TransactionId ids = 1;
}
message InvTransactionsMessage { repeated TransactionId ids = 1; }
message PingMessage{
uint64 nonce = 1;
}
message PingMessage { uint64 nonce = 1; }
message PongMessage{
uint64 nonce = 1;
}
message PongMessage { uint64 nonce = 1; }
message VerackMessage{
}
message VerackMessage {}
message VersionMessage{
message VersionMessage {
uint32 protocolVersion = 1;
uint64 services = 2;
int64 timestamp = 3;
@ -149,19 +120,15 @@ message VersionMessage{
string network = 10;
}
message RejectMessage{
string reason = 1;
}
message RejectMessage { string reason = 1; }
message RequestPruningPointUTXOSetMessage{
Hash pruningPointHash = 1;
}
message RequestPruningPointUTXOSetMessage { Hash pruningPointHash = 1; }
message PruningPointUtxoSetChunkMessage{
message PruningPointUtxoSetChunkMessage {
repeated OutpointAndUtxoEntryPair outpointAndUtxoEntryPairs = 1;
}
message OutpointAndUtxoEntryPair{
message OutpointAndUtxoEntryPair {
Outpoint outpoint = 1;
UtxoEntry utxoEntry = 2;
}
@ -173,54 +140,40 @@ message UtxoEntry {
bool isCoinbase = 4;
}
message RequestNextPruningPointUtxoSetChunkMessage {
}
message RequestNextPruningPointUtxoSetChunkMessage {}
message DonePruningPointUtxoSetChunksMessage {
}
message DonePruningPointUtxoSetChunksMessage {}
message RequestIBDBlocksMessage{
repeated Hash hashes = 1;
}
message RequestIBDBlocksMessage { repeated Hash hashes = 1; }
message UnexpectedPruningPointMessage{
}
message UnexpectedPruningPointMessage {}
message IbdBlockLocatorMessage {
Hash targetHash = 1;
repeated Hash blockLocatorHashes = 2;
}
message RequestIBDChainBlockLocatorMessage{
message RequestIBDChainBlockLocatorMessage {
Hash lowHash = 1;
Hash highHash = 2;
}
message IbdChainBlockLocatorMessage {
repeated Hash blockLocatorHashes = 1;
}
message IbdChainBlockLocatorMessage { repeated Hash blockLocatorHashes = 1; }
message RequestAnticoneMessage{
message RequestAnticoneMessage {
Hash blockHash = 1;
Hash contextHash = 2;
}
message IbdBlockLocatorHighestHashMessage {
Hash highestHash = 1;
}
message IbdBlockLocatorHighestHashMessage { Hash highestHash = 1; }
message IbdBlockLocatorHighestHashNotFoundMessage {
}
message IbdBlockLocatorHighestHashNotFoundMessage {}
message BlockHeadersMessage {
repeated BlockHeader blockHeaders = 1;
}
message BlockHeadersMessage { repeated BlockHeader blockHeaders = 1; }
message RequestPruningPointAndItsAnticoneMessage {
}
message RequestPruningPointAndItsAnticoneMessage {}
message RequestNextPruningPointAndItsAnticoneBlocksMessage{
}
message RequestNextPruningPointAndItsAnticoneBlocksMessage {}
message BlockWithTrustedDataMessage {
BlockMessage block = 1;
@ -258,26 +211,19 @@ message BluesAnticoneSizes {
uint32 anticoneSize = 2;
}
message DoneBlocksWithTrustedDataMessage {
}
message DoneBlocksWithTrustedDataMessage {}
message PruningPointsMessage {
repeated BlockHeader headers = 1;
}
message PruningPointsMessage { repeated BlockHeader headers = 1; }
message RequestPruningPointProofMessage {
}
message RequestPruningPointProofMessage {}
message PruningPointProofMessage {
repeated PruningPointProofHeaderArray headers = 1;
}
message PruningPointProofHeaderArray {
repeated BlockHeader headers = 1;
}
message PruningPointProofHeaderArray { repeated BlockHeader headers = 1; }
message ReadyMessage {
}
message ReadyMessage {}
message BlockWithTrustedDataV4Message {
BlockMessage block = 1;

View File

@ -1,11 +1,14 @@
// 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
// ResponseMessage (likewise wrapped in a KaspadMessage) respective to the original RequestMessage.
// Having received a RequestMessage, (wrapped in a KaspadMessage) the RPC server
// 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";
package protowire;
@ -14,10 +17,9 @@ option go_package = "github.com/kaspanet/kaspad/protowire";
// RPCError represents a generic non-internal error.
//
// Receivers of any ResponseMessage are expected to check whether its error field is not null.
message RPCError{
string message = 1;
}
// Receivers of any ResponseMessage are expected to check whether its error
// field is not null.
message RPCError { string message = 1; }
message RpcBlock {
RpcBlockHeader header = 1;
@ -40,11 +42,9 @@ message RpcBlockHeader {
uint64 blueScore = 13;
}
message RpcBlockLevelParents {
repeated string parentHashes = 1;
}
message RpcBlockLevelParents { repeated string parentHashes = 1; }
message RpcBlockVerboseData{
message RpcBlockVerboseData {
string hash = 1;
double difficulty = 11;
string selectedParentHash = 13;
@ -66,7 +66,7 @@ message RpcTransaction {
uint64 gas = 6;
string payload = 8;
RpcTransactionVerboseData verboseData = 9;
uint64 mass = 10; // <<< BPS10 - Add mass to RpcTransaction
uint64 mass = 10;
}
message RpcTransactionInput {
@ -100,7 +100,7 @@ message RpcUtxoEntry {
bool isCoinbase = 4;
}
message RpcTransactionVerboseData{
message RpcTransactionVerboseData {
string transactionId = 1;
string hash = 2;
uint64 mass = 4;
@ -108,35 +108,35 @@ message RpcTransactionVerboseData{
uint64 blockTime = 14;
}
message RpcTransactionInputVerboseData{
}
message RpcTransactionInputVerboseData {}
message RpcTransactionOutputVerboseData{
message RpcTransactionOutputVerboseData {
string scriptPublicKeyType = 5;
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
message GetCurrentNetworkRequestMessage{
}
message GetCurrentNetworkRequestMessage {}
message GetCurrentNetworkResponseMessage{
message GetCurrentNetworkResponseMessage {
string currentNetwork = 1;
RPCError error = 1000;
}
// 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
message SubmitBlockRequestMessage{
message SubmitBlockRequestMessage {
RpcBlock block = 2;
bool allowNonDAABlocks = 3;
}
message SubmitBlockResponseMessage{
message SubmitBlockResponseMessage {
enum RejectReason {
NONE = 0;
BLOCK_INVALID = 1;
@ -147,115 +147,108 @@ message SubmitBlockResponseMessage{
}
// 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
message GetBlockTemplateRequestMessage{
message GetBlockTemplateRequestMessage {
// Which kaspa address should the coinbase block reward transaction pay into
string payAddress = 1;
string extraData = 2;
}
message GetBlockTemplateResponseMessage{
message GetBlockTemplateResponseMessage {
RpcBlock block = 3;
// Whether kaspad thinks that it's synced.
// Callers are discouraged (but not forbidden) from solving blocks when kaspad is not synced.
// That is because when kaspad isn't in sync with the rest of the network there's a high
// chance the block will never be accepted, thus the solving effort would have been wasted.
// Callers are discouraged (but not forbidden) from solving blocks when kaspad
// is not synced. That is because when kaspad isn't in sync with the rest of
// the network there's a high chance the block will never be accepted, thus
// the solving effort would have been wasted.
bool isSynced = 2;
RPCError error = 1000;
}
// NotifyBlockAddedRequestMessage registers this connection for blockAdded notifications.
// NotifyBlockAddedRequestMessage registers this connection for blockAdded
// notifications.
//
// See: BlockAddedNotificationMessage
message NotifyBlockAddedRequestMessage{
}
message NotifyBlockAddedRequestMessage {}
message NotifyBlockAddedResponseMessage{
RPCError error = 1000;
}
message NotifyBlockAddedResponseMessage { RPCError error = 1000; }
// BlockAddedNotificationMessage is sent whenever a blocks has been added (NOT accepted)
// into the DAG.
// BlockAddedNotificationMessage is sent whenever a blocks has been added (NOT
// accepted) into the DAG.
//
// See: NotifyBlockAddedRequestMessage
message BlockAddedNotificationMessage{
RpcBlock block = 3;
}
message BlockAddedNotificationMessage { RpcBlock block = 3; }
// GetPeerAddressesRequestMessage requests the list of known kaspad addresses in the
// current network. (mainnet, testnet, etc.)
message GetPeerAddressesRequestMessage{
}
// GetPeerAddressesRequestMessage requests the list of known kaspad addresses in
// the current network. (mainnet, testnet, etc.)
message GetPeerAddressesRequestMessage {}
message GetPeerAddressesResponseMessage{
message GetPeerAddressesResponseMessage {
repeated GetPeerAddressesKnownAddressMessage addresses = 1;
repeated GetPeerAddressesKnownAddressMessage bannedAddresses = 2;
RPCError error = 1000;
}
message GetPeerAddressesKnownAddressMessage {
string Addr = 1;
}
message GetPeerAddressesKnownAddressMessage { string Addr = 1; }
// GetSelectedTipHashRequestMessage requests the hash of the current virtual's
// selected parent.
message GetSelectedTipHashRequestMessage{
}
message GetSelectedTipHashRequestMessage {}
message GetSelectedTipHashResponseMessage{
message GetSelectedTipHashResponseMessage {
string selectedTipHash = 1;
RPCError error = 1000;
}
// GetMempoolEntryRequestMessage requests information about a specific transaction
// in the mempool.
message GetMempoolEntryRequestMessage{
// GetMempoolEntryRequestMessage requests information about a specific
// transaction in the mempool.
message GetMempoolEntryRequestMessage {
// The transaction's TransactionID.
string txId = 1;
bool includeOrphanPool = 2;
bool filterTransactionPool = 3;
}
message GetMempoolEntryResponseMessage{
message GetMempoolEntryResponseMessage {
MempoolEntry entry = 1;
RPCError error = 1000;
}
// GetMempoolEntriesRequestMessage requests information about all the transactions
// currently in the mempool.
message GetMempoolEntriesRequestMessage{
bool includeOrphanPool = 1;
bool filterTransactionPool = 2;
// GetMempoolEntriesRequestMessage requests information about all the
// transactions currently in the mempool.
message GetMempoolEntriesRequestMessage {
bool includeOrphanPool = 1;
bool filterTransactionPool = 2;
}
message GetMempoolEntriesResponseMessage{
message GetMempoolEntriesResponseMessage {
repeated MempoolEntry entries = 1;
RPCError error = 1000;
}
message MempoolEntry{
message MempoolEntry {
uint64 fee = 1;
RpcTransaction transaction = 3;
bool isOrphan = 4;
}
// GetConnectedPeerInfoRequestMessage requests information about all the p2p peers
// currently connected to this kaspad.
message GetConnectedPeerInfoRequestMessage{
}
// GetConnectedPeerInfoRequestMessage requests information about all the p2p
// peers currently connected to this kaspad.
message GetConnectedPeerInfoRequestMessage {}
message GetConnectedPeerInfoResponseMessage{
message GetConnectedPeerInfoResponseMessage {
repeated GetConnectedPeerInfoMessage infos = 1;
RPCError error = 1000;
}
message GetConnectedPeerInfoMessage{
message GetConnectedPeerInfoMessage {
string id = 1;
string address = 2;
@ -279,58 +272,58 @@ message GetConnectedPeerInfoMessage{
// AddPeerRequestMessage adds a peer to kaspad's outgoing connection list.
// This will, in most cases, result in kaspad connecting to said peer.
message AddPeerRequestMessage{
message AddPeerRequestMessage {
string address = 1;
// Whether to keep attempting to connect to this peer after disconnection
bool isPermanent = 2;
}
message AddPeerResponseMessage{
RPCError error = 1000;
}
message AddPeerResponseMessage { RPCError error = 1000; }
// SubmitTransactionRequestMessage submits a transaction to the mempool
message SubmitTransactionRequestMessage{
message SubmitTransactionRequestMessage {
RpcTransaction transaction = 1;
bool allowOrphan = 2;
}
message SubmitTransactionResponseMessage{
message SubmitTransactionResponseMessage {
// The transaction ID of the submitted transaction
string transactionId = 1;
RPCError error = 1000;
}
// NotifyVirtualSelectedParentChainChangedRequestMessage registers this connection for virtualSelectedParentChainChanged notifications.
// NotifyVirtualSelectedParentChainChangedRequestMessage registers this
// connection for virtualSelectedParentChainChanged notifications.
//
// See: VirtualSelectedParentChainChangedNotificationMessage
message NotifyVirtualSelectedParentChainChangedRequestMessage{
message NotifyVirtualSelectedParentChainChangedRequestMessage {
bool includeAcceptedTransactionIds = 1;
}
message NotifyVirtualSelectedParentChainChangedResponseMessage{
message NotifyVirtualSelectedParentChainChangedResponseMessage {
RPCError error = 1000;
}
// VirtualSelectedParentChainChangedNotificationMessage is sent whenever the DAG's selected parent
// chain had changed.
// VirtualSelectedParentChainChangedNotificationMessage is sent whenever the
// DAG's selected parent chain had changed.
//
// See: NotifyVirtualSelectedParentChainChangedRequestMessage
message VirtualSelectedParentChainChangedNotificationMessage{
message VirtualSelectedParentChainChangedNotificationMessage {
// The chain blocks that were removed, in high-to-low order
repeated string removedChainBlockHashes = 1;
// The chain blocks that were added, in low-to-high order
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;
}
// GetBlockRequestMessage requests information about a specific block
message GetBlockRequestMessage{
message GetBlockRequestMessage {
// The hash of the requested block
string hash = 1;
@ -338,7 +331,7 @@ message GetBlockRequestMessage{
bool includeTransactions = 3;
}
message GetBlockResponseMessage{
message GetBlockResponseMessage {
RpcBlock block = 3;
RPCError error = 1000;
}
@ -346,28 +339,26 @@ message GetBlockResponseMessage{
// GetSubnetworkRequestMessage requests information about a specific subnetwork
//
// Currently unimplemented
message GetSubnetworkRequestMessage{
string subnetworkId = 1;
}
message GetSubnetworkRequestMessage { string subnetworkId = 1; }
message GetSubnetworkResponseMessage{
message GetSubnetworkResponseMessage {
uint64 gasLimit = 1;
RPCError error = 1000;
}
// GetVirtualSelectedParentChainFromBlockRequestMessage requests the virtual selected
// parent chain from some startHash to this kaspad's current virtual
message GetVirtualSelectedParentChainFromBlockRequestMessage{
// GetVirtualSelectedParentChainFromBlockRequestMessage requests the virtual
// selected parent chain from some startHash to this kaspad's current virtual
message GetVirtualSelectedParentChainFromBlockRequestMessage {
string startHash = 1;
bool includeAcceptedTransactionIds = 2;
}
message AcceptedTransactionIds{
message AcceptedTransactionIds {
string acceptingBlockHash = 1;
repeated string acceptedTransactionIds = 2;
}
message GetVirtualSelectedParentChainFromBlockResponseMessage{
message GetVirtualSelectedParentChainFromBlockResponseMessage {
// The chain blocks that were removed, in high-to-low order
repeated string removedChainBlockHashes = 1;
@ -375,43 +366,42 @@ message GetVirtualSelectedParentChainFromBlockResponseMessage{
repeated string addedChainBlockHashes = 3;
// 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;
RPCError error = 1000;
}
// GetBlocksRequestMessage requests blocks between a certain block lowHash up to this
// kaspad's current virtual.
message GetBlocksRequestMessage{
// GetBlocksRequestMessage requests blocks between a certain block lowHash up to
// this kaspad's current virtual.
message GetBlocksRequestMessage {
string lowHash = 1;
bool includeBlocks = 2;
bool includeTransactions = 3;
}
message GetBlocksResponseMessage{
message GetBlocksResponseMessage {
repeated string blockHashes = 4;
repeated RpcBlock blocks = 3;
RPCError error = 1000;
}
// GetBlockCountRequestMessage requests the current number of blocks in this kaspad.
// Note that this number may decrease as pruning occurs.
message GetBlockCountRequestMessage{
}
// GetBlockCountRequestMessage requests the current number of blocks in this
// kaspad. Note that this number may decrease as pruning occurs.
message GetBlockCountRequestMessage {}
message GetBlockCountResponseMessage{
message GetBlockCountResponseMessage {
uint64 blockCount = 1;
uint64 headerCount = 2;
RPCError error = 1000;
}
// GetBlockDagInfoRequestMessage requests general information about the current state
// of this kaspad's DAG.
message GetBlockDagInfoRequestMessage{
}
// GetBlockDagInfoRequestMessage requests general information about the current
// state of this kaspad's DAG.
message GetBlockDagInfoRequestMessage {}
message GetBlockDagInfoResponseMessage{
message GetBlockDagInfoResponseMessage {
string networkName = 1;
uint64 blockCount = 2;
uint64 headerCount = 3;
@ -424,52 +414,40 @@ message GetBlockDagInfoResponseMessage{
RPCError error = 1000;
}
message ResolveFinalityConflictRequestMessage{
string finalityBlockHash = 1;
}
message ResolveFinalityConflictRequestMessage { string finalityBlockHash = 1; }
message ResolveFinalityConflictResponseMessage{
RPCError error = 1000;
}
message ResolveFinalityConflictResponseMessage { RPCError error = 1000; }
message NotifyFinalityConflictsRequestMessage{
}
message NotifyFinalityConflictsRequestMessage {}
message NotifyFinalityConflictsResponseMessage{
RPCError error = 1000;
}
message NotifyFinalityConflictsResponseMessage { RPCError error = 1000; }
message FinalityConflictNotificationMessage{
string violatingBlockHash = 1;
}
message FinalityConflictNotificationMessage { string violatingBlockHash = 1; }
message FinalityConflictResolvedNotificationMessage{
message FinalityConflictResolvedNotificationMessage {
string finalityBlockHash = 1;
}
// ShutDownRequestMessage shuts down this kaspad.
message ShutDownRequestMessage{
}
message ShutDownRequestMessage {}
message ShutDownResponseMessage{
RPCError error = 1000;
}
message ShutDownResponseMessage { RPCError error = 1000; }
// GetHeadersRequestMessage requests headers between the given startHash and the
// current virtual, up to the given limit.
message GetHeadersRequestMessage{
message GetHeadersRequestMessage {
string startHash = 1;
uint64 limit = 2;
bool isAscending = 3;
}
message GetHeadersResponseMessage{
message GetHeadersResponseMessage {
repeated string headers = 1;
RPCError error = 1000;
}
// NotifyUtxosChangedRequestMessage registers this connection for utxoChanged notifications
// for the given addresses.
// NotifyUtxosChangedRequestMessage registers this connection for utxoChanged
// notifications for the given addresses.
//
// 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
}
message NotifyUtxosChangedResponseMessage {
RPCError error = 1000;
}
message NotifyUtxosChangedResponseMessage { 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
message UtxosChangedNotificationMessage {
@ -496,8 +473,8 @@ message UtxosByAddressesEntry {
RpcUtxoEntry utxoEntry = 3;
}
// StopNotifyingUtxosChangedRequestMessage unregisters this connection for utxoChanged notifications
// for the given addresses.
// StopNotifyingUtxosChangedRequestMessage unregisters this connection for
// utxoChanged notifications for the given addresses.
//
// This call is only available when this kaspad was started with `--utxoindex`
//
@ -506,16 +483,13 @@ message StopNotifyingUtxosChangedRequestMessage {
repeated string addresses = 1;
}
message StopNotifyingUtxosChangedResponseMessage {
RPCError error = 1000;
}
message StopNotifyingUtxosChangedResponseMessage { 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`
message GetUtxosByAddressesRequestMessage {
repeated string addresses = 1;
}
message GetUtxosByAddressesRequestMessage { repeated string addresses = 1; }
message GetUtxosByAddressesResponseMessage {
repeated UtxosByAddressesEntry entries = 1;
@ -523,12 +497,11 @@ message GetUtxosByAddressesResponseMessage {
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`
message GetBalanceByAddressRequestMessage {
string address = 1;
}
message GetBalanceByAddressRequestMessage { string address = 1; }
message GetBalanceByAddressResponseMessage {
uint64 balance = 1;
@ -536,11 +509,9 @@ message GetBalanceByAddressResponseMessage {
RPCError error = 1000;
}
message GetBalancesByAddressesRequestMessage {
repeated string addresses = 1;
}
message GetBalancesByAddressesRequestMessage { repeated string addresses = 1; }
message BalancesByAddressEntry{
message BalancesByAddressEntry {
string address = 1;
uint64 balance = 2;
@ -553,10 +524,9 @@ message GetBalancesByAddressesResponseMessage {
RPCError error = 1000;
}
// GetVirtualSelectedParentBlueScoreRequestMessage requests the blue score of the current selected parent
// of the virtual block.
message GetVirtualSelectedParentBlueScoreRequestMessage {
}
// GetVirtualSelectedParentBlueScoreRequestMessage requests the blue score of
// the current selected parent of the virtual block.
message GetVirtualSelectedParentBlueScoreRequestMessage {}
message GetVirtualSelectedParentBlueScoreResponseMessage {
uint64 blueScore = 1;
@ -564,19 +534,18 @@ message GetVirtualSelectedParentBlueScoreResponseMessage {
RPCError error = 1000;
}
// NotifyVirtualSelectedParentBlueScoreChangedRequestMessage registers this connection for
// virtualSelectedParentBlueScoreChanged notifications.
// NotifyVirtualSelectedParentBlueScoreChangedRequestMessage registers this
// connection for virtualSelectedParentBlueScoreChanged notifications.
//
// See: VirtualSelectedParentBlueScoreChangedNotificationMessage
message NotifyVirtualSelectedParentBlueScoreChangedRequestMessage {
}
message NotifyVirtualSelectedParentBlueScoreChangedRequestMessage {}
message NotifyVirtualSelectedParentBlueScoreChangedResponseMessage {
RPCError error = 1000;
}
// VirtualSelectedParentBlueScoreChangedNotificationMessage is sent whenever the blue score
// of the virtual's selected parent changes.
// VirtualSelectedParentBlueScoreChangedNotificationMessage is sent whenever the
// blue score of the virtual's selected parent changes.
//
// See NotifyVirtualSelectedParentBlueScoreChangedRequestMessage
message VirtualSelectedParentBlueScoreChangedNotificationMessage {
@ -587,12 +556,9 @@ message VirtualSelectedParentBlueScoreChangedNotificationMessage {
// virtualDaaScoreChanged notifications.
//
// See: VirtualDaaScoreChangedNotificationMessage
message NotifyVirtualDaaScoreChangedRequestMessage {
}
message NotifyVirtualDaaScoreChangedRequestMessage {}
message NotifyVirtualDaaScoreChangedResponseMessage {
RPCError error = 1000;
}
message NotifyVirtualDaaScoreChangedResponseMessage { RPCError error = 1000; }
// VirtualDaaScoreChangedNotificationMessage is sent whenever the DAA score
// of the virtual changes.
@ -608,57 +574,44 @@ message VirtualDaaScoreChangedNotificationMessage {
// This call is only available when this kaspad was started with `--utxoindex`
//
// See: NotifyPruningPointUTXOSetOverrideResponseMessage
message NotifyPruningPointUTXOSetOverrideRequestMessage {
}
message NotifyPruningPointUTXOSetOverrideRequestMessage {}
message NotifyPruningPointUTXOSetOverrideResponseMessage {
RPCError error = 1000;
}
// PruningPointUTXOSetOverrideNotificationMessage is sent whenever the UTXO index
// resets due to pruning point change via IBD.
// PruningPointUTXOSetOverrideNotificationMessage is sent whenever the UTXO
// index resets due to pruning point change via IBD.
//
// See NotifyPruningPointUTXOSetOverrideRequestMessage
message PruningPointUTXOSetOverrideNotificationMessage {
}
message PruningPointUTXOSetOverrideNotificationMessage {}
// StopNotifyingPruningPointUTXOSetOverrideRequestMessage unregisters this connection for
// pruning point UTXO set override notifications.
// StopNotifyingPruningPointUTXOSetOverrideRequestMessage unregisters this
// connection for pruning point UTXO set override notifications.
//
// This call is only available when this kaspad was started with `--utxoindex`
//
// See: PruningPointUTXOSetOverrideNotificationMessage
message StopNotifyingPruningPointUTXOSetOverrideRequestMessage {
}
message StopNotifyingPruningPointUTXOSetOverrideRequestMessage {}
message StopNotifyingPruningPointUTXOSetOverrideResponseMessage {
RPCError error = 1000;
}
// BanRequestMessage bans the given ip.
message BanRequestMessage{
string ip = 1;
}
message BanRequestMessage { string ip = 1; }
message BanResponseMessage{
RPCError error = 1000;
}
message BanResponseMessage { RPCError error = 1000; }
// UnbanRequestMessage unbans the given ip.
message UnbanRequestMessage{
string ip = 1;
}
message UnbanRequestMessage { string ip = 1; }
message UnbanResponseMessage{
RPCError error = 1000;
}
message UnbanResponseMessage { RPCError error = 1000; }
// GetInfoRequestMessage returns info about the node.
message GetInfoRequestMessage{
}
message GetInfoRequestMessage {}
message GetInfoResponseMessage{
message GetInfoResponseMessage {
string p2pId = 1;
uint64 mempoolSize = 2;
string serverVersion = 3;
@ -667,12 +620,12 @@ message GetInfoResponseMessage{
RPCError error = 1000;
}
message EstimateNetworkHashesPerSecondRequestMessage{
message EstimateNetworkHashesPerSecondRequestMessage {
uint32 windowSize = 1;
string startHash = 2;
}
message EstimateNetworkHashesPerSecondResponseMessage{
message EstimateNetworkHashesPerSecondResponseMessage {
uint64 networkHashesPerSecond = 1;
RPCError error = 1000;
}
@ -681,50 +634,46 @@ message EstimateNetworkHashesPerSecondResponseMessage{
// NewBlockTemplate notifications.
//
// See: NewBlockTemplateNotificationMessage
message NotifyNewBlockTemplateRequestMessage {
}
message NotifyNewBlockTemplateRequestMessage {}
message NotifyNewBlockTemplateResponseMessage {
RPCError error = 1000;
}
message NotifyNewBlockTemplateResponseMessage { RPCError error = 1000; }
// NewBlockTemplateNotificationMessage is sent whenever a new updated block template is
// available for miners.
// NewBlockTemplateNotificationMessage is sent whenever a new updated block
// template is available for miners.
//
// See NotifyNewBlockTemplateRequestMessage
message NewBlockTemplateNotificationMessage {
}
message NewBlockTemplateNotificationMessage {}
message MempoolEntryByAddress{
message MempoolEntryByAddress {
string address = 1;
repeated MempoolEntry sending = 2;
repeated MempoolEntry receiving = 3;
}
message GetMempoolEntriesByAddressesRequestMessage{
message GetMempoolEntriesByAddressesRequestMessage {
repeated string addresses = 1;
bool includeOrphanPool = 2;
bool filterTransactionPool = 3;
}
message GetMempoolEntriesByAddressesResponseMessage{
message GetMempoolEntriesByAddressesResponseMessage {
repeated MempoolEntryByAddress entries = 1;
RPCError error = 1000;
}
message GetCoinSupplyRequestMessage{
message GetCoinSupplyRequestMessage {}
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 circulatingSompi = 2;
RPCError error = 1000;
}
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 circulatingSompi = 2;
RPCError error = 1000;
}
message PingRequestMessage{
}
message PingRequestMessage {}
message PingResponseMessage { RPCError error = 1000; }
@ -853,7 +802,7 @@ message GetDaaScoreTimestampEstimateRequestMessage {
repeated uint64 daaScores = 1;
}
message GetDaaScoreTimestampEstimateResponseMessage{
message GetDaaScoreTimestampEstimateResponseMessage {
repeated uint64 timestamps = 1;
RPCError error = 1000;
}