@nosana/node 1.1.57 → 1.1.58-rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nosana/node",
3
- "version": "1.1.57",
3
+ "version": "1.1.58-rc",
4
4
  "description": "",
5
5
  "bin": {
6
6
  "nosana-node": "./dist/src/index.js"
@@ -7,6 +7,7 @@ export type NodeMetricsResponse = operations["getNodesByIdMetrics"]["responses"]
7
7
  type RequiredResourcesResponse = operations["getMarketsByIdRequired-resources"]["responses"][200]["content"]["application/json"];
8
8
  type HeartbeatResponse = operations["postNodesHeartbeat"]["responses"][200]["content"]["application/json"];
9
9
  type ErrorReportBody = operations["postErrorsReport"]["requestBody"]["content"]["application/json"];
10
+ type SubmitAccessKeyTxResponse = operations["postNodesAccess-keySubmit"]["responses"][200]["content"]["application/json"];
10
11
  export type FeedbackReport = NonNullable<RequestMarketResponse["feedbackReport"]>;
11
12
  export type RequestMarketResult = Pick<RequestMarketResponse, "status" | "market" | "feedbackReport"> & {
12
13
  notRegistered?: true;
@@ -74,7 +75,7 @@ export declare class HostManager {
74
75
  };
75
76
  };
76
77
  }, `${string}/${string}`>>;
77
- static syncNodeAfterMint(address: string): Promise<void>;
78
+ static submitAccessKeyTx(signedTx: string): Promise<SubmitAccessKeyTxResponse>;
78
79
  static getNode(address: string): Promise<GetNodeResponse | null>;
79
80
  static getNodeMetrics(address: string): Promise<NodeMetricsResponse | null>;
80
81
  static getMarketRequiredResources(marketId: string): Promise<RequiredResourcesResponse | null>;
