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

Stablization of 3.0-beta builds #919

Merged
merged 14 commits into from
May 7, 2024
Merged
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
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ on:
required: false
default: "holesky"
provider_version:
description: "Provider version (e.g., v0.14.0 or pre-rel-v0.14.1)"
description: "Provider version (e.g., v0.15.0 or pre-rel-v0.15.1)"
required: false
default: "v0.14.0"
default: "v0.15.0"
requestor_version:
description: "Requestor version (e.g., v0.14.0 or pre-rel-v0.14.1)"
description: "Requestor version (e.g., v0.15.0 or pre-rel-v0.15.1)"
required: false
default: "v0.14.0"
default: "v0.15.0"
provider_wasi_version:
description: "Provider WASI version (e.g., v0.2.2)"
required: false
Expand All @@ -40,8 +40,8 @@ permissions:
contents: read # for checkout

env:
PROVIDER_VERSION: ${{ github.event.inputs.provider_version || 'v0.14.0' }}
REQUESTOR_VERSION: ${{ github.event.inputs.requestor_version || 'v0.14.0' }}
PROVIDER_VERSION: ${{ github.event.inputs.provider_version || 'v0.15.0' }}
REQUESTOR_VERSION: ${{ github.event.inputs.requestor_version || 'v0.15.0' }}
PROVIDER_WASI_VERSION: ${{ github.event.inputs.provider_wasi_version || 'v0.2.2' }}
PROVIDER_VM_VERSION: ${{ github.event.inputs.provider_vm_version || 'v0.3.0' }}
PAYMENT_NETWORK: ${{ github.event.inputs.payment_network || 'holesky' }}
Expand Down
1 change: 1 addition & 0 deletions examples/basic/hello-world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import { pinoPrettyLogger } from "@golem-sdk/pino-logger";

