@reclaimprotocol/attestor-core 5.0.4 → 5.0.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/lib/avs/client/create-claim-on-avs.d.ts +4 -4
- package/lib/avs/config.d.ts +1 -1
- package/lib/avs/types/index.d.ts +4 -4
- package/lib/avs/utils/contracts.d.ts +3 -3
- package/lib/avs/utils/register.d.ts +1 -1
- package/lib/avs/utils/tasks.d.ts +1 -1
- package/lib/client/create-claim.d.ts +2 -2
- package/lib/client/tunnels/make-rpc-tcp-tunnel.d.ts +2 -2
- package/lib/client/tunnels/make-rpc-tls-tunnel.d.ts +2 -2
- package/lib/client/utils/attestor-pool.d.ts +1 -1
- package/lib/client/utils/client-socket.d.ts +4 -4
- package/lib/client/utils/message-handler.d.ts +2 -2
- package/lib/config/index.d.ts +1 -1
- package/lib/external-rpc/handle-incoming-msg.d.ts +1 -1
- package/lib/external-rpc/index.js +25 -8
- package/lib/external-rpc/jsc-polyfills/1.d.ts +1 -1
- package/lib/external-rpc/jsc-polyfills/index.d.ts +2 -2
- package/lib/external-rpc/setup-browser.d.ts +1 -1
- package/lib/external-rpc/setup-jsc.d.ts +2 -2
- package/lib/external-rpc/types.d.ts +7 -7
- package/lib/external-rpc/utils.d.ts +2 -2
- package/lib/index.js +26 -9
- package/lib/mechain/client/create-claim-on-mechain.d.ts +3 -3
- package/lib/mechain/types/index.d.ts +2 -2
- package/lib/providers/http/index.d.ts +1 -1
- package/lib/providers/http/utils.d.ts +3 -3
- package/lib/providers/index.d.ts +1 -1
- package/lib/scripts/generate-receipt.d.ts +2 -2
- package/lib/scripts/jsc-cli-rpc.d.ts +1 -1
- package/lib/scripts/start-server.d.ts +1 -1
- package/lib/server/handlers/claimTeeBundle.d.ts +1 -1
- package/lib/server/handlers/claimTunnel.d.ts +1 -1
- package/lib/server/handlers/completeClaimOnChain.d.ts +1 -1
- package/lib/server/handlers/createClaimOnChain.d.ts +1 -1
- package/lib/server/handlers/createTaskOnMechain.d.ts +1 -1
- package/lib/server/handlers/createTunnel.d.ts +1 -1
- package/lib/server/handlers/disconnectTunnel.d.ts +1 -1
- package/lib/server/handlers/fetchCertificateBytes.d.ts +1 -1
- package/lib/server/handlers/index.d.ts +1 -1
- package/lib/server/handlers/init.d.ts +1 -1
- package/lib/server/handlers/toprf.d.ts +1 -1
- package/lib/server/socket.d.ts +4 -4
- package/lib/server/tunnels/make-tcp-tunnel.d.ts +3 -3
- package/lib/server/utils/assert-valid-claim-request.d.ts +4 -4
- package/lib/server/utils/gcp-attestation.d.ts +1 -1
- package/lib/server/utils/generics.d.ts +8 -2
- package/lib/server/utils/oprf-raw.d.ts +2 -2
- package/lib/server/utils/process-handshake.d.ts +2 -2
- package/lib/server/utils/tee-oprf-mpc-verification.d.ts +3 -3
- package/lib/server/utils/tee-oprf-verification.d.ts +3 -3
- package/lib/server/utils/tee-transcript-reconstruction.d.ts +3 -3
- package/lib/server/utils/tee-verification.d.ts +3 -3
- package/lib/server/utils/validation.d.ts +1 -1
- package/lib/types/claims.d.ts +6 -6
- package/lib/types/client.d.ts +5 -5
- package/lib/types/general.d.ts +1 -1
- package/lib/types/handlers.d.ts +3 -3
- package/lib/types/providers.d.ts +5 -5
- package/lib/types/rpc.d.ts +2 -2
- package/lib/types/tunnel.d.ts +1 -1
- package/lib/types/zk.d.ts +1 -1
- package/lib/utils/auth.d.ts +2 -2
- package/lib/utils/bgp-listener.d.ts +1 -1
- package/lib/utils/claims.d.ts +3 -3
- package/lib/utils/error.d.ts +1 -1
- package/lib/utils/generics.d.ts +2 -2
- package/lib/utils/http-parser.d.ts +1 -1
- package/lib/utils/logger.d.ts +1 -1
- package/lib/utils/prepare-packets.d.ts +2 -2
- package/lib/utils/redactions.d.ts +1 -1
- package/lib/utils/retries.d.ts +1 -1
- package/lib/utils/signatures/eth.d.ts +1 -1
- package/lib/utils/signatures/index.d.ts +2 -2
- package/lib/utils/socket-base.d.ts +3 -3
- package/lib/utils/zk.d.ts +4 -4
- package/package.json +4 -3
- package/lib/avs/abis/avsDirectoryABI.js +0 -340
- package/lib/avs/abis/delegationABI.js +0 -1
- package/lib/avs/abis/registryABI.js +0 -725
- package/lib/avs/client/create-claim-on-avs.js +0 -138
- package/lib/avs/config.js +0 -20
- package/lib/avs/contracts/ReclaimServiceManager.js +0 -1
- package/lib/avs/contracts/common.js +0 -1
- package/lib/avs/contracts/factories/ReclaimServiceManager__factory.js +0 -1169
- package/lib/avs/contracts/factories/index.js +0 -4
- package/lib/avs/contracts/index.js +0 -2
- package/lib/avs/types/index.js +0 -1
- package/lib/avs/utils/contracts.js +0 -33
- package/lib/avs/utils/register.js +0 -78
- package/lib/avs/utils/tasks.js +0 -40
- package/lib/client/create-claim.js +0 -433
- package/lib/client/index.js +0 -3
- package/lib/client/tunnels/make-rpc-tcp-tunnel.js +0 -51
- package/lib/client/tunnels/make-rpc-tls-tunnel.js +0 -131
- package/lib/client/utils/attestor-pool.js +0 -25
- package/lib/client/utils/client-socket.js +0 -98
- package/lib/client/utils/message-handler.js +0 -87
- package/lib/config/index.js +0 -44
- package/lib/external-rpc/benchmark.js +0 -69
- package/lib/external-rpc/event-bus.js +0 -14
- package/lib/external-rpc/handle-incoming-msg.js +0 -233
- package/lib/external-rpc/jsc-polyfills/1.js +0 -82
- package/lib/external-rpc/jsc-polyfills/2.js +0 -20
- package/lib/external-rpc/jsc-polyfills/event.js +0 -14
- package/lib/external-rpc/jsc-polyfills/index.js +0 -2
- package/lib/external-rpc/jsc-polyfills/ws.js +0 -81
- package/lib/external-rpc/setup-browser.js +0 -33
- package/lib/external-rpc/setup-jsc.js +0 -22
- package/lib/external-rpc/types.js +0 -1
- package/lib/external-rpc/utils.js +0 -100
- package/lib/external-rpc/zk.js +0 -63
- package/lib/mechain/abis/governanceABI.js +0 -458
- package/lib/mechain/abis/taskABI.js +0 -509
- package/lib/mechain/client/create-claim-on-mechain.js +0 -28
- package/lib/mechain/client/index.js +0 -1
- package/lib/mechain/constants/index.js +0 -3
- package/lib/mechain/index.js +0 -2
- package/lib/mechain/types/index.js +0 -1
- package/lib/proto/api.js +0 -4273
- package/lib/proto/tee-bundle.js +0 -1316
- package/lib/providers/http/index.js +0 -658
- package/lib/providers/http/patch-parse5-tree.js +0 -33
- package/lib/providers/http/utils.js +0 -324
- package/lib/providers/index.js +0 -4
- package/lib/scripts/fetch-ec2-metadata.d.ts +0 -1
- package/lib/server/create-server.js +0 -103
- package/lib/server/handlers/claimTeeBundle.js +0 -252
- package/lib/server/handlers/claimTunnel.js +0 -73
- package/lib/server/handlers/completeClaimOnChain.js +0 -22
- package/lib/server/handlers/createClaimOnChain.js +0 -26
- package/lib/server/handlers/createTaskOnMechain.js +0 -47
- package/lib/server/handlers/createTunnel.js +0 -93
- package/lib/server/handlers/disconnectTunnel.js +0 -5
- package/lib/server/handlers/fetchCertificateBytes.js +0 -41
- package/lib/server/handlers/index.js +0 -22
- package/lib/server/handlers/init.js +0 -32
- package/lib/server/handlers/toprf.js +0 -16
- package/lib/server/index.js +0 -4
- package/lib/server/socket.js +0 -109
- package/lib/server/tunnels/make-tcp-tunnel.js +0 -177
- package/lib/server/utils/apm.js +0 -36
- package/lib/server/utils/assert-valid-claim-request.js +0 -204
- package/lib/server/utils/config-env.js +0 -4
- package/lib/server/utils/dns.js +0 -18
- package/lib/server/utils/gcp-attestation.js +0 -289
- package/lib/server/utils/generics.js +0 -51
- package/lib/server/utils/iso.js +0 -256
- package/lib/server/utils/keep-alive.js +0 -38
- package/lib/server/utils/nitro-attestation.js +0 -325
- package/lib/server/utils/process-handshake.js +0 -215
- package/lib/server/utils/proxy-session.js +0 -6
- package/lib/server/utils/tee-oprf-mpc-verification.js +0 -90
- package/lib/server/utils/tee-oprf-verification.js +0 -174
- package/lib/server/utils/tee-transcript-reconstruction.js +0 -187
- package/lib/server/utils/tee-verification.js +0 -421
- package/lib/server/utils/validation.js +0 -38
- package/lib/types/bgp.js +0 -1
- package/lib/types/claims.js +0 -1
- package/lib/types/client.js +0 -1
- package/lib/types/general.js +0 -1
- package/lib/types/handlers.js +0 -1
- package/lib/types/index.js +0 -10
- package/lib/types/providers.gen.js +0 -10
- package/lib/types/providers.js +0 -1
- package/lib/types/rpc.js +0 -1
- package/lib/types/signatures.js +0 -1
- package/lib/types/tunnel.js +0 -1
- package/lib/types/zk.js +0 -1
- package/lib/utils/auth.js +0 -59
- package/lib/utils/b64-json.js +0 -17
- package/lib/utils/bgp-listener.js +0 -119
- package/lib/utils/claims.js +0 -99
- package/lib/utils/env.js +0 -15
- package/lib/utils/error.js +0 -50
- package/lib/utils/generics.js +0 -317
- package/lib/utils/http-parser.js +0 -246
- package/lib/utils/index.js +0 -13
- package/lib/utils/logger.js +0 -91
- package/lib/utils/prepare-packets.js +0 -62
- package/lib/utils/redactions.js +0 -148
- package/lib/utils/retries.js +0 -24
- package/lib/utils/signatures/eth.js +0 -29
- package/lib/utils/signatures/index.js +0 -7
- package/lib/utils/socket-base.js +0 -90
- package/lib/utils/tls.js +0 -58
- package/lib/utils/ws.js +0 -22
- package/lib/utils/zk.js +0 -577
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { ethers, Wallet } from 'ethers';
|
|
2
|
-
import { CHAIN_CONFIGS, SELECTED_CHAIN_ID } from "../config.js";
|
|
3
|
-
import { initialiseContracts } from "../utils/contracts.js";
|
|
4
|
-
import { createNewClaimRequestOnChain, signClaimRequest } from "../utils/tasks.js";
|
|
5
|
-
import { createClaimOnAttestor as _createClaimOnAttestor, getAttestorClientFromPool } from "../../client/index.js";
|
|
6
|
-
import { AttestorError, canonicalStringify, getIdentifierFromClaimInfo, logger as LOGGER, unixTimestampSeconds } from "../../utils/index.js";
|
|
7
|
-
const EMPTY_CLAIM_USER_ID = ethers.utils.hexlify(new Uint8Array(32));
|
|
8
|
-
/**
|
|
9
|
-
* Creates a Reclaim claim on the AVS chain.
|
|
10
|
-
*/
|
|
11
|
-
export async function createClaimOnAvs({ onStep, createClaimOnAttestor = _createClaimOnAttestor, chainId = SELECTED_CHAIN_ID, payer, ...opts }) {
|
|
12
|
-
const { logger = LOGGER, ownerPrivateKey, name, params, context, } = opts;
|
|
13
|
-
const { contract, wallet } = initialiseContracts(CHAIN_CONFIGS[chainId], ownerPrivateKey);
|
|
14
|
-
logger.info({ owner: wallet.address, contract: contract.address }, 'creating claim');
|
|
15
|
-
const arg = await requestClaimCreation();
|
|
16
|
-
logger.info({
|
|
17
|
-
index: arg.taskIndex,
|
|
18
|
-
operators: arg.task.operators.length,
|
|
19
|
-
}, 'task created, collecting claim signatures...');
|
|
20
|
-
onStep?.({ type: 'taskCreated', data: arg });
|
|
21
|
-
const responses = [];
|
|
22
|
-
const timestampS = +arg.task.createdAt.toString();
|
|
23
|
-
for (const op of arg.task.operators) {
|
|
24
|
-
const res = await createClaimOnAttestor({
|
|
25
|
-
...opts,
|
|
26
|
-
client: { url: op.url },
|
|
27
|
-
timestampS,
|
|
28
|
-
onStep: (step) => (onStep?.({
|
|
29
|
-
type: 'attestorStep',
|
|
30
|
-
data: {
|
|
31
|
-
operatorAddress: op.addr,
|
|
32
|
-
step,
|
|
33
|
-
},
|
|
34
|
-
})),
|
|
35
|
-
logger: logger.child({ operator: op.addr }),
|
|
36
|
-
});
|
|
37
|
-
const signature = res.signatures?.claimSignature;
|
|
38
|
-
if (!signature) {
|
|
39
|
-
throw new Error('INTERNAL: Claim signature not generated');
|
|
40
|
-
}
|
|
41
|
-
const diff = getClaimRequestDifference(res.request?.data, res.claim);
|
|
42
|
-
if (diff) {
|
|
43
|
-
throw new AttestorError('ERROR_INVALID_CLAIM', `Claim request does not match the claim res data: ${diff}`, {
|
|
44
|
-
diff,
|
|
45
|
-
request: res.request?.data?.[diff],
|
|
46
|
-
claim: res.claim?.[diff]
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
responses.push(res);
|
|
50
|
-
logger.info({ operator: op.addr }, 'signature generated');
|
|
51
|
-
onStep?.({
|
|
52
|
-
type: 'attestorDone',
|
|
53
|
-
data: {
|
|
54
|
-
task: arg,
|
|
55
|
-
responsesDone: responses,
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
const rslt = await completeTask();
|
|
60
|
-
logger.info({ tx: rslt.txHash, task: arg.taskIndex }, 'claim submitted & validated');
|
|
61
|
-
return { ...rslt, claimData: responses[0].claim };
|
|
62
|
-
async function requestClaimCreation() {
|
|
63
|
-
const request = {
|
|
64
|
-
provider: name,
|
|
65
|
-
// blank for now -- till we figure out the right
|
|
66
|
-
// algorithm for this
|
|
67
|
-
claimUserId: EMPTY_CLAIM_USER_ID,
|
|
68
|
-
claimHash: getIdentifierFromClaimInfo({
|
|
69
|
-
provider: name,
|
|
70
|
-
parameters: canonicalStringify(params),
|
|
71
|
-
context: context
|
|
72
|
-
? canonicalStringify(context)
|
|
73
|
-
: '',
|
|
74
|
-
}),
|
|
75
|
-
owner: wallet.address,
|
|
76
|
-
requestedAt: unixTimestampSeconds()
|
|
77
|
-
};
|
|
78
|
-
if (!payer) {
|
|
79
|
-
const wallet = new Wallet(ownerPrivateKey, contract.provider);
|
|
80
|
-
const { task } = await createNewClaimRequestOnChain({
|
|
81
|
-
request,
|
|
82
|
-
payer: wallet,
|
|
83
|
-
owner: wallet,
|
|
84
|
-
chainId
|
|
85
|
-
});
|
|
86
|
-
return task;
|
|
87
|
-
}
|
|
88
|
-
const requestSignature = await signClaimRequest(request, wallet, chainId);
|
|
89
|
-
const client = getAttestorClientFromPool(payer.attestor);
|
|
90
|
-
await client.waitForInit();
|
|
91
|
-
const rslt = await client.rpc('createClaimOnChain', {
|
|
92
|
-
chainId: +chainId,
|
|
93
|
-
jsonCreateClaimRequest: JSON.stringify(request),
|
|
94
|
-
requestSignature
|
|
95
|
-
});
|
|
96
|
-
return JSON.parse(rslt.jsonTask);
|
|
97
|
-
}
|
|
98
|
-
async function completeTask() {
|
|
99
|
-
const data = {
|
|
100
|
-
task: arg.task,
|
|
101
|
-
signatures: responses
|
|
102
|
-
.map(res => (ethers.utils.hexlify(res.signatures?.claimSignature))),
|
|
103
|
-
};
|
|
104
|
-
if (!payer) {
|
|
105
|
-
const tx = await contract.taskCompleted(data, arg.taskIndex);
|
|
106
|
-
const rslt = await tx.wait();
|
|
107
|
-
// check task created event was emitted
|
|
108
|
-
const ev = rslt.events?.[0];
|
|
109
|
-
return {
|
|
110
|
-
object: ev?.args,
|
|
111
|
-
txHash: rslt.transactionHash
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
const client = getAttestorClientFromPool(payer.attestor);
|
|
115
|
-
await client.waitForInit();
|
|
116
|
-
const rslt = await client.rpc('completeClaimOnChain', {
|
|
117
|
-
chainId: +chainId,
|
|
118
|
-
taskIndex: arg.taskIndex,
|
|
119
|
-
completedTaskJson: JSON.stringify(data)
|
|
120
|
-
});
|
|
121
|
-
const object = JSON.parse(rslt.taskCompletedObjectJson);
|
|
122
|
-
return { object, txHash: rslt.txHash };
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function getClaimRequestDifference(a, b) {
|
|
126
|
-
if (a.provider !== b.provider) {
|
|
127
|
-
return 'provider';
|
|
128
|
-
}
|
|
129
|
-
if (a.context !== b.context) {
|
|
130
|
-
return 'context';
|
|
131
|
-
}
|
|
132
|
-
if (a.parameters !== b.parameters) {
|
|
133
|
-
return 'parameters';
|
|
134
|
-
}
|
|
135
|
-
if (a.timestampS !== b.timestampS) {
|
|
136
|
-
return 'timestampS';
|
|
137
|
-
}
|
|
138
|
-
}
|
package/lib/avs/config.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { getEnvVariable } from "../utils/env.js";
|
|
2
|
-
export const CHAIN_CONFIGS = {
|
|
3
|
-
'31337': {
|
|
4
|
-
rpcUrl: 'http://localhost:8545',
|
|
5
|
-
contractAddress: '0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB',
|
|
6
|
-
delegationManagerAddress: '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9',
|
|
7
|
-
stakeRegistryAddress: '0x9E545E3C0baAB3E08CdfD552C960A1050f373042',
|
|
8
|
-
avsDirectoryAddress: '0x5FC8d32690cc91D4c39d9d3abcBD16989F875707'
|
|
9
|
-
},
|
|
10
|
-
'17000': {
|
|
11
|
-
rpcUrl: getEnvVariable('RPC_URL') || 'https://rpc.holesky.ethpandaops.io',
|
|
12
|
-
contractAddress: '0x0861afc305999bfD3028dB66145395BdD7299366',
|
|
13
|
-
delegationManagerAddress: '0xA44151489861Fe9e3055d95adC98FbD462B948e7',
|
|
14
|
-
stakeRegistryAddress: '0xDa11C9Da04Ab02C4AF9374B27A5E727944D3E1dD',
|
|
15
|
-
avsDirectoryAddress: '0x055733000064333CaDDbC92763c58BF0192fFeBf'
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
export const PRIVATE_KEY = getEnvVariable('PRIVATE_KEY');
|
|
19
|
-
export const SELECTED_CHAIN_ID = getEnvVariable('CHAIN_ID');
|
|
20
|
-
export const RECLAIM_PUBLIC_URL = getEnvVariable('RECLAIM_PUBLIC_URL');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|