2022-05-19 19:56:03 +00:00
|
|
|
## Nim-Codex
|
2021-08-30 19:25:20 +00:00
|
|
|
## Copyright (c) 2021 Status Research & Development GmbH
|
|
|
|
## Licensed under either of
|
|
|
|
## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
|
|
|
## * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
|
|
|
## at your option.
|
|
|
|
## This file may not be copied, modified, or distributed except according to
|
|
|
|
## those terms.
|
|
|
|
|
2022-01-10 15:32:56 +00:00
|
|
|
import std/sequtils
|
|
|
|
import std/os
|
2022-12-03 00:00:55 +00:00
|
|
|
import std/tables
|
2022-01-10 15:32:56 +00:00
|
|
|
|
|
|
|
import pkg/chronicles
|
|
|
|
import pkg/chronos
|
|
|
|
import pkg/presto
|
|
|
|
import pkg/libp2p
|
|
|
|
import pkg/confutils
|
|
|
|
import pkg/confutils/defs
|
|
|
|
import pkg/nitro
|
|
|
|
import pkg/stew/io2
|
2022-04-13 16:32:35 +00:00
|
|
|
import pkg/stew/shims/net as stewnet
|
2022-12-03 00:00:55 +00:00
|
|
|
import pkg/datastore
|
2022-01-10 15:32:56 +00:00
|
|
|
|
|
|
|
import ./node
|
|
|
|
import ./conf
|
|
|
|
import ./rng
|
|
|
|
import ./rest/api
|
2022-03-02 16:30:42 +00:00
|
|
|
import ./stores
|
2022-01-10 15:32:56 +00:00
|
|
|
import ./blockexchange
|
|
|
|
import ./utils/fileutils
|
2022-04-06 00:34:29 +00:00
|
|
|
import ./erasure
|
2022-04-13 16:32:35 +00:00
|
|
|
import ./discovery
|
2022-04-13 12:15:22 +00:00
|
|
|
import ./contracts
|
2023-04-19 13:06:00 +00:00
|
|
|
import ./contracts/clock
|
2022-11-02 00:58:41 +00:00
|
|
|
import ./utils/addrutils
|
2022-12-03 00:00:55 +00:00
|
|
|
import ./namespaces
|
2022-11-02 00:58:41 +00:00
|
|
|
|
|
|
|
logScope:
|
|
|
|
topics = "codex node"
|
2022-01-10 15:32:56 +00:00
|
|
|
|
|
|
|
type
|
2022-05-19 19:56:03 +00:00
|
|
|
CodexServer* = ref object
|
2022-01-10 15:32:56 +00:00
|
|
|
runHandle: Future[void]
|
2022-05-19 19:56:03 +00:00
|
|
|
config: CodexConf
|
2022-01-10 15:32:56 +00:00
|
|
|
restServer: RestServerRef
|
2022-05-19 19:56:03 +00:00
|
|
|
codexNode: CodexNodeRef
|
2022-12-03 00:00:55 +00:00
|
|
|
repoStore: RepoStore
|
2023-03-08 15:04:54 +00:00
|
|
|
maintenance: BlockMaintainer
|
2022-01-10 15:32:56 +00:00
|
|
|
|
2022-11-02 00:58:41 +00:00
|
|
|
CodexPrivateKey* = libp2p.PrivateKey # alias
|
|
|
|
|
2022-05-19 19:56:03 +00:00
|
|
|
proc start*(s: CodexServer) {.async.} =
|
2022-12-03 00:00:55 +00:00
|
|
|
notice "Starting codex node"
|
|
|
|
|
|
|
|
await s.repoStore.start()
|
2022-01-10 15:32:56 +00:00
|
|
|
s.restServer.start()
|
2022-05-19 19:56:03 +00:00
|
|
|
await s.codexNode.start()
|
2023-03-08 15:04:54 +00:00
|
|
|
s.maintenance.start()
|
2022-01-10 15:32:56 +00:00
|
|
|
|
2022-11-02 00:58:41 +00:00
|
|
|
let
|
2022-12-03 00:00:55 +00:00
|
|
|
# TODO: Can't define these as constants, pity
|
2022-11-02 00:58:41 +00:00
|
|
|
natIpPart = MultiAddress.init("/ip4/" & $s.config.nat & "/")
|
|
|
|
.expect("Should create multiaddress")
|
|
|
|
anyAddrIp = MultiAddress.init("/ip4/0.0.0.0/")
|
|
|
|
.expect("Should create multiaddress")
|
|
|
|
loopBackAddrIp = MultiAddress.init("/ip4/127.0.0.1/")
|
|
|
|
.expect("Should create multiaddress")
|
|
|
|
|
|
|
|
# announce addresses should be set to bound addresses,
|
|
|
|
# but the IP should be mapped to the provided nat ip
|
|
|
|
announceAddrs = s.codexNode.switch.peerInfo.addrs.mapIt:
|
|
|
|
block:
|
|
|
|
let
|
|
|
|
listenIPPart = it[multiCodec("ip4")].expect("Should get IP")
|
|
|
|
|
|
|
|
if listenIPPart == anyAddrIp or
|
|
|
|
(listenIPPart == loopBackAddrIp and natIpPart != loopBackAddrIp):
|
|
|
|
it.remapAddr(s.config.nat.some)
|
|
|
|
else:
|
|
|
|
it
|
|
|
|
|
|
|
|
s.codexNode.discovery.updateAnnounceRecord(announceAddrs)
|
|
|
|
s.codexNode.discovery.updateDhtRecord(s.config.nat, s.config.discoveryPort)
|
|
|
|
|
2022-11-15 15:46:21 +00:00
|
|
|
s.runHandle = newFuture[void]("codex.runHandle")
|
2022-01-10 15:32:56 +00:00
|
|
|
await s.runHandle
|
|
|
|
|
2022-05-19 19:56:03 +00:00
|
|
|
proc stop*(s: CodexServer) {.async.} =
|
2022-12-03 00:00:55 +00:00
|
|
|
notice "Stopping codex node"
|
|
|
|
|
2022-01-10 15:32:56 +00:00
|
|
|
await allFuturesThrowing(
|
2022-12-03 00:00:55 +00:00
|
|
|
s.restServer.stop(),
|
|
|
|
s.codexNode.stop(),
|
2023-03-08 15:04:54 +00:00
|
|
|
s.repoStore.stop(),
|
|
|
|
s.maintenance.stop())
|
2022-01-10 15:32:56 +00:00
|
|
|
|
|
|
|
s.runHandle.complete()
|
|
|
|
|
[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
|
|
|
proc new(_: type Contracts,
|
|
|
|
config: CodexConf,
|
|
|
|
repo: RepoStore): Contracts =
|
|
|
|
|
2023-04-19 13:06:00 +00:00
|
|
|
if not config.persistence and not config.validator:
|
2022-08-09 04:29:06 +00:00
|
|
|
if config.ethAccount.isSome:
|
2023-04-19 13:06:00 +00:00
|
|
|
warn "Ethereum account was set, but neither persistence nor validator is enabled"
|
2022-08-09 04:29:06 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
without account =? config.ethAccount:
|
2023-04-19 13:06:00 +00:00
|
|
|
if config.persistence:
|
|
|
|
error "Persistence enabled, but no Ethereum account was set"
|
|
|
|
if config.validator:
|
|
|
|
error "Validator enabled, but no Ethereum account was set"
|
2022-08-09 04:29:06 +00:00
|
|
|
quit QuitFailure
|
|
|
|
|
[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
|
|
|
var deploy: Deployment
|
|
|
|
try:
|
|
|
|
if deployFile =? config.ethDeployment:
|
|
|
|
deploy = Deployment.init(deployFile)
|
|
|
|
else:
|
|
|
|
deploy = Deployment.init()
|
|
|
|
except IOError as e:
|
|
|
|
error "Unable to read deployment json"
|
|
|
|
quit QuitFailure
|
|
|
|
|
|
|
|
without marketplaceAddress =? deploy.address(Marketplace):
|
|
|
|
error "Marketplace contract address not found in deployment file"
|
|
|
|
quit QuitFailure
|
|
|
|
|
2023-04-19 13:06:00 +00:00
|
|
|
let provider = JsonRpcProvider.new(config.ethProvider)
|
|
|
|
let signer = provider.getSigner(account)
|
|
|
|
let marketplace = Marketplace.new(marketplaceAddress, signer)
|
|
|
|
let market = OnChainMarket.new(marketplace)
|
|
|
|
let clock = OnChainClock.new(provider)
|
|
|
|
|
|
|
|
var client: ?ClientInteractions
|
|
|
|
var host: ?HostInteractions
|
|
|
|
var validator: ?ValidatorInteractions
|
|
|
|
if config.persistence:
|
|
|
|
let purchasing = Purchasing.new(market, clock)
|
|
|
|
let proving = Proving.new(market, clock)
|
|
|
|
let sales = Sales.new(market, clock, proving, repo)
|
|
|
|
client = some ClientInteractions.new(clock, purchasing)
|
|
|
|
host = some HostInteractions.new(clock, sales, proving)
|
|
|
|
if config.validator:
|
|
|
|
let validation = Validation.new(clock, market, config.validatorMaxSlots)
|
|
|
|
validator = some ValidatorInteractions.new(clock, validation)
|
|
|
|
|
|
|
|
(client, host, validator)
|
2022-08-09 04:29:06 +00:00
|
|
|
|
2022-11-02 00:58:41 +00:00
|
|
|
proc new*(T: type CodexServer, config: CodexConf, privateKey: CodexPrivateKey): T =
|
2022-01-10 15:32:56 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
switch = SwitchBuilder
|
|
|
|
.new()
|
2022-04-13 16:32:35 +00:00
|
|
|
.withPrivateKey(privateKey)
|
2022-10-27 13:44:56 +00:00
|
|
|
.withAddresses(config.listenAddrs)
|
2022-01-10 15:32:56 +00:00
|
|
|
.withRng(Rng.instance())
|
|
|
|
.withNoise()
|
|
|
|
.withMplex(5.minutes, 5.minutes)
|
|
|
|
.withMaxConnections(config.maxPeers)
|
|
|
|
.withAgentVersion(config.agentString)
|
2022-04-13 16:32:35 +00:00
|
|
|
.withSignedPeerRecord(true)
|
2022-01-10 15:32:56 +00:00
|
|
|
.withTcpTransport({ServerFlags.ReuseAddr})
|
|
|
|
.build()
|
|
|
|
|
2022-08-04 23:51:05 +00:00
|
|
|
var
|
2022-11-15 15:46:21 +00:00
|
|
|
cache: CacheStore = nil
|
2022-08-04 23:51:05 +00:00
|
|
|
|
|
|
|
if config.cacheSize > 0:
|
|
|
|
cache = CacheStore.new(cacheSize = config.cacheSize * MiB)
|
2023-03-08 15:04:54 +00:00
|
|
|
## Is unused?
|
2022-03-02 16:30:42 +00:00
|
|
|
|
2022-01-10 15:32:56 +00:00
|
|
|
let
|
2022-12-03 00:00:55 +00:00
|
|
|
discoveryDir = config.dataDir / CodexDhtNamespace
|
|
|
|
|
|
|
|
if io2.createPath(discoveryDir).isErr:
|
|
|
|
trace "Unable to create discovery directory for block store", discoveryDir = discoveryDir
|
|
|
|
raise (ref Defect)(
|
|
|
|
msg: "Unable to create discovery directory for block store: " & discoveryDir)
|
|
|
|
|
|
|
|
let
|
|
|
|
discoveryStore = Datastore(
|
|
|
|
SQLiteDatastore.new(config.dataDir / CodexDhtProvidersNamespace)
|
|
|
|
.expect("Should create discovery datastore!"))
|
2022-10-27 13:44:56 +00:00
|
|
|
|
2022-11-02 00:58:41 +00:00
|
|
|
discovery = Discovery.new(
|
2022-10-27 13:44:56 +00:00
|
|
|
switch.peerInfo.privateKey,
|
2022-11-02 00:58:41 +00:00
|
|
|
announceAddrs = config.listenAddrs,
|
|
|
|
bindIp = config.discoveryIp,
|
|
|
|
bindPort = config.discoveryPort,
|
2022-10-27 13:44:56 +00:00
|
|
|
bootstrapNodes = config.bootstrapNodes,
|
|
|
|
store = discoveryStore)
|
2022-04-13 16:32:35 +00:00
|
|
|
|
2022-01-10 15:32:56 +00:00
|
|
|
wallet = WalletRef.new(EthPrivateKey.random())
|
|
|
|
network = BlockExcNetwork.new(switch)
|
2022-08-08 21:42:05 +00:00
|
|
|
|
2023-03-14 22:32:15 +00:00
|
|
|
repoData = case config.repoKind
|
|
|
|
of repoFS: Datastore(FSDatastore.new($config.dataDir, depth = 5)
|
|
|
|
.expect("Should create repo file data store!"))
|
|
|
|
of repoSQLite: Datastore(SQLiteDatastore.new($config.dataDir)
|
|
|
|
.expect("Should create repo SQLite data store!"))
|
|
|
|
|
2022-12-03 00:00:55 +00:00
|
|
|
repoStore = RepoStore.new(
|
2023-03-14 22:32:15 +00:00
|
|
|
repoDs = repoData,
|
2022-12-03 00:00:55 +00:00
|
|
|
metaDs = SQLiteDatastore.new(config.dataDir / CodexMetaNamespace)
|
|
|
|
.expect("Should create meta data store!"),
|
|
|
|
quotaMaxBytes = config.storageQuota.uint,
|
2023-03-08 15:04:54 +00:00
|
|
|
blockTtl = config.blockTtlSeconds.seconds)
|
|
|
|
|
|
|
|
maintenance = BlockMaintainer.new(
|
|
|
|
repoStore,
|
|
|
|
interval = config.blockMaintenanceIntervalSeconds.seconds,
|
|
|
|
numberOfBlocksPerInterval = config.blockMaintenanceNumberOfBlocks)
|
2022-08-08 21:42:05 +00:00
|
|
|
|
2022-05-19 02:29:15 +00:00
|
|
|
peerStore = PeerCtxStore.new()
|
|
|
|
pendingBlocks = PendingBlocksManager.new()
|
2022-12-03 00:00:55 +00:00
|
|
|
blockDiscovery = DiscoveryEngine.new(repoStore, peerStore, network, discovery, pendingBlocks)
|
|
|
|
engine = BlockExcEngine.new(repoStore, wallet, network, blockDiscovery, peerStore, pendingBlocks)
|
|
|
|
store = NetworkStore.new(engine, repoStore)
|
2022-04-06 00:34:29 +00:00
|
|
|
erasure = Erasure.new(store, leoEncoderProvider, leoDecoderProvider)
|
[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
|
|
|
contracts = Contracts.new(config, repoStore)
|
2022-11-02 00:58:41 +00:00
|
|
|
codexNode = CodexNodeRef.new(switch, store, engine, erasure, discovery, contracts)
|
2022-01-10 15:32:56 +00:00
|
|
|
restServer = RestServerRef.new(
|
2022-05-19 19:56:03 +00:00
|
|
|
codexNode.initRestApi(config),
|
2023-03-08 11:45:55 +00:00
|
|
|
initTAddress(config.apiBindAddress , config.apiPort),
|
2022-01-10 15:32:56 +00:00
|
|
|
bufferSize = (1024 * 64),
|
|
|
|
maxRequestBodySize = int.high)
|
2022-11-02 00:58:41 +00:00
|
|
|
.expect("Should start rest server!")
|
2022-01-10 15:32:56 +00:00
|
|
|
|
|
|
|
switch.mount(network)
|
|
|
|
T(
|
|
|
|
config: config,
|
2022-05-19 19:56:03 +00:00
|
|
|
codexNode: codexNode,
|
2022-12-03 00:00:55 +00:00
|
|
|
restServer: restServer,
|
2023-03-08 15:04:54 +00:00
|
|
|
repoStore: repoStore,
|
|
|
|
maintenance: maintenance)
|