// This will keep the script waiting for payments etc
await lease.finalize();
await allocation.release();
} catch (err) {
console.error("Failed to run example on Golem", err);
} finally {
Expand Down
10 changes: 5 additions & 5 deletions examples/deployment/new-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ async function main() {
// image: "golem/node:20",
// image: "http://golem.io/node:20",
// imageHash: "0x30984084039480493840",
minCpuCores: 4,
minMemGib: 8,
minStorageGib: 16,
minCpuCores: 1,
minMemGib: 2,
minStorageGib: 10,
},
market: {
rentHours: 12,
Expand All @@ -49,8 +49,8 @@ async function main() {
.createActivityPool("db", {
demand: {
imageTag: "golem/alpine:latest",
minCpuCores: 2,
minMemGib: 16,
minCpuCores: 1,
minMemGib: 2,
minStorageGib: 4,
},
market: {
Expand Down
6 changes: 3 additions & 3 deletions examples/pool/hello-world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import { pinoPrettyLogger } from "@golem-sdk/pino-logger";
const demandOptions = {
demand: {
imageTag: "golem/alpine:latest",
minCpuCores: 4,
minMemGib: 8,
minStorageGib: 16,
minCpuCores: 1,
minMemGib: 1,
minStorageGib: 2,
},
market: {
rentHours: 12,
Expand Down
2 changes: 1 addition & 1 deletion src/golem-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class GolemNetwork {
agreementRepository,
this.logger,
),
marketApi: new MarketApiAdapter(this.yagna),
marketApi: new MarketApiAdapter(this.yagna, this.logger),
fileServer: new GftpServerAdapter(this.storageProvider),
};

Expand Down
28 changes: 5 additions & 23 deletions src/market/market.module.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { EventEmitter } from "eventemitter3";
import {
DemandConfig,
DemandNew,
DraftOfferProposalPool,
GolemMarketError,
MarketApi,
MarketErrorCode,
NewProposalEvent,
ProposalFilter,
} from "./index";
import {
Agreement,
LegacyAgreementServiceOptions,
LeaseProcess,
IPaymentApi,
IActivityApi,
AgreementPool,
AgreementPoolOptions,
} from "../agreement";
import { DemandConfig, DemandNew, DraftOfferProposalPool, MarketApi, NewProposalEvent, ProposalFilter } from "./index";
import { Agreement, AgreementPool, AgreementPoolOptions, IActivityApi, IPaymentApi, LeaseProcess } from "../agreement";
import { defaultLogger, Logger, YagnaApi } from "../shared/utils";
import { Allocation, PaymentModule } from "../payment";
import { Allocation } from "../payment";
import { Package } from "./package";
import { bufferTime, filter, map, Observable, switchMap, tap, OperatorFunction } from "rxjs";
import { bufferTime, filter, map, Observable, OperatorFunction, switchMap, tap } from "rxjs";
import { IProposalRepository, ProposalNew } from "./proposal";
import { ComparisonOperator, DecorationsBuilder } from "./builder";
import { ProposalFilterNew } from "./service";
Expand Down Expand Up @@ -237,8 +220,8 @@ export class MarketModuleImpl implements MarketModule {
// Configure payment platform
builder
.addProperty(`golem.com.payment.platform.${payerDetails.getPaymentPlatform()}.address`, payerDetails.address)
.addProperty("golem.com.payment.protocol.version", "2")
.addConstraint(`golem.com.payment.platform.${payerDetails.getPaymentPlatform()}.address`, "*")
.addProperty("golem.com.payment.protocol.version", "2")
.addConstraint("golem.com.payment.protocol.version", "1", ComparisonOperator.Gt);

return builder.getDemandSpecification(payerDetails.getPaymentPlatform(), demandSpecificConfig.expirationSec);
Expand Down Expand Up @@ -416,7 +399,6 @@ export class MarketModuleImpl implements MarketModule {
const subscription = source.subscribe((proposal) => {
if (proposal.isInitial()) {
proposalsBatch.addProposal(proposal);
this.logger.debug("Added initial proposal to batch", { proposal: proposal.id });
} else {
destination.next(proposal);
}
Expand Down
3 changes: 2 additions & 1 deletion src/shared/yagna/adapters/market-api-adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { YagnaApi } from "../yagnaApi";
import { MarketApiAdapter } from "./market-api-adapter";
import { DemandNew, DemandSpecification, ProposalNew } from "../../../market";
import { take, takeUntil, timer } from "rxjs";
import { Logger } from "../../utils";

const mockMarket = mock(YaTsClient.MarketApi.RequestorService);
const mockYagna = mock(YagnaApi);
Expand All @@ -14,7 +15,7 @@ beforeEach(() => {
reset(mockYagna);
reset(mockMarket);
when(mockYagna.market).thenReturn(instance(mockMarket));
api = new MarketApiAdapter(instance(mockYagna));
api = new MarketApiAdapter(instance(mockYagna), instance(imock<Logger>()));
});

describe("Market Api Adapter", () => {
Expand Down
11 changes: 8 additions & 3 deletions src/shared/yagna/adapters/market-api-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { Observable } from "rxjs";
import { MarketApi, ProposalEvent } from "../../../market/api";
import { DemandNew, DemandSpecification, MarketApi, ProposalEvent, ProposalNew } from "../../../market";
import { YagnaApi } from "../yagnaApi";
import YaTsClient from "ya-ts-client";
import { DemandNew, DemandSpecification, ProposalNew } from "../../../market";
import { GolemInternalError } from "../../error/golem-error";
import { Logger } from "../../utils";

export class MarketApiAdapter implements MarketApi {
constructor(private readonly yagnaApi: YagnaApi) {}
constructor(
private readonly yagnaApi: YagnaApi,
private readonly logger: Logger,
) {}

async publishDemandSpecification(specification: DemandSpecification): Promise<DemandNew> {
const idOrError = await this.yagnaApi.market.subscribeDemand(specification.decoration);
Expand All @@ -21,6 +24,7 @@ export class MarketApiAdapter implements MarketApi {
if (result?.message) {
throw new Error(`Failed to unsubscribe from demand: ${result.message}`);
}
this.logger.info("Demand unsubscribed", { demand: demand.id });
}

observeProposalEvents(demand: DemandNew): Observable<ProposalEvent> {
Expand Down Expand Up @@ -58,6 +62,7 @@ export class MarketApiAdapter implements MarketApi {
};
});
}

async counterProposal(receivedProposal: ProposalNew, specification: DemandSpecification): Promise<ProposalNew> {
const decorationClone = structuredClone(specification.decoration);
decorationClone.properties["golem.com.payment.chosen-platform"] = specification.paymentPlatform;
Expand Down
4 changes: 2 additions & 2 deletions src/shared/yagna/yagna.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const mockIdentityModel = imock<IdentityApi.IdentityDTO>();

describe("Yagna Utils", () => {
describe("Yagna version support checking", () => {
describe("Positive cases - given min supported version is 0.13.2", () => {
it.each(["0.13.2", "0.15.0-rc5", "pre-rel-v0.15.0-rc5"])(
describe("Positive cases - given min supported version is 0.15.0", () => {
it.each(["0.15.0", "0.15.2", "0.15.3-rc5", "pre-rel-v0.15.3-rc5"])(
"should not throw when connect is called and the yagna version is %s",
async (version) => {
const mockVersionResponse = {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/yagna/yagnaApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type YagnaOptions = {
logger?: Logger;
};

export const MIN_SUPPORTED_YAGNA = "0.13.2";
export const MIN_SUPPORTED_YAGNA = "0.15.0";

// Workarounds for an issue with missing support for discriminators
// {@link https://github.com/ferdikoomen/openapi-typescript-codegen/issues/985}
Expand Down
2 changes: 1 addition & 1 deletion tests/docker/Provider.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG UBUNTU_VERSION=22.04
ARG YA_CORE_PROVIDER_VERSION=v0.12.3
ARG YA_CORE_PROVIDER_VERSION=v0.15.0
ARG YA_WASI_VERSION=v0.2.2
ARG YA_VM_VERSION=v0.3.0

Expand Down
2 changes: 1 addition & 1 deletion tests/docker/Requestor.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG UBUNTU_VERSION=22.04
ARG YA_CORE_REQUESTOR_VERSION=v0.12.3
ARG YA_CORE_REQUESTOR_VERSION=v0.15.0

FROM node:18.18.2
ARG YA_CORE_REQUESTOR_VERSION
Expand Down
20 changes: 9 additions & 11 deletions tests/docker/data-node/ya-provider/presets.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
{
"ver": "V1",
"active": ["wasmtime", "vm"],
"presets": [
{
"name": "default",
"exeunit-name": "wasmtime",
"pricing-model": "linear",
"usage-coeffs": {
"cpu": 0.100000001,
"duration": 0.0,
"initial": 0.0
}
"initial-price": 0.0,
"usage-coeffs": {}
},
{
"name": "vm",
"exeunit-name": "vm",
"pricing-model": "linear",
"initial-price": 0.0,
"usage-coeffs": {
"cpu": 0.100000001,
"duration": 0.0,
"initial": 0.0
"golem.usage.cpu_sec": 0.100000001,
"golem.usage.duration_sec": 0.0
}
},
{
"name": "wasmtime",
"exeunit-name": "wasmtime",
"pricing-model": "linear",
"initial-price": 0.0,
"usage-coeffs": {
"cpu": 0.100000001,
"duration": 0.0,
"initial": 0.0
"golem.usage.cpu_sec": 0.100000001,
"golem.usage.duration_sec": 0.0
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/activityPool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("ActivityPool", () => {
afterEach(async () => {
await proposalSubscription.unsubscribe();
await agreementPool.drainAndClear();
proposalPool.clear();
await proposalPool.clear();
});

it("should run a simple script on the activity from the pool", async () => {
Expand Down
Loading