2023-03-15 13:10:53 +00:00
openapi : 3.0 .3
info :
version : 0.0 .1
title : Codex API
description : "List of endpoints and interfaces available to Codex API users"
security :
- { }
components :
schemas :
MultiAddress :
type : string
description : Address of node as specified by the multi-address specification https://multiformats.io/multiaddr/
example : /ip4/127.0.0.1/tcp/8080
PeerId :
type : string
description : Peer Identity reference as specified at https://docs.libp2p.io/concepts/fundamentals/peers/
example : QmYyQSo1c1Ym7orWxLYvCrM2EmxFTANf8wXmmE7DWjhx5N
2024-03-21 10:53:45 +00:00
Id :
type : string
description : 32bits identifier encoded in hex-decimal string.
2024-09-24 08:37:08 +00:00
minLength : 66
maxLength : 66
2024-03-21 10:53:45 +00:00
example : 0x...
BigInt :
type : string
description : Integer represented as decimal string
2023-03-15 13:10:53 +00:00
Cid :
type : string
description : Content Identifier as specified at https://github.com/multiformats/cid
example : QmYyQSo1c1Ym7orWxLYvCrM2EmxFTANf8wXmmE7DWjhx5N
2023-12-07 01:16:36 +00:00
SlotId :
type : string
description : Keccak hash of the abi encoded tuple (RequestId, slot index)
example : 268a781e0db3f7cf36b18e5f4fdb7f586ec9edd08e5500b17c0e518a769f114a
2023-03-15 13:10:53 +00:00
LogLevel :
type : string
description : "One of the log levels: TRACE, DEBUG, INFO, NOTICE, WARN, ERROR or FATAL"
example : DEBUG
EthereumAddress :
type : string
description : Address of Ethereum address
Reward :
type : string
description : The maximum amount of tokens paid per second per slot to hosts the client is willing to pay
Duration :
type : string
2023-06-21 05:46:18 +00:00
description : The duration of the request in seconds as decimal string
2023-03-15 13:10:53 +00:00
2023-03-27 13:47:25 +00:00
ProofProbability :
type : string
2023-06-21 05:46:18 +00:00
description : How often storage proofs are required as decimal string
2023-03-27 13:47:25 +00:00
2023-03-15 13:10:53 +00:00
Expiry :
type : string
description : A timestamp as seconds since unix epoch at which this request expires if the Request does not find requested amount of nodes to host the data.
default : 10 minutes
2024-04-02 11:13:49 +00:00
SPR :
type : string
description : Signed Peer Record (libp2p)
SPRRead :
type : object
properties :
spr :
$ref : "#/components/schemas/SPR"
PeerIdRead :
type : object
properties :
id :
$ref : "#/components/schemas/PeerId"
2023-03-15 13:10:53 +00:00
Content :
type : object
description : Parameters specifying the content
properties :
cid :
$ref : "#/components/schemas/Cid"
2024-10-25 07:20:00 +00:00
Node :
type : object
properties :
nodeId :
type : string
peerId :
type : string
record :
type : string
address :
type : string
seen :
type : boolean
CodexVersion :
type : object
properties :
version :
type : string
example : v0.1.7
revision :
type : string
example : 0c647d8
PeersTable :
type : object
properties :
localNode :
$ref : "#/components/schemas/Node"
nodes :
type : array
items :
$ref : "#/components/schemas/Node"
2023-03-15 13:10:53 +00:00
DebugInfo :
type : object
properties :
id :
$ref : "#/components/schemas/PeerId"
addrs :
type : array
items :
$ref : "#/components/schemas/MultiAddress"
repo :
type : string
description : Path of the data repository where all nodes data are stored
spr :
2024-04-02 11:13:49 +00:00
$ref : "#/components/schemas/SPR"
2024-10-25 07:20:00 +00:00
table :
$ref : "#/components/schemas/PeersTable"
codex :
$ref : "#/components/schemas/CodexVersion"
2023-03-15 13:10:53 +00:00
SalesAvailability :
type : object
properties :
id :
2024-03-21 10:53:45 +00:00
$ref : "#/components/schemas/Id"
totalSize :
2023-03-15 13:10:53 +00:00
type : string
2024-03-21 10:53:45 +00:00
description : Total size of availability's storage in bytes as decimal string
2023-03-15 13:10:53 +00:00
duration :
$ref : "#/components/schemas/Duration"
minPrice :
type : string
2024-09-24 08:37:08 +00:00
description : Minimal price paid (in amount of tokens) for the whole hosted request's slot for the request's duration as decimal string
2023-04-14 09:04:17 +00:00
maxCollateral :
type : string
2023-06-21 05:46:18 +00:00
description : Maximum collateral user is willing to pay per filled Slot (in amount of tokens) as decimal string
2023-03-15 13:10:53 +00:00
2024-03-21 10:53:45 +00:00
SalesAvailabilityREAD :
allOf :
- $ref : "#/components/schemas/SalesAvailability"
- type : object
properties :
freeSize :
type : string
description : Unused size of availability's storage in bytes as decimal string
SalesAvailabilityCREATE :
allOf :
- $ref : "#/components/schemas/SalesAvailability"
- required :
- totalSize
- minPrice
- maxCollateral
- duration
2023-06-20 12:52:15 +00:00
Slot :
type : object
properties :
id :
2023-12-07 01:16:36 +00:00
$ref : "#/components/schemas/SlotId"
2023-06-20 12:52:15 +00:00
request :
$ref : "#/components/schemas/StorageRequest"
slotIndex :
type : string
2024-09-24 08:37:08 +00:00
description : Slot Index as decimal string
SlotAgent :
type : object
properties :
id :
$ref : "#/components/schemas/SlotId"
slotIndex :
type : string
description : Slot Index as decimal string
requestId :
$ref : "#/components/schemas/Id"
request :
$ref : "#/components/schemas/StorageRequest"
reservation :
$ref : "#/components/schemas/Reservation"
state :
type : string
description : Description of the slot's
enum :
- SaleCancelled
- SaleDownloading
- SaleErrored
- SaleFailed
- SaleFilled
- SaleFilling
- SaleFinished
- SaleIgnored
- SaleInitialProving
- SalePayout
- SalePreparing
- SaleProving
- SaleUnknown
2023-06-20 12:52:15 +00:00
2024-03-21 10:53:45 +00:00
Reservation :
type : object
properties :
id :
$ref : "#/components/schemas/Id"
availabilityId :
$ref : "#/components/schemas/Id"
size :
$ref : "#/components/schemas/BigInt"
requestId :
$ref : "#/components/schemas/Id"
slotIndex :
type : string
2024-09-24 08:37:08 +00:00
description : Slot Index as decimal string
2024-03-21 10:53:45 +00:00
2023-03-15 13:10:53 +00:00
StorageRequestCreation :
type : object
required :
- reward
- duration
2023-03-27 13:47:25 +00:00
- proofProbability
2023-04-14 09:04:17 +00:00
- collateral
2023-11-22 11:35:26 +00:00
- expiry
2023-03-15 13:10:53 +00:00
properties :
duration :
$ref : "#/components/schemas/Duration"
reward :
$ref : "#/components/schemas/Reward"
2023-03-27 13:47:25 +00:00
proofProbability :
$ref : "#/components/schemas/ProofProbability"
2023-03-15 13:10:53 +00:00
nodes :
description : Minimal number of nodes the content should be stored on
2024-03-29 18:18:41 +00:00
type : integer
2023-03-27 13:47:25 +00:00
default : 1
2023-03-15 13:10:53 +00:00
tolerance :
description : Additional number of nodes on top of the `nodes` property that can be lost before pronouncing the content lost
2024-03-29 18:18:41 +00:00
type : integer
2023-03-27 13:47:25 +00:00
default : 0
2023-04-14 09:04:17 +00:00
collateral :
type : string
2023-11-13 14:39:22 +00:00
description : Number as decimal string that represents how much collateral is asked from hosts that wants to fill a slots
expiry :
type : string
2024-05-06 15:35:46 +00:00
description : Number as decimal string that represents expiry threshold in seconds from when the Request is submitted. When the threshold is reached and the Request does not find requested amount of nodes to host the data, the Request is voided. The number of seconds can not be higher then the Request's duration itself.
2023-03-15 13:10:53 +00:00
StorageAsk :
type : object
required :
- reward
properties :
slots :
description : Number of slots (eq. hosts) that the Request want to have the content spread over
2024-03-29 18:18:41 +00:00
type : integer
2023-03-15 13:10:53 +00:00
slotSize :
type : string
2023-06-21 05:46:18 +00:00
description : Amount of storage per slot (in bytes) as decimal string
2023-03-15 13:10:53 +00:00
duration :
$ref : "#/components/schemas/Duration"
proofProbability :
2023-03-27 13:47:25 +00:00
$ref : "#/components/schemas/ProofProbability"
2023-03-15 13:10:53 +00:00
reward :
$ref : "#/components/schemas/Reward"
maxSlotLoss :
2024-03-29 18:18:41 +00:00
type : integer
2023-03-15 13:10:53 +00:00
description : Max slots that can be lost without data considered to be lost
StorageRequest :
type : object
properties :
2023-06-20 12:52:15 +00:00
id :
type : string
description : Request ID
2023-03-15 13:10:53 +00:00
client :
$ref : "#/components/schemas/EthereumAddress"
ask :
$ref : "#/components/schemas/StorageAsk"
content :
$ref : "#/components/schemas/Content"
expiry :
$ref : "#/components/schemas/Expiry"
nonce :
type : string
description : Random data
2023-03-30 00:02:25 +00:00
Purchase :
2023-03-15 13:10:53 +00:00
type : object
properties :
state :
type : string
description : Description of the Request's state
2024-09-24 08:37:08 +00:00
enum :
- cancelled
- error
- failed
- finished
- pending
- started
- submitted
- unknown
2023-03-15 13:10:53 +00:00
error :
type : string
description : If Request failed, then here is presented the error message
request :
$ref : "#/components/schemas/StorageRequest"
2023-11-09 08:47:09 +00:00
DataList :
type : object
properties :
content :
type : array
items :
$ref : "#/components/schemas/DataItem"
DataItem :
type : object
properties :
cid :
$ref : "#/components/schemas/Cid"
manifest :
$ref : "#/components/schemas/ManifestItem"
ManifestItem :
type : object
properties :
2024-10-29 10:47:41 +00:00
treeCid :
2023-11-09 08:47:09 +00:00
$ref : "#/components/schemas/Cid"
description : "Root hash of the content"
2024-10-29 10:47:41 +00:00
datasetSize :
2024-03-29 18:18:41 +00:00
type : integer
2024-06-06 09:44:58 +00:00
format : int64
2023-11-09 08:47:09 +00:00
description : "Length of original content in bytes"
blockSize :
2024-03-29 18:18:41 +00:00
type : integer
2023-11-09 08:47:09 +00:00
description : "Size of blocks"
protected :
type : boolean
description : "Indicates if content is protected by erasure-coding"
2024-10-25 13:43:19 +00:00
filename :
type : string
description : "The original name of the uploaded content (optional)"
example : codex.png
mimetype :
type : string
description : "The original mimetype of the uploaded content (optional)"
example : image/png
uploadedAt :
type : integer
format : int64
description : "The UTC upload timestamp in seconds"
example : 1729244192
2023-11-09 08:47:09 +00:00
2023-12-14 10:57:16 +00:00
Space :
type : object
properties :
totalBlocks :
description : "Number of blocks stored by the node"
2024-03-29 18:18:41 +00:00
type : integer
2024-06-06 09:44:58 +00:00
format : int64
2023-12-14 10:57:16 +00:00
quotaMaxBytes :
2024-03-29 18:18:41 +00:00
type : integer
2024-06-06 09:44:58 +00:00
format : int64
2024-10-08 06:37:10 +00:00
description : "Maximum storage space (in bytes) available for the node in Codex's local repository."
2023-12-14 10:57:16 +00:00
quotaUsedBytes :
2024-03-29 18:18:41 +00:00
type : integer
2024-06-06 09:44:58 +00:00
format : int64
2024-10-08 06:37:10 +00:00
description : "Amount of storage space (in bytes) currently used for storing files in Codex's local repository."
2023-12-14 10:57:16 +00:00
quotaReservedBytes :
2024-03-29 18:18:41 +00:00
type : integer
2024-06-06 09:44:58 +00:00
format : int64
2024-10-08 06:37:10 +00:00
description : "Amount of storage reserved (in bytes) in the Codex's local repository for future use when storage requests will be picked up and hosted by the node using node's availabilities. This does not include the storage currently in use."
2023-12-14 10:57:16 +00:00
2023-03-15 13:10:53 +00:00
servers :
- url : "http://localhost:8080/api/codex/v1"
tags :
- name : Marketplace
description : Marketplace information and operations
- name : Data
description : Data operations
- name : Node
description : Node management
- name : Debug
description : Debugging configuration
paths :
"/connect/{peerId}" :
get :
summary : "Connect to a peer"
description : |
If `addrs` param is supplied, it will be used to dial the peer, otherwise the `peerId` is used
to invoke peer discovery, if it succeeds the returned addresses will be used to dial.
tags : [ Node ]
operationId : connectPeer
parameters :
- in : path
name : peerId
required : true
schema :
$ref : "#/components/schemas/PeerId"
description : Peer that should be dialed.
- in : query
name : addrs
schema :
type : array
nullable : true
items :
$ref : "#/components/schemas/MultiAddress"
description : |
If supplied, it will be used to dial the peer.
The address has to target the listening address of the peer,
which is specified with the `--listen-addrs` CLI flag.
responses :
"200" :
description : Successfully connected to peer
"400" :
description : Peer either not found or was not possible to dial
2023-11-21 00:14:06 +00:00
"/data" :
2023-03-15 13:10:53 +00:00
get :
2023-11-09 08:47:09 +00:00
summary : "Lists manifest CIDs stored locally in node."
2023-03-15 13:10:53 +00:00
tags : [ Data ]
2023-11-09 08:47:09 +00:00
operationId : listData
2024-10-25 13:43:19 +00:00
parameters :
- name : content-type
in : header
required : false
description : The content type of the file. Must be valid.
schema :
type : string
example : "image/png"
- name : content-disposition
in : header
required : false
description : The content disposition used to send the filename.
schema :
type : string
example : "attachment; filename=\"codex.png\""
2023-03-15 13:10:53 +00:00
responses :
"200" :
2023-11-09 08:47:09 +00:00
description : Retrieved list of content CIDs
2023-03-15 13:10:53 +00:00
content :
2023-11-09 08:47:09 +00:00
application/json :
2023-03-15 13:10:53 +00:00
schema :
2024-03-26 15:12:15 +00:00
$ref : "#/components/schemas/DataList"
2023-03-15 13:10:53 +00:00
"400" :
description : Invalid CID is specified
"404" :
description : Content specified by the CID is not found
2024-10-25 13:43:19 +00:00
"422" :
description : The content type is not a valid content type or the filename is not valid
2023-03-15 13:10:53 +00:00
"500" :
description : Well it was bad-bad
post :
2023-11-09 08:47:09 +00:00
summary : "Upload a file in a streaming manner. Once finished, the file is stored in the node and can be retrieved by any node in the network using the returned CID."
2023-03-15 13:10:53 +00:00
tags : [ Data ]
operationId : upload
requestBody :
content :
application/octet-stream :
schema :
type : string
format : binary
responses :
"200" :
description : CID of uploaded file
content :
text/plain :
schema :
type : string
"500" :
description : Well it was bad-bad and the upload did not work out
2023-11-09 08:47:09 +00:00
"/data/{cid}" :
get :
2023-11-21 00:14:06 +00:00
summary : "Download a file from the local node in a streaming manner. If the file is not available locally, a 404 is returned."
tags : [ Data ]
operationId : downloadLocal
parameters :
- in : path
name : cid
required : true
schema :
$ref : "#/components/schemas/Cid"
description : File to be downloaded.
responses :
"200" :
description : Retrieved content specified by CID
content :
application/octet-stream :
schema :
type : string
format : binary
"400" :
description : Invalid CID is specified
"404" :
description : Content specified by the CID is unavailable locally
"500" :
description : Well it was bad-bad
"/data/{cid}/network" :
2024-10-17 16:54:28 +00:00
post :
summary : "Download a file from the network to the local node if it's not available locally. Note: Download is performed async. Call can return before download is completed."
tags : [ Data ]
operationId : downloadNetwork
parameters :
- in : path
name : cid
required : true
schema :
$ref : "#/components/schemas/Cid"
description : "File to be downloaded."
responses :
"200" :
description : Manifest information for download that has been started.
content :
application/json :
schema :
$ref : "#/components/schemas/DataItem"
"400" :
description : Invalid CID is specified
"404" :
description : Failed to download dataset manifest
"500" :
description : Well it was bad-bad
"/data/{cid}/network/stream" :
2023-11-21 00:14:06 +00:00
get :
summary : "Download a file from the network in a streaming manner. If the file is not available locally, it will be retrieved from other nodes in the network if able."
2023-11-09 08:47:09 +00:00
tags : [ Data ]
2024-10-17 16:54:28 +00:00
operationId : downloadNetworkStream
2023-11-09 08:47:09 +00:00
parameters :
- in : path
name : cid
required : true
schema :
$ref : "#/components/schemas/Cid"
2023-12-14 10:57:16 +00:00
description : "File to be downloaded."
2023-11-09 08:47:09 +00:00
responses :
"200" :
description : Retrieved content specified by CID
content :
application/octet-stream :
schema :
type : string
format : binary
"400" :
description : Invalid CID is specified
"404" :
description : Content specified by the CID is not found
"500" :
description : Well it was bad-bad
2024-10-17 16:54:28 +00:00
"/data/{cid}/network/manifest" :
get :
summary : "Download only the dataset manifest from the network to the local node if it's not available locally."
tags : [ Data ]
operationId : downloadNetworkManifest
parameters :
- in : path
name : cid
required : true
schema :
$ref : "#/components/schemas/Cid"
description : "File for which the manifest is to be downloaded."
responses :
"200" :
description : Manifest information.
content :
application/json :
schema :
$ref : "#/components/schemas/DataItem"
"400" :
description : Invalid CID is specified
"404" :
description : Failed to download dataset manifest
"500" :
description : Well it was bad-bad
2023-12-14 10:57:16 +00:00
"/space" :
get :
summary : "Gets a summary of the storage space allocation of the node."
tags : [ Data ]
operationId : space
responses :
"200" :
description : "Summary of storage allocation"
content :
application/json :
schema :
$ref : "#/components/schemas/Space"
"500" :
description : "It's not working as planned"
2023-06-20 12:52:15 +00:00
"/sales/slots" :
get :
summary : "Returns active slots"
tags : [ Marketplace ]
operationId : getActiveSlots
responses :
"200" :
description : Retrieved active slots
content :
application/json :
schema :
type : array
items :
$ref : "#/components/schemas/Slot"
"503" :
2024-09-24 08:37:08 +00:00
description : Persistence is not enabled
2023-06-20 12:52:15 +00:00
2023-12-07 01:16:36 +00:00
"/sales/slots/{slotId}" :
get :
summary : "Returns active slot with id {slotId} for the host"
tags : [ Marketplace ]
operationId : getActiveSlotById
parameters :
- in : path
name : slotId
required : true
schema :
$ref : "#/components/schemas/Cid"
description : File to be downloaded.
responses :
"200" :
description : Retrieved active slot
content :
application/json :
schema :
2024-09-24 08:37:08 +00:00
$ref : "#/components/schemas/SlotAgent"
2023-12-07 01:16:36 +00:00
"400" :
description : Invalid or missing SlotId
"404" :
description : Host is not in an active sale for the slot
"503" :
2024-09-24 08:37:08 +00:00
description : Persistence is not enabled
2023-12-07 01:16:36 +00:00
2023-03-15 13:10:53 +00:00
"/sales/availability" :
get :
summary : "Returns storage that is for sale"
tags : [ Marketplace ]
2024-09-24 08:37:08 +00:00
operationId : getAvailabilities
2023-03-15 13:10:53 +00:00
responses :
"200" :
2023-06-20 12:52:15 +00:00
description : Retrieved storage availabilities of the node
2023-03-15 13:10:53 +00:00
content :
application/json :
schema :
type : array
items :
2024-09-24 08:37:08 +00:00
$ref : "#/components/schemas/SalesAvailabilityREAD"
[marketplace] Add Reservations Module (#340)
* [marketplace] reservations module
- add de/serialization for Availability
- add markUsed/markUnused in persisted availability
- add query for unused
- add reserve/release
- reservation module tests
- split ContractInteractions into client contracts and host contracts
- remove reservations start/stop as the repo start/stop is being managed by the node
- remove dedicated reservations metadata store and use the metadata store from the repo instead
- Split ContractInteractions into:
- ClientInteractions (with purchasing)
- HostInteractions (with sales and proving)
- compilation fix for nim 1.2
[repostore] fix started flag, add tests
[marketplace] persist slot index
For loading the sales state from chain, the slot index was not previously persisted in the contract. Will retrieve the slot index from the contract when the sales state is loaded.
* Revert repostore changes
In favour of separate PR https://github.com/status-im/nim-codex/pull/374.
* remove warnings
* clean up
* tests: stop repostore during teardown
* change constructor type identifier
Change Contracts constructor to accept Contracts type instead of ContractInteractions.
* change constructor return type to Result instead of Option
* fix and split interactions tests
* clean up, fix tests
* find availability by slot id
* remove duplication in host/client interactions
* add test for finding availability by slotId
* log instead of raiseAssert when failed to mark availability as unused
* move to SaleErrored state instead of raiseAssert
* remove unneeded reverse
It appears that order is not preserved in the repostore, so reversing does not have the intended effect here.
* update open api spec for potential rest endpoint errors
* move functions about available bytes to repostore
* WIP: reserve and release availabilities as needed
WIP: not tested yet
Availabilities are marked as used when matched (just before downloading starts) so that future matching logic does not match an availability currently in use.
As the download progresses, batches of blocks are written to disk, and the equivalent bytes are released from the reservation module. The size of the availability is reduced as well.
During a reserve or release operation, availability updates occur after the repo is manipulated. If the availability update operation fails, the reserve or release is rolled back to maintain correct accounting of bytes.
Finally, once download completes, or if an error occurs, the availability is marked as unused so future matching can occur.
* delete availability when all bytes released
* fix tests + cleanup
* remove availability from SalesContext callbacks
Availability is no longer used past the SaleDownloading state in the state machine. Cleanup of Availability (marking unused) is handled directly in the SaleDownloading state, and no longer in SaleErrored or SaleFinished. Likewise, Availabilities shouldn’t need to be handled on node restart.
Additionally, Availability was being passed in SalesContext callbacks, and now that Availability is only used temporarily in the SaleDownloading state, Availability is contextually irrelevant to the callbacks, except in OnStore possibly, though it was not being consumed.
* test clean up
* - remove availability from callbacks and constructors from previous commit that needed to be removed (oopsie)
- fix integration test that checks availabilities
- there was a bug fixed that crashed the node due to a missing `return success` in onStore
- the test was fixed by ensuring that availabilities are remaining on the node, and the size has been reduced
- change Availability back to non-ref object and constructor back to init
- add trace logging of all state transitions in state machine
- add generally useful trace logging
* fixes after rebase
1. Fix onProve callbacks
2. Use Slot type instead of tuple for retrieving active slot.
3. Bump codex-contracts-eth that exposes getActivceSlot call.
* swap contracts branch to not support slot collateral
Slot collateral changes in the contracts require further changes in the client code, so we’ll skip those changes for now and add in a separate commit.
* modify Interactions and Deployment constructors
- `HostInteractions` and `ClientInteractions` constructors were simplified to take a contract address and no overloads
- `Interactions` prepared simplified so there are no overloads
- `Deployment` constructor updated so that it takes an optional string parameter, instead `Option[string]`
* Move `batchProc` declaration
`batchProc` needs to be consumed by both `node` and `salescontext`, and they can’t reference each other as it creates a circular dependency.
* [reservations] rename `available` to `hasAvailable`
* [reservations] default error message to inner error msg
* add SaleIngored state
When a storage request is handled but the request does match availabilities, the sales agent machine is sent to the SaleIgnored state. In addition, the agent is constructed in a way that if the request is ignored, the sales agent is removed from the list of active agents being tracked in the sales module.
2023-04-04 07:05:16 +00:00
"500" :
description : Error getting unused availabilities
2023-03-15 13:10:53 +00:00
"503" :
2024-09-24 08:37:08 +00:00
description : Persistence is not enabled
2023-03-15 13:10:53 +00:00
post :
summary : "Offers storage for sale"
operationId : offerStorage
tags : [ Marketplace ]
2024-03-21 10:53:45 +00:00
requestBody :
content :
application/json :
schema :
$ref : "#/components/schemas/SalesAvailabilityCREATE"
responses :
"201" :
description : Created storage availability
content :
application/json :
schema :
$ref : "#/components/schemas/SalesAvailabilityREAD"
"400" :
description : Invalid data input
"422" :
description : Not enough node's storage quota available
"500" :
description : Error reserving availability
"503" :
2024-09-24 08:37:08 +00:00
description : Persistence is not enabled
2024-03-21 10:53:45 +00:00
"/sales/availability/{id}" :
patch :
summary : "Updates availability"
description : |
The new parameters will be only considered for new requests.
Existing Requests linked to this Availability will continue as is.
operationId : updateOfferedStorage
tags : [ Marketplace ]
parameters :
- in : path
name : id
required : true
schema :
type : string
description : ID of Availability
2023-03-15 13:10:53 +00:00
requestBody :
content :
application/json :
schema :
$ref : "#/components/schemas/SalesAvailability"
2024-03-21 10:53:45 +00:00
responses :
"204" :
description : Availability successfully updated
"400" :
description : Invalid data input
"404" :
description : Availability not found
"422" :
description : Not enough node's storage quota available
"500" :
description : Error reserving availability
"503" :
2024-09-24 08:37:08 +00:00
description : Persistence is not enabled
2024-03-21 10:53:45 +00:00
"/sales/availability/{id}/reservations" :
2024-09-24 08:37:08 +00:00
get :
2024-03-21 10:53:45 +00:00
summary : "Get availability's reservations"
description : Return's list of Reservations for ongoing Storage Requests that the node hosts.
operationId : getReservations
tags : [ Marketplace ]
parameters :
- in : path
name : id
required : true
schema :
type : string
description : ID of Availability
2023-03-15 13:10:53 +00:00
responses :
"200" :
2024-03-21 10:53:45 +00:00
description : Retrieved storage availabilities of the node
2023-03-15 13:10:53 +00:00
content :
application/json :
schema :
2024-03-21 10:53:45 +00:00
type : array
items :
$ref : "#/components/schemas/Reservation"
"400" :
description : Invalid Availability ID
"404" :
description : Availability not found
[marketplace] Add Reservations Module (#340)
* [marketplace] reservations module
- add de/serialization for Availability
- add markUsed/markUnused in persisted availability
- add query for unused
- add reserve/release
- reservation module tests
- split ContractInteractions into client contracts and host contracts
- remove reservations start/stop as the repo start/stop is being managed by the node
- remove dedicated reservations metadata store and use the metadata store from the repo instead
- Split ContractInteractions into:
- ClientInteractions (with purchasing)
- HostInteractions (with sales and proving)
- compilation fix for nim 1.2
[repostore] fix started flag, add tests
[marketplace] persist slot index
For loading the sales state from chain, the slot index was not previously persisted in the contract. Will retrieve the slot index from the contract when the sales state is loaded.
* Revert repostore changes
In favour of separate PR https://github.com/status-im/nim-codex/pull/374.
* remove warnings
* clean up
* tests: stop repostore during teardown
* change constructor type identifier
Change Contracts constructor to accept Contracts type instead of ContractInteractions.
* change constructor return type to Result instead of Option
* fix and split interactions tests
* clean up, fix tests
* find availability by slot id
* remove duplication in host/client interactions
* add test for finding availability by slotId
* log instead of raiseAssert when failed to mark availability as unused
* move to SaleErrored state instead of raiseAssert
* remove unneeded reverse
It appears that order is not preserved in the repostore, so reversing does not have the intended effect here.
* update open api spec for potential rest endpoint errors
* move functions about available bytes to repostore
* WIP: reserve and release availabilities as needed
WIP: not tested yet
Availabilities are marked as used when matched (just before downloading starts) so that future matching logic does not match an availability currently in use.
As the download progresses, batches of blocks are written to disk, and the equivalent bytes are released from the reservation module. The size of the availability is reduced as well.
During a reserve or release operation, availability updates occur after the repo is manipulated. If the availability update operation fails, the reserve or release is rolled back to maintain correct accounting of bytes.
Finally, once download completes, or if an error occurs, the availability is marked as unused so future matching can occur.
* delete availability when all bytes released
* fix tests + cleanup
* remove availability from SalesContext callbacks
Availability is no longer used past the SaleDownloading state in the state machine. Cleanup of Availability (marking unused) is handled directly in the SaleDownloading state, and no longer in SaleErrored or SaleFinished. Likewise, Availabilities shouldn’t need to be handled on node restart.
Additionally, Availability was being passed in SalesContext callbacks, and now that Availability is only used temporarily in the SaleDownloading state, Availability is contextually irrelevant to the callbacks, except in OnStore possibly, though it was not being consumed.
* test clean up
* - remove availability from callbacks and constructors from previous commit that needed to be removed (oopsie)
- fix integration test that checks availabilities
- there was a bug fixed that crashed the node due to a missing `return success` in onStore
- the test was fixed by ensuring that availabilities are remaining on the node, and the size has been reduced
- change Availability back to non-ref object and constructor back to init
- add trace logging of all state transitions in state machine
- add generally useful trace logging
* fixes after rebase
1. Fix onProve callbacks
2. Use Slot type instead of tuple for retrieving active slot.
3. Bump codex-contracts-eth that exposes getActivceSlot call.
* swap contracts branch to not support slot collateral
Slot collateral changes in the contracts require further changes in the client code, so we’ll skip those changes for now and add in a separate commit.
* modify Interactions and Deployment constructors
- `HostInteractions` and `ClientInteractions` constructors were simplified to take a contract address and no overloads
- `Interactions` prepared simplified so there are no overloads
- `Deployment` constructor updated so that it takes an optional string parameter, instead `Option[string]`
* Move `batchProc` declaration
`batchProc` needs to be consumed by both `node` and `salescontext`, and they can’t reference each other as it creates a circular dependency.
* [reservations] rename `available` to `hasAvailable`
* [reservations] default error message to inner error msg
* add SaleIngored state
When a storage request is handled but the request does match availabilities, the sales agent machine is sent to the SaleIgnored state. In addition, the agent is constructed in a way that if the request is ignored, the sales agent is removed from the list of active agents being tracked in the sales module.
2023-04-04 07:05:16 +00:00
"500" :
2024-03-21 10:53:45 +00:00
description : Error getting reservations
2023-03-15 13:10:53 +00:00
"503" :
2024-09-24 08:37:08 +00:00
description : Persistence is not enabled
2023-03-15 13:10:53 +00:00
2023-11-13 11:30:27 +00:00
"/storage/request/{cid}" :
post :
summary : "Creates a new Request for storage"
tags : [ Marketplace ]
operationId : createStorageRequest
parameters :
- in : path
name : cid
required : true
schema :
$ref : "#/components/schemas/Cid"
description : CID of the uploaded data that should be stored
requestBody :
content :
application/json :
schema :
$ref : "#/components/schemas/StorageRequestCreation"
responses :
"200" :
description : Returns the Request ID as decimal string
2024-03-26 15:12:15 +00:00
content :
text/plain :
schema :
type : string
2023-11-13 11:30:27 +00:00
"400" :
description : Invalid or missing Request ID
"404" :
description : Request ID not found
"503" :
2024-09-24 08:37:08 +00:00
description : Persistence is not enabled
2023-11-13 11:30:27 +00:00
"/storage/purchases" :
get :
summary : "Returns list of purchase IDs"
tags : [ Marketplace ]
operationId : getPurchases
responses :
"200" :
description : Gets all purchase IDs stored in node
content :
application/json :
schema :
type : array
items :
type : string
"503" :
2024-09-24 08:37:08 +00:00
description : Persistence is not enabled
2023-11-13 11:30:27 +00:00
2023-03-15 13:10:53 +00:00
"/storage/purchases/{id}" :
get :
2023-03-30 00:02:25 +00:00
summary : "Returns purchase details"
2023-03-15 13:10:53 +00:00
tags : [ Marketplace ]
2023-03-30 00:02:25 +00:00
operationId : getPurchase
2023-03-15 13:10:53 +00:00
parameters :
- in : path
name : id
required : true
schema :
type : string
2023-03-30 00:02:25 +00:00
description : Hexadecimal ID of a Purchase
2023-03-15 13:10:53 +00:00
responses :
"200" :
2023-03-30 00:02:25 +00:00
description : Purchase details
2023-03-15 13:10:53 +00:00
content :
application/json :
schema :
2023-12-07 01:16:36 +00:00
$ref : "#/components/schemas/Purchase"
2023-03-15 13:10:53 +00:00
"400" :
2023-03-30 00:02:25 +00:00
description : Invalid or missing Purchase ID
2023-03-15 13:10:53 +00:00
"404" :
2023-03-30 00:02:25 +00:00
description : Purchase not found
2023-03-15 13:10:53 +00:00
"503" :
2024-09-24 08:37:08 +00:00
description : Persistence is not enabled
2023-03-15 13:10:53 +00:00
2024-10-14 17:26:58 +00:00
"/spr" :
2024-04-02 11:13:49 +00:00
get :
summary : "Get Node's SPR"
operationId : getSPR
tags : [ Node ]
responses :
"200" :
description : Node's SPR
content :
plain/text :
schema :
$ref : "#/components/schemas/SPR"
application/json :
schema :
$ref : "#/components/schemas/SPRRead"
"503" :
description : Node SPR not ready, try again later
2024-10-14 17:26:58 +00:00
"/peerid" :
2024-04-02 11:13:49 +00:00
get :
summary : "Get Node's PeerID"
operationId : getPeerId
tags : [ Node ]
responses :
"200" :
description : Node's Peer ID
content :
plain/text :
schema :
$ref : "#/components/schemas/PeerId"
application/json :
schema :
$ref : "#/components/schemas/PeerIdRead"
2023-03-15 13:10:53 +00:00
"/debug/chronicles/loglevel" :
post :
summary : "Set log level at run time"
tags : [ Debug ]
operationId : setDebugLogLevel
parameters :
- in : query
name : level
required : true
schema :
$ref : "#/components/schemas/LogLevel"
responses :
"200" :
description : Successfully log level set
"400" :
description : Invalid or missing log level
"500" :
description : Well it was bad-bad
"/debug/info" :
get :
summary : "Gets node information"
operationId : getDebugInfo
tags : [ Debug ]
responses :
"200" :
description : Node's information
content :
application/json :
schema :
$ref : "#/components/schemas/DebugInfo"