@aztec/prover-node 0.76.1 → 0.76.3

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.
Files changed (76) hide show
  1. package/dest/config.d.ts +1 -7
  2. package/dest/config.d.ts.map +1 -1
  3. package/dest/config.js +2 -23
  4. package/dest/factory.d.ts.map +1 -1
  5. package/dest/factory.js +3 -32
  6. package/dest/job/epoch-proving-job.d.ts +1 -0
  7. package/dest/job/epoch-proving-job.d.ts.map +1 -1
  8. package/dest/job/epoch-proving-job.js +4 -1
  9. package/dest/monitors/epoch-monitor.d.ts +0 -1
  10. package/dest/monitors/epoch-monitor.d.ts.map +1 -1
  11. package/dest/monitors/epoch-monitor.js +2 -2
  12. package/dest/monitors/index.d.ts +0 -1
  13. package/dest/monitors/index.d.ts.map +1 -1
  14. package/dest/monitors/index.js +1 -2
  15. package/dest/prover-node-publisher.d.ts +0 -7
  16. package/dest/prover-node-publisher.d.ts.map +1 -1
  17. package/dest/prover-node-publisher.js +9 -10
  18. package/dest/prover-node.d.ts +12 -26
  19. package/dest/prover-node.d.ts.map +1 -1
  20. package/dest/prover-node.js +24 -89
  21. package/package.json +20 -20
  22. package/src/config.ts +1 -37
  23. package/src/factory.ts +2 -40
  24. package/src/job/epoch-proving-job.ts +4 -0
  25. package/src/monitors/epoch-monitor.ts +1 -2
  26. package/src/monitors/index.ts +0 -1
  27. package/src/prover-node-publisher.ts +8 -10
  28. package/src/prover-node.ts +29 -106
  29. package/dest/bond/bond-manager.d.ts +0 -22
  30. package/dest/bond/bond-manager.d.ts.map +0 -1
  31. package/dest/bond/bond-manager.js +0 -42
  32. package/dest/bond/config.d.ts +0 -8
  33. package/dest/bond/config.d.ts.map +0 -1
  34. package/dest/bond/config.js +0 -17
  35. package/dest/bond/escrow-contract.d.ts +0 -19
  36. package/dest/bond/escrow-contract.d.ts.map +0 -1
  37. package/dest/bond/escrow-contract.js +0 -32
  38. package/dest/bond/factory.d.ts +0 -6
  39. package/dest/bond/factory.d.ts.map +0 -1
  40. package/dest/bond/factory.js +0 -17
  41. package/dest/bond/index.d.ts +0 -3
  42. package/dest/bond/index.d.ts.map +0 -1
  43. package/dest/bond/index.js +0 -3
  44. package/dest/bond/token-contract.d.ts +0 -26
  45. package/dest/bond/token-contract.d.ts.map +0 -1
  46. package/dest/bond/token-contract.js +0 -58
  47. package/dest/monitors/claims-monitor.d.ts +0 -24
  48. package/dest/monitors/claims-monitor.d.ts.map +0 -1
  49. package/dest/monitors/claims-monitor.js +0 -54
  50. package/dest/quote-provider/http.d.ts +0 -15
  51. package/dest/quote-provider/http.d.ts.map +0 -1
  52. package/dest/quote-provider/http.js +0 -33
  53. package/dest/quote-provider/index.d.ts +0 -6
  54. package/dest/quote-provider/index.d.ts.map +0 -1
  55. package/dest/quote-provider/index.js +0 -2
  56. package/dest/quote-provider/simple.d.ts +0 -9
  57. package/dest/quote-provider/simple.d.ts.map +0 -1
  58. package/dest/quote-provider/simple.js +0 -11
  59. package/dest/quote-provider/utils.d.ts +0 -4
  60. package/dest/quote-provider/utils.d.ts.map +0 -1
  61. package/dest/quote-provider/utils.js +0 -8
  62. package/dest/quote-signer.d.ts +0 -13
  63. package/dest/quote-signer.d.ts.map +0 -1
  64. package/dest/quote-signer.js +0 -18
  65. package/src/bond/bond-manager.ts +0 -48
  66. package/src/bond/config.ts +0 -25
  67. package/src/bond/escrow-contract.ts +0 -50
  68. package/src/bond/factory.ts +0 -28
  69. package/src/bond/index.ts +0 -2
  70. package/src/bond/token-contract.ts +0 -72
  71. package/src/monitors/claims-monitor.ts +0 -69
  72. package/src/quote-provider/http.ts +0 -48
  73. package/src/quote-provider/index.ts +0 -8
  74. package/src/quote-provider/simple.ts +0 -15
  75. package/src/quote-provider/utils.ts +0 -10
  76. package/src/quote-signer.ts +0 -24
