code.vegaprotocol.io/vega@v0.79.0/protos/sources/vega/api/v1/core.proto (about)

     1  syntax = "proto3";
     2  
     3  package vega.api.v1;
     4  
     5  import "google/api/field_behavior.proto";
     6  import "protoc-gen-openapiv2/options/annotations.proto";
     7  import "vega/commands/v1/transaction.proto";
     8  import "vega/events/v1/events.proto";
     9  import "vega/vega.proto";
    10  
    11  option go_package = "code.vegaprotocol.io/vega/protos/vega/api/v1";
    12  option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
    13    info: {
    14      title: "Vega core APIs";
    15      version: "v0.79.0";
    16    }
    17    schemes: [
    18      HTTP,
    19      HTTPS
    20    ]
    21    host: "lb.testnet.vega.xyz"
    22  };
    23  
    24  service CoreService {
    25    // Submit transaction
    26    //
    27    // Submit a signed transaction to the network containing a command to be executed such that if the submission is successful then it will be included in the chain's mempool.
    28    // The network will then attempt to execute the transaction in the next available block, where the results of its execution can be seen on the EventBus.
    29    rpc SubmitTransaction(SubmitTransactionRequest) returns (SubmitTransactionResponse);
    30  
    31    // Chain event
    32    //
    33    // Propagate a chain event
    34    rpc PropagateChainEvent(PropagateChainEventRequest) returns (PropagateChainEventResponse);
    35  
    36    // Statistics
    37    //
    38    // Get statistics on Vega
    39    rpc Statistics(StatisticsRequest) returns (StatisticsResponse);
    40  
    41    // Blockchain height
    42    //
    43    // Get the height of the last tendermint block
    44    rpc LastBlockHeight(LastBlockHeightRequest) returns (LastBlockHeightResponse);
    45  
    46    // Vega time
    47    //
    48    // Get current Vega time
    49    rpc GetVegaTime(GetVegaTimeRequest) returns (GetVegaTimeResponse);
    50  
    51    // Events subscription
    52    //
    53    // Subscribe to a stream of events from the core
    54    rpc ObserveEventBus(stream ObserveEventBusRequest) returns (stream ObserveEventBusResponse);
    55  
    56    // Submit raw transaction
    57    //
    58    // Submit a pre-serialised signed transaction containing a command to the network to be executed, such that if the submission is successful then it will be included in the chain's mempool.
    59    // The network will then attempt to execute the transaction in the next available block, where the results of its execution can be seen on the EventBus.
    60    rpc SubmitRawTransaction(SubmitRawTransactionRequest) returns (SubmitRawTransactionResponse);
    61  
    62    // Check transaction
    63    //
    64    // Send a signed transaction containing a command to the network to be checked, but not added to the chain's mempool.
    65    // This is useful for checking the validity of a potential transaction before submitting it.
    66    rpc CheckTransaction(CheckTransactionRequest) returns (CheckTransactionResponse);
    67  
    68    // Check raw transaction
    69    //
    70    // Send a pre-serialised transaction containing a command to the network to be checked, but then not added to the chain's mempool.
    71    // This is useful for checking the validity of a potential transaction before submitting it.
    72    rpc CheckRawTransaction(CheckRawTransactionRequest) returns (CheckRawTransactionResponse);
    73  
    74    // Get Spam statistics
    75    //
    76    // Get the spam statistics for a given party.
    77    rpc GetSpamStatistics(GetSpamStatisticsRequest) returns (GetSpamStatisticsResponse);
    78  }
    79  
    80  // Request for a new event sent by the blockchain queue to be propagated on Vega
    81  message PropagateChainEventRequest {
    82    // Chain event to propagate.
    83    bytes event = 1 [(google.api.field_behavior) = REQUIRED];
    84    // Public key of the key pair used to sign messages.
    85    string pub_key = 2 [(google.api.field_behavior) = REQUIRED];
    86    // Signature generated by the private key associated with the public key.
    87    bytes signature = 3 [(google.api.field_behavior) = REQUIRED];
    88  }
    89  
    90  // Response for a new event sent by the blockchain queue to be propagated on Vega
    91  message PropagateChainEventResponse {
    92    // Success will be true if the event was accepted by the node,
    93    // **Important** - success does not mean that the event is confirmed by consensus
    94    bool success = 1;
    95  }
    96  
    97  // Request for submitting a transaction v2 on Vega
    98  message SubmitTransactionRequest {
    99    // Blockchain transaction type.
   100    enum Type {
   101      TYPE_UNSPECIFIED = 0;
   102      // Transaction will be submitted without waiting for a response.
   103      TYPE_ASYNC = 1;
   104      // Transaction will be submitted, and blocking until the mempool returns a response.
   105      TYPE_SYNC = 2;
   106      // Transaction will be submitted, and blocking until the network has committed it into a block.
   107      // Used only for debugging local network, not for submitting transactions.
   108      TYPE_COMMIT = 3;
   109    }
   110    // Transaction containing a command to execute on the network, and a signature to provide authentication.
   111    vega.commands.v1.Transaction tx = 1 [(google.api.field_behavior) = REQUIRED];
   112    // Method of submission.
   113    Type type = 2 [(google.api.field_behavior) = REQUIRED];
   114  }
   115  
   116  // Response for submitting a transaction on the network.
   117  message SubmitTransactionResponse {
   118    // Whether or not the transaction was validated and submitted to the chain's mempool.
   119    bool success = 1;
   120    // Hash of the transaction, which can be used to identify the transaction in a node's event stream.
   121    string tx_hash = 2;
   122    // Error code to indicate the category of failure if the transaction was not successfully submitted.
   123    uint32 code = 3;
   124    // Further details for why the transaction was not successfully submitted.
   125    string data = 4;
   126    // Further details for the underlying consensus layer of the result of the transaction.
   127    string log = 5;
   128    // Unused.
   129    int64 height = 6;
   130  }
   131  
   132  // Request for checking a transaction v2 on Vega
   133  message CheckTransactionRequest {
   134    // Transaction containing a command to be checked on the network, and not added to the chain's mempool.
   135    vega.commands.v1.Transaction tx = 1 [(google.api.field_behavior) = REQUIRED];
   136  }
   137  
   138  message CheckTransactionResponse {
   139    // Whether or not the transaction passed the submission checks.
   140    bool success = 1;
   141    // Error code to indicate the category of failure if the transaction was not successfully checked.
   142    uint32 code = 2;
   143    // Amount of space in a block that the transaction will fill. This does not relate to any monetary cost for submitting the transaction.
   144    int64 gas_wanted = 3;
   145    // Unused.
   146    int64 gas_used = 4;
   147    // Further details for why the transaction was not successfully submitted.
   148    string data = 5;
   149    // Further details for the underlying consensus layer of the result of the transaction.
   150    string log = 6;
   151    // Unused.
   152    string info = 7;
   153  }
   154  
   155  // Request for submitting a version agnostic transaction on Vega
   156  message SubmitRawTransactionRequest {
   157    // Blockchain transaction type
   158    enum Type {
   159      TYPE_UNSPECIFIED = 0;
   160      // Transaction will be submitted without waiting for response
   161      TYPE_ASYNC = 1;
   162      // Transaction will be submitted, and blocking until the
   163      // tendermint mempool returns a response
   164      TYPE_SYNC = 2;
   165      // Transaction will be submitted, and blocking until the tendermint
   166      // network has committed it into a block. Used only for debugging,
   167      // not for submitting transactions
   168      TYPE_COMMIT = 3;
   169    }
   170    // Bundle of signed payload and signature marshalled into a byte array, to form a transaction that will be submitted to the Vega blockchain
   171    bytes tx = 1 [(google.api.field_behavior) = REQUIRED];
   172    // Type of transaction request, for example ASYNC, meaning the transaction will be submitted and not block on a response
   173    Type type = 2 [(google.api.field_behavior) = REQUIRED];
   174  }
   175  
   176  // Response for submitting a version agnostic transaction on Vega
   177  message SubmitRawTransactionResponse {
   178    // Whether or not the transaction was validated and submitted to the chain's mempool.
   179    bool success = 1;
   180    // Hash of the transaction, which can be used to identify the transaction in a node's event stream.
   181    string tx_hash = 2;
   182    // Error code to indicate the category of failure if the transaction was not successfully submitted.
   183    uint32 code = 3;
   184    // Further details for why the transaction was not successfully submitted.
   185    string data = 4;
   186    // Further details for the underlying consensus layer of the result of the transaction.
   187    string log = 5;
   188    // Unused.
   189    int64 height = 6;
   190  }
   191  
   192  // Request for checking a version agnostic transaction on Vega
   193  message CheckRawTransactionRequest {
   194    // Bundle of signed payload and signature marshalled into a byte array, to form a transaction that would be submitted to the Vega blockchain
   195    bytes tx = 1 [(google.api.field_behavior) = REQUIRED];
   196  }
   197  
   198  // Response for checking a version agnostic transaction on Vega
   199  message CheckRawTransactionResponse {
   200    // Whether or not the transaction passed the submission checks.
   201    bool success = 1;
   202    // Error code to indicate the category of failure if the transaction was not successfully submitted.
   203    uint32 code = 2;
   204    // Amount of space in a block that the transaction will fill. This does not relate to any monetary cost for submitting the transaction.
   205    int64 gas_wanted = 3;
   206    // Unused.
   207    int64 gas_used = 4;
   208    // Further details for why the transaction was not successfully checked.
   209    string data = 5;
   210    // Further details for the underlying consensus layer of the result of the transaction.
   211    string log = 6;
   212    // Unused
   213    string info = 7;
   214  }
   215  
   216  // Request for the current time of the Vega network
   217  message GetVegaTimeRequest {}
   218  
   219  // Response for the current consensus coordinated time on the Vega network, referred to as "VegaTime"
   220  message GetVegaTimeResponse {
   221    // Timestamp representation of current VegaTime as represented in
   222    // Unix nanoseconds, for example `1580473859111222333` corresponds to `2020-01-31T12:30:59.111222333Z`
   223    int64 timestamp = 1;
   224  }
   225  
   226  // Request to subscribe to a stream of one or more event types from the Vega event bus
   227  message ObserveEventBusRequest {
   228    // One or more types of event, required field
   229    repeated vega.events.v1.BusEventType type = 1;
   230    // Market ID to filter events for, optional field. If omitted, no markets will be filtered out.
   231    string market_id = 2;
   232    // Party ID to filter events for, optional field. If omitted, no parties will be filtered out.
   233    string party_id = 3;
   234    // Batch size, optional field -
   235    // If not specified, any events received will be sent immediately. If the client is not ready
   236    // for the next data-set, data may be dropped a number of times, and eventually the stream is closed.
   237    // if specified, the first batch will be sent when ready. To receive the next set of events, the client
   238    // must write an `ObserveEventBatch` message on the stream to flush the buffer.
   239    // If no message is received in 5 seconds, the stream is closed.
   240    // Default: 0, send any and all events when they are available.
   241    int64 batch_size = 4;
   242  }
   243  
   244  // Response to a subscribed stream of events from the Vega event bus
   245  message ObserveEventBusResponse {
   246    // One or more events that match the subscription request criteria.
   247    repeated vega.events.v1.BusEvent events = 1;
   248  }
   249  
   250  // Request for statistics about the Vega network
   251  message StatisticsRequest {}
   252  
   253  // Response containing statistics about the Vega network
   254  message StatisticsResponse {
   255    Statistics statistics = 1;
   256  }
   257  
   258  // Vega domain specific statistics as reported by the node the caller is connected to
   259  message Statistics {
   260    // Current block height as reported by the Vega blockchain
   261    uint64 block_height = 1;
   262    // Current backlog length i.e., number of transactions, that are waiting to be included in a block
   263    uint64 backlog_length = 2;
   264    // Total number of connected peers to this node
   265    uint64 total_peers = 3;
   266    // Genesis block date and time formatted in ISO-8601 datetime format with nanosecond precision
   267    string genesis_time = 4;
   268    // Current system date and time formatted in ISO-8601 datetime format with nanosecond precision
   269    string current_time = 5;
   270    // Current Vega date and time formatted in ISO-8601 datetime format with nanosecond precision
   271    string vega_time = 6;
   272    // Status of the connection to the Vega blockchain
   273    vega.ChainStatus status = 7;
   274    // Transactions per block
   275    uint64 tx_per_block = 8;
   276    // Average transaction size in bytes
   277    uint64 average_tx_bytes = 9;
   278    // Average orders per block
   279    uint64 average_orders_per_block = 10;
   280    // Trades emitted per second
   281    uint64 trades_per_second = 11;
   282    // Orders processed per second
   283    uint64 orders_per_second = 12;
   284    // Total markets on this Vega network
   285    uint64 total_markets = 13;
   286    // Total number of order amendments since genesis across all markets
   287    uint64 total_amend_order = 16;
   288    // Total number of order cancellations since genesis across all markets
   289    uint64 total_cancel_order = 17;
   290    // Total number of order submissions since genesis across all markets
   291    uint64 total_create_order = 18;
   292    // Total number of orders processed since genesis across all markets
   293    uint64 total_orders = 19;
   294    // Total number of trades emitted since genesis across all markets
   295    uint64 total_trades = 20;
   296    // Current number of stream subscribers to order data
   297    uint32 order_subscriptions = 21;
   298    // Current number of stream subscribers to trade data
   299    uint32 trade_subscriptions = 22;
   300    // Current number of stream subscribers to candlestick data
   301    uint32 candle_subscriptions = 23;
   302    // Current number of stream subscribers to market depth data
   303    uint32 market_depth_subscriptions = 24;
   304    // Current number of stream subscribers to positions data
   305    uint32 positions_subscriptions = 25;
   306    // Current number of stream subscribers to account data
   307    uint32 account_subscriptions = 26;
   308    // Current number of stream subscribers to market data
   309    uint32 market_data_subscriptions = 27;
   310    // Version hash of the Vega node software
   311    string app_version_hash = 28;
   312    // Version of the Vega node software
   313    string app_version = 29;
   314    // Version of the underlying Vega blockchain
   315    string chain_version = 30;
   316    // Current block duration, in nanoseconds
   317    uint64 block_duration = 31;
   318    // Total uptime for this node formatted in ISO-8601 datetime format with nanosecond precision
   319    string uptime = 32;
   320    // Unique ID for the underlying Vega blockchain
   321    string chain_id = 33;
   322    // Current number of stream subscribers to market depth update data
   323    uint32 market_depth_updates_subscriptions = 34;
   324    // Current block hash
   325    string block_hash = 35;
   326    // Current epoch
   327    uint64 epoch_seq = 36;
   328    // Epoch start time
   329    string epoch_start_time = 37;
   330    // Epoch expected end time
   331    string epoch_expiry_time = 38;
   332    // Number of events in the last block
   333    uint64 event_count = 39;
   334    // Rate of events per second in the last block
   335    uint64 events_per_second = 40;
   336  }
   337  
   338  // Request to get the height of the very last block processed
   339  // by tendermint
   340  message LastBlockHeightRequest {}
   341  
   342  // Response with the height of the last block processed by
   343  // tendermint
   344  message LastBlockHeightResponse {
   345    // Last block height
   346    uint64 height = 1;
   347    // Last block hash
   348    string hash = 2;
   349    // Supported proof of work hash function
   350    string spam_pow_hash_function = 3;
   351    // Difficulty of the proof of work, i.e. the target number of zeros
   352    uint32 spam_pow_difficulty = 4;
   353    // Supported proof of work number of blocks behind current height allowed
   354    uint32 spam_pow_number_of_past_blocks = 5;
   355    // Allowed number of transactions per block
   356    uint32 spam_pow_number_of_tx_per_block = 6;
   357    // Boolean indicating whether increasing difficulty is allowed for using the
   358    // same height for more than `spam_pow_number_of_past_blocks` transactions
   359    bool spam_pow_increasing_difficulty = 7;
   360    // Network chain id from which the block comes from
   361    string chain_id = 8;
   362  }
   363  
   364  // Request to retrieve the spam statistics of a party for the given epoch
   365  message GetSpamStatisticsRequest {
   366    // Party ID whose statistics are requested
   367    string party_id = 1 [(google.api.field_behavior) = REQUIRED];
   368  }
   369  
   370  // Statistics for a given spam policy
   371  message SpamStatistic {
   372    // Current transaction count received from the party during this epoch for this policy
   373    uint64 count_for_epoch = 1;
   374    // Maximum number of transactions allowed for this policy in an epoch
   375    uint64 max_for_epoch = 2;
   376    // If blocked the timestamp when the party will be unblocked as RFC3339Nano
   377    optional string banned_until = 4;
   378    // Effective minimum number of tokens required to submit a transaction of this type
   379    string min_tokens_required = 5;
   380  }
   381  
   382  // Voting statistics by proposal for a given party for the current epoch
   383  message VoteSpamStatistics {
   384    // List of statistics for proposals voted on by the party
   385    repeated VoteSpamStatistic statistics = 1;
   386    // Maximum number of votes per proposal allowed in an epoch
   387    uint64 max_for_epoch = 2;
   388    // If blocked the timestamp when the party will be unblocked as RFC3339Nano
   389    optional string banned_until = 3;
   390  }
   391  
   392  // Vote statistics for the voting spam policies
   393  // which are calculated as a ratio of the total votes
   394  // that have been rejected.
   395  message VoteSpamStatistic {
   396    // Unique ID of the proposal being voted on by the party.
   397    string proposal = 1;
   398    // Current vote count received from the party for the given proposal during this epoch
   399    uint64 count_for_epoch = 2;
   400    // Effective minimum number of tokens required to vote on the proposal
   401    string min_tokens_required = 3;
   402  }
   403  
   404  // Proof of Work state for a given block
   405  message PoWBlockState {
   406    // Block height for the current Proof of Work state statistics
   407    uint64 block_height = 1;
   408    // Hash of the current block
   409    string block_hash = 2;
   410    // Total number of transactions seen in the block
   411    uint64 transactions_seen = 3;
   412    // This is the minimum required difficulty for the next transaction submitted on this block
   413    // if it is possible to submit more transactions on this block, otherwise nil.
   414    optional uint64 expected_difficulty = 4;
   415    // Hashing function used to calculate the block hash
   416    string hash_function = 5;
   417    // Base difficulty for this block for when transactions seen < tx_per_block
   418    uint64 difficulty = 6;
   419    // Number of transactions that can have their proof-of-work calculated with this block hash before
   420    // either the difficulty increases, or no more transactions can use this block hash
   421    uint64 tx_per_block = 7;
   422    // Whether or not this block allows for increasing proof-of-work difficulty if the
   423    // tx-per-block-hash limit has been reached
   424    bool increasing_difficulty = 8;
   425  }
   426  
   427  // Proof of work statistics for a party
   428  message PoWStatistic {
   429    // Block state for each block in scope for PoW calculation
   430    repeated PoWBlockState block_states = 1;
   431    // PoW banned until timestamp as RFC3339Nano
   432    optional string banned_until = 2;
   433    // Number of block behind the current block whose hash can be used for proof-of-work calculations
   434    uint64 number_of_past_blocks = 3;
   435  }
   436  
   437  // Complete spam statistics captured for a given party
   438  message SpamStatistics {
   439    // Statistics for proposal transactions made by the party.
   440    SpamStatistic proposals = 1;
   441    // Statistics for delegation transactions made by the party.
   442    SpamStatistic delegations = 2;
   443    // Statistics for transfer transactions made by the party.
   444    SpamStatistic transfers = 3;
   445    // Statistics for node announcement transactions made by the party.
   446    SpamStatistic node_announcements = 4;
   447    // Statistics for proposal votes made by the party.
   448    VoteSpamStatistics votes = 5;
   449    // Statistics for proof of work difficulty observed per block for the party.
   450    PoWStatistic pow = 6;
   451    // Statistics for multisig signatures issued for the party.
   452    SpamStatistic issue_signatures = 7;
   453    // Epoch in which these statistics apply to.
   454    uint64 epoch_seq = 8;
   455    // Statistics for transactions made by the party to create referral sets.
   456    SpamStatistic create_referral_set = 9;
   457    // Statistics for transactions made by the party to update referral sets.
   458    SpamStatistic update_referral_set = 10;
   459    // Statistics for transactions made by the party to apply referral codes.
   460    SpamStatistic apply_referral_code = 11;
   461  }
   462  
   463  // Response containing all the spam statistics of a party for the current epoch
   464  message GetSpamStatisticsResponse {
   465    // Chain ID for which the statistics are captured.
   466    string chain_id = 1;
   467    // Spam statistics for the party
   468    SpamStatistics statistics = 2;
   469  }