@drift-labs/sdk-browser 2.155.0-beta.1 ā 2.155.0-beta.2
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/VERSION +1 -1
- package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +6 -8
- package/lib/browser/accounts/types.d.ts +4 -12
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.js +6 -8
- package/lib/node/accounts/types.d.ts +4 -12
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/scripts/grpc-client-test-comparison.ts +3 -2
- package/scripts/grpc-multiuser-client-test-comparison.ts +138 -140
- package/scripts/single-grpc-client-test.ts +21 -39
- package/src/accounts/laserProgramAccountSubscriber.ts +6 -9
- package/src/accounts/types.ts +4 -14
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.155.0-beta.
|
|
1
|
+
2.155.0-beta.2
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import {
|
|
3
|
+
import { GrpcConfigs, ResubOpts } from './types';
|
|
4
4
|
import { Program } from '@coral-xyz/anchor';
|
|
5
5
|
import { Context, MemcmpFilter, PublicKey } from '@solana/web3.js';
|
|
6
6
|
import { WebSocketProgramAccountSubscriber } from './webSocketProgramAccountSubscriber';
|
|
@@ -12,7 +12,7 @@ export declare class LaserstreamProgramAccountSubscriber<T> extends WebSocketPro
|
|
|
12
12
|
listenerId?: number;
|
|
13
13
|
private readonly laserConfig;
|
|
14
14
|
private constructor();
|
|
15
|
-
static create<U>(grpcConfigs:
|
|
15
|
+
static create<U>(grpcConfigs: GrpcConfigs, subscriptionName: string, accountDiscriminator: string, program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => U, options?: {
|
|
16
16
|
filters: MemcmpFilter[];
|
|
17
17
|
}, resubOpts?: ResubOpts): Promise<LaserstreamProgramAccountSubscriber<U>>;
|
|
18
18
|
subscribe(onChange: (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void): Promise<void>;
|
|
@@ -37,19 +37,17 @@ class LaserstreamProgramAccountSubscriber extends webSocketProgramAccountSubscri
|
|
|
37
37
|
static async create(grpcConfigs, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = {
|
|
38
38
|
filters: [],
|
|
39
39
|
}, resubOpts) {
|
|
40
|
-
var _a
|
|
41
|
-
const channelOptions = {
|
|
42
|
-
'grpc.default_compression_algorithm': grpc_1.CompressionAlgorithms.zstd,
|
|
43
|
-
'grpc.max_receive_message_length': 1000000000,
|
|
44
|
-
...((_a = grpcConfigs.channelOptions) !== null && _a !== void 0 ? _a : {}),
|
|
45
|
-
};
|
|
40
|
+
var _a;
|
|
46
41
|
const laserConfig = {
|
|
47
42
|
apiKey: grpcConfigs.token,
|
|
48
43
|
endpoint: grpcConfigs.endpoint,
|
|
49
44
|
maxReconnectAttempts: grpcConfigs.enableReconnect ? 10 : 0,
|
|
50
|
-
channelOptions
|
|
45
|
+
channelOptions: {
|
|
46
|
+
'grpc.default_compression_algorithm': grpc_1.CompressionAlgorithms.zstd,
|
|
47
|
+
'grpc.max_receive_message_length': 1000000000,
|
|
48
|
+
},
|
|
51
49
|
};
|
|
52
|
-
const commitmentLevel = (
|
|
50
|
+
const commitmentLevel = (_a = grpcConfigs.commitmentLevel) !== null && _a !== void 0 ? _a : grpc_1.CommitmentLevel.CONFIRMED;
|
|
53
51
|
return new LaserstreamProgramAccountSubscriber(laserConfig, commitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
|
|
54
52
|
}
|
|
55
53
|
async subscribe(onChange) {
|
|
@@ -8,7 +8,7 @@ import { Context, PublicKey } from '@solana/web3.js';
|
|
|
8
8
|
import { Account } from '@solana/spl-token';
|
|
9
9
|
import { OracleInfo, OraclePriceData } from '../oracles/types';
|
|
10
10
|
import { User } from '../user';
|
|
11
|
-
import {
|
|
11
|
+
import { ChannelOptions, CommitmentLevel } from '../isomorphic/grpc';
|
|
12
12
|
export interface AccountSubscriber<T> {
|
|
13
13
|
dataAndSlot?: DataAndSlot<T>;
|
|
14
14
|
subscribe(onChange: (data: T) => void): Promise<void>;
|
|
@@ -155,25 +155,18 @@ export interface UserStatsAccountSubscriber {
|
|
|
155
155
|
unsubscribe(): Promise<void>;
|
|
156
156
|
getUserStatsAccountAndSlot(): DataAndSlot<UserStatsAccount>;
|
|
157
157
|
}
|
|
158
|
-
type
|
|
158
|
+
export type GrpcConfigs = {
|
|
159
159
|
endpoint: string;
|
|
160
160
|
token: string;
|
|
161
161
|
commitmentLevel?: CommitmentLevel;
|
|
162
|
+
channelOptions?: ChannelOptions;
|
|
162
163
|
/**
|
|
163
164
|
* Whether to enable automatic reconnection on connection loss .
|
|
164
165
|
* Defaults to false, will throw on connection loss.
|
|
165
166
|
*/
|
|
166
167
|
enableReconnect?: boolean;
|
|
168
|
+
client?: 'yellowstone' | 'laser';
|
|
167
169
|
};
|
|
168
|
-
export type YellowstoneGrpcConfigs = BaseGrpcConfigs & {
|
|
169
|
-
client?: 'yellowstone';
|
|
170
|
-
channelOptions?: ConstructorParameters<typeof Client>[2];
|
|
171
|
-
};
|
|
172
|
-
export type LaserGrpcConfigs = BaseGrpcConfigs & {
|
|
173
|
-
client: 'laser';
|
|
174
|
-
channelOptions?: LaserstreamConfig['channelOptions'];
|
|
175
|
-
};
|
|
176
|
-
export type GrpcConfigs = YellowstoneGrpcConfigs | LaserGrpcConfigs;
|
|
177
170
|
export interface HighLeverageModeConfigAccountSubscriber {
|
|
178
171
|
eventEmitter: StrictEventEmitter<EventEmitter, HighLeverageModeConfigAccountEvents>;
|
|
179
172
|
isSubscribed: boolean;
|
|
@@ -199,4 +192,3 @@ export interface ConstituentAccountEvents {
|
|
|
199
192
|
update: void;
|
|
200
193
|
error: (e: Error) => void;
|
|
201
194
|
}
|
|
202
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import {
|
|
3
|
+
import { GrpcConfigs, ResubOpts } from './types';
|
|
4
4
|
import { Program } from '@coral-xyz/anchor';
|
|
5
5
|
import { Context, MemcmpFilter, PublicKey } from '@solana/web3.js';
|
|
6
6
|
import { WebSocketProgramAccountSubscriber } from './webSocketProgramAccountSubscriber';
|
|
@@ -12,7 +12,7 @@ export declare class LaserstreamProgramAccountSubscriber<T> extends WebSocketPro
|
|
|
12
12
|
listenerId?: number;
|
|
13
13
|
private readonly laserConfig;
|
|
14
14
|
private constructor();
|
|
15
|
-
static create<U>(grpcConfigs:
|
|
15
|
+
static create<U>(grpcConfigs: GrpcConfigs, subscriptionName: string, accountDiscriminator: string, program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => U, options?: {
|
|
16
16
|
filters: MemcmpFilter[];
|
|
17
17
|
}, resubOpts?: ResubOpts): Promise<LaserstreamProgramAccountSubscriber<U>>;
|
|
18
18
|
subscribe(onChange: (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"laserProgramAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/accounts/laserProgramAccountSubscriber.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"laserProgramAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/accounts/laserProgramAccountSubscriber.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,OAAO,EACN,oBAAoB,EAOpB,MAAM,oBAAoB,CAAC;AAE5B,KAAK,eAAe,GACnB,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;AAElE,qBAAa,mCAAmC,CAC/C,CAAC,CACA,SAAQ,iCAAiC,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,MAAM,CAMD;IAEb,OAAO,CAAC,eAAe,CAAkB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE3B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;IAEhD,OAAO;WAsBa,MAAM,CAAC,CAAC,EAC3B,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,MAAM,EACxB,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,CAAC,EACtD,OAAO,GAAE;QAAE,OAAO,EAAE,YAAY,EAAE,CAAA;KAEjC,EACD,SAAS,CAAC,EAAE,SAAS,GACnB,OAAO,CAAC,mCAAmC,CAAC,CAAC,CAAC,CAAC;IA0B5C,SAAS,CACd,QAAQ,EAAE,CACT,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,KACV,IAAI,GACP,OAAO,CAAC,IAAI,CAAC;IAmFH,WAAW,CAAC,OAAO,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBjD,iBAAiB,CACvB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAChC,eAAe;CASlB"}
|
|
@@ -37,19 +37,17 @@ class LaserstreamProgramAccountSubscriber extends webSocketProgramAccountSubscri
|
|
|
37
37
|
static async create(grpcConfigs, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = {
|
|
38
38
|
filters: [],
|
|
39
39
|
}, resubOpts) {
|
|
40
|
-
var _a
|
|
41
|
-
const channelOptions = {
|
|
42
|
-
'grpc.default_compression_algorithm': grpc_1.CompressionAlgorithms.zstd,
|
|
43
|
-
'grpc.max_receive_message_length': 1000000000,
|
|
44
|
-
...((_a = grpcConfigs.channelOptions) !== null && _a !== void 0 ? _a : {}),
|
|
45
|
-
};
|
|
40
|
+
var _a;
|
|
46
41
|
const laserConfig = {
|
|
47
42
|
apiKey: grpcConfigs.token,
|
|
48
43
|
endpoint: grpcConfigs.endpoint,
|
|
49
44
|
maxReconnectAttempts: grpcConfigs.enableReconnect ? 10 : 0,
|
|
50
|
-
channelOptions
|
|
45
|
+
channelOptions: {
|
|
46
|
+
'grpc.default_compression_algorithm': grpc_1.CompressionAlgorithms.zstd,
|
|
47
|
+
'grpc.max_receive_message_length': 1000000000,
|
|
48
|
+
},
|
|
51
49
|
};
|
|
52
|
-
const commitmentLevel = (
|
|
50
|
+
const commitmentLevel = (_a = grpcConfigs.commitmentLevel) !== null && _a !== void 0 ? _a : grpc_1.CommitmentLevel.CONFIRMED;
|
|
53
51
|
return new LaserstreamProgramAccountSubscriber(laserConfig, commitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
|
|
54
52
|
}
|
|
55
53
|
async subscribe(onChange) {
|
|
@@ -8,7 +8,7 @@ import { Context, PublicKey } from '@solana/web3.js';
|
|
|
8
8
|
import { Account } from '@solana/spl-token';
|
|
9
9
|
import { OracleInfo, OraclePriceData } from '../oracles/types';
|
|
10
10
|
import { User } from '../user';
|
|
11
|
-
import {
|
|
11
|
+
import { ChannelOptions, CommitmentLevel } from '../isomorphic/grpc';
|
|
12
12
|
export interface AccountSubscriber<T> {
|
|
13
13
|
dataAndSlot?: DataAndSlot<T>;
|
|
14
14
|
subscribe(onChange: (data: T) => void): Promise<void>;
|
|
@@ -155,25 +155,18 @@ export interface UserStatsAccountSubscriber {
|
|
|
155
155
|
unsubscribe(): Promise<void>;
|
|
156
156
|
getUserStatsAccountAndSlot(): DataAndSlot<UserStatsAccount>;
|
|
157
157
|
}
|
|
158
|
-
type
|
|
158
|
+
export type GrpcConfigs = {
|
|
159
159
|
endpoint: string;
|
|
160
160
|
token: string;
|
|
161
161
|
commitmentLevel?: CommitmentLevel;
|
|
162
|
+
channelOptions?: ChannelOptions;
|
|
162
163
|
/**
|
|
163
164
|
* Whether to enable automatic reconnection on connection loss .
|
|
164
165
|
* Defaults to false, will throw on connection loss.
|
|
165
166
|
*/
|
|
166
167
|
enableReconnect?: boolean;
|
|
168
|
+
client?: 'yellowstone' | 'laser';
|
|
167
169
|
};
|
|
168
|
-
export type YellowstoneGrpcConfigs = BaseGrpcConfigs & {
|
|
169
|
-
client?: 'yellowstone';
|
|
170
|
-
channelOptions?: ConstructorParameters<typeof Client>[2];
|
|
171
|
-
};
|
|
172
|
-
export type LaserGrpcConfigs = BaseGrpcConfigs & {
|
|
173
|
-
client: 'laser';
|
|
174
|
-
channelOptions?: LaserstreamConfig['channelOptions'];
|
|
175
|
-
};
|
|
176
|
-
export type GrpcConfigs = YellowstoneGrpcConfigs | LaserGrpcConfigs;
|
|
177
170
|
export interface HighLeverageModeConfigAccountSubscriber {
|
|
178
171
|
eventEmitter: StrictEventEmitter<EventEmitter, HighLeverageModeConfigAccountEvents>;
|
|
179
172
|
isSubscribed: boolean;
|
|
@@ -199,5 +192,4 @@ export interface ConstituentAccountEvents {
|
|
|
199
192
|
update: void;
|
|
200
193
|
error: (e: Error) => void;
|
|
201
194
|
}
|
|
202
|
-
export {};
|
|
203
195
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/accounts/types.ts"],"names":[],"mappings":";;;AAAA,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EACl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2
|
"name": "@drift-labs/sdk-browser",
|
|
3
|
-
"version": "2.155.0-beta.
|
|
3
|
+
"version": "2.155.0-beta.2",
|
|
4
4
|
"main": "lib/node/index.js",
|
|
5
5
|
"types": "lib/node/index.d.ts",
|
|
6
6
|
"module": "./lib/browser/index.js",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@solana/web3.js": "1.98.0",
|
|
57
57
|
"@switchboard-xyz/common": "3.0.14",
|
|
58
58
|
"@switchboard-xyz/on-demand": "2.4.1",
|
|
59
|
-
"@triton-one/yellowstone-grpc": "
|
|
59
|
+
"@triton-one/yellowstone-grpc": "1.4.1",
|
|
60
60
|
"anchor-bankrun": "0.3.0",
|
|
61
61
|
"gill": "^0.10.2",
|
|
62
62
|
"helius-laserstream": "0.1.8",
|
|
@@ -96,8 +96,9 @@ async function initializeGrpcDriftClientV2VersusV1() {
|
|
|
96
96
|
token: TOKEN,
|
|
97
97
|
commitmentLevel: CommitmentLevel.PROCESSED,
|
|
98
98
|
channelOptions: {
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
'grpc.keepalive_time_ms': 10_000,
|
|
100
|
+
'grpc.keepalive_timeout_ms': 1_000,
|
|
101
|
+
'grpc.keepalive_permit_without_calls': 1,
|
|
101
102
|
},
|
|
102
103
|
},
|
|
103
104
|
};
|
|
@@ -13,146 +13,144 @@ const TOKEN = process.env.TOKEN;
|
|
|
13
13
|
const RPC_ENDPOINT = process.env.RPC_ENDPOINT;
|
|
14
14
|
|
|
15
15
|
const USER_ACCOUNT_PUBKEYS = [
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// Add user account public keys here, e.g.:
|
|
17
|
+
// new PublicKey('...')
|
|
18
18
|
];
|
|
19
19
|
|
|
20
20
|
async function testGrpcUserAccountSubscriberV1VsV2() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
testGrpcUserAccountSubscriberV1VsV2().catch(console.error);
|
|
21
|
+
console.log('š Initializing User Account Subscriber V1 vs V2 Test...');
|
|
22
|
+
|
|
23
|
+
if (USER_ACCOUNT_PUBKEYS.length === 0) {
|
|
24
|
+
console.error('ā No user account public keys provided. Please add some to USER_ACCOUNT_PUBKEYS array.');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const connection = new Connection(RPC_ENDPOINT);
|
|
29
|
+
const wallet = new Wallet(new Keypair());
|
|
30
|
+
|
|
31
|
+
const programId = new PublicKey(DRIFT_PROGRAM_ID);
|
|
32
|
+
const provider = new AnchorProvider(
|
|
33
|
+
connection,
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
wallet,
|
|
36
|
+
{
|
|
37
|
+
commitment: 'processed',
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const program = new Program(driftIDL as Idl, programId, provider);
|
|
42
|
+
|
|
43
|
+
const grpcConfigs = {
|
|
44
|
+
endpoint: GRPC_ENDPOINT,
|
|
45
|
+
token: TOKEN,
|
|
46
|
+
commitmentLevel: CommitmentLevel.PROCESSED,
|
|
47
|
+
channelOptions: {
|
|
48
|
+
'grpc.keepalive_time_ms': 10_000,
|
|
49
|
+
'grpc.keepalive_timeout_ms': 1_000,
|
|
50
|
+
'grpc.keepalive_permit_without_calls': 1,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
console.log(`š Testing ${USER_ACCOUNT_PUBKEYS.length} user accounts...`);
|
|
55
|
+
|
|
56
|
+
// V1: Create individual subscribers for each user account
|
|
57
|
+
const v1Subscribers = USER_ACCOUNT_PUBKEYS.map(
|
|
58
|
+
(pubkey) =>
|
|
59
|
+
new grpcUserAccountSubscriber(
|
|
60
|
+
grpcConfigs,
|
|
61
|
+
program,
|
|
62
|
+
pubkey,
|
|
63
|
+
{ logResubMessages: true }
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// V2: Create a single multi-subscriber and get per-user interfaces
|
|
68
|
+
const v2MultiSubscriber = new grpcMultiUserAccountSubscriber(
|
|
69
|
+
program,
|
|
70
|
+
grpcConfigs,
|
|
71
|
+
{ logResubMessages: true }
|
|
72
|
+
);
|
|
73
|
+
const v2Subscribers = USER_ACCOUNT_PUBKEYS.map((pubkey) =>
|
|
74
|
+
v2MultiSubscriber.forUser(pubkey)
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// Subscribe all V1 subscribers
|
|
78
|
+
console.log('š Subscribing V1 subscribers...');
|
|
79
|
+
await Promise.all(v1Subscribers.map((sub) => sub.subscribe()));
|
|
80
|
+
console.log('ā
V1 subscribers ready');
|
|
81
|
+
|
|
82
|
+
// Subscribe all V2 subscribers
|
|
83
|
+
console.log('š Subscribing V2 subscribers...');
|
|
84
|
+
await v2MultiSubscriber.subscribe();
|
|
85
|
+
console.log('ā
V2 subscribers ready');
|
|
86
|
+
|
|
87
|
+
const compare = () => {
|
|
88
|
+
try {
|
|
89
|
+
let passedTests = 0;
|
|
90
|
+
let totalTests = 0;
|
|
91
|
+
|
|
92
|
+
// Test each user account
|
|
93
|
+
for (let i = 0; i < USER_ACCOUNT_PUBKEYS.length; i++) {
|
|
94
|
+
const pubkey = USER_ACCOUNT_PUBKEYS[i];
|
|
95
|
+
const v1Sub = v1Subscribers[i];
|
|
96
|
+
const v2Sub = v2Subscribers[i];
|
|
97
|
+
|
|
98
|
+
totalTests++;
|
|
99
|
+
|
|
100
|
+
// 1. Test isSubscribed
|
|
101
|
+
assert.strictEqual(
|
|
102
|
+
v1Sub.isSubscribed,
|
|
103
|
+
v2Sub.isSubscribed,
|
|
104
|
+
`User ${pubkey.toBase58()}: isSubscribed should match`
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
// 2. Test getUserAccountAndSlot
|
|
108
|
+
const v1Data = v1Sub.getUserAccountAndSlot();
|
|
109
|
+
const v2Data = v2Sub.getUserAccountAndSlot();
|
|
110
|
+
|
|
111
|
+
// Compare the user account data
|
|
112
|
+
assert.deepStrictEqual(
|
|
113
|
+
v1Data.data,
|
|
114
|
+
v2Data.data,
|
|
115
|
+
`User ${pubkey.toBase58()}: account data should match`
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// Slots might differ slightly due to timing, but let's check if they're close
|
|
119
|
+
const slotDiff = Math.abs(v1Data.slot - v2Data.slot);
|
|
120
|
+
if (slotDiff > 10) {
|
|
121
|
+
console.warn(
|
|
122
|
+
`ā ļø User ${pubkey.toBase58()}: slot difference is ${slotDiff} (v1: ${v1Data.slot}, v2: ${v2Data.slot})`
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
passedTests++;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
console.log(`ā
All comparisons passed (${passedTests}/${totalTests} user accounts)`);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
console.error('ā Comparison failed:', error);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// Run initial comparison
|
|
136
|
+
compare();
|
|
137
|
+
|
|
138
|
+
// Run comparison every second to verify live updates
|
|
139
|
+
const interval = setInterval(compare, 1000);
|
|
140
|
+
|
|
141
|
+
const cleanup = async () => {
|
|
142
|
+
clearInterval(interval);
|
|
143
|
+
console.log('š§¹ Cleaning up...');
|
|
144
|
+
await Promise.all([
|
|
145
|
+
...v1Subscribers.map((sub) => sub.unsubscribe()),
|
|
146
|
+
...v2Subscribers.map((sub) => sub.unsubscribe()),
|
|
147
|
+
]);
|
|
148
|
+
console.log('ā
Cleanup complete');
|
|
149
|
+
process.exit(0);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
process.on('SIGINT', cleanup);
|
|
153
|
+
process.on('SIGTERM', cleanup);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
testGrpcUserAccountSubscriberV1VsV2().catch(console.error);
|
|
@@ -94,18 +94,18 @@ async function initializeSingleGrpcClient() {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
console.log(
|
|
98
|
-
`š Markets: ${perpMarketIndexes.length} perp, ${spotMarketIndexes.length} spot`
|
|
99
|
-
);
|
|
97
|
+
console.log(`š Markets: ${perpMarketIndexes.length} perp, ${spotMarketIndexes.length} spot`);
|
|
100
98
|
console.log(`š® Oracles: ${oracleInfos.length}`);
|
|
101
99
|
|
|
100
|
+
|
|
102
101
|
const grpcConfigs = {
|
|
103
102
|
endpoint: GRPC_ENDPOINT,
|
|
104
103
|
token: TOKEN,
|
|
105
104
|
commitmentLevel: CommitmentLevel.PROCESSED,
|
|
106
105
|
channelOptions: {
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
'grpc.keepalive_time_ms': 10_000,
|
|
107
|
+
'grpc.keepalive_timeout_ms': 1_000,
|
|
108
|
+
'grpc.keepalive_permit_without_calls': 1,
|
|
109
109
|
},
|
|
110
110
|
};
|
|
111
111
|
|
|
@@ -171,9 +171,7 @@ async function initializeSingleGrpcClient() {
|
|
|
171
171
|
await client.subscribe();
|
|
172
172
|
|
|
173
173
|
console.log('ā
Client subscribed successfully!');
|
|
174
|
-
console.log(
|
|
175
|
-
'š Starting high-load testing (50 reads/sec per perp market)...'
|
|
176
|
-
);
|
|
174
|
+
console.log('š Starting high-load testing (50 reads/sec per perp market)...');
|
|
177
175
|
|
|
178
176
|
// High-frequency load testing - 50 reads per second per perp market
|
|
179
177
|
const loadTestInterval = setInterval(async () => {
|
|
@@ -181,35 +179,25 @@ async function initializeSingleGrpcClient() {
|
|
|
181
179
|
// Test getPerpMarketAccount for each perp market (50 times per second per market)
|
|
182
180
|
for (const marketIndex of perpMarketIndexes) {
|
|
183
181
|
const perpMarketAccount = client.getPerpMarketAccount(marketIndex);
|
|
184
|
-
console.log(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
marketIndex: perpMarketAccount.marketIndex,
|
|
192
|
-
name: decodeName(perpMarketAccount.name),
|
|
193
|
-
baseAssetReserve: perpMarketAccount.amm.baseAssetReserve.toString(),
|
|
194
|
-
quoteAssetReserve:
|
|
195
|
-
perpMarketAccount.amm.quoteAssetReserve.toString(),
|
|
196
|
-
})
|
|
197
|
-
);
|
|
182
|
+
console.log("perpMarketAccount name: ", decodeName(perpMarketAccount.name));
|
|
183
|
+
console.log("perpMarketAccount data: ", JSON.stringify({
|
|
184
|
+
marketIndex: perpMarketAccount.marketIndex,
|
|
185
|
+
name: decodeName(perpMarketAccount.name),
|
|
186
|
+
baseAssetReserve: perpMarketAccount.amm.baseAssetReserve.toString(),
|
|
187
|
+
quoteAssetReserve: perpMarketAccount.amm.quoteAssetReserve.toString()
|
|
188
|
+
}));
|
|
198
189
|
}
|
|
199
190
|
|
|
200
191
|
// Test getMMOracleDataForPerpMarket for each perp market (50 times per second per market)
|
|
201
192
|
for (const marketIndex of perpMarketIndexes) {
|
|
202
193
|
try {
|
|
203
194
|
const oracleData = client.getMMOracleDataForPerpMarket(marketIndex);
|
|
204
|
-
console.log(
|
|
205
|
-
console.log(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
slot: oracleData.slot?.toString(),
|
|
211
|
-
})
|
|
212
|
-
);
|
|
195
|
+
console.log("oracleData price: ", oracleData.price.toString());
|
|
196
|
+
console.log("oracleData: ", JSON.stringify({
|
|
197
|
+
price: oracleData.price.toString(),
|
|
198
|
+
confidence: oracleData.confidence?.toString(),
|
|
199
|
+
slot: oracleData.slot?.toString()
|
|
200
|
+
}));
|
|
213
201
|
} catch (error) {
|
|
214
202
|
// Ignore errors for load testing
|
|
215
203
|
}
|
|
@@ -223,14 +211,8 @@ async function initializeSingleGrpcClient() {
|
|
|
223
211
|
const statsInterval = setInterval(() => {
|
|
224
212
|
console.log('\nš Event Counts:', eventCounts);
|
|
225
213
|
console.log(`ā±ļø Client subscribed: ${client.isSubscribed}`);
|
|
226
|
-
console.log(
|
|
227
|
-
|
|
228
|
-
);
|
|
229
|
-
console.log(
|
|
230
|
-
`š„ Load: ${perpMarketIndexes.length * 50 * 2} reads/sec (${
|
|
231
|
-
perpMarketIndexes.length
|
|
232
|
-
} markets Ć 50 getPerpMarketAccount + 50 getMMOracleDataForPerpMarket)`
|
|
233
|
-
);
|
|
214
|
+
console.log(`š Account subscriber subscribed: ${client.accountSubscriber.isSubscribed}`);
|
|
215
|
+
console.log(`š„ Load: ${perpMarketIndexes.length * 50 * 2} reads/sec (${perpMarketIndexes.length} markets Ć 50 getPerpMarketAccount + 50 getMMOracleDataForPerpMarket)`);
|
|
234
216
|
}, 5000);
|
|
235
217
|
|
|
236
218
|
// Handle shutdown signals - just exit without cleanup since they never unsubscribe
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GrpcConfigs, ResubOpts } from './types';
|
|
2
2
|
import { Program } from '@coral-xyz/anchor';
|
|
3
3
|
import { Context, MemcmpFilter, PublicKey } from '@solana/web3.js';
|
|
4
4
|
import * as Buffer from 'buffer';
|
|
@@ -56,7 +56,7 @@ export class LaserstreamProgramAccountSubscriber<
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
public static async create<U>(
|
|
59
|
-
grpcConfigs:
|
|
59
|
+
grpcConfigs: GrpcConfigs,
|
|
60
60
|
subscriptionName: string,
|
|
61
61
|
accountDiscriminator: string,
|
|
62
62
|
program: Program,
|
|
@@ -66,17 +66,14 @@ export class LaserstreamProgramAccountSubscriber<
|
|
|
66
66
|
},
|
|
67
67
|
resubOpts?: ResubOpts
|
|
68
68
|
): Promise<LaserstreamProgramAccountSubscriber<U>> {
|
|
69
|
-
const channelOptions = {
|
|
70
|
-
'grpc.default_compression_algorithm': CompressionAlgorithms.zstd,
|
|
71
|
-
'grpc.max_receive_message_length': 1_000_000_000,
|
|
72
|
-
...(grpcConfigs.channelOptions ?? {}),
|
|
73
|
-
};
|
|
74
|
-
|
|
75
69
|
const laserConfig: LaserstreamConfig = {
|
|
76
70
|
apiKey: grpcConfigs.token,
|
|
77
71
|
endpoint: grpcConfigs.endpoint,
|
|
78
72
|
maxReconnectAttempts: grpcConfigs.enableReconnect ? 10 : 0,
|
|
79
|
-
channelOptions
|
|
73
|
+
channelOptions: {
|
|
74
|
+
'grpc.default_compression_algorithm': CompressionAlgorithms.zstd,
|
|
75
|
+
'grpc.max_receive_message_length': 1_000_000_000,
|
|
76
|
+
},
|
|
80
77
|
};
|
|
81
78
|
|
|
82
79
|
const commitmentLevel =
|
package/src/accounts/types.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { Context, PublicKey } from '@solana/web3.js';
|
|
|
15
15
|
import { Account } from '@solana/spl-token';
|
|
16
16
|
import { OracleInfo, OraclePriceData } from '../oracles/types';
|
|
17
17
|
import { User } from '../user';
|
|
18
|
-
import {
|
|
18
|
+
import { ChannelOptions, CommitmentLevel } from '../isomorphic/grpc';
|
|
19
19
|
|
|
20
20
|
export interface AccountSubscriber<T> {
|
|
21
21
|
dataAndSlot?: DataAndSlot<T>;
|
|
@@ -225,29 +225,19 @@ export interface UserStatsAccountSubscriber {
|
|
|
225
225
|
getUserStatsAccountAndSlot(): DataAndSlot<UserStatsAccount>;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
type
|
|
228
|
+
export type GrpcConfigs = {
|
|
229
229
|
endpoint: string;
|
|
230
230
|
token: string;
|
|
231
231
|
commitmentLevel?: CommitmentLevel;
|
|
232
|
+
channelOptions?: ChannelOptions;
|
|
232
233
|
/**
|
|
233
234
|
* Whether to enable automatic reconnection on connection loss .
|
|
234
235
|
* Defaults to false, will throw on connection loss.
|
|
235
236
|
*/
|
|
236
237
|
enableReconnect?: boolean;
|
|
238
|
+
client?: 'yellowstone' | 'laser';
|
|
237
239
|
};
|
|
238
240
|
|
|
239
|
-
export type YellowstoneGrpcConfigs = BaseGrpcConfigs & {
|
|
240
|
-
client?: 'yellowstone';
|
|
241
|
-
channelOptions?: ConstructorParameters<typeof Client>[2];
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
export type LaserGrpcConfigs = BaseGrpcConfigs & {
|
|
245
|
-
client: 'laser';
|
|
246
|
-
channelOptions?: LaserstreamConfig['channelOptions'];
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
export type GrpcConfigs = YellowstoneGrpcConfigs | LaserGrpcConfigs;
|
|
250
|
-
|
|
251
241
|
export interface HighLeverageModeConfigAccountSubscriber {
|
|
252
242
|
eventEmitter: StrictEventEmitter<
|
|
253
243
|
EventEmitter,
|