@@ -1,33 +0,0 @@
1
- import { jsonStringify } from '@aztec/foundation/json-rpc';
2
- import { getTotalFees, getTxCount } from './utils.js';
3
- export class HttpQuoteProvider {
4
- constructor(url) {
5
- this.url = url;
6
- }
7
- async getQuote(epochNumber, epoch) {
8
- const payload = {
9
- epochNumber,
10
- fromBlock: epoch[0].number,
11
- toBlock: epoch.at(-1).number,
12
- totalFees: getTotalFees(epoch).toString(),
13
- txCount: getTxCount(epoch),
14
- };
15
- const response = await fetch(this.url, {
16
- method: 'POST',
17
- body: jsonStringify(payload),
18
- headers: { 'content-type': 'application/json' },
19
- });
20
- if (!response.ok) {
21
- throw new Error(`Failed to fetch quote: ${response.statusText}`);
22
- }
23
- const data = await response.json();
24
- if (!data.basisPointFee || !data.bondAmount) {
25
- throw new Error(`Missing required fields (basisPointFee | bondAmount) in response: ${jsonStringify(data)}`);
26
- }
27
- const basisPointFee = Number(data.basisPointFee);
28
- const bondAmount = BigInt(data.bondAmount);
29
- const validUntilSlot = data.validUntilSlot ? BigInt(data.validUntilSlot) : undefined;
30
- return { basisPointFee, bondAmount, validUntilSlot };
31
- }
32
- }
33
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHR0cC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9xdW90ZS1wcm92aWRlci9odHRwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUczRCxPQUFPLEVBQUUsWUFBWSxFQUFFLFVBQVUsRUFBRSxNQUFNLFlBQVksQ0FBQztBQUV0RCxNQUFNLE9BQU8saUJBQWlCO0lBQzVCLFlBQTZCLEdBQVc7UUFBWCxRQUFHLEdBQUgsR0FBRyxDQUFRO0lBQUcsQ0FBQztJQUVyQyxLQUFLLENBQUMsUUFBUSxDQUFDLFdBQW1CLEVBQUUsS0FBZ0I7UUFDekQsTUFBTSxPQUFPLEdBQTRCO1lBQ3ZDLFdBQVc7WUFDWCxTQUFTLEVBQUUsS0FBSyxDQUFDLENBQUMs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FJLENBQUMsY0FBYyxDQUFDLENBQUMsQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxTQUFTLENBQUM7UUFFckYsT0FBTyxFQUFFLGFBQWEsRUFBRSxVQUFVLEVBQUUsY0FBYyxFQUFFLENBQUM7SUFDdkQsQ0FBQztDQUNGIn0=
@@ -1,6 +0,0 @@
1
- import { type EpochProofQuotePayload, type L2Block } from '@aztec/circuit-types';
2
- export type QuoteProviderResult = Pick<EpochProofQuotePayload, 'basisPointFee' | 'bondAmount'> & Partial<Pick<EpochProofQuotePayload, 'validUntilSlot'>>;
3
- export interface QuoteProvider {
4
- getQuote(epochNumber: number, epoch: L2Block[]): Promise<QuoteProviderResult | undefined>;
5
- }
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/quote-provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,sBAAsB,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEjF,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,sBAAsB,EAAE,eAAe,GAAG,YAAY,CAAC,GAC5F,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAE1D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;CAC3F"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcXVvdGUtcHJvdmlkZXIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
@@ -1,9 +0,0 @@
1
- import { type EpochProofQuotePayload, type L2Block } from '@aztec/circuit-types';
2
- import { type QuoteProvider } from './index.js';
3
- export declare class SimpleQuoteProvider implements QuoteProvider {
4
- readonly basisPointFee: number;
5
- readonly bondAmount: bigint;
6
- constructor(basisPointFee: number, bondAmount: bigint);
7
- getQuote(_epochNumber: number, _epoch: L2Block[]): Promise<Pick<EpochProofQuotePayload, 'basisPointFee' | 'bondAmount'>>;
8
- }
9
- //# sourceMappingURL=simple.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"simple.d.ts","sourceRoot":"","sources":["../../src/quote-provider/simple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,sBAAsB,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEjF,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,qBAAa,mBAAoB,YAAW,aAAa;aAC3B,aAAa,EAAE,MAAM;aAAkB,UAAU,EAAE,MAAM;gBAAzD,aAAa,EAAE,MAAM,EAAkB,UAAU,EAAE,MAAM;IAErF,QAAQ,CACN,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,OAAO,EAAE,GAChB,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,eAAe,GAAG,YAAY,CAAC,CAAC;CAIzE"}
@@ -1,11 +0,0 @@
1
- export class SimpleQuoteProvider {
2
- constructor(basisPointFee, bondAmount) {
3
- this.basisPointFee = basisPointFee;
4
- this.bondAmount = bondAmount;
5
- }
6
- getQuote(_epochNumber, _epoch) {
7
- const { basisPointFee, bondAmount } = this;
8
- return Promise.resolve({ basisPointFee, bondAmount });
9
- }
10
- }
11
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2ltcGxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3F1b3RlLXByb3ZpZGVyL3NpbXBsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFJQSxNQUFNLE9BQU8sbUJBQW1CO0lBQzlCLFlBQTRCLGFBQXFCLEVBQWtCLFVBQWtCO1FBQXpELGtCQUFhLEdBQWIsYUFBYSxDQUFRO1FBQWtCLGVBQVUsR0FBVixVQUFVLENBQVE7SUFBRyxDQUFDO0lBRXpGLFFBQVEsQ0FDTixZQUFvQixFQUNwQixNQUFpQjtRQUVqQixNQUFNLEVBQUUsYUFBYSxFQUFFLFVBQVUsRUFBRSxHQUFHLElBQUksQ0FBQztRQUMzQyxPQUFPLE9BQU8sQ0FBQyxPQUFPLENBQUMsRUFBRSxhQUFhLEVBQUUsVUFBVSxFQUFFLENBQUMsQ0FBQztJQUN4RCxDQUFDO0NBQ0YifQ==
@@ -1,4 +0,0 @@
1
- import { type L2Block } from '@aztec/circuit-types';
2
- export declare function getTotalFees(epoch: L2Block[]): bigint;
3
- export declare function getTxCount(epoch: L2Block[]): number;
4
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/quote-provider/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGpD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,UAE5C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,UAE1C"}
@@ -1,8 +0,0 @@
1
- import { Fr } from '@aztec/circuits.js';
2
- export function getTotalFees(epoch) {
3
- return epoch.reduce((total, block) => total.add(block.header.totalFees), Fr.ZERO).toBigInt();
4
- }
5
- export function getTxCount(epoch) {
6
- return epoch.reduce((total, block) => total + block.body.txEffects.length, 0);
7
- }
8
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcXVvdGUtcHJvdmlkZXIvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXhDLE1BQU0sVUFBVSxZQUFZLENBQUMsS0FBZ0I7SUFDM0MsT0FBTyxLQUFLLENBQUMsTUFBTSxDQUFDLENBQUMsS0FBSyxFQUFFLEtBQUssRUFBRSxFQUFFLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLFNBQVMsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxJQUFJLENBQUMsQ0FBQyxRQUFRLEVBQUUsQ0FBQztBQUMvRixDQUFDO0FBRUQsTUFBTSxVQUFVLFVBQVUsQ0FBQyxLQUFnQjtJQUN6QyxPQUFPLEtBQUssQ0FBQyxNQUFNLENBQUMsQ0FBQyxLQUFLLEVBQUUsS0FBSyxFQUFFLEVBQUUsQ0FBQyxLQUFLLEdBQUcsS0FBSyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxFQUFFLENBQUMsQ0FBQyxDQUFDO0FBQ2hGLENBQUMifQ==
@@ -1,13 +0,0 @@
1
- import { EpochProofQuote, type EpochProofQuotePayload } from '@aztec/circuit-types';
2
- import { Buffer32 } from '@aztec/foundation/buffer';
3
- import { Secp256k1Signer } from '@aztec/foundation/crypto';
4
- import { type RollupAbi } from '@aztec/l1-artifacts';
5
- import { type GetContractReturnType, type PublicClient } from 'viem';
6
- export declare class QuoteSigner {
7
- private readonly signer;
8
- private readonly quoteToDigest;
9
- constructor(signer: Secp256k1Signer, quoteToDigest: (payload: EpochProofQuotePayload) => Promise<Buffer32>);
10
- static new(privateKey: Buffer32, rollupContract: GetContractReturnType<typeof RollupAbi, PublicClient>): QuoteSigner;
11
- sign(payload: EpochProofQuotePayload): Promise<EpochProofQuote>;
12
- }
13
- //# sourceMappingURL=quote-signer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"quote-signer.d.ts","sourceRoot":"","sources":["../src/quote-signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAErE,qBAAa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBADb,MAAM,EAAE,eAAe,EACvB,aAAa,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,OAAO,CAAC,QAAQ,CAAC;IAGxF,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,qBAAqB,CAAC,OAAO,SAAS,EAAE,YAAY,CAAC,GAAG,WAAW;IAMvG,IAAI,CAAC,OAAO,EAAE,sBAAsB;CAIlD"}
@@ -1,18 +0,0 @@
1
- import { EpochProofQuote } from '@aztec/circuit-types';
2
- import { Buffer32 } from '@aztec/foundation/buffer';
3
- import { Secp256k1Signer } from '@aztec/foundation/crypto';
4
- export class QuoteSigner {
5
- constructor(signer, quoteToDigest) {
6
- this.signer = signer;
7
- this.quoteToDigest = quoteToDigest;
8
- }
9
- static new(privateKey, rollupContract) {
10
- const quoteToDigest = (payload) => rollupContract.read.quoteToDigest([payload.toViemArgs()]).then(Buffer32.fromString);
11
- return new QuoteSigner(new Secp256k1Signer(privateKey), quoteToDigest);
12
- }
13
- async sign(payload) {
14
- const digest = await this.quoteToDigest(payload);
15
- return EpochProofQuote.new(digest, payload, this.signer);
16
- }
17
- }
18
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uI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QyxDQUFDO0lBQzNELENBQUM7Q0FDRiJ9
@@ -1,48 +0,0 @@
1
- import { createLogger } from '@aztec/foundation/log';
2
-
3
- import { type EscrowContract } from './escrow-contract.js';
4
- import { type TokenContract } from './token-contract.js';
5
-
6
- export class BondManager {
7
- private readonly logger = createLogger('prover-node:bond-manager');
8
-
9
- constructor(
10
- private readonly tokenContract: TokenContract,
11
- private readonly escrowContract: EscrowContract,
12
- /** Minimum escrowed bond. A top-up will be issued once this threshold is hit. */
13
- public minimumAmount: bigint,
14
- /** Target escrowed bond. Top-up will target this value. */
15
- public targetAmount: bigint,
16
- ) {}
17
-
18
- /**
19
- * Ensures the bond is at least minimumBond, or sends a tx to deposit the remaining to reach targetBond.
20
- * @param overrideMinimum - Override the minimum bond threshold. Also overrides target if it is higher.
21
- */
22
- public async ensureBond(overrideMinimum?: bigint) {
23
- const minimum = overrideMinimum ?? this.minimumAmount;
24
- const target = overrideMinimum && overrideMinimum > this.targetAmount ? overrideMinimum : this.targetAmount;
25
-
26
- try {
27
- const current = await this.escrowContract.getProverDeposit();
28
- if (current >= minimum) {
29
- this.logger.debug(`Current prover bond ${current} is above minimum ${minimum}`);
30
- return;
31
- }
32
-
33
- const topUpAmount = target - current;
34
- this.logger.verbose(`Prover bond top-up ${topUpAmount} required to get ${current} to target ${target}`);
35
-
36
- const balance = await this.tokenContract.getBalance();
37
- if (balance < topUpAmount) {
38
- throw new Error(`Not enough balance to top-up prover bond: ${balance} < ${topUpAmount}`);
39
- }
40
-
41
- await this.tokenContract.ensureAllowance(this.escrowContract.getEscrowAddress());
42
- await this.escrowContract.depositProverBond(topUpAmount);
43
- this.logger.verbose(`Prover bond top-up of ${topUpAmount} completed`);
44
- } catch (err) {
45
- throw new Error(`Could not set prover bond: ${err}`);
46
- }
47
- }
48
- }
@@ -1,25 +0,0 @@
1
- import { type ConfigMappingsType, bigintConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
2
-
3
- export type ProverBondManagerConfig = {
4
- proverMinimumEscrowAmount: bigint;
5
- proverTargetEscrowAmount?: bigint;
6
- };
7
-
8
- export const proverBondManagerConfigMappings: ConfigMappingsType<ProverBondManagerConfig> = {
9
- proverMinimumEscrowAmount: {
10
- env: 'PROVER_MINIMUM_ESCROW_AMOUNT',
11
- description:
12
- 'Minimum amount to ensure is staked in the escrow contract for this prover. Prover node will top up whenever escrow falls below this number.',
13
- ...bigintConfigHelper(100000n),
14
- },
15
- proverTargetEscrowAmount: {
16
- env: 'PROVER_TARGET_ESCROW_AMOUNT',
17
- description:
18
- 'Target amount to ensure is staked in the escrow contract for this prover. Prover node will top up to this value. Defaults to twice the minimum amount.',
19
- ...bigintConfigHelper(),
20
- },
21
- };
22
-
23
- export function getProverBondManagerConfigFromEnv(): ProverBondManagerConfig {
24
- return getConfigFromMappings<ProverBondManagerConfig>(proverBondManagerConfigMappings);
25
- }
@@ -1,50 +0,0 @@
1
- import { EthAddress } from '@aztec/circuits.js';
2
- import { type L1Clients } from '@aztec/ethereum';
3
- import { IProofCommitmentEscrowAbi } from '@aztec/l1-artifacts';
4
-
5
- import {
6
- type Chain,
7
- type GetContractReturnType,
8
- type HttpTransport,
9
- type PrivateKeyAccount,
10
- type WalletClient,
11
- getContract,
12
- } from 'viem';
13
-
14
- export class EscrowContract {
15
- private escrow: GetContractReturnType<
16
- typeof IProofCommitmentEscrowAbi,
17
- WalletClient<HttpTransport, Chain, PrivateKeyAccount>
18
- >;
19
-
20
- constructor(private readonly client: L1Clients['walletClient'], address: EthAddress) {
21
- this.escrow = getContract({ address: address.toString(), abi: IProofCommitmentEscrowAbi, client });
22
- }
23
-
24
- /** Returns the deposit of the publisher sender address on the proof commitment escrow contract. */
25
- public async getProverDeposit() {
26
- return await this.escrow.read.deposits([this.getSenderAddress().toString()]);
27
- }
28
-
29
- /**
30
- * Deposits the given amount of tokens into the proof commitment escrow contract. Returns once the tx is mined.
31
- * @param amount - The amount to deposit.
32
- */
33
- public async depositProverBond(amount: bigint) {
34
- const hash = await this.escrow.write.deposit([amount]);
35
- await this.client.waitForTransactionReceipt({ hash });
36
- }
37
-
38
- /** Returns the sender address for the client. */
39
- public getSenderAddress(): EthAddress {
40
- return EthAddress.fromString(this.client.account.address);
41
- }
42
-
43
- public getEscrowAddress(): EthAddress {
44
- return EthAddress.fromString(this.escrow.address);
45
- }
46
-
47
- public async getTokenAddress(): Promise<EthAddress> {
48
- return EthAddress.fromString(await this.escrow.read.token());
49
- }
50
- }
@@ -1,28 +0,0 @@
1
- import { type EthAddress } from '@aztec/circuits.js';
2
- import { type L1Clients } from '@aztec/ethereum';
3
- import { compact } from '@aztec/foundation/collection';
4
-
5
- import { BondManager } from './bond-manager.js';
6
- import { type ProverBondManagerConfig, getProverBondManagerConfigFromEnv } from './config.js';
7
- import { EscrowContract } from './escrow-contract.js';
8
- import { TokenContract } from './token-contract.js';
9
-
10
- export async function createBondManager(
11
- escrowContractAddress: EthAddress,
12
- client: L1Clients['walletClient'],
13
- overrides: Partial<ProverBondManagerConfig> = {},
14
- ) {
15
- const config = { ...getProverBondManagerConfigFromEnv(), ...compact(overrides) };
16
- const { proverMinimumEscrowAmount: minimumStake, proverTargetEscrowAmount: maybeTargetStake } = config;
17
- const targetStake = maybeTargetStake ?? minimumStake * 2n;
18
-
19
- const escrow = new EscrowContract(client, escrowContractAddress);
20
-
21
- const tokenContractAddress = await escrow.getTokenAddress();
22
- const token = new TokenContract(client, tokenContractAddress);
23
-
24
- // Ensure the prover has enough balance to cover escrow and try to mint otherwise if on a dev environment
25
- await token.ensureBalance(targetStake * 2n);
26
-
27
- return new BondManager(token, escrow, minimumStake, targetStake);
28
- }
package/src/bond/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export { BondManager } from './bond-manager.js';
2
- export * from './factory.js';
@@ -1,72 +0,0 @@
1
- import { EthAddress } from '@aztec/circuits.js';
2
- import { type L1Clients } from '@aztec/ethereum';
3
- import { createLogger } from '@aztec/foundation/log';
4
- import { IERC20Abi, TestERC20Abi } from '@aztec/l1-artifacts';
5
-
6
- import {
7
- type Chain,
8
- type GetContractReturnType,
9
- type HttpTransport,
10
- type PrivateKeyAccount,
11
- type WalletClient,
12
- getContract,
13
- } from 'viem';
14
-
15
- const MAX_ALLOWANCE = (1n << 256n) - 1n;
16
- const MIN_ALLOWANCE = 1n << 255n;
17
-
18
- export class TokenContract {
19
- private token: GetContractReturnType<typeof IERC20Abi, WalletClient<HttpTransport, Chain, PrivateKeyAccount>>;
20
- private logger = createLogger('prover-node:token-contract');
21
-
22
- constructor(private readonly client: L1Clients['walletClient'], address: EthAddress) {
23
- this.token = getContract({ address: address.toString(), abi: IERC20Abi, client });
24
- }
25
-
26
- /**
27
- * Ensures the allowed address has near-maximum allowance, or sets it otherwise.
28
- * Returns once allowance tx is mined successfully.
29
- * @param allowed - Who to allow.
30
- */
31
- public async ensureAllowance(allowed: EthAddress) {
32
- const allowance = await this.token.read.allowance([this.getSenderAddress().toString(), allowed.toString()]);
33
- if (allowance < MIN_ALLOWANCE) {
34
- this.logger.verbose(`Approving max allowance for ${allowed.toString()}`);
35
- const hash = await this.token.write.approve([allowed.toString(), MAX_ALLOWANCE]);
36
- await this.client.waitForTransactionReceipt({ hash });
37
- }
38
- }
39
-
40
- /**
41
- * Checks the sender address has enough balance.
42
- * If it doesn't, it tries calling a `mint` method, available on testing environments.
43
- * If it can't, it throws an error.
44
- * @param amount - The balance to ensure.
45
- */
46
- public async ensureBalance(amount: bigint) {
47
- const balance = await this.getBalance();
48
- if (balance < amount) {
49
- this.logger.verbose(`Balance ${balance} is below required ${amount}. Attempting mint.`);
50
- const testToken = getContract({ address: this.token.address, abi: TestERC20Abi, client: this.client });
51
- try {
52
- await testToken.simulate.mint([this.getSenderAddress().toString(), amount - balance]);
53
- const hash = await testToken.write.mint([this.getSenderAddress().toString(), amount - balance]);
54
- await this.client.waitForTransactionReceipt({ hash });
55
- this.logger.verbose(`Minted ${amount - balance} test tokens`);
56
- } catch (err) {
57
- this.logger.warn(`Error minting test tokens: ${err}`);
58
- throw new Error(`Insufficient balance for ${this.getSenderAddress().toString()}: ${balance} < ${amount}`);
59
- }
60
- }
61
- }
62
-
63
- /** Returns the sender address. */
64
- public getSenderAddress(): EthAddress {
65
- return EthAddress.fromString(this.client.account.address);
66
- }
67
-
68
- /** Returns the balance of the sender. */
69
- public async getBalance() {
70
- return await this.token.read.balanceOf([this.getSenderAddress().toString()]);
71
- }
72
- }
@@ -1,69 +0,0 @@
1
- import { type EpochProofClaim } from '@aztec/circuit-types';
2
- import { type EthAddress } from '@aztec/circuits.js';
3
- import { createLogger } from '@aztec/foundation/log';
4
- import { RunningPromise } from '@aztec/foundation/running-promise';
5
- import {
6
- type TelemetryClient,
7
- type Traceable,
8
- type Tracer,
9
- getTelemetryClient,
10
- trackSpan,
11
- } from '@aztec/telemetry-client';
12
-
13
- import { type ProverNodePublisher } from '../prover-node-publisher.js';
14
-
15
- export interface ClaimsMonitorHandler {
16
- handleClaim(proofClaim: EpochProofClaim): Promise<void>;
17
- }
18
-
19
- export class ClaimsMonitor implements Traceable {
20
- private runningPromise: RunningPromise;
21
- private log = createLogger('prover-node:claims-monitor');
22
-
23
- private handler: ClaimsMonitorHandler | undefined;
24
- private lastClaimEpochNumber: bigint | undefined;
25
-
26
- public readonly tracer: Tracer;
27
-
28
- constructor(
29
- private readonly l1Publisher: ProverNodePublisher,
30
- private options: { pollingIntervalMs: number },
31
- telemetry: TelemetryClient = getTelemetryClient(),
32
- ) {
33
- this.tracer = telemetry.getTracer('ClaimsMonitor');
34
- this.runningPromise = new RunningPromise(this.work.bind(this), this.log, this.options.pollingIntervalMs);
35
- }
36
-
37
- public start(handler: ClaimsMonitorHandler) {
38
- this.handler = handler;
39
- this.runningPromise.start();
40
- this.log.info(`Started ClaimsMonitor with prover address ${this.getProverAddress().toString()}`, this.options);
41
- }
42
-
43
- public async stop() {
44
- this.log.verbose('Stopping ClaimsMonitor');
45
- await this.runningPromise.stop();
46
- this.log.info('Stopped ClaimsMonitor');
47
- }
48
-
49
- @trackSpan('ClaimsMonitor.work')
50
- public async work() {
51
- const proofClaim = await this.l1Publisher.getProofClaim();
52
- if (!proofClaim) {
53
- this.log.trace(`Found no proof claim`);
54
- return;
55
- }
56
-
57
- if (this.lastClaimEpochNumber === undefined || proofClaim.epochToProve > this.lastClaimEpochNumber) {
58
- this.log.verbose(`Found new claim for epoch ${proofClaim.epochToProve} by ${proofClaim.bondProvider.toString()}`);
59
- if (proofClaim.bondProvider.equals(this.getProverAddress())) {
60
- await this.handler?.handleClaim(proofClaim);
61
- }
62
- this.lastClaimEpochNumber = proofClaim.epochToProve;
63
- }
64
- }
65
-
66
- protected getProverAddress(): EthAddress {
67
- return this.l1Publisher.getSenderAddress();
68
- }
69
- }
@@ -1,48 +0,0 @@
1
- import { type L2Block } from '@aztec/circuit-types';
2
- import { jsonStringify } from '@aztec/foundation/json-rpc';
3
-
4
- import { type QuoteProvider, type QuoteProviderResult } from './index.js';
5
- import { getTotalFees, getTxCount } from './utils.js';
6
-
7
- export class HttpQuoteProvider implements QuoteProvider {
8
- constructor(private readonly url: string) {}
9
-
10
- public async getQuote(epochNumber: number, epoch: L2Block[]): Promise<QuoteProviderResult | undefined> {
11
- const payload: HttpQuoteRequestPayload = {
12
- epochNumber,
13
- fromBlock: epoch[0].number,
14
- toBlock: epoch.at(-1)!.number,
15
- totalFees: getTotalFees(epoch).toString(),
16
- txCount: getTxCount(epoch),
17
- };
18
-
19
- const response = await fetch(this.url, {
20
- method: 'POST',
21
- body: jsonStringify(payload),
22
- headers: { 'content-type': 'application/json' },
23
- });
24
-
25
- if (!response.ok) {
26
- throw new Error(`Failed to fetch quote: ${response.statusText}`);
27
- }
28
-
29
- const data = await response.json();
30
- if (!data.basisPointFee || !data.bondAmount) {
31
- throw new Error(`Missing required fields (basisPointFee | bondAmount) in response: ${jsonStringify(data)}`);
32
- }
33
-
34
- const basisPointFee = Number(data.basisPointFee);
35
- const bondAmount = BigInt(data.bondAmount);
36
- const validUntilSlot = data.validUntilSlot ? BigInt(data.validUntilSlot) : undefined;
37
-
38
- return { basisPointFee, bondAmount, validUntilSlot };
39
- }
40
- }
41
-
42
- export type HttpQuoteRequestPayload = {
43
- epochNumber: number;
44
- fromBlock: number;
45
- toBlock: number;
46
- totalFees: string;
47
- txCount: number;
48
- };
@@ -1,8 +0,0 @@
1
- import { type EpochProofQuotePayload, type L2Block } from '@aztec/circuit-types';
2
-
3
- export type QuoteProviderResult = Pick<EpochProofQuotePayload, 'basisPointFee' | 'bondAmount'> &
4
- Partial<Pick<EpochProofQuotePayload, 'validUntilSlot'>>;
5
-
6
- export interface QuoteProvider {
7
- getQuote(epochNumber: number, epoch: L2Block[]): Promise<QuoteProviderResult | undefined>;
8
- }
@@ -1,15 +0,0 @@
1
- import { type EpochProofQuotePayload, type L2Block } from '@aztec/circuit-types';
2
-
3
- import { type QuoteProvider } from './index.js';
4
-
5
- export class SimpleQuoteProvider implements QuoteProvider {
6
- constructor(public readonly basisPointFee: number, public readonly bondAmount: bigint) {}
7
-
8
- getQuote(
9
- _epochNumber: number,
10
- _epoch: L2Block[],
11
- ): Promise<Pick<EpochProofQuotePayload, 'basisPointFee' | 'bondAmount'>> {
12
- const { basisPointFee, bondAmount } = this;
13
- return Promise.resolve({ basisPointFee, bondAmount });
14
- }
15
- }
@@ -1,10 +0,0 @@
1
- import { type L2Block } from '@aztec/circuit-types';
2
- import { Fr } from '@aztec/circuits.js';
3
-
4
- export function getTotalFees(epoch: L2Block[]) {
5
- return epoch.reduce((total, block) => total.add(block.header.totalFees), Fr.ZERO).toBigInt();
6
- }
7
-
8
- export function getTxCount(epoch: L2Block[]) {
9
- return epoch.reduce((total, block) => total + block.body.txEffects.length, 0);
10
- }
@@ -1,24 +0,0 @@
1
- import { EpochProofQuote, type EpochProofQuotePayload } from '@aztec/circuit-types';
2
- import { Buffer32 } from '@aztec/foundation/buffer';
3
- import { Secp256k1Signer } from '@aztec/foundation/crypto';
4
- import { type RollupAbi } from '@aztec/l1-artifacts';
5
-
6
- import { type GetContractReturnType, type PublicClient } from 'viem';
7
-
8
- export class QuoteSigner {
9
- constructor(
10
- private readonly signer: Secp256k1Signer,
11
- private readonly quoteToDigest: (payload: EpochProofQuotePayload) => Promise<Buffer32>,
12
- ) {}
13
-
14
- static new(privateKey: Buffer32, rollupContract: GetContractReturnType<typeof RollupAbi, PublicClient>): QuoteSigner {
15
- const quoteToDigest = (payload: EpochProofQuotePayload) =>
16
- rollupContract.read.quoteToDigest([payload.toViemArgs()]).then(Buffer32.fromString);
17
- return new QuoteSigner(new Secp256k1Signer(privateKey), quoteToDigest);
18
- }
19
-
20
- public async sign(payload: EpochProofQuotePayload) {
21
- const digest = await this.quoteToDigest(payload);
22
- return EpochProofQuote.new(digest, payload, this.signer);
23
- }
24
- }