443 Commits

Author SHA1 Message Date
Veaceslav Doina
55c00fff9b
Dockerfile now support build arguments 2023-06-13 14:33:06 +03:00
Slava
cb621ac618
We use master branch
Signed-off-by: Slava <20563034+veaceslavdoina@users.noreply.github.com>
2023-05-24 18:23:09 +03:00
Slava
95c69bda5c
Workflow optimized using matrix
Signed-off-by: Slava <20563034+veaceslavdoina@users.noreply.github.com>
2023-05-22 19:02:01 +03:00
Slava
2a14cea7d0
Build x86-64 and arm and push a multi-architecture image
Signed-off-by: Slava <20563034+veaceslavdoina@users.noreply.github.com>
2023-05-11 20:44:38 +03:00
benbierens
c777387556
fixes load and push for amd docker build 2023-05-05 08:58:54 +02:00
Eric Mastro
6a115a43ff
[docker] modify startCodex.sh
- include overridden node name in log output if specified in test
- quote `—log-level` value so that multiple log levels can be specified
- ensure any CLI parameter env vars are passed through to the codex binary, instead of conditionally including them
- add `—persistence`
- add `—validator`
2023-05-05 15:35:24 +10:00
Eric Mastro
4f6915f528
Update arm64 arm of docker ci 2023-05-05 15:32:54 +10:00
benbierens
20ff017b89
Sets up separate docker build for arm 2023-05-04 15:06:09 +02:00
benbierens
977e62b34d
Changes switchPeers source from KeyBook to AddressBook (filed ticket in libp2p, discussed with Tanguy) 2023-04-30 10:03:40 +02:00
benbierens
ecf1ab534d
fixes misalignment of debug peer info array 2023-04-28 08:50:35 +02:00
benbierens
476ce2f0b2
Moves debug image-building 2023-04-28 08:26:21 +02:00
Eric Mastro
a9885502d4
Add image to CI, and update startCodex.sh 2023-04-28 16:03:59 +10:00
Eric Mastro
84f88d4316
Add --simulate-proof-failures env variable, update docker-compose to point to slimmed image 2023-04-28 15:26:47 +10:00
benbierens
f9122424f7
Applies multiarch ubuntu dockerfile as codex-dockerfile. 2023-04-28 14:15:42 +10:00
benbierens
c6d0cd47b3
api-names slightly kinder to json serializers 2023-04-28 14:15:42 +10:00
Eric Mastro
5a3b8948b6
first steps towards support for arm64 2023-04-28 14:15:42 +10:00
benbierens
e5c5896680
exposes peer information via debug/info 2023-04-28 14:15:42 +10:00
benbierens
bf17bc821f
Support for building docker images with local modifications for the purpose of testing and debugging 2023-04-28 14:15:42 +10:00
benbierens
132d860ff3
Uses correct string for marketplace address 2023-04-28 14:15:42 +10:00
Eric Mastro
477d4891d8
hide —simulate-proof-failures behind compile flag
The `--simulate-proof-failures` cli param is now only available when codex is compile using the `-d:codex_enable_proof_failures` flag.
2023-04-24 19:38:32 +10:00
Eric Mastro
04d223ba71
make integration test very loose
Accurate integration tests counting the exact number of expected missed proofs has proved elusive to tackle due to trying to emulate whether or not the validator should be able to mark missing proofs or not.

As a workaround for the time being, loose tests are now being used that ensure a slot is freed after enough proofs are missed (due to being invalid).
2023-04-24 19:37:19 +10:00
Eric Mastro
f9cfaf628d
clean up logging 2023-04-24 16:32:32 +10:00
Eric Mastro
757221e532
set test log level to trace 2023-04-20 19:21:22 +10:00
Eric Mastro
fb882d2ce3
multinode test setup for invalid proof submission tests
# Conflicts:
#	codex/contracts/market.nim
#	codex/validation.nim
#	tests/integration/testproofs.nim
2023-04-20 19:12:30 +10:00
Eric Mastro
9cf8ed75f3
fix rebase
# Conflicts:
#	codex/validation.nim
#	tests/integration/testproofs.nim
2023-04-20 19:07:00 +10:00
Eric Mastro
81bf77375d
WIP simulation integration test
Committing so latest work can be rebased.
2023-04-20 18:58:14 +10:00
Eric Mastro
90fee8eebb
clean up 2023-04-20 18:57:56 +10:00
Eric Mastro
cbdf9be736
[marketplace] Simulate invalid proof submissions
Closes #392.

Create a simulated prover that sends an invalid proof (seq[byte] of length 0) every `N` proofs, where `N` is defined by a new cli param `--simulate-failed-proofs`.
2023-04-20 18:57:36 +10:00
markspanbroek
d56eb6aee1
Validator (#387)
* [contracts] Add SlotFreed event

* [integration] allow test node to be stopped twice

* [cli] add --validator option

* [contracts] remove dead code

* [contracts] instantiate OnChainMarket and OnChainClock only once

* [contracts] add Validation

* [sales] remove duplicate import

* [market] add missing import

* [market] subscribe to all SlotFilled events

* [market] add freeSlot()

* [sales] fix warnings

* [market] subscribe to SlotFreed events

* [contracts] fix warning

* [validator] keep track of filled slots

* [validation] remove slots that have ended

* [proving] absorb Proofs into Market

Both Proofs and Market are abstractions around
the Marketplace contract, having them separately
is more trouble than it's worth at the moment.

* [market] add markProofAsMissing()

* [clock] speed up waiting for clock in tests

* [validator] mark proofs as missing

* [timer] fix error on node shutdown

* [cli] handle --persistence and --validator separately

* [market] allow retrieval of proof timeout value

* [validator] do not subscribe to SlotFreed events

Freed slots are already handled in
removeSlotsThatHaveEnded(), and onSlotsFreed()
interfered with its iterator.

* [validator] Start validation at the start of a new period

To decrease the likelihood that we hit the validation timeout.

* [validator] do not mark proofs as missing after timeout

* [market] check whether proof can be marked as missing

* [validator] simplify validation

Simulate a transaction to mark proof as missing, instead
of trying to keep track of all the conditions that may
lead to a proof being marked as missing.

* [build] use nim-ethers PR #40

Uses "pending" blocktag instead of "latest" blocktag
for better simulation of transactions before sending
them.

https://github.com/status-im/nim-ethers/pull/40

* [integration] integration test for validator

* [validator] monitor a maximum number of slots

Adds cli parameter --validator-max-slots.

* [market] fix missing collateral argument

After rebasing, add the new argument to fillSlot calls.

* [build] update to nim-ethers 0.2.5

* [validator] use Set instead of Table to keep track of slots

* [validator] add logging

* [validator] add test for slot failure

* [market] use "pending" blocktag to use more up to date block time

* [contracts] remove unused import

* [validator] fix: wait until after period ends

The smart contract checks that 'end < block.timestamp',
so we need to wait until the block timestamp is greater
than the period end.
2023-04-19 15:06:00 +02:00
Ben Bierens
80106cd3d2
Creates marketplace_address.json during docker start. (#397)
* Creates marketplace_address.json during docker start.

Signed-off-by: Ben Bierens <39762930+benbierens@users.noreply.github.com>

* Enables manual start for docker workflow

---------

Signed-off-by: Ben Bierens <39762930+benbierens@users.noreply.github.com>
2023-04-18 14:17:24 +02:00
Adam Uhlíř
131d003a0c
feat: collateral per slot (#390)
Co-authored-by: Eric Mastro <github@egonat.me>
2023-04-14 11:04:17 +02:00
Dmitriy Ryajov
86a3f74448
adding some clarification comments (#391) 2023-04-10 14:45:10 -06:00
Eric Mastro
ccf349bd14
[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 17:05:16 +10:00
Adam Uhlíř
3198db414d
fix: approving tokens transfer when creating request (#385) 2023-03-30 11:34:38 +02:00
Eric Mastro
d756bf9dc5
[rest api] fix purchases documentation (#380)
Documentation in the REST OpenAPI spec were showing incorrect information about Purchasing endpoints.

Update the open api spec to reflect information about purchases, not requests.
2023-03-30 11:02:25 +11:00
Adam Uhlíř
1c9c22ad63
docs: api documentation linked (#382) 2023-03-29 14:55:17 +02:00
Yaroslav Kukharuk
97989682f8
Update references to make exec (#384)
Signed-off-by: Yaroslav Kukharuk <i.kukharuk@gmail.com>
2023-03-27 18:08:13 -06:00
markspanbroek
4ffe7b8e06
Generate proofs when required (#383)
* [maintenance] speedup integration test

* [rest api] add proofProbability parameter to storage requests

* [integration] negotiation test ends when contract starts

* [integration] reusable 2 node setup for tests

* [integration] introduce CodexClient for tests

* [node] submit storage proofs when required

* [contracts] Add Slot type

* [proving] replace onProofRequired & submitProof with onProve

Removes duplication between Sales.onProve() and
Proving.onProofRequired()
2023-03-27 15:47:25 +02:00
Adam Uhlíř
067c1c9625
ci: lint openapi on all prs (#381) 2023-03-23 12:19:33 +01:00
Ben Bierens
b2048377e8
Makes required arguments overrideable from environment variables (#377) 2023-03-20 15:07:07 +01:00
Eric Mastro
c9a62de13f
fix: repostore started flag in stop() (#374) 2023-03-16 09:00:36 -06:00
markspanbroek
086b5c3914
[build] fix: ignore logging when running singular tests (#369)
* [build] fix: ignore logging when running singular tests

Ensures that logging is ignored at runtime when running
individual tests using `nim c -r tests/...`

* [build] Allow tests to be run with -d:chronicles_log_level

When running tests with chronicles_log_level set, do not
hide the the logs.
2023-03-16 15:32:09 +01:00
Adam Uhlíř
5ae545bc3c
docs: openapi specification (#355)
Co-authored-by: Eric Mastro <github@egonat.me>
2023-03-15 14:10:53 +01:00
c-blake
7cdd4f79e3
Resuscitate https://github.com/status-im/nim-codex/pull/251 except for (#358)
A) renaming to --repo-kind which makes more sense in the current code
and B) without a working cacheStore (yet)

Tagging related https://github.com/status-im/nim-codex/issues/357
2023-03-14 16:32:15 -06:00
Dmitriy Ryajov
98f6bb4ed9
fix docker to use new make command (#364) 2023-03-14 16:28:17 -06:00
Dmitriy Ryajov
de3d97db1e
running make should build exec (#356) 2023-03-13 17:56:03 -06:00
Adam Uhlíř
6cbf3ab044
fix(api): correctly using tolerance for storage request (#359) 2023-03-13 13:23:50 +01:00
Ben Bierens
c3095f78a2
Adds linux/arm/v7 (#360) 2023-03-12 11:27:33 +01:00
Ben Bierens
da79660f8e
Enable stylecheck (#353)
* applying styleCheck

* stuck on vendor folder

* Applies style check

* Turns styleCheck back off

* switches to stylecheck:usages

* Fixes empty template casing

* rolls up nim-blscurve, nim-datastore, nim-ethers, nim-leopard, and nim-taskpools.

* bumps nim-confutils and removes unused import from fileutils.nim

* Unused using in fileutils.nim is required by CI

* Reverts bump of nim-confutils module
2023-03-10 08:02:54 +01:00
markspanbroek
7a0a48e4a5
Fix warnings (drops Nim 1.2) (#348)
* [build] disable XCannotRaiseY hint

There are too many {.raises:[Defect].} in the
libraries that we use, drowning out all other
warnings and hints

* [build] disable BareExcept warning

Not yet enabled in a released version of Nim,
so libraries that we depend on have not fixed
this yet, drowning out our own hints and warnings

* [build] disable DotLikeOps warning

dot-like ops were an experiment that is not going
land in Nim

* [build] compile log statements in tests

When running tests, all log statements are compiled.
They are filtered out at runtime during a test run.

* [build] do not build executable when running unit test

It's already built in the integration test

* [build] Fix warnings

- remove unused code
- remove unused imports
- stop using deprecated stuff

* [build] Put compiler flags behind nim version checks

* [CI] remove Nim 1.2 compatibility
2023-03-09 12:23:45 +01:00