@@ -43,7 +43,7 @@ export class HostManager {
43
43
  if (data.market) {
44
44
  result.market = {
45
45
  address: data.market.address,
46
- sftTx: data.market.sftTx ?? undefined,
46
+ accessKeyTx: data.market.accessKeyTx ?? undefined,
47
47
  };
48
48
  }
49
49
  if (data.nextTestAt) {
@@ -64,13 +64,14 @@ export class HostManager {
64
64
  }
65
65
  return data;
66
66
  }
67
- static async syncNodeAfterMint(address) {
68
- const { error } = await hostManagerClientSelector().POST("/nodes/sync-node", {
69
- body: { address },
67
+ static async submitAccessKeyTx(signedTx) {
68
+ const { data, error } = await hostManagerClientSelector().POST("/nodes/access-key/submit", {
69
+ body: { signedTx },
70
70
  });
71
- if (error) {
72
- throw new Error(`Error syncing node after mint: ${error}`);
71
+ if (error || !data) {
72
+ throw new Error(`Error submitting access key transaction: ${JSON.stringify(error)}`);
73
73
  }
74
+ return data;
74
75
  }
75
76
  static async getNode(address) {
76
77
  const { data, error, response } = await hostManagerClientSelector().GET("/nodes/{id}", {
@@ -1,8 +1,11 @@
1
1
  import { Client as SDK } from '@nosana/sdk';
2
+ /**
3
+ * The host-manager builds the access-key transaction, co-signs it with the
4
+ * mint authority and submits it. We only sign it as fee payer.
5
+ */
2
6
  export declare class MarketAccessHandler {
3
7
  private sdk;
4
8
  constructor(sdk: SDK);
5
- mintAccessKey(sftTxBase64: string): Promise<string>;
6
- private signAndSendTransaction;
7
- private confirmTransaction;
9
+ submitAccessKey(accessKeyTx: string): Promise<string>;
10
+ private signAsFeePayer;
8
11
  }
@@ -1,53 +1,24 @@
1
- import { VersionedTransaction, } from '@solana/web3.js';
2
- import { getRawTransaction } from '../../sdk/index.js';
1
+ import { VersionedTransaction } from '@solana/web3.js';
2
+ import { HostManager } from './hostManager.js';
3
+ /**
4
+ * The host-manager builds the access-key transaction, co-signs it with the
5
+ * mint authority and submits it. We only sign it as fee payer.
6
+ */
3
7
  export class MarketAccessHandler {
4
8
  constructor(sdk) {
5
9
  this.sdk = sdk;
6
10
  }
7
- async mintAccessKey(sftTxBase64) {
8
- // Incase of blockheight exceeded error, retry 3 times
9
- for (let i = 0; i < 3; i++) {
10
- try {
11
- const txnSignature = await this.signAndSendTransaction(sftTxBase64);
12
- await this.confirmTransaction(txnSignature);
13
- if (!txnSignature) {
14
- throw new Error("Transaction signature is undefined");
15
- }
16
- return txnSignature;
17
- }
18
- catch (error) {
19
- if (i === 2 ||
20
- !error?.message.includes("TransactionExpiredBlockheightExceededError")) {
21
- throw error;
22
- }
23
- }
11
+ async submitAccessKey(accessKeyTx) {
12
+ const result = await HostManager.submitAccessKeyTx(this.signAsFeePayer(accessKeyTx));
13
+ if (result.status !== 'confirmed' || !result.signature) {
14
+ throw new Error(`Access key transaction ${result.status}${result.reason ? `: ${result.reason}` : ''}`);
24
15
  }
25
- throw new Error("Failed to mint access key after 3 retries");
16
+ return result.signature;
26
17
  }
27
- async signAndSendTransaction(txData) {
18
+ signAsFeePayer(txBase64) {
28
19
  const feePayer = (this.sdk.solana.provider?.wallet).payer;
29
- const recoveredTransaction = await getRawTransaction(Buffer.from(txData, 'base64'));
30
- if (recoveredTransaction instanceof VersionedTransaction) {
31
- recoveredTransaction.sign([feePayer]);
32
- }
33
- else {
34
- recoveredTransaction.partialSign(feePayer);
35
- }
36
- const txnSignature = await this.sdk.solana.connection?.sendRawTransaction(recoveredTransaction.serialize());
37
- return txnSignature;
38
- }
39
- async confirmTransaction(txnSignature) {
40
- const latestBlockHash = await this.sdk.solana.connection?.getLatestBlockhash();
41
- if (latestBlockHash && txnSignature) {
42
- const confirmStrategy = {
43
- blockhash: latestBlockHash.blockhash,
44
- lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,
45
- signature: txnSignature,
46
- };
47
- await this.sdk.solana.connection?.confirmTransaction(confirmStrategy);
48
- }
49
- else {
50
- throw new Error("Could not confirm minting transaction");
51
- }
20
+ const transaction = VersionedTransaction.deserialize(Buffer.from(txBase64, 'base64'));
21
+ transaction.sign([feePayer]);
22
+ return Buffer.from(transaction.serialize()).toString('base64');
52
23
  }
53
24
  }
@@ -44,11 +44,9 @@ export class MarketHandler {
44
44
  // host issued so lifecycle metrics aren't re-requested on the retry.
45
45
  return await this.request(requestedMarket, result.session ?? session, benchmarkRetries);
46
46
  }
47
- // Sign and send SFT mint/burn transaction if provided
48
- if (result.market?.sftTx) {
49
- await this.marketAccessHandler.mintAccessKey(result.market.sftTx);
50
- await sleep(30);
51
- await HostManager.syncNodeAfterMint(this.address.toString());
47
+ // Sign as fee payer; the host-manager submits and confirms it.
48
+ if (result.market?.accessKeyTx) {
49
+ await this.marketAccessHandler.submitAccessKey(result.market.accessKeyTx);
52
50
  }
53
51
  await this.logLatestMeasurements();
54
52
  if (result.feedbackReport) {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@nosana/node",
3
- "version": "1.1.57",
3
+ "version": "1.1.58-rc",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@nosana/node",
9
- "version": "1.1.57",
9
+ "version": "1.1.58-rc",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "@coral-xyz/anchor": "^0.28.1-beta.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nosana/node",
3
- "version": "1.1.57",
3
+ "version": "1.1.58-rc",
4
4
  "description": "",
5
5
  "bin": {
6
6
  "nosana-node": "./dist/src/index.js"