@nosana/node 1.1.57 → 1.1.58
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 +1 -1
- package/dist/src/NodeManager/node/market/hostManager.d.ts +2 -1
- package/dist/src/NodeManager/node/market/hostManager.js +7 -6
- package/dist/src/NodeManager/node/market/marketAccess.d.ts +6 -3
- package/dist/src/NodeManager/node/market/marketAccess.js +15 -44
- package/dist/src/NodeManager/node/market/marketHandler.js +3 -5
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
|
68
|
-
const { error } = await hostManagerClientSelector().POST("/nodes/
|
|
69
|
-
body: {
|
|
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
|
|
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
|
-
|
|
6
|
-
private
|
|
7
|
-
private confirmTransaction;
|
|
9
|
+
submitAccessKey(accessKeyTx: string): Promise<string>;
|
|
10
|
+
private signAsFeePayer;
|
|
8
11
|
}
|
|
@@ -1,53 +1,24 @@
|
|
|
1
|
-
import { VersionedTransaction
|
|
2
|
-
import {
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
16
|
+
return result.signature;
|
|
26
17
|
}
|
|
27
|
-
|
|
18
|
+
signAsFeePayer(txBase64) {
|
|
28
19
|
const feePayer = (this.sdk.solana.provider?.wallet).payer;
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
48
|
-
if (result.market?.
|
|
49
|
-
await this.marketAccessHandler.
|
|
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) {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nosana/node",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.58",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@nosana/node",
|
|
9
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.58",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@coral-xyz/anchor": "^0.28.1-beta.1",
|