tig-monorepopool/swagger.yaml
2024-10-23 12:22:14 +01:00

1045 lines
29 KiB
YAML

openapi: 3.0.3
info:
title: The Innovation Game API
description: |-
This is the OpenAPI 3.0 specification for The Innovation Game (TIG) API. You can find out more about TIG [https://tig.foundation](https://tig.foundation).
Some useful links:
- [TIG repository](https://github.com/tig-foundation/tig-monorepo)
- [TIG whitepaper](https://www.tig.foundation/whitepaper)
termsOfService: https://github.com/tig-foundation/tig-monorepo/blob/main/docs/agreements/terms_of_use.pdf
contact:
email: contact@tig.foundation
license:
name: End User License Agreement
url: https://github.com/tig-foundation/tig-monorepo/blob/main/docs/agreements/end_user_license_agreement.pdf
version: 1.0.0
servers:
- url: https://mainnet-api.tig.foundation
- url: https://testnet-api.tig.foundation
tags:
- name: GET
description: There is a rate limit per IP address.
- name: POST
description: There is a rate limit per IP address.
paths:
/get-algorithms:
get:
tags:
- GET
summary: Get latest algorithm data
description: |-
# Notes
* Query parameter `<block_id>` can be latest block for **ANY** round. Use `/get-block` endpoint
* Fields `algorithm.code` and `wasm.wasm_blob` will always be `null`
* If `algorithm.round_pushed != null`, the data can be accessed via:
* `code`: `https://github.com/tig-foundation/tig-monorepo/blob/<branch>/tig-algorithms/src/<branch>/benchmarker_outbound.rs`
* `wasm_blob`: `https://github.com/tig-foundation/tig-monorepo/blob/<branch>/tig-algorithms/wasm/<branch>.wasm`
where `<branch>` is `<challenge_name>/<algorithm_name>`
parameters:
- name: block_id
in: query
required: true
schema:
$ref: '#/components/schemas/MD5'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/GetAlgorithmsResponse'
/get-benchmarks:
get:
tags:
- GET
summary: Get latest confirmed benchmarks for a player
description: |-
# Notes
* Query parameter `<block_id>` must be latest block for **CURRENT** round. Use `/get-block` endpoint
* Query parameter `<player_id>` must be lowercase and start with `0x`
* Returns all confirmed precommits, benchmarks, proofs, and frauds for the player where the benchmark was started within `120` blocks of the latest block.
* Fields `benchmark.solution_nonces`, `proof.merkle_proofs`, and `fraud.allegation` will always be `null`
* To retrieve that data, use /get-benchmark-data endpoint
parameters:
- name: block_id
in: query
required: true
schema:
$ref: '#/components/schemas/MD5'
- name: player_id
in: query
description: Id of player
required: true
schema:
$ref: '#/components/schemas/Address'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/GetBenchmarksResponse'
/get-benchmark-data:
get:
tags:
- GET
summary: Get all data for a benchmark
description: |-
# Notes
* Will include data for fields `benchmark.solution_nonces`, `proof.merkle_proofs`, and `fraud.allegation`.
parameters:
- name: benchmark_id
in: query
description: Id of benchmark
required: true
schema:
$ref: '#/components/schemas/MD5'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/GetBenchmarkDataResponse'
/get-block:
get:
tags:
- GET
summary: Get latest block for a round
description: |-
# Notes
* Specify query parameter `<round>` to get the latest block for that round.
* Omit query parameter `<round>` to get the latest block for the current round.
* Set `<include_data>` to `true` to include data for `block.data`.
parameters:
- name: round
in: query
required: false
schema:
type: integer
- name: include_data
in: query
required: false
schema:
type: boolean
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/GetBlockResponse'
/get-challenges:
get:
tags:
- GET
summary: Get latest data for challenges
description: |-
# Notes
* Query parameter `<block_id>` must be latest block for **CURRENT** round. Use `/get-block` endpoint
parameters:
- name: block_id
in: query
required: true
schema:
$ref: '#/components/schemas/MD5'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/GetChallengesResponse'
/get-fee-balance:
get:
tags:
- GET
summary: Get fee balance for a player
description: |-
# Notes
* Query parameter `<block_id>` must be latest block for **CURRENT** round. Use `/get-block` endpoint
* Query parameter `<player_id>` must be lowercase and start with `0x`
* Returns current fee balance and all topups for the player
parameters:
- name: block_id
in: query
required: true
schema:
$ref: '#/components/schemas/MD5'
- name: player_id
in: query
required: true
schema:
$ref: '#/components/schemas/Address'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/GetFeeBalanceResponse'
/get-players:
get:
tags:
- GET
summary: Get latest round data for all players
description: |-
# Notes
* Query parameter `<block_id>` can be latest block for **ANY** round. Use `/get-block` endpoint
* If query parameter `<player_type>` is set to `benchmarker`, returns players who had active benchmarks in this round
* If query parameter `<player_type>` is set to `innovator`, returns players who had active algorithms in this round
* `player.round_earnings` will always have a value. All other fields will be `null` unless the player has active benchmarks
parameters:
- name: block_id
in: query
required: true
schema:
$ref: '#/components/schemas/MD5'
- name: player_type
in: query
description: Type of player
required: true
schema:
type: string
enum:
- benchmarker
- innovator
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/GetPlayersResponse'
/get-wasm-blob:
get:
tags:
- GET
summary: Get WASM blob for a specific algorithm
parameters:
- name: algorithm_id
in: query
required: true
schema:
$ref: '#/components/schemas/AlgorithmId'
responses:
'200':
description: Successful response
content:
application/octet-stream:
schema:
type: string
format: binary
/request-api-key:
post:
tags:
- POST
summary: Requests an api key from an address and signature
description: |-
# Notes
* `<address>` must be lowercase. `<signature>` must be generated from signing the following message:
```
I am signing this message to prove that I control address <address>
```
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/RequestApiKeyRequest'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/RequestApiKeyResponse'
/submit-algorithm:
post:
tags:
- POST
summary: Submit an algorithm
description: |-
# Notes
* This endpoint can only be invoked once every few seconds
* If an algorithm submission has failed to compile (`wasm.state.compiled_success = false`), you can re-use the same algorithm name.
* `<tx_hash>` is the id of the transaction that has burnt the required `block.config.algorithm_submissions.submission_fee` TIG to the `block.config.erc20.burn_address`
* Header `X-Api-Key` is required. Use `/request-api-key` endpoint.
* If `<api_key>` is invalid, a `401` error will be returned
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SubmitAlgorithmRequest'
parameters:
- in: header
name: X-Api-Key
description: <api_key> from /request-api-key endpoint
schema:
$ref: '#/components/schemas/MD5'
responses:
'200':
description: Success
/submit-precommit:
post:
tags:
- POST
summary: Submit a precommit
description: |-
# Notes
* This endpoint can only be invoked once every few seconds
* When a precommit is confirmed (`precommit.state != null`), a random string will be set (`precommit.state.rand_hash`). This string must be used when generating seeds
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SubmitPrecommitRequest'
parameters:
- in: header
name: X-Api-Key
description: <api_key> from /request-api-key endpoint
schema:
$ref: '#/components/schemas/MD5'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/SubmitPrecommitResponse'
/submit-benchmark:
post:
tags:
- POST
summary: Submit a benchmark
description: |-
# Notes
* This endpoint can only be invoked once every few seconds
* Order of `solution_nonces` does not matter
* When a benchmark is confirmed (`benchmark.state != null`), up to `3` nonces will be sampled (`benchmark.state.sampled_nonces`) for which the corresponding `merkle_proof` must be submitted via `/submit-proof` endpoint
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SubmitBenchmarkRequest'
parameters:
- in: header
name: X-Api-Key
description: <api_key> from /request-api-key endpoint
schema:
$ref: '#/components/schemas/MD5'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/SubmitBenchmarkResponse'
/submit-proof:
post:
tags:
- POST
summary: Submit proof for a particular benchmark
description: |-
# Notes
* This endpoint can only be invoked once every few seconds
* Order of `merkle_proofs` does not matter
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SubmitProofRequest'
parameters:
- in: header
name: X-Api-Key
description: <api_key> from /request-api-key endpoint
schema:
$ref: '#/components/schemas/MD5'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/SubmitProofResponse'
/submit-topup:
post:
tags:
- POST
summary: Submit a topup transaction
description: |-
# Notes
* This endpoint can only be invoked once every few seconds
* `<tx_hash>` is the id of the transaction that has burnt the required `block.config.precommit_submissions.topup_amount` TIG to the `block.config.erc20.burn_address`
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SubmitTopupRequest'
parameters:
- in: header
name: X-Api-Key
description: <api_key> from /request-api-key endpoint
schema:
$ref: '#/components/schemas/MD5'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/SubmitTopupResponse'
components:
schemas:
Address:
type: string
pattern: ^0x[a-f0-9]{40}$
Algorithm:
type: object
properties:
id:
type: string
details:
$ref: '#/components/schemas/AlgorithmDetails'
state:
$ref: '#/components/schemas/AlgorithmState'
block_data:
$ref: '#/components/schemas/AlgorithmBlockData'
code:
type: string
AlgorithmDetails:
type: object
properties:
name:
$ref: '#/components/schemas/AlgorithmName'
player_id:
$ref: '#/components/schemas/Address'
challenge_id:
$ref: '#/components/schemas/ChallengeId'
tx_hash:
$ref: '#/components/schemas/TxHash'
AlgorithmId:
type: string
pattern: ^c[0-9]{3}_a[0-9]{3}$
example: c002_a001
AlgorithmName:
type: string
pattern: ^[a-z][a-z_]{4,19}$
example: clarke_wright
AlgorithmState:
type: object
properties:
block_confirmed:
type: integer
format: uint32
round_submitted:
type: integer
format: uint32
round_pushed:
type: integer
format: uint32
round_merged:
type: integer
format: uint32
banned:
type: boolean
AlgorithmBlockData:
type: object
properties:
num_qualifiers_by_player:
type: object
additionalProperties:
type: integer
format: uint32
example:
"0x100af566d1b9809915fd03ebee5e02e2e7926d98": 10
"0x0000000000000000000000000000000000000001": 15
adoption:
$ref: '#/components/schemas/PreciseNumber'
merge_points:
type: integer
format: uint32
reward:
$ref: '#/components/schemas/PreciseNumber'
round_earnings:
$ref: '#/components/schemas/PreciseNumber'
Benchmark:
type: object
properties:
id:
type: string
details:
$ref: '#/components/schemas/BenchmarkDetails'
state:
$ref: '#/components/schemas/BenchmarkState'
solution_nonces:
type: array
items:
type: integer
format: uint64
BenchmarkSettings:
type: object
properties:
player_id:
$ref: '#/components/schemas/Address'
block_id:
$ref: '#/components/schemas/MD5'
challenge_id:
$ref: '#/components/schemas/ChallengeId'
algorithm_id:
$ref: '#/components/schemas/AlgorithmId'
difficulty:
$ref: '#/components/schemas/Difficulty'
BenchmarkDetails:
type: object
properties:
num_solutions:
type: integer
format: uint32
merkle_root:
$ref: '#/components/schemas/MerkleHash'
BenchmarkState:
type: object
properties:
block_confirmed:
type: integer
format: uint32
sampled_nonces:
type: array
items:
type: integer
format: uint64
Block:
type: object
properties:
id:
$ref: '#/components/schemas/MD5'
details:
$ref: '#/components/schemas/BlockDetails'
data:
$ref: '#/components/schemas/BlockData'
config:
$ref: '#/components/schemas/ProtocolConfig'
BlockDetails:
type: object
properties:
prev_block_id:
$ref: '#/components/schemas/MD5'
height:
type: integer
format: uint32
round:
type: integer
format: uint32
BlockData:
type: object
properties:
confirmed_challenge_ids:
type: array
items:
$ref: '#/components/schemas/ChallengeId'
confirmed_algorithm_ids:
type: array
items:
$ref: '#/components/schemas/AlgorithmId'
confirmed_benchmark_ids:
type: array
items:
$ref: '#/components/schemas/MD5'
confirmed_precommit_ids:
type: array
items:
$ref: '#/components/schemas/MD5'
confirmed_proof_ids:
type: array
items:
$ref: '#/components/schemas/MD5'
confirmed_fraud_ids:
type: array
items:
$ref: '#/components/schemas/MD5'
confirmed_topup_ids:
type: array
items:
$ref: '#/components/schemas/MD5'
confirmed_wasm_ids:
type: array
items:
$ref: '#/components/schemas/AlgorithmId'
active_challenge_ids:
type: array
items:
$ref: '#/components/schemas/ChallengeId'
active_algorithm_ids:
type: array
items:
$ref: '#/components/schemas/AlgorithmId'
active_benchmark_ids:
type: array
items:
$ref: '#/components/schemas/MD5'
active_player_ids:
type: array
items:
$ref: '#/components/schemas/Address'
Challenge:
type: object
properties:
id:
$ref: '#/components/schemas/ChallengeId'
details:
$ref: '#/components/schemas/ChallengeDetails'
state:
$ref: '#/components/schemas/ChallengeState'
block_data:
$ref: '#/components/schemas/ChallengeBlockData'
ChallengeBlockData:
type: object
properties:
solution_signature_threshold:
type: integer
format: uint32
num_qualifiers:
type: integer
format: uint32
qualifier_difficulties:
type: array
items:
$ref: '#/components/schemas/Difficulty'
base_frontier:
$ref: '#/components/schemas/Frontier'
scaled_frontier:
$ref: '#/components/schemas/Frontier'
scaling_factor:
type: number
format: double
base_fee:
$ref: '#/components/schemas/PreciseNumber'
per_nonce_fee:
$ref: '#/components/schemas/PreciseNumber'
ChallengeDetails:
type: object
properties:
name:
type: string
ChallengeId:
type: string
pattern: ^c[0-9]{3}$
example: c002
ChallengeState:
type: object
properties:
block_confirmed:
type: integer
format: uint32
round_active:
type: integer
format: uint32
Difficulty:
type: array
items:
type: integer
format: int32
example: [40, 250]
Frontier:
type: array
items:
$ref: '#/components/schemas/Difficulty'
Player:
type: object
properties:
id:
$ref: '#/components/schemas/Address'
details:
$ref: '#/components/schemas/PlayerDetails'
state:
$ref: '#/components/schemas/PlayerState'
block_data:
$ref: '#/components/schemas/PlayerBlockData'
PlayerBlockData:
type: object
properties:
num_qualifiers_by_challenge:
type: object
additionalProperties:
type: integer
format: uint32
example:
c001: 10
c002: 15
c003: 20
cutoff:
type: integer
format: uint32
deposit:
$ref: '#/components/schemas/PreciseNumber'
rolling_deposit:
$ref: '#/components/schemas/PreciseNumber'
qualifying_percent_rolling_deposit:
$ref: '#/components/schemas/PreciseNumber'
imbalance:
$ref: '#/components/schemas/PreciseNumber'
imbalance_penalty:
$ref: '#/components/schemas/PreciseNumber'
influence:
$ref: '#/components/schemas/PreciseNumber'
reward:
$ref: '#/components/schemas/PreciseNumber'
round_earnings:
$ref: '#/components/schemas/PreciseNumber'
PlayerDetails:
type: object
properties:
name:
$ref: '#/components/schemas/Address'
is_multisig:
type: boolean
PlayerState:
type: object
properties:
total_fees_paid:
$ref: '#/components/schemas/PreciseNumber'
available_fee_balance:
$ref: '#/components/schemas/PreciseNumber'
PreciseNumber:
type: integer
format: uint256
Precommit:
type: object
properties:
benchmark_id:
$ref: '#/components/schemas/MD5'
details:
$ref: '#/components/schemas/PrecommitDetails'
settings:
$ref: '#/components/schemas/BenchmarkSettings'
state:
$ref: '#/components/schemas/PrecommitState'
PrecommitDetails:
type: object
properties:
block_started:
type: integer
format: uint32
num_nonces:
type: integer
format: uint32
fee_paid:
$ref: '#/components/schemas/PreciseNumber'
PrecommitState:
type: object
properties:
block_confirmed:
type: integer
format: uint32
rand_hash:
type: string
MerkleProof:
type: object
properties:
leaf:
$ref: '#/components/schemas/OutputData'
branch:
$ref: '#/components/schemas/MerkleBranch'
Proof:
type: object
properties:
benchmark_id:
$ref: '#/components/schemas/MD5'
state:
$ref: '#/components/schemas/ProofState'
merkle_proofs:
type: array
items:
$ref: '#/components/schemas/MerkleProof'
ProofState:
type: object
properties:
block_confirmed:
type: integer
format: uint32
submission_delay:
type: integer
format: uint32
OutputData:
type: object
properties:
nonce:
type: integer
format: uint64
runtime_signature:
type: integer
format: uint64
fuel_consumed:
type: integer
format: uint64
solution:
type: object
Fraud:
type: object
properties:
benchmark_id:
$ref: '#/components/schemas/MD5'
state:
$ref: '#/components/schemas/FraudState'
allegation:
type: string
FraudState:
type: object
properties:
block_confirmed:
type: integer
format: uint32
TopUp:
type: object
properties:
id:
$ref: '#/components/schemas/MD5'
details:
$ref: '#/components/schemas/TopUpDetails'
state:
$ref: '#/components/schemas/TopUpState'
TopUpDetails:
type: object
properties:
player_id:
$ref: '#/components/schemas/Address'
amount:
$ref: '#/components/schemas/PreciseNumber'
TopUpState:
type: object
properties:
block_confirmed:
type: integer
format: uint32
Wasm:
type: object
properties:
algorithm_id:
$ref: '#/components/schemas/MD5'
details:
$ref: '#/components/schemas/WasmDetails'
state:
$ref: '#/components/schemas/WasmState'
WasmDetails:
type: object
properties:
compile_success:
type: boolean
download_url:
type: string
WasmState:
type: object
properties:
block_confirmed:
type: integer
format: uint32
MD5:
type: string
pattern: ^[a-f0-9]{32}$
Signature:
type: string
pattern: ^0x([a-f0-9]{130})+$
TxHash:
type: string
pattern: ^0x[a-f0-9]{64}$
MerkleHash:
type: string
pattern: ^[a-f0-9]{64}$
MerkleBranch:
type: string
pattern: ^([a-f0-9]{66}){0,32}$
ProtocolConfig:
type: object
GetAlgorithmsResponse:
type: object
properties:
block_id:
$ref: '#/components/schemas/MD5'
block_details:
$ref: '#/components/schemas/BlockDetails'
algorithms:
type: array
items:
$ref: '#/components/schemas/Algorithm'
GetBenchmarksResponse:
type: object
properties:
precommits:
type: array
items:
$ref: '#/components/schemas/Precommit'
benchmarks:
type: array
items:
$ref: '#/components/schemas/Benchmark'
proofs:
type: array
items:
$ref: '#/components/schemas/Proof'
frauds:
type: array
items:
$ref: '#/components/schemas/Fraud'
GetBenchmarkDataResponse:
type: object
properties:
precommit:
$ref: '#/components/schemas/Precommit'
benchmark:
$ref: '#/components/schemas/Benchmark'
proof:
$ref: '#/components/schemas/Proof'
fraud:
$ref: '#/components/schemas/Fraud'
GetBlockResponse:
type: object
properties:
block:
$ref: '#/components/schemas/Block'
GetChallengesResponse:
type: object
properties:
block_id:
$ref: '#/components/schemas/MD5'
block_details:
$ref: '#/components/schemas/BlockDetails'
challenges:
type: array
items:
$ref: '#/components/schemas/Challenge'
GetPlayersResponse:
type: object
properties:
block_id:
$ref: '#/components/schemas/MD5'
block_details:
$ref: '#/components/schemas/BlockDetails'
players:
type: array
items:
$ref: '#/components/schemas/Player'
GetFeeBalanceResponse:
type: object
properties:
state:
$ref: '#/components/schemas/PlayerState'
topups:
type: array
items:
$ref: '#/components/schemas/TopUp'
RequestApiKeyRequest:
type: object
properties:
address:
$ref: '#/components/schemas/Address'
signature:
$ref: '#/components/schemas/Signature'
RequestApiKeyResponse:
type: object
properties:
api_key:
$ref: '#/components/schemas/MD5'
name:
type: string
SubmitAlgorithmRequest:
type: object
properties:
name:
$ref: '#/components/schemas/AlgorithmName'
challenge_id:
$ref: '#/components/schemas/ChallengeId'
tx_hash:
$ref: '#/components/schemas/TxHash'
code:
type: string
SubmitPrecommitRequest:
type: object
properties:
settings:
$ref: '#/components/schemas/BenchmarkSettings'
num_nonces:
type: integer
format: uint32
SubmitPrecommitResponse:
type: object
properties:
benchmark_id:
$ref: '#/components/schemas/MD5'
SubmitBenchmarkRequest:
type: object
properties:
benchmark_id:
$ref: '#/components/schemas/MD5'
merkle_root:
$ref: '#/components/schemas/MerkleHash'
solution_nonces:
type: array
items:
type: integer
format: uint64
SubmitBenchmarkResponse:
type: object
properties:
ok:
type: boolean
SubmitProofRequest:
type: object
properties:
benchmark_id:
$ref: '#/components/schemas/MD5'
merkle_proofs:
type: array
items:
$ref: '#/components/schemas/MerkleProof'
SubmitProofResponse:
type: object
properties:
verified:
type: string
SubmitTopupRequest:
type: object
properties:
tx_hash:
$ref: '#/components/schemas/TxHash'
SubmitTopupResponse:
type: object
properties:
ok:
type: boolean