Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions codex/clock.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pkg/chronos
import pkg/stew/endians2
import pkg/upraises
import pkg/stint

type
Clock* = ref object of RootObj
Expand Down Expand Up @@ -42,6 +41,3 @@ proc toSecondsSince1970*(bytes: seq[byte]): SecondsSince1970 =

proc toSecondsSince1970*(num: uint64): SecondsSince1970 =
cast[int64](num)

proc toSecondsSince1970*(bigint: UInt256): SecondsSince1970 =
bigint.truncate(int64)
12 changes: 5 additions & 7 deletions codex/codex.nim
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ proc bootstrapInteractions(s: CodexServer): Future[void] {.async.} =
quit QuitFailure

let marketplace = Marketplace.new(marketplaceAddress, signer)
let market = OnChainMarket.new(
marketplace, config.rewardRecipient, config.marketplaceRequestCacheSize
)
without market =?
await OnChainMarket.load(marketplace, config.marketplaceRequestCacheSize), error:
fatal "Cannot load market", error = error.msg
quit QuitFailure

let clock = OnChainClock.new(provider)

var client: ?ClientInteractions
Expand All @@ -134,10 +136,6 @@ proc bootstrapInteractions(s: CodexServer): Future[void] {.async.} =
if config.simulateProofFailures > 0:
warn "Proof failure simulation is not enabled for this build! Configuration ignored"

if error =? (await market.loadConfig()).errorOption:
fatal "Cannot load market configuration", error = error.msg
quit QuitFailure

let purchasing = Purchasing.new(market, clock)
let sales = Sales.new(market, clock, repo, proofFailures)
client = some ClientInteractions.new(clock, purchasing)
Expand Down
5 changes: 0 additions & 5 deletions codex/conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,6 @@ type
name: "validator-group-index"
.}: uint16

rewardRecipient* {.
desc: "Address to send payouts to (eg rewards and refunds)",
name: "reward-recipient"
.}: Option[EthAddress]

marketplaceRequestCacheSize* {.
desc:
"Maximum number of StorageRequests kept in memory." &
Expand Down
10 changes: 7 additions & 3 deletions codex/contracts/config.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pkg/contractabi
import pkg/ethers/contracts/fields
import pkg/questionable/results
import ./requests

export contractabi

Expand All @@ -11,7 +12,7 @@ type
collateral*: CollateralConfig
proofs*: ProofConfig
reservations*: SlotReservationsConfig
requestDurationLimit*: uint64
requestDurationLimit*: StorageDuration

CollateralConfig* = object
repairRewardPercentage*: uint8
Expand All @@ -22,8 +23,8 @@ type
# percentage of the slashed amount going to the validators

ProofConfig* = object
period*: uint64 # proofs requirements are calculated per period (in seconds)
timeout*: uint64 # mark proofs as missing before the timeout (in seconds)
period*: StorageDuration # proofs requirements are calculated per period (in seconds)
timeout*: StorageDuration # mark proofs as missing before the timeout (in seconds)
downtime*: uint8 # ignore this much recent blocks for proof requirements
downtimeProduct*: uint8
zkeyHash*: string # hash of the zkey file which is linked to the verifier
Expand Down Expand Up @@ -62,6 +63,9 @@ func fromTuple(_: type MarketplaceConfig, tupl: tuple): MarketplaceConfig =
requestDurationLimit: tupl[3],
)

func solidityType(_: type StUint[40]): string =
"uint40"

func solidityType*(_: type SlotReservationsConfig): string =
solidityType(SlotReservationsConfig.fieldTypes)

Expand Down
2 changes: 1 addition & 1 deletion codex/contracts/deployment.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Deployment* = ref object
const knownAddresses = {
# Hardhat localhost network
"31337":
{"Marketplace": Address.init("0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44")}.toTable,
{"Marketplace": Address.init("0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f")}.toTable,
# Taiko Alpha-3 Testnet
"167005":
{"Marketplace": Address.init("0x948CF9291b77Bd7ad84781b9047129Addf1b894F")}.toTable,
Expand Down
Loading
Loading