Skip to content

Implement qubic-cli interface to oracle queries #709

@philippwerner

Description

@philippwerner

Request info via qubic-cli

A new command needs to be added to qubic-cli for requesting and displaying information about oracle queries. I think it would be good to make it similar to -queryassets (one command with several subcommands).

  • qubic-cli [...] -getoraclequery [QUERY_ID] -> printing the oracle query, metadata, and reply if available
  • qubic-cli [...] -getoraclequery pending -> print the query IDs or all pending queries
  • qubic-cli [...] -getoraclequery pending+ -> printing the oracle query, metadata, and reply if available for each query ID received by pending
  • qubic-cli [...] -getoraclequery all [TICK] -> print the query IDs or all queries started in the given tick
  • qubic-cli [...] -getoraclequery all+ [TICK] -> printing the oracle query, metadata, and reply if available for each query ID received by all
  • qubic-cli [...] -getoraclequery user [TICK] -> print the query IDs or all user queries started in the given tick
  • qubic-cli [...] -getoraclequery user+ [TICK] -> printing the oracle query, metadata, and reply if available for each query ID received by user
  • qubic-cli [...] -getoraclequery contract [TICK] -> print the query IDs or all contract one-time queries started in the given tick
  • qubic-cli [...] -getoraclequery contract+ [TICK] -> printing the oracle query, metadata, and reply if available for each query ID received by contract
  • qubic-cli [...] -getoraclequery subscription [TICK] -> print the query IDs or all contract subscription queries started in the given tick
  • qubic-cli [...] -getoraclequery subscription+ [TICK] -> printing the oracle query, metadata, and reply if available for each query ID received by subscription

We will later add a similar command with subcommands for requesting and printing subscription metadata.

The communication protocol is defined in network_messages/oracles.h and the core side is implemented in oracle_core/net_msg_impl.h.

Start oracle query via qubic-cli

We should add a command for initiating a user query to a oracle by sending OracleUserQueryTransaction, such as:

qubic-cli [...] -queryoracle [INTERFACE] [QUERY_STRING] [TIMEOUT_IN_SECONDS]

  • [INTERFACE] is an index or string name for one of the oracle interfaces in oracle_interfaces, such as "Price", "Mock", or "IntResult".
  • [QUERY_STRING] interface-specific string, for example, key-value pairs of the values required for Price::OracleQuery. On parsing error, empty string, etc., a interface-specific help on the QUERY_STRING should be shown.
  • [TIMEOUT_IN_SECONDS]: optional timeout, by default use a reasonable value such as 60 seconds.

Recommendations

  • RespondOracleData is a variable-size response message, so receiving the data must must support that (similar to receiving transactions)
  • Oracle interfaces (Price etc) need to be supported in order to:
    • print oracle queries and oracle replies
    • parse oracle query parameters that need to be passed when a user oracle query is started
    • compute the fees for an oracle query
  • IMO, in order to reduce copy and paste of code we should add the core as a git submodule and include interface files from there directly. Same applies to network message definitions, at least in the long term.
  • Building on the interface definitions from the core, we should implement parsing and printing in a generalized way, for example with a common template class that takes the oracle interface struct (for example Price) as a template parameter. Whenever an oracle interface is added a template specialization needs to implemented including functions for printing and parsing query and printing reply. And a function describing the [QUERY_STRING].

Priorities

The commands -getoraclequery [QUERY_ID], -getoraclequery pending, -getoraclequery pending+ are required first.
-queryoracle [INTERFACE] [QUERY_STRING] [TIMEOUT_IN_SECONDS] is lowest prio, because for early testing oracle query transactions can be also created with sendcustomtransaction.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

🏗 In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions