Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/escrow_payments #828

Open
wants to merge 9 commits into
base: feature/docker_refactor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 11 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,25 @@ jobs:
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Run Barge
working-directory: ${{ github.workspace }}/barge
env:
CONTRACTS_VERSION: escrow
run: |
bash -x start_ocean.sh --no-aquarius --no-provider --no-dashboard --with-c2d --with-typesense 2>&1 > start_ocean.log &
bash -x start_ocean.sh --no-aquarius --no-provider --no-dashboard --with-typesense 2>&1 > start_ocean.log &
- run: npm ci
- run: npm run build
- run: docker image ls
- name: Delete default runner images
run: |
rm -rf /usr/share/swift/
- name: Wait for contracts deployment and C2D cluster to be ready
- name: Wait for contracts deployment
working-directory: ${{ github.workspace }}/barge
run: |
for i in $(seq 1 250); do
sleep 10
[ -f "$HOME/.ocean/ocean-contracts/artifacts/ready" -a -f "$HOME/.ocean/ocean-c2d/ready" ] && break
sleep 5
[ -f "$HOME/.ocean/ocean-contracts/artifacts/ready" ] && break
done
- name: docker logs
run: docker logs ocean-ocean-contracts-1 && docker logs ocean-kindcluster-1 && docker logs ocean-computetodata-1 && docker logs ocean-typesense-1
run: docker logs ocean-ocean-contracts-1 && docker logs ocean-typesense-1
if: ${{ failure() }}
- name: integration tests
run: npm run test:integration:cover
Expand Down Expand Up @@ -210,8 +212,9 @@ jobs:
- name: Run Barge
working-directory: ${{ github.workspace }}/barge
run: |
bash -x start_ocean.sh --no-aquarius --no-provider --no-dashboard --with-c2d --with-typesense 2>&1 > start_ocean.log &

bash -x start_ocean.sh --no-aquarius --no-provider --no-dashboard --with-typesense 2>&1 > start_ocean.log &
env:
CONTRACTS_VERSION: escrow
- run: npm ci
- run: npm run build
- run: docker image ls
Expand All @@ -224,7 +227,7 @@ jobs:
run: |
for i in $(seq 1 250); do
sleep 10
[ -f "$HOME/.ocean/ocean-contracts/artifacts/ready" -a -f "$HOME/.ocean/ocean-c2d/ready" ] && break
[ -f "$HOME/.ocean/ocean-contracts/artifacts/ready" ] && break
done

- name: docker logs
Expand Down
4 changes: 4 additions & 0 deletions docs/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Environmental variables are also tracked in `ENVIRONMENT_VARIABLES` within `src/
- `MAX_CHECKSUM_LENGTH`: Define the maximum length for a file if checksum is required (Mb). Example: `10`
- `IS_BOOTSTRAP`: Is this node to be used as bootstrap node or not. Default is `false`.

## Payments

- `ESCROW_CLAIM_TIMEOUT`: Amount of time reserved to claim a escrow payment, in seconds. Defaults to `600`. Example: `600`

## Logs

- `LOG_LEVEL`: Define the default log level. Example: `debug`
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@libp2p/upnp-nat": "^1.2.1",
"@libp2p/websockets": "^8.1.1",
"@multiformats/multiaddr": "^10.2.0",
"@oceanprotocol/contracts": "^2.2.0",
"@oceanprotocol/contracts": "^2.3.0-next.1",
"@rdfjs/dataset": "^2.0.1",
"@rdfjs/types": "^1.1.0",
"@types/lodash.clonedeep": "^4.5.7",
Expand Down
20 changes: 16 additions & 4 deletions src/@types/C2D/C2D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type ComputeResourceType = 'cpu' | 'ram' | 'disk' | any

export interface ComputeResourcesPricingInfo {
id: ComputeResourceType
price: number // price per unit
price: number // price per unit per minute
}

export interface ComputeResource {
Expand All @@ -41,6 +41,10 @@ export interface ComputeResourceRequest {
amount: number
}

export interface ComputeResourceRequestWithPrice extends ComputeResourceRequest {
price?: number // price per unit per minute
}

export interface ComputeEnvFees {
feeToken: string
prices: ComputeResourcesPricingInfo[]
Expand Down Expand Up @@ -120,8 +124,7 @@ export interface ComputeJob {
results: ComputeResult[]
inputDID?: string[]
algoDID?: string
agreementId?: string
expireTimestamp: number
maxJobDuration: number
environment?: string
}

Expand Down Expand Up @@ -160,6 +163,12 @@ export interface AlgoChecksums {
container: string
}

export interface DBComputeJobPayment {
chainId: number
token: string
lockTx: string
claimTx: string
}
// this is the internal structure
export interface DBComputeJob extends ComputeJob {
clusterHash: string
Expand All @@ -173,8 +182,11 @@ export interface DBComputeJob extends ComputeJob {
isRunning: boolean
isStarted: boolean
containerImage: string
resources: ComputeResourceRequest[]
isFree: boolean
algoStartTimestamp: string
algoStopTimestamp: string
resources: ComputeResourceRequestWithPrice[]
payment?: DBComputeJobPayment
}

// make sure we keep them both in sync
Expand Down
94 changes: 0 additions & 94 deletions src/@types/C2D/C2D_OPFK8.ts

This file was deleted.

17 changes: 17 additions & 0 deletions src/@types/Escrow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export interface EscrowAuthorization {
address: string
maxLockedAmount: BigInt
currentLockedAmount: BigInt
maxLockSeconds: BigInt
maxLockCounts: BigInt
currentLocks: BigInt
}

export interface EscrowLock {
jobId: BigInt
payer: string
payee: string
amount: BigInt
expiry: BigInt
token: string
}
10 changes: 9 additions & 1 deletion src/@types/Fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export interface ProviderFeeData {

export interface ProviderFeeValidation {
isValid: boolean // true if valid provider fee for download
isComputeValid: boolean // true is valid for compute
message: any
validUntil: number
}
Expand Down Expand Up @@ -57,7 +56,16 @@ export interface ProviderComputeInitialize {
providerFee?: ProviderFees
}

export interface ProviderComputeInitializePayment {
escrowAddress: string
payee: string
chainId: number
minLockSeconds: number
token: string
amount: string
}
export interface ProviderComputeInitializeResults {
algorithm?: ProviderComputeInitialize
datasets?: ProviderComputeInitialize[]
payment: ProviderComputeInitializePayment
}
1 change: 1 addition & 0 deletions src/@types/OceanNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export interface OceanNodeConfig {
httpPort: number
feeStrategy: FeeStrategy
supportedNetworks?: RPCS
claimDurationTimeout: number
indexingNetworks?: RPCS
c2dClusters: C2DClusterInfo[]
c2dNodeUri: string
Expand Down
25 changes: 10 additions & 15 deletions src/@types/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,29 +151,21 @@ export interface ComputeGetEnvironmentsCommand extends Command {
chainId?: number
}

export interface ComputeDetails {
env: string // with hash
validUntil: number
export interface ComputePayment {
chainId: number
token: string
maxJobDuration: number // in seconds
resources?: ComputeResourceRequest[]
}
export interface ComputeInitializeCommand extends Command {
datasets: [ComputeAsset]
algorithm: ComputeAlgorithm
compute: ComputeDetails
environment: string
payment: ComputePayment
consumerAddress: string
signature?: string
}

export interface ComputeStartCommand extends Command {
consumerAddress: string
signature: string
nonce: string
environment: string
algorithm: ComputeAlgorithm
datasets?: ComputeAsset[]
output?: ComputeOutput
resources?: ComputeResourceRequest[]
chainId?: number // network used by payment
}
export interface FreeComputeStartCommand extends Command {
consumerAddress: string
signature: string
Expand All @@ -184,6 +176,9 @@ export interface FreeComputeStartCommand extends Command {
output?: ComputeOutput
resources?: ComputeResourceRequest[]
}
export interface PaidComputeStartCommand extends FreeComputeStartCommand {
payment: ComputePayment
}

export interface ComputeStopCommand extends Command {
consumerAddress: string
Expand Down
Loading
Loading