@arcium-hq/client 0.6.4 → 0.6.6
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/README.md +1 -1
- package/build/index.cjs +317 -80
- package/build/index.d.ts +265 -68
- package/build/index.mjs +316 -82
- package/package.json +1 -1
package/build/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { Program, EventManager } from '@coral-xyz/anchor';
|
|
|
8
8
|
import { randomBytes as randomBytes$1 } from '@noble/hashes/utils';
|
|
9
9
|
import { twistedEdwards } from '@noble/curves/abstract/edwards';
|
|
10
10
|
import fs from 'fs';
|
|
11
|
-
import { PublicKey } from '@solana/web3.js';
|
|
11
|
+
import { PublicKey, AddressLookupTableProgram } from '@solana/web3.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Scalar field prime modulus for Curve25519: 2^252 + 27742317777372353535851937790883648493
|
|
@@ -1790,7 +1790,7 @@ function createPacker(fields, typeName = 'Packer') {
|
|
|
1790
1790
|
var address = "Arcj82pX7HxYKLR92qvgZUAd7vGS1k4hQvAFcPATFdEQ";
|
|
1791
1791
|
var metadata = {
|
|
1792
1792
|
name: "arcium",
|
|
1793
|
-
version: "0.6.
|
|
1793
|
+
version: "0.6.6",
|
|
1794
1794
|
spec: "0.1.0",
|
|
1795
1795
|
description: "The Arcium program"
|
|
1796
1796
|
};
|
|
@@ -2885,6 +2885,107 @@ var instructions = [
|
|
|
2885
2885
|
}
|
|
2886
2886
|
]
|
|
2887
2887
|
},
|
|
2888
|
+
{
|
|
2889
|
+
name: "claim_node_fees",
|
|
2890
|
+
discriminator: [
|
|
2891
|
+
68,
|
|
2892
|
+
13,
|
|
2893
|
+
185,
|
|
2894
|
+
34,
|
|
2895
|
+
151,
|
|
2896
|
+
76,
|
|
2897
|
+
194,
|
|
2898
|
+
43
|
|
2899
|
+
],
|
|
2900
|
+
accounts: [
|
|
2901
|
+
{
|
|
2902
|
+
name: "node_authority",
|
|
2903
|
+
writable: true,
|
|
2904
|
+
signer: true
|
|
2905
|
+
},
|
|
2906
|
+
{
|
|
2907
|
+
name: "recipient",
|
|
2908
|
+
writable: true
|
|
2909
|
+
},
|
|
2910
|
+
{
|
|
2911
|
+
name: "cluster",
|
|
2912
|
+
writable: true,
|
|
2913
|
+
pda: {
|
|
2914
|
+
seeds: [
|
|
2915
|
+
{
|
|
2916
|
+
kind: "const",
|
|
2917
|
+
value: [
|
|
2918
|
+
67,
|
|
2919
|
+
108,
|
|
2920
|
+
117,
|
|
2921
|
+
115,
|
|
2922
|
+
116,
|
|
2923
|
+
101,
|
|
2924
|
+
114
|
|
2925
|
+
]
|
|
2926
|
+
},
|
|
2927
|
+
{
|
|
2928
|
+
kind: "arg",
|
|
2929
|
+
path: "cluster_offset"
|
|
2930
|
+
}
|
|
2931
|
+
]
|
|
2932
|
+
}
|
|
2933
|
+
},
|
|
2934
|
+
{
|
|
2935
|
+
name: "node",
|
|
2936
|
+
pda: {
|
|
2937
|
+
seeds: [
|
|
2938
|
+
{
|
|
2939
|
+
kind: "const",
|
|
2940
|
+
value: [
|
|
2941
|
+
65,
|
|
2942
|
+
114,
|
|
2943
|
+
120,
|
|
2944
|
+
78,
|
|
2945
|
+
111,
|
|
2946
|
+
100,
|
|
2947
|
+
101
|
|
2948
|
+
]
|
|
2949
|
+
},
|
|
2950
|
+
{
|
|
2951
|
+
kind: "arg",
|
|
2952
|
+
path: "node_offset"
|
|
2953
|
+
}
|
|
2954
|
+
]
|
|
2955
|
+
}
|
|
2956
|
+
},
|
|
2957
|
+
{
|
|
2958
|
+
name: "pool",
|
|
2959
|
+
writable: true,
|
|
2960
|
+
pda: {
|
|
2961
|
+
seeds: [
|
|
2962
|
+
{
|
|
2963
|
+
kind: "const",
|
|
2964
|
+
value: [
|
|
2965
|
+
70,
|
|
2966
|
+
101,
|
|
2967
|
+
101,
|
|
2968
|
+
80,
|
|
2969
|
+
111,
|
|
2970
|
+
111,
|
|
2971
|
+
108
|
|
2972
|
+
]
|
|
2973
|
+
}
|
|
2974
|
+
]
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
],
|
|
2978
|
+
args: [
|
|
2979
|
+
{
|
|
2980
|
+
name: "cluster_offset",
|
|
2981
|
+
type: "u32"
|
|
2982
|
+
},
|
|
2983
|
+
{
|
|
2984
|
+
name: "node_offset",
|
|
2985
|
+
type: "u32"
|
|
2986
|
+
}
|
|
2987
|
+
]
|
|
2988
|
+
},
|
|
2888
2989
|
{
|
|
2889
2990
|
name: "close_key_recovery",
|
|
2890
2991
|
docs: [
|
|
@@ -3945,6 +4046,29 @@ var instructions = [
|
|
|
3945
4046
|
]
|
|
3946
4047
|
}
|
|
3947
4048
|
},
|
|
4049
|
+
{
|
|
4050
|
+
name: "cluster_acc",
|
|
4051
|
+
pda: {
|
|
4052
|
+
seeds: [
|
|
4053
|
+
{
|
|
4054
|
+
kind: "const",
|
|
4055
|
+
value: [
|
|
4056
|
+
67,
|
|
4057
|
+
108,
|
|
4058
|
+
117,
|
|
4059
|
+
115,
|
|
4060
|
+
116,
|
|
4061
|
+
101,
|
|
4062
|
+
114
|
|
4063
|
+
]
|
|
4064
|
+
},
|
|
4065
|
+
{
|
|
4066
|
+
kind: "arg",
|
|
4067
|
+
path: "cluster_offset"
|
|
4068
|
+
}
|
|
4069
|
+
]
|
|
4070
|
+
}
|
|
4071
|
+
},
|
|
3948
4072
|
{
|
|
3949
4073
|
name: "executing_pool",
|
|
3950
4074
|
writable: true,
|
|
@@ -4033,6 +4157,17 @@ var instructions = [
|
|
|
4033
4157
|
{
|
|
4034
4158
|
name: "callback_transaction_index",
|
|
4035
4159
|
type: "u8"
|
|
4160
|
+
},
|
|
4161
|
+
{
|
|
4162
|
+
name: "bls_sig",
|
|
4163
|
+
type: {
|
|
4164
|
+
option: {
|
|
4165
|
+
array: [
|
|
4166
|
+
"u8",
|
|
4167
|
+
64
|
|
4168
|
+
]
|
|
4169
|
+
}
|
|
4170
|
+
}
|
|
4036
4171
|
}
|
|
4037
4172
|
]
|
|
4038
4173
|
},
|
|
@@ -5124,6 +5259,17 @@ var instructions = [
|
|
|
5124
5259
|
]
|
|
5125
5260
|
}
|
|
5126
5261
|
},
|
|
5262
|
+
{
|
|
5263
|
+
name: "address_lookup_table",
|
|
5264
|
+
docs: [
|
|
5265
|
+
"Seeds are checked in the CPI to LUT program, so no need to check them here."
|
|
5266
|
+
],
|
|
5267
|
+
writable: true
|
|
5268
|
+
},
|
|
5269
|
+
{
|
|
5270
|
+
name: "lut_program",
|
|
5271
|
+
address: "AddressLookupTab1e1111111111111111111111111"
|
|
5272
|
+
},
|
|
5127
5273
|
{
|
|
5128
5274
|
name: "comp_def_acc",
|
|
5129
5275
|
writable: true,
|
|
@@ -5238,6 +5384,11 @@ var instructions = [
|
|
|
5238
5384
|
224
|
|
5239
5385
|
],
|
|
5240
5386
|
accounts: [
|
|
5387
|
+
{
|
|
5388
|
+
name: "authority",
|
|
5389
|
+
writable: true,
|
|
5390
|
+
signer: true
|
|
5391
|
+
},
|
|
5241
5392
|
{
|
|
5242
5393
|
name: "payer",
|
|
5243
5394
|
writable: true,
|
|
@@ -6035,6 +6186,17 @@ var instructions = [
|
|
|
6035
6186
|
]
|
|
6036
6187
|
}
|
|
6037
6188
|
},
|
|
6189
|
+
{
|
|
6190
|
+
name: "address_lookup_table",
|
|
6191
|
+
docs: [
|
|
6192
|
+
"Seeds are checked in the CPI to LUT program, so no need to check them here."
|
|
6193
|
+
],
|
|
6194
|
+
writable: true
|
|
6195
|
+
},
|
|
6196
|
+
{
|
|
6197
|
+
name: "lut_program",
|
|
6198
|
+
address: "AddressLookupTab1e1111111111111111111111111"
|
|
6199
|
+
},
|
|
6038
6200
|
{
|
|
6039
6201
|
name: "clock",
|
|
6040
6202
|
writable: true,
|
|
@@ -7017,12 +7179,6 @@ var instructions = [
|
|
|
7017
7179
|
name: "mxe_program",
|
|
7018
7180
|
type: "pubkey"
|
|
7019
7181
|
},
|
|
7020
|
-
{
|
|
7021
|
-
name: "callback_url",
|
|
7022
|
-
type: {
|
|
7023
|
-
option: "string"
|
|
7024
|
-
}
|
|
7025
|
-
},
|
|
7026
7182
|
{
|
|
7027
7183
|
name: "custom_callback_instructions",
|
|
7028
7184
|
type: {
|
|
@@ -7413,16 +7569,16 @@ var instructions = [
|
|
|
7413
7569
|
]
|
|
7414
7570
|
},
|
|
7415
7571
|
{
|
|
7416
|
-
name: "
|
|
7572
|
+
name: "reclaim_failure_rent_idempotent",
|
|
7417
7573
|
discriminator: [
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7574
|
+
138,
|
|
7575
|
+
13,
|
|
7576
|
+
253,
|
|
7577
|
+
191,
|
|
7578
|
+
226,
|
|
7579
|
+
239,
|
|
7580
|
+
246,
|
|
7581
|
+
10
|
|
7426
7582
|
],
|
|
7427
7583
|
accounts: [
|
|
7428
7584
|
{
|
|
@@ -7430,51 +7586,19 @@ var instructions = [
|
|
|
7430
7586
|
writable: true,
|
|
7431
7587
|
signer: true
|
|
7432
7588
|
},
|
|
7589
|
+
{
|
|
7590
|
+
name: "recipient",
|
|
7591
|
+
docs: [
|
|
7592
|
+
"failure PDA"
|
|
7593
|
+
],
|
|
7594
|
+
writable: true
|
|
7595
|
+
},
|
|
7433
7596
|
{
|
|
7434
7597
|
name: "failure_acc",
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
kind: "const",
|
|
7440
|
-
value: [
|
|
7441
|
-
70,
|
|
7442
|
-
97,
|
|
7443
|
-
105,
|
|
7444
|
-
108,
|
|
7445
|
-
117,
|
|
7446
|
-
114,
|
|
7447
|
-
101,
|
|
7448
|
-
67,
|
|
7449
|
-
108,
|
|
7450
|
-
97,
|
|
7451
|
-
105,
|
|
7452
|
-
109,
|
|
7453
|
-
65,
|
|
7454
|
-
99,
|
|
7455
|
-
99,
|
|
7456
|
-
111,
|
|
7457
|
-
117,
|
|
7458
|
-
110,
|
|
7459
|
-
116,
|
|
7460
|
-
72,
|
|
7461
|
-
101,
|
|
7462
|
-
97,
|
|
7463
|
-
100,
|
|
7464
|
-
101,
|
|
7465
|
-
114
|
|
7466
|
-
]
|
|
7467
|
-
},
|
|
7468
|
-
{
|
|
7469
|
-
kind: "arg",
|
|
7470
|
-
path: "mxe_program"
|
|
7471
|
-
},
|
|
7472
|
-
{
|
|
7473
|
-
kind: "arg",
|
|
7474
|
-
path: "comp_offset"
|
|
7475
|
-
}
|
|
7476
|
-
]
|
|
7477
|
-
}
|
|
7598
|
+
docs: [
|
|
7599
|
+
"the checks and close by hand in the instruction handler."
|
|
7600
|
+
],
|
|
7601
|
+
writable: true
|
|
7478
7602
|
}
|
|
7479
7603
|
],
|
|
7480
7604
|
args: [
|
|
@@ -9571,6 +9695,19 @@ var events = [
|
|
|
9571
9695
|
186
|
|
9572
9696
|
]
|
|
9573
9697
|
},
|
|
9698
|
+
{
|
|
9699
|
+
name: "KeyRecoveryEvent",
|
|
9700
|
+
discriminator: [
|
|
9701
|
+
83,
|
|
9702
|
+
147,
|
|
9703
|
+
226,
|
|
9704
|
+
153,
|
|
9705
|
+
39,
|
|
9706
|
+
242,
|
|
9707
|
+
109,
|
|
9708
|
+
254
|
|
9709
|
+
]
|
|
9710
|
+
},
|
|
9574
9711
|
{
|
|
9575
9712
|
name: "QueueComputationEvent",
|
|
9576
9713
|
discriminator: [
|
|
@@ -9711,6 +9848,11 @@ var errors = [
|
|
|
9711
9848
|
name: "InvalidCallbackIndex",
|
|
9712
9849
|
msg: "Invalid callback transaction index"
|
|
9713
9850
|
},
|
|
9851
|
+
{
|
|
9852
|
+
code: 6212,
|
|
9853
|
+
name: "MultiTxCallbacksDisabled",
|
|
9854
|
+
msg: "Multi-transaction callbacks disabled"
|
|
9855
|
+
},
|
|
9714
9856
|
{
|
|
9715
9857
|
code: 6300,
|
|
9716
9858
|
name: "ComputationDefinitionNotCompleted",
|
|
@@ -9941,6 +10083,16 @@ var errors = [
|
|
|
9941
10083
|
name: "MustNotBeCalledViaCpi",
|
|
9942
10084
|
msg: "This instruction must be called directly, not via CPI"
|
|
9943
10085
|
},
|
|
10086
|
+
{
|
|
10087
|
+
code: 6621,
|
|
10088
|
+
name: "FeePriceExceedsMax",
|
|
10089
|
+
msg: "Fee price exceeds maximum allowed"
|
|
10090
|
+
},
|
|
10091
|
+
{
|
|
10092
|
+
code: 6622,
|
|
10093
|
+
name: "NoFeesToClaim",
|
|
10094
|
+
msg: "No fees available to claim"
|
|
10095
|
+
},
|
|
9944
10096
|
{
|
|
9945
10097
|
code: 6700,
|
|
9946
10098
|
name: "MxeNotInRecoveryState",
|
|
@@ -10023,8 +10175,8 @@ var errors = [
|
|
|
10023
10175
|
},
|
|
10024
10176
|
{
|
|
10025
10177
|
code: 6716,
|
|
10026
|
-
name: "
|
|
10027
|
-
msg: "
|
|
10178
|
+
name: "MxeInRecoveryState",
|
|
10179
|
+
msg: "MXE is in recovery state, cannot queue new computations"
|
|
10028
10180
|
}
|
|
10029
10181
|
];
|
|
10030
10182
|
var types = [
|
|
@@ -10867,12 +11019,6 @@ var types = [
|
|
|
10867
11019
|
}
|
|
10868
11020
|
}
|
|
10869
11021
|
},
|
|
10870
|
-
{
|
|
10871
|
-
name: "callback_url",
|
|
10872
|
-
type: {
|
|
10873
|
-
option: "string"
|
|
10874
|
-
}
|
|
10875
|
-
},
|
|
10876
11022
|
{
|
|
10877
11023
|
name: "custom_callback_instructions",
|
|
10878
11024
|
type: {
|
|
@@ -11352,6 +11498,26 @@ var types = [
|
|
|
11352
11498
|
]
|
|
11353
11499
|
}
|
|
11354
11500
|
},
|
|
11501
|
+
{
|
|
11502
|
+
name: "KeyRecoveryEvent",
|
|
11503
|
+
type: {
|
|
11504
|
+
kind: "struct",
|
|
11505
|
+
fields: [
|
|
11506
|
+
{
|
|
11507
|
+
name: "computation_offset",
|
|
11508
|
+
type: "u64"
|
|
11509
|
+
},
|
|
11510
|
+
{
|
|
11511
|
+
name: "mxe_program_id",
|
|
11512
|
+
type: "pubkey"
|
|
11513
|
+
},
|
|
11514
|
+
{
|
|
11515
|
+
name: "backup_mxe_program_id",
|
|
11516
|
+
type: "pubkey"
|
|
11517
|
+
}
|
|
11518
|
+
]
|
|
11519
|
+
}
|
|
11520
|
+
},
|
|
11355
11521
|
{
|
|
11356
11522
|
name: "LargeExecPool",
|
|
11357
11523
|
serialization: "bytemuckunsafe",
|
|
@@ -12930,6 +13096,11 @@ const RECOVERY_CLUSTER_ACC_SEED = 'RecoveryClusterAccount';
|
|
|
12930
13096
|
* @constant {string}
|
|
12931
13097
|
*/
|
|
12932
13098
|
const MXE_RECOVERY_ACC_SEED = 'MxeRecoveryAccount';
|
|
13099
|
+
/**
|
|
13100
|
+
* Seed for ComputationDefinitionRaw PDA
|
|
13101
|
+
* @constant {string}
|
|
13102
|
+
*/
|
|
13103
|
+
const RAW_CIRCUIT_ACC_SEED = 'ComputationDefinitionRaw';
|
|
12933
13104
|
/**
|
|
12934
13105
|
* Maximum number of bytes that can be reallocated per instruction.
|
|
12935
13106
|
* @constant {number}
|
|
@@ -13089,6 +13260,32 @@ function getMxeRecoveryAccAddress(backupMxeProgramId, originalMxeProgramId) {
|
|
|
13089
13260
|
];
|
|
13090
13261
|
return generateArciumPDAFrom(seeds)[0];
|
|
13091
13262
|
}
|
|
13263
|
+
/**
|
|
13264
|
+
* Derives the raw circuit account address for a given computation definition and index.
|
|
13265
|
+
* @param compDefPubkey - The public key of the computation definition account.
|
|
13266
|
+
* @param rawCircuitIndex - The index of the raw circuit account (0-based).
|
|
13267
|
+
* @returns The derived raw circuit account public key.
|
|
13268
|
+
*/
|
|
13269
|
+
function getRawCircuitAccAddress(compDefPubkey, rawCircuitIndex) {
|
|
13270
|
+
const seeds = [
|
|
13271
|
+
Buffer.from(RAW_CIRCUIT_ACC_SEED),
|
|
13272
|
+
compDefPubkey.toBuffer(),
|
|
13273
|
+
Buffer.from([rawCircuitIndex]),
|
|
13274
|
+
];
|
|
13275
|
+
return generateArciumPDAFrom(seeds)[0];
|
|
13276
|
+
}
|
|
13277
|
+
/**
|
|
13278
|
+
* Derives the address lookup table address for an MXE program.
|
|
13279
|
+
* @param mxeProgramId - The public key of the MXE program.
|
|
13280
|
+
* @param lutIndex - The index of the lookup table (defaults to 0).
|
|
13281
|
+
* @returns The derived address lookup table public key.
|
|
13282
|
+
*/
|
|
13283
|
+
function getLookupTableAddress(mxeProgramId, lutIndex = 0) {
|
|
13284
|
+
const mxeAccount = getMXEAccAddress(mxeProgramId);
|
|
13285
|
+
const lutIndexBuffer = new anchor.BN(lutIndex).toArrayLike(Buffer, 'le', 8);
|
|
13286
|
+
const seeds = [mxeAccount.toBuffer(), lutIndexBuffer];
|
|
13287
|
+
return PublicKey.findProgramAddressSync(seeds, AddressLookupTableProgram.programId)[0];
|
|
13288
|
+
}
|
|
13092
13289
|
/**
|
|
13093
13290
|
* Generates a program-derived address (PDA) from the provided seeds and the Arcium program ID.
|
|
13094
13291
|
* @param seeds - An array of Buffer seeds used for PDA derivation.
|
|
@@ -13341,6 +13538,21 @@ async function getMXEPublicKey(provider, mxeProgramId) {
|
|
|
13341
13538
|
async function getMXEArcisEd25519VerifyingKey(provider, mxeProgramId) {
|
|
13342
13539
|
return getMXEUtilityKey(provider, mxeProgramId, 'ed25519VerifyingKey');
|
|
13343
13540
|
}
|
|
13541
|
+
/**
|
|
13542
|
+
* Determines the current state of a circuit based on its on-chain configuration.
|
|
13543
|
+
* @internal Called internally by `uploadCircuit` - most users don't need this directly.
|
|
13544
|
+
* @param circuitSource - The circuitSource field from ComputationDefinitionAccount.
|
|
13545
|
+
* @returns The current state of the circuit.
|
|
13546
|
+
*/
|
|
13547
|
+
function getCircuitState(circuitSource) {
|
|
13548
|
+
if (!('onChain' in circuitSource) || !circuitSource.onChain) {
|
|
13549
|
+
return 'Offchain';
|
|
13550
|
+
}
|
|
13551
|
+
if (circuitSource.onChain[0].isCompleted) {
|
|
13552
|
+
return 'OnchainFinalized';
|
|
13553
|
+
}
|
|
13554
|
+
return 'OnchainPending';
|
|
13555
|
+
}
|
|
13344
13556
|
/**
|
|
13345
13557
|
* Uploads a circuit to the blockchain, splitting it into multiple accounts if necessary.
|
|
13346
13558
|
* @param provider - The Anchor provider to use for transactions.
|
|
@@ -13352,10 +13564,17 @@ async function getMXEArcisEd25519VerifyingKey(provider, mxeProgramId) {
|
|
|
13352
13564
|
* @returns An array of transaction signatures for all upload and finalize transactions.
|
|
13353
13565
|
*/
|
|
13354
13566
|
async function uploadCircuit(provider, circuitName, mxeProgramId, rawCircuit, logging = true, chunkSize = 500) {
|
|
13355
|
-
// 9 = 8-byte discriminator + 1-byte bump for ComputationDefinitionRaw account
|
|
13356
|
-
const numAccs = Math.ceil(rawCircuit.length / (MAX_ACCOUNT_SIZE - 9));
|
|
13357
13567
|
const compDefAccInfo = getCompDefAccInfo(circuitName, mxeProgramId);
|
|
13358
13568
|
const program = getArciumProgram(provider);
|
|
13569
|
+
const compDefAcc = await program.account.computationDefinitionAccount.fetch(compDefAccInfo.pubkey);
|
|
13570
|
+
// Type assertion at boundary where Anchor's fetch() returns the account data
|
|
13571
|
+
const state = getCircuitState(compDefAcc.circuitSource);
|
|
13572
|
+
if (state !== 'OnchainPending') {
|
|
13573
|
+
optionalLog(logging, `Circuit ${circuitName} skipped: ${state}`);
|
|
13574
|
+
return [];
|
|
13575
|
+
}
|
|
13576
|
+
// 9 = 8-byte discriminator + 1-byte bump for ComputationDefinitionRaw account
|
|
13577
|
+
const numAccs = Math.ceil(rawCircuit.length / (MAX_ACCOUNT_SIZE - 9));
|
|
13359
13578
|
const sigs = [];
|
|
13360
13579
|
const uploadPromises = [];
|
|
13361
13580
|
for (let i = 0; i < numAccs; i++) {
|
|
@@ -13398,15 +13617,26 @@ async function buildFinalizeCompDefTx(provider, compDefOffset, mxeProgramId) {
|
|
|
13398
13617
|
.transaction();
|
|
13399
13618
|
}
|
|
13400
13619
|
async function uploadToCircuitAcc(provider, program, rawCircuitPart, rawCircuitIndex, compDefAccInfo, mxeProgramId, shouldLog = true, chunkSize = 500) {
|
|
13620
|
+
const rawCircuitPda = getRawCircuitAccAddress(compDefAccInfo.pubkey, rawCircuitIndex);
|
|
13621
|
+
const existingAcc = await provider.connection.getAccountInfo(rawCircuitPda);
|
|
13622
|
+
// Skip entirely if account exists with correct size (pre-seeded at genesis or already uploaded)
|
|
13623
|
+
// Account layout: 8-byte discriminator + 1-byte bump + circuit data
|
|
13624
|
+
const requiredAccountSize = rawCircuitPart.length + 9;
|
|
13625
|
+
if (existingAcc !== null && existingAcc.data.length >= requiredAccountSize) {
|
|
13626
|
+
optionalLog(shouldLog, `Raw circuit acc ${rawCircuitIndex} already exists with sufficient size, skipping`);
|
|
13627
|
+
return [];
|
|
13628
|
+
}
|
|
13401
13629
|
const sigs = [];
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13630
|
+
if (existingAcc === null) {
|
|
13631
|
+
const initTx = await program.methods
|
|
13632
|
+
.initRawCircuitAcc(compDefAccInfo.offset, mxeProgramId, rawCircuitIndex)
|
|
13633
|
+
.accounts({
|
|
13634
|
+
signer: provider.publicKey,
|
|
13635
|
+
})
|
|
13636
|
+
.rpc();
|
|
13637
|
+
optionalLog(shouldLog, `Initiated raw circuit acc with raw circuit index ${rawCircuitIndex}`);
|
|
13638
|
+
sigs.push(initTx);
|
|
13639
|
+
}
|
|
13410
13640
|
if (rawCircuitPart.length > MAX_REALLOC_PER_IX) {
|
|
13411
13641
|
// We only need to add size if the init didn't already make us big enough
|
|
13412
13642
|
const nonAsyncTxCount = Math.ceil(rawCircuitPart.length / (MAX_REALLOC_PER_IX * MAX_EMBIGGEN_IX_PER_TX));
|
|
@@ -13431,8 +13661,10 @@ async function uploadToCircuitAcc(provider, program, rawCircuitPart, rawCircuitI
|
|
|
13431
13661
|
const blockInfo = await provider.connection.getLatestBlockhash();
|
|
13432
13662
|
for (let i = 0; i < remainingTxCount; i += chunkSize) {
|
|
13433
13663
|
optionalLog(shouldLog, `Sending chunk ${i / chunkSize + 1} of ${Math.ceil(remainingTxCount / chunkSize)}`);
|
|
13434
|
-
|
|
13435
|
-
const
|
|
13664
|
+
// Array to hold promises for the current chunk
|
|
13665
|
+
const chunkPromises = [];
|
|
13666
|
+
// Handle the last chunk
|
|
13667
|
+
const currentChunkSize = Math.min(chunkSize, remainingTxCount - i);
|
|
13436
13668
|
for (let j = 0; j < currentChunkSize; j++) {
|
|
13437
13669
|
const offset = MAX_UPLOAD_PER_TX_BYTES * (i + j);
|
|
13438
13670
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -13442,7 +13674,8 @@ async function uploadToCircuitAcc(provider, program, rawCircuitPart, rawCircuitI
|
|
|
13442
13674
|
// Wait for the current chunk to complete before proceeding
|
|
13443
13675
|
// eslint-disable-next-line no-await-in-loop
|
|
13444
13676
|
const chunkResults = await Promise.all(chunkPromises);
|
|
13445
|
-
|
|
13677
|
+
// Add the results of the current chunk to the main array
|
|
13678
|
+
remainingTxs.push(...chunkResults);
|
|
13446
13679
|
optionalLog(shouldLog, `Done sending chunk ${i / chunkSize + 1} of ${Math.ceil(remainingTxCount / chunkSize)}`);
|
|
13447
13680
|
}
|
|
13448
13681
|
return sigs.concat(remainingTxs);
|
|
@@ -13692,6 +13925,7 @@ async function initMxePart2(provider, clusterOffset, mxeProgramId, recoveryPeers
|
|
|
13692
13925
|
mxeProgram: mxeProgramId,
|
|
13693
13926
|
poolAccount: getFeePoolAccAddress(),
|
|
13694
13927
|
mxeAuthority: mxeAuthority ?? provider.publicKey,
|
|
13928
|
+
addressLookupTable: getLookupTableAddress(mxeProgramId),
|
|
13695
13929
|
})
|
|
13696
13930
|
.transaction();
|
|
13697
13931
|
return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: 'confirmed' }));
|
|
@@ -13755,4 +13989,4 @@ async function awaitEvent(eventListener, eventName, eventCheck, commitment = 'co
|
|
|
13755
13989
|
return { event: foundEvent[0], sig: foundEvent[1] };
|
|
13756
13990
|
}
|
|
13757
13991
|
|
|
13758
|
-
export { ARCIUM_ADDR, ARCIUM_IDL, Aes128Cipher, Aes192Cipher, Aes256Cipher, ArcisModule, ArcisType, ArcisValueField, CSplRescueCipher, CURVE25519_BASE_FIELD, CURVE25519_SCALAR_FIELD, CURVE25519_SCALAR_FIELD_MODULUS, IntegerInfo, Matrix, RescueCipher, RescueDesc, RescuePrimeHash, arcisEd25519, awaitComputationFinalization, buildFinalizeCompDefTx, createPacker, deserializeLE, finalizeKeyRecoveryExecution, generateRandomFieldElem, getArciumAccountBaseSeed, getArciumEnv, getArciumProgram, getArciumProgramId, getArxNodeAccAddress, getClockAccAddress, getClusterAccAddress, getCompDefAccAddress, getCompDefAccOffset, getComputationAccAddress, getComputationsInMempool, getExecutingPoolAccAddress, getExecutingPoolAccInfo, getFeePoolAccAddress, getMXEAccAddress, getMXEArcisEd25519VerifyingKey, getMXEPublicKey, getMempoolAccAddress, getMempoolAccInfo, getMempoolPriorityFeeStats, getMxeRecoveryAccAddress, getRecoveryClusterAccAddress, initKeyRecoveryExecution, initMxePart1, initMxePart2, isNullRef, positiveModulo, queueKeyRecoveryInit, randMatrix, recoverMxe, serializeLE, sha256, submitKeyRecoveryShare, toVec, uploadCircuit };
|
|
13992
|
+
export { ARCIUM_ADDR, ARCIUM_IDL, Aes128Cipher, Aes192Cipher, Aes256Cipher, ArcisModule, ArcisType, ArcisValueField, CSplRescueCipher, CURVE25519_BASE_FIELD, CURVE25519_SCALAR_FIELD, CURVE25519_SCALAR_FIELD_MODULUS, IntegerInfo, Matrix, RescueCipher, RescueDesc, RescuePrimeHash, arcisEd25519, awaitComputationFinalization, buildFinalizeCompDefTx, createPacker, deserializeLE, finalizeKeyRecoveryExecution, generateRandomFieldElem, getArciumAccountBaseSeed, getArciumEnv, getArciumProgram, getArciumProgramId, getArxNodeAccAddress, getCircuitState, getClockAccAddress, getClusterAccAddress, getCompDefAccAddress, getCompDefAccOffset, getComputationAccAddress, getComputationsInMempool, getExecutingPoolAccAddress, getExecutingPoolAccInfo, getFeePoolAccAddress, getLookupTableAddress, getMXEAccAddress, getMXEArcisEd25519VerifyingKey, getMXEPublicKey, getMempoolAccAddress, getMempoolAccInfo, getMempoolPriorityFeeStats, getMxeRecoveryAccAddress, getRawCircuitAccAddress, getRecoveryClusterAccAddress, initKeyRecoveryExecution, initMxePart1, initMxePart2, isNullRef, positiveModulo, queueKeyRecoveryInit, randMatrix, recoverMxe, serializeLE, sha256, submitKeyRecoveryShare, toVec, uploadCircuit };
|