From ec356e210e777775b02c76843e63ec52869637ff Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 3 Oct 2024 17:12:38 +0000 Subject: [PATCH] Revert "feat: Prover node stakes to escrow contract (#8975)" This reverts commit 9eb8815dc00641d6568e952b336e6f7348728054. --- .../token_bridge/1_depositing_to_aztec.md | 4 +- .../src/core/ProofCommitmentEscrow.sol | 10 +-- l1-contracts/src/core/Rollup.sol | 9 +-- .../interfaces/IProofCommitmentEscrow.sol | 3 - l1-contracts/src/core/libraries/Errors.sol | 1 - .../src/mock/MockProofCommitmentEscrow.sol | 16 +--- l1-contracts/test/Rollup.t.sol | 17 +---- l1-contracts/{src/mock => test}/TestERC20.sol | 0 l1-contracts/test/TestERC20.t.sol | 2 +- l1-contracts/test/portals/TokenPortal.t.sol | 11 +-- l1-contracts/test/portals/UniswapPortal.t.sol | 9 +-- .../ProofCommitmentEscrow.t.sol | 5 +- l1-contracts/test/sparta/Sparta.t.sol | 11 +-- yarn-project/aztec/src/sandbox.ts | 6 -- yarn-project/cli/src/utils/aztec.ts | 7 +- .../src/e2e_prover/e2e_prover_test.ts | 22 +----- .../src/fixtures/setup_l1_contracts.ts | 12 +-- .../src/fixtures/snapshot_manager.ts | 2 - yarn-project/end-to-end/src/fixtures/utils.ts | 17 +---- .../ethereum/src/deploy_l1_contracts.ts | 34 +-------- yarn-project/foundation/src/config/env_var.ts | 2 - yarn-project/foundation/src/config/index.ts | 2 +- .../scripts/generate-artifacts.sh | 3 - yarn-project/prover-node/package.json | 2 +- .../prover-node/src/bond/bond-manager.test.ts | 74 ------------------- .../prover-node/src/bond/bond-manager.ts | 48 ------------ yarn-project/prover-node/src/bond/config.ts | 25 ------- .../prover-node/src/bond/escrow-contract.ts | 63 ---------------- yarn-project/prover-node/src/bond/factory.ts | 44 ----------- yarn-project/prover-node/src/bond/index.ts | 2 - .../prover-node/src/bond/token-contract.ts | 62 ---------------- yarn-project/prover-node/src/config.ts | 4 - yarn-project/prover-node/src/factory.ts | 6 -- .../prover-node/src/prover-node.test.ts | 56 ++++++++------ yarn-project/prover-node/src/prover-node.ts | 29 +++----- .../src/publisher/l1-publisher.ts | 31 +------- 36 files changed, 72 insertions(+), 579 deletions(-) rename l1-contracts/{src/mock => test}/TestERC20.sol (100%) delete mode 100644 yarn-project/prover-node/src/bond/bond-manager.test.ts delete mode 100644 yarn-project/prover-node/src/bond/bond-manager.ts delete mode 100644 yarn-project/prover-node/src/bond/config.ts delete mode 100644 yarn-project/prover-node/src/bond/escrow-contract.ts delete mode 100644 yarn-project/prover-node/src/bond/factory.ts delete mode 100644 yarn-project/prover-node/src/bond/index.ts delete mode 100644 yarn-project/prover-node/src/bond/token-contract.ts diff --git a/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/1_depositing_to_aztec.md b/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/1_depositing_to_aztec.md index dccc268926b..ba35449ba13 100644 --- a/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/1_depositing_to_aztec.md +++ b/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/1_depositing_to_aztec.md @@ -34,7 +34,7 @@ Create a basic ERC20 contract that can mint tokens to anyone. We will use this t Create a file `TestERC20.sol` in the same folder and add: -#include_code contract /l1-contracts/src/mock/TestERC20.sol solidity +#include_code contract /l1-contracts/test/TestERC20.sol solidity Replace the openzeppelin import with this: @@ -81,7 +81,7 @@ Here we want to send a message to mint tokens privately on Aztec! Some key diffe - The content hash uses a different function name - `mint_private`. This is done to make it easy to separate concerns. If the contentHash between the public and private message was the same, then an attacker could consume a private message publicly! - Since we want to mint tokens privately, we shouldn’t specify a `to` Aztec address (remember that Ethereum is completely public). Instead, we will use a secret hash - `secretHashForRedeemingMintedNotes`. Only he who knows the preimage to the secret hash can actually mint the notes. This is similar to the mechanism we use for message consumption on L2 - Like with the public flow, we move the user’s funds to the portal -- We now send the message to the inbox with the `recipient` (the sister contract on L2 along with the version of aztec the message is intended for) and the `secretHashForL2MessageConsumption` (such that on L2, the consumption of the message can be private). +- We now send the message to the inbox with the `recipient` (the sister contract on L2 along with the version of aztec the message is intended for) and the `secretHashForL2MessageConsumption` (such that on L2, the consumption of the message can be private). Note that because L1 is public, everyone can inspect and figure out the contentHash and the recipient contract address. diff --git a/l1-contracts/src/core/ProofCommitmentEscrow.sol b/l1-contracts/src/core/ProofCommitmentEscrow.sol index 654a74d2124..a29f92ac0c4 100644 --- a/l1-contracts/src/core/ProofCommitmentEscrow.sol +++ b/l1-contracts/src/core/ProofCommitmentEscrow.sol @@ -18,7 +18,7 @@ contract ProofCommitmentEscrow is IProofCommitmentEscrow { Timestamp executableAt; } - address public ROLLUP; + address public immutable ROLLUP; uint256 public constant WITHDRAW_DELAY = Constants.ETHEREUM_SLOT_DURATION * Constants.AZTEC_EPOCH_DURATION * 3; mapping(address => uint256) public deposits; @@ -30,13 +30,9 @@ contract ProofCommitmentEscrow is IProofCommitmentEscrow { _; } - constructor(IERC20 _token) { + constructor(IERC20 _token, address _owner) { token = _token; - } - - function initialize(address _rollup) external { - require(ROLLUP == address(0)); - ROLLUP = _rollup; + ROLLUP = _owner; } /** diff --git a/l1-contracts/src/core/Rollup.sol b/l1-contracts/src/core/Rollup.sol index 33da46e58cb..c6f08a170e1 100644 --- a/l1-contracts/src/core/Rollup.sol +++ b/l1-contracts/src/core/Rollup.sol @@ -83,14 +83,13 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { constructor( IFeeJuicePortal _fpcJuicePortal, - IProofCommitmentEscrow _proofCommitmentEscrow, // We should create a new instance instead of accepting one, once we remove the Mock version bytes32 _vkTreeRoot, address _ares, address[] memory _validators ) Leonidas(_ares) { epochProofVerifier = new MockVerifier(); FEE_JUICE_PORTAL = _fpcJuicePortal; - PROOF_COMMITMENT_ESCROW = _proofCommitmentEscrow; + PROOF_COMMITMENT_ESCROW = new MockProofCommitmentEscrow(); INBOX = IInbox(address(new Inbox(address(this), Constants.L1_TO_L2_MSG_SUBTREE_HEIGHT))); OUTBOX = IOutbox(address(new Outbox(address(this)))); vkTreeRoot = _vkTreeRoot; @@ -629,12 +628,6 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { ) ); - uint256 availableFundsInEscrow = PROOF_COMMITMENT_ESCROW.deposits(_quote.quote.prover); - require( - _quote.quote.bondAmount <= availableFundsInEscrow, - Errors.Rollup__InsufficientFundsInEscrow(_quote.quote.bondAmount, availableFundsInEscrow) - ); - require( _quote.quote.validUntilSlot >= currentSlot, Errors.Rollup__QuoteExpired(currentSlot, _quote.quote.validUntilSlot) diff --git a/l1-contracts/src/core/interfaces/IProofCommitmentEscrow.sol b/l1-contracts/src/core/interfaces/IProofCommitmentEscrow.sol index f73333c8396..e844400fba5 100644 --- a/l1-contracts/src/core/interfaces/IProofCommitmentEscrow.sol +++ b/l1-contracts/src/core/interfaces/IProofCommitmentEscrow.sol @@ -3,7 +3,6 @@ pragma solidity >=0.8.27; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; -import {IERC20} from "@oz/token/ERC20/IERC20.sol"; interface IProofCommitmentEscrow { event Deposit(address indexed depositor, uint256 amount); @@ -18,6 +17,4 @@ interface IProofCommitmentEscrow { function stakeBond(address _prover, uint256 _amount) external; function unstakeBond(address _prover, uint256 _amount) external; function minBalanceAtTime(Timestamp _timestamp, address _prover) external view returns (uint256); - function deposits(address) external view returns (uint256); - function token() external view returns (IERC20); } diff --git a/l1-contracts/src/core/libraries/Errors.sol b/l1-contracts/src/core/libraries/Errors.sol index cdc8e113db6..8df16131fd1 100644 --- a/l1-contracts/src/core/libraries/Errors.sol +++ b/l1-contracts/src/core/libraries/Errors.sol @@ -47,7 +47,6 @@ library Errors { // Rollup error Rollup__InsufficientBondAmount(uint256 minimum, uint256 provided); // 0xa165f276 - error Rollup__InsufficientFundsInEscrow(uint256 required, uint256 available); // 0xa165f276 error Rollup__InvalidArchive(bytes32 expected, bytes32 actual); // 0xb682a40e error Rollup__InvalidBlockHash(bytes32 expected, bytes32 actual); error Rollup__InvalidBlockNumber(uint256 expected, uint256 actual); // 0xe5edf847 diff --git a/l1-contracts/src/mock/MockProofCommitmentEscrow.sol b/l1-contracts/src/mock/MockProofCommitmentEscrow.sol index f556f787901..4568f3392eb 100644 --- a/l1-contracts/src/mock/MockProofCommitmentEscrow.sol +++ b/l1-contracts/src/mock/MockProofCommitmentEscrow.sol @@ -4,20 +4,10 @@ pragma solidity >=0.8.27; import {IProofCommitmentEscrow} from "@aztec/core/interfaces/IProofCommitmentEscrow.sol"; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; -import {IERC20} from "@oz/token/ERC20/IERC20.sol"; -import {TestERC20} from "@aztec/mock/TestERC20.sol"; contract MockProofCommitmentEscrow is IProofCommitmentEscrow { - mapping(address => uint256) public deposits; - - IERC20 public immutable token; - - constructor() { - token = new TestERC20(); - } - function deposit(uint256 _amount) external override { - deposits[msg.sender] += _amount; + // do nothing } function startWithdraw(uint256 _amount) external override { @@ -36,7 +26,7 @@ contract MockProofCommitmentEscrow is IProofCommitmentEscrow { // do nothing } - function minBalanceAtTime(Timestamp, address _who) external view override returns (uint256) { - return deposits[_who]; + function minBalanceAtTime(Timestamp, address) external pure override returns (uint256) { + return 0; } } diff --git a/l1-contracts/test/Rollup.t.sol b/l1-contracts/test/Rollup.t.sol index 424a9360043..cc481648bfa 100644 --- a/l1-contracts/test/Rollup.t.sol +++ b/l1-contracts/test/Rollup.t.sol @@ -15,13 +15,11 @@ import {Outbox} from "@aztec/core/messagebridge/Outbox.sol"; import {Errors} from "@aztec/core/libraries/Errors.sol"; import {Rollup} from "@aztec/core/Rollup.sol"; import {IRollup} from "@aztec/core/interfaces/IRollup.sol"; -import {IProofCommitmentEscrow} from "@aztec/core/interfaces/IProofCommitmentEscrow.sol"; import {FeeJuicePortal} from "@aztec/core/FeeJuicePortal.sol"; import {Leonidas} from "@aztec/core/Leonidas.sol"; import {NaiveMerkle} from "./merkle/Naive.sol"; import {MerkleTestUtil} from "./merkle/TestUtil.sol"; -import {TestERC20} from "@aztec/mock/TestERC20.sol"; -import {MockProofCommitmentEscrow} from "@aztec/mock/MockProofCommitmentEscrow.sol"; +import {TestERC20} from "./TestERC20.sol"; import {TxsDecoderHelper} from "./decoders/helpers/TxsDecoderHelper.sol"; import {IERC20Errors} from "@oz/interfaces/draft-IERC6093.sol"; @@ -46,7 +44,6 @@ contract RollupTest is DecoderBase { TxsDecoderHelper internal txsHelper; TestERC20 internal testERC20; FeeJuicePortal internal feeJuicePortal; - IProofCommitmentEscrow internal proofCommitmentEscrow; SignatureLib.Signature[] internal signatures; @@ -73,9 +70,7 @@ contract RollupTest is DecoderBase { feeJuicePortal.initialize( address(registry), address(testERC20), bytes32(Constants.FEE_JUICE_ADDRESS) ); - proofCommitmentEscrow = new MockProofCommitmentEscrow(); - rollup = - new Rollup(feeJuicePortal, proofCommitmentEscrow, bytes32(0), address(this), new address[](0)); + rollup = new Rollup(feeJuicePortal, bytes32(0), address(this), new address[](0)); inbox = Inbox(address(rollup.INBOX())); outbox = Outbox(address(rollup.OUTBOX())); @@ -86,20 +81,14 @@ contract RollupTest is DecoderBase { uint256 privateKey = 0x123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234; address signer = vm.addr(privateKey); - uint256 bond = rollup.PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST(); quote = EpochProofQuoteLib.EpochProofQuote({ epochToProve: Epoch.wrap(0), validUntilSlot: Slot.wrap(1), - bondAmount: bond, + bondAmount: rollup.PROOF_COMMITMENT_MIN_BOND_AMOUNT_IN_TST(), prover: signer, basisPointFee: 0 }); signedQuote = _quoteToSignedQuote(quote); - - testERC20.mint(signer, bond * 10); - vm.prank(signer); - proofCommitmentEscrow.deposit(bond * 10); - _; } diff --git a/l1-contracts/src/mock/TestERC20.sol b/l1-contracts/test/TestERC20.sol similarity index 100% rename from l1-contracts/src/mock/TestERC20.sol rename to l1-contracts/test/TestERC20.sol diff --git a/l1-contracts/test/TestERC20.t.sol b/l1-contracts/test/TestERC20.t.sol index 3b7abc4cfa7..4f50cb73f21 100644 --- a/l1-contracts/test/TestERC20.t.sol +++ b/l1-contracts/test/TestERC20.t.sol @@ -1,7 +1,7 @@ pragma solidity ^0.8.18; import "forge-std/Test.sol"; -import {TestERC20} from "@aztec/mock/TestERC20.sol"; +import {TestERC20} from "./TestERC20.sol"; contract TestERC20Test is Test { TestERC20 testERC20; diff --git a/l1-contracts/test/portals/TokenPortal.t.sol b/l1-contracts/test/portals/TokenPortal.t.sol index d2dde1af4aa..dff8eca55b1 100644 --- a/l1-contracts/test/portals/TokenPortal.t.sol +++ b/l1-contracts/test/portals/TokenPortal.t.sol @@ -14,11 +14,10 @@ import {Hash} from "@aztec/core/libraries/crypto/Hash.sol"; import {IInbox} from "@aztec/core/interfaces/messagebridge/IInbox.sol"; import {IOutbox} from "@aztec/core/interfaces/messagebridge/IOutbox.sol"; import {IFeeJuicePortal} from "@aztec/core/interfaces/IFeeJuicePortal.sol"; -import {IProofCommitmentEscrow} from "@aztec/core/interfaces/IProofCommitmentEscrow.sol"; // Portal tokens import {TokenPortal} from "./TokenPortal.sol"; -import {TestERC20} from "@aztec/mock/TestERC20.sol"; +import {TestERC20} from "../TestERC20.sol"; import {NaiveMerkle} from "../merkle/Naive.sol"; @@ -61,13 +60,7 @@ contract TokenPortalTest is Test { function setUp() public { registry = new Registry(address(this)); testERC20 = new TestERC20(); - rollup = new Rollup( - IFeeJuicePortal(address(0)), - IProofCommitmentEscrow(address(0)), - bytes32(0), - address(this), - new address[](0) - ); + rollup = new Rollup(IFeeJuicePortal(address(0)), bytes32(0), address(this), new address[](0)); inbox = rollup.INBOX(); outbox = rollup.OUTBOX(); diff --git a/l1-contracts/test/portals/UniswapPortal.t.sol b/l1-contracts/test/portals/UniswapPortal.t.sol index ce692130c8b..afb986f9046 100644 --- a/l1-contracts/test/portals/UniswapPortal.t.sol +++ b/l1-contracts/test/portals/UniswapPortal.t.sol @@ -15,7 +15,6 @@ import {IERC20} from "@oz/token/ERC20/IERC20.sol"; import {IOutbox} from "@aztec/core/interfaces/messagebridge/IOutbox.sol"; import {NaiveMerkle} from "../merkle/Naive.sol"; import {IFeeJuicePortal} from "@aztec/core/interfaces/IFeeJuicePortal.sol"; -import {IProofCommitmentEscrow} from "@aztec/core/interfaces/IProofCommitmentEscrow.sol"; // Portals import {TokenPortal} from "./TokenPortal.sol"; @@ -53,13 +52,7 @@ contract UniswapPortalTest is Test { vm.selectFork(forkId); registry = new Registry(address(this)); - rollup = new Rollup( - IFeeJuicePortal(address(0)), - IProofCommitmentEscrow(address(0)), - bytes32(0), - address(this), - new address[](0) - ); + rollup = new Rollup(IFeeJuicePortal(address(0)), bytes32(0), address(this), new address[](0)); registry.upgrade(address(rollup)); daiTokenPortal = new TokenPortal(); diff --git a/l1-contracts/test/prover-coordination/ProofCommitmentEscrow.t.sol b/l1-contracts/test/prover-coordination/ProofCommitmentEscrow.t.sol index b986b7182d9..401fd67a2bc 100644 --- a/l1-contracts/test/prover-coordination/ProofCommitmentEscrow.t.sol +++ b/l1-contracts/test/prover-coordination/ProofCommitmentEscrow.t.sol @@ -8,7 +8,7 @@ import {ProofCommitmentEscrow} from "@aztec/core/ProofCommitmentEscrow.sol"; import {Errors} from "@aztec/core/libraries/Errors.sol"; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; -import {TestERC20} from "@aztec/mock/TestERC20.sol"; +import {TestERC20} from "../TestERC20.sol"; // solhint-disable comprehensive-interface @@ -32,8 +32,7 @@ contract TestProofCommitmentEscrow is Test { function setUp() public { TOKEN = new TestERC20(); - ESCROW = new ProofCommitmentEscrow(TOKEN); - ESCROW.initialize(address(this)); + ESCROW = new ProofCommitmentEscrow(TOKEN, address(this)); } function testDeposit() public setupWithApproval(address(42), 100) { diff --git a/l1-contracts/test/sparta/Sparta.t.sol b/l1-contracts/test/sparta/Sparta.t.sol index b222961537a..a6e290c2fc1 100644 --- a/l1-contracts/test/sparta/Sparta.t.sol +++ b/l1-contracts/test/sparta/Sparta.t.sol @@ -15,10 +15,9 @@ import {Rollup} from "@aztec/core/Rollup.sol"; import {Leonidas} from "@aztec/core/Leonidas.sol"; import {NaiveMerkle} from "../merkle/Naive.sol"; import {MerkleTestUtil} from "../merkle/TestUtil.sol"; -import {TestERC20} from "@aztec/mock/TestERC20.sol"; +import {TestERC20} from "../TestERC20.sol"; import {TxsDecoderHelper} from "../decoders/helpers/TxsDecoderHelper.sol"; import {IFeeJuicePortal} from "@aztec/core/interfaces/IFeeJuicePortal.sol"; -import {IProofCommitmentEscrow} from "@aztec/core/interfaces/IProofCommitmentEscrow.sol"; import {MessageHashUtils} from "@oz/utils/cryptography/MessageHashUtils.sol"; import {Slot, Epoch, SlotLib, EpochLib} from "@aztec/core/libraries/TimeMath.sol"; @@ -75,13 +74,7 @@ contract SpartaTest is DecoderBase { } testERC20 = new TestERC20(); - rollup = new Rollup( - IFeeJuicePortal(address(0)), - IProofCommitmentEscrow(address(0)), - bytes32(0), - address(this), - initialValidators - ); + rollup = new Rollup(IFeeJuicePortal(address(0)), bytes32(0), address(this), initialValidators); inbox = Inbox(address(rollup.INBOX())); outbox = Outbox(address(rollup.OUTBOX())); diff --git a/yarn-project/aztec/src/sandbox.ts b/yarn-project/aztec/src/sandbox.ts index 121875bdf3a..9e508647a4b 100644 --- a/yarn-project/aztec/src/sandbox.ts +++ b/yarn-project/aztec/src/sandbox.ts @@ -18,8 +18,6 @@ import { FeeJuicePortalBytecode, InboxAbi, InboxBytecode, - MockProofCommitmentEscrowAbi, - MockProofCommitmentEscrowBytecode, OutboxAbi, OutboxBytecode, RegistryAbi, @@ -117,10 +115,6 @@ export async function deployContractsToL1( contractAbi: FeeJuicePortalAbi, contractBytecode: FeeJuicePortalBytecode, }, - proofCommitmentEscrow: { - contractAbi: MockProofCommitmentEscrowAbi, - contractBytecode: MockProofCommitmentEscrowBytecode, - }, }; const chain = aztecNodeConfig.l1RpcUrl diff --git a/yarn-project/cli/src/utils/aztec.ts b/yarn-project/cli/src/utils/aztec.ts index da0260c88b6..2c6f4316ee2 100644 --- a/yarn-project/cli/src/utils/aztec.ts +++ b/yarn-project/cli/src/utils/aztec.ts @@ -69,8 +69,7 @@ export async function deployAztecContracts( RegistryBytecode, RollupAbi, RollupBytecode, - MockProofCommitmentEscrowAbi, - MockProofCommitmentEscrowBytecode, + FeeJuicePortalAbi, FeeJuicePortalBytecode, TestERC20Abi, @@ -108,10 +107,6 @@ export async function deployAztecContracts( contractAbi: FeeJuicePortalAbi, contractBytecode: FeeJuicePortalBytecode, }, - proofCommitmentEscrow: { - contractAbi: MockProofCommitmentEscrowAbi, - contractBytecode: MockProofCommitmentEscrowBytecode, - }, }; const { getVKTreeRoot } = await import('@aztec/noir-protocol-circuits-types'); diff --git a/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts b/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts index ca6b956d067..ba5f1c0f4bf 100644 --- a/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts +++ b/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts @@ -24,8 +24,7 @@ import { type UltraKeccakHonkProtocolArtifact, } from '@aztec/bb-prover'; import { compileContract } from '@aztec/ethereum'; -import { Buffer32 } from '@aztec/foundation/buffer'; -import { RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts'; +import { RollupAbi } from '@aztec/l1-artifacts'; import { TokenContract } from '@aztec/noir-contracts.js'; import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node'; import { type PXEService } from '@aztec/pxe'; @@ -34,8 +33,7 @@ import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; // TODO(#7373): Deploy honk solidity verifier // @ts-expect-error solc-js doesn't publish its types https://github.com/ethereum/solc-js/issues/689 import solc from 'solc'; -import { type Hex, getContract } from 'viem'; -import { privateKeyToAddress } from 'viem/accounts'; +import { getContract } from 'viem'; import { waitRegisteredAccountSynced } from '../benchmarks/utils.js'; import { getACVMConfig } from '../fixtures/get_acvm_config.js'; @@ -96,7 +94,7 @@ export class FullProverTest { `full_prover_integration/${testName}`, dataPath, {}, - { assumeProvenThrough: undefined, useRealProofCommitmentEscrow: true }, + { assumeProvenThrough: undefined }, ); } @@ -260,10 +258,6 @@ export class FullProverTest { // The simulated prover node (now shutdown) used private key index 2 const proverNodePrivateKey = getPrivateKeyFromIndex(2); - const proverNodeSenderAddress = privateKeyToAddress(new Buffer32(proverNodePrivateKey!).to0xString()); - - this.logger.verbose(`Funding prover node at ${proverNodeSenderAddress}`); - await this.mintL1ERC20(proverNodeSenderAddress, 100_000_000n); this.logger.verbose('Starting prover node'); const proverConfig: ProverNodeConfig = { @@ -278,8 +272,6 @@ export class FullProverTest { proverNodePollingIntervalMs: 100, quoteProviderBasisPointFee: 100, quoteProviderBondAmount: 1000n, - proverMinimumStakeAmount: 3000n, - proverTargetStakeAmount: 6000n, }; this.proverNode = await createProverNode(proverConfig, { aztecNodeTxProvider: this.aztecNode, @@ -291,14 +283,6 @@ export class FullProverTest { return this; } - private async mintL1ERC20(recipient: Hex, amount: bigint) { - const erc20Address = this.context.deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress; - const client = this.context.deployL1ContractsValues.walletClient; - const erc20 = getContract({ abi: TestERC20Abi, address: erc20Address.toString(), client }); - const hash = await erc20.write.mint([recipient, amount]); - await this.context.deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash }); - } - snapshot = ( name: string, apply: (context: SubsystemsContext) => Promise, diff --git a/yarn-project/end-to-end/src/fixtures/setup_l1_contracts.ts b/yarn-project/end-to-end/src/fixtures/setup_l1_contracts.ts index 8ac08664c4c..c62950d85cb 100644 --- a/yarn-project/end-to-end/src/fixtures/setup_l1_contracts.ts +++ b/yarn-project/end-to-end/src/fixtures/setup_l1_contracts.ts @@ -5,12 +5,8 @@ import { FeeJuicePortalBytecode, InboxAbi, InboxBytecode, - MockProofCommitmentEscrowAbi, - MockProofCommitmentEscrowBytecode, OutboxAbi, OutboxBytecode, - ProofCommitmentEscrowAbi, - ProofCommitmentEscrowBytecode, RegistryAbi, RegistryBytecode, RollupAbi, @@ -30,7 +26,7 @@ export const setupL1Contracts = async ( l1RpcUrl: string, account: HDAccount | PrivateKeyAccount, logger: DebugLogger, - args: Pick, + args: Pick, ) => { const l1Artifacts: L1ContractArtifactsForDeployment = { registry: { @@ -57,12 +53,6 @@ export const setupL1Contracts = async ( contractAbi: FeeJuicePortalAbi, contractBytecode: FeeJuicePortalBytecode, }, - proofCommitmentEscrow: { - contractAbi: args.useRealProofCommitmentEscrow ? ProofCommitmentEscrowAbi : MockProofCommitmentEscrowAbi, - contractBytecode: args.useRealProofCommitmentEscrow - ? ProofCommitmentEscrowBytecode - : MockProofCommitmentEscrowBytecode, - }, }; const l1Data = await deployL1Contracts(l1RpcUrl, account, foundry, logger, l1Artifacts, { diff --git a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts index 019872443b9..ebf17583e63 100644 --- a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts +++ b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts @@ -281,8 +281,6 @@ export async function createAndSyncProverNode( proverNodePollingIntervalMs: 200, quoteProviderBasisPointFee: 100, quoteProviderBondAmount: 1000n, - proverMinimumStakeAmount: 0n, - proverTargetStakeAmount: 0n, }; const proverNode = await createProverNode(proverConfig, { aztecNodeTxProvider: aztecNode, diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index 3bbe488f4ab..db443194996 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -47,12 +47,8 @@ import { FeeJuicePortalBytecode, InboxAbi, InboxBytecode, - MockProofCommitmentEscrowAbi, - MockProofCommitmentEscrowBytecode, OutboxAbi, OutboxBytecode, - ProofCommitmentEscrowAbi, - ProofCommitmentEscrowBytecode, RegistryAbi, RegistryBytecode, RollupAbi, @@ -117,12 +113,7 @@ export const setupL1Contracts = async ( l1RpcUrl: string, account: HDAccount | PrivateKeyAccount, logger: DebugLogger, - args: { - salt?: number; - initialValidators?: EthAddress[]; - assumeProvenThrough?: number; - useRealProofCommitmentEscrow?: boolean; - } = { + args: { salt?: number; initialValidators?: EthAddress[]; assumeProvenThrough?: number } = { assumeProvenThrough: Number.MAX_SAFE_INTEGER, }, chain: Chain = foundry, @@ -152,12 +143,6 @@ export const setupL1Contracts = async ( contractAbi: FeeJuicePortalAbi, contractBytecode: FeeJuicePortalBytecode, }, - proofCommitmentEscrow: { - contractAbi: args.useRealProofCommitmentEscrow ? ProofCommitmentEscrowAbi : MockProofCommitmentEscrowAbi, - contractBytecode: args.useRealProofCommitmentEscrow - ? ProofCommitmentEscrowBytecode - : MockProofCommitmentEscrowBytecode, - }, }; const l1Data = await deployL1Contracts(l1RpcUrl, account, chain, logger, l1Artifacts, { diff --git a/yarn-project/ethereum/src/deploy_l1_contracts.ts b/yarn-project/ethereum/src/deploy_l1_contracts.ts index 87c874d60f9..6fe962560bc 100644 --- a/yarn-project/ethereum/src/deploy_l1_contracts.ts +++ b/yarn-project/ethereum/src/deploy_l1_contracts.ts @@ -3,9 +3,8 @@ import { EthAddress } from '@aztec/foundation/eth-address'; import { type Fr } from '@aztec/foundation/fields'; import { type DebugLogger } from '@aztec/foundation/log'; -import type { Abi, AbiConstructor, Narrow } from 'abitype'; +import type { Abi, Narrow } from 'abitype'; import { - type AbiFunction, type Account, type Chain, type Hex, @@ -90,10 +89,6 @@ export interface L1ContractArtifactsForDeployment { * Fee juice portal contract artifacts. Optional for now as gas is not strictly enforced */ feeJuicePortal: ContractArtifacts; - /** - * Proof commitment escrow. Either mock or actual implementation. - */ - proofCommitmentEscrow: ContractArtifacts; } export interface DeployL1ContractsArgs { @@ -117,10 +112,6 @@ export interface DeployL1ContractsArgs { * The initial validators for the rollup contract. */ initialValidators?: EthAddress[]; - /** - * Whether to deploy the real proof commitment escrow as opposed to the mock. - */ - useRealProofCommitmentEscrow?: boolean; } export type L1Clients = { @@ -216,19 +207,8 @@ export const deployL1Contracts = async ( logger.info(`Deployed Gas Portal at ${feeJuicePortalAddress}`); - // Mock implementation of escrow takes no arguments - const proofCommitmentEscrow = await deployer.deploy( - contractsToDeploy.proofCommitmentEscrow, - (contractsToDeploy.proofCommitmentEscrow.contractAbi as Abi).find( - (fn): fn is AbiConstructor => fn.type === 'constructor', - )?.inputs.length === 0 - ? [] - : [feeJuiceAddress.toString()], - ); - const rollupAddress = await deployer.deploy(contractsToDeploy.rollup, [ getAddress(feeJuicePortalAddress.toString()), - proofCommitmentEscrow.toString(), args.vkTreeRoot.toString(), account.address.toString(), args.initialValidators?.map(v => v.toString()) ?? [], @@ -259,18 +239,6 @@ export const deployL1Contracts = async ( // Transaction hashes to await const txHashes: Hex[] = []; - // Remove this conditional once we dump the MockProofCommitmentEscrow - if ( - (contractsToDeploy.proofCommitmentEscrow.contractAbi as Abi).find(fn => (fn as AbiFunction).name === 'initialize') - ) { - const proofCommitmentEscrowContract = getContract({ - address: proofCommitmentEscrow.toString(), - abi: contractsToDeploy.proofCommitmentEscrow.contractAbi, - client: walletClient, - }); - txHashes.push(await proofCommitmentEscrowContract.write.initialize([rollupAddress.toString()])); - } - // @note This value MUST match what is in `constants.nr`. It is currently specified here instead of just importing // because there is circular dependency hell. This is a temporary solution. #3342 // @todo #8084 diff --git a/yarn-project/foundation/src/config/env_var.ts b/yarn-project/foundation/src/config/env_var.ts index 9f345739847..d20de524be5 100644 --- a/yarn-project/foundation/src/config/env_var.ts +++ b/yarn-project/foundation/src/config/env_var.ts @@ -105,8 +105,6 @@ export type EnvVar = | 'QUOTE_PROVIDER_BASIS_POINT_FEE' | 'QUOTE_PROVIDER_BOND_AMOUNT' | 'QUOTE_PROVIDER_URL' - | 'PROVER_TARGET_STAKE_AMOUNT' - | 'PROVER_MINIMUM_STAKE_AMOUNT' | 'REGISTRY_CONTRACT_ADDRESS' | 'ROLLUP_CONTRACT_ADDRESS' | 'SEQ_ALLOWED_SETUP_FN' diff --git a/yarn-project/foundation/src/config/index.ts b/yarn-project/foundation/src/config/index.ts index 48cbe0301a7..a075be3fccf 100644 --- a/yarn-project/foundation/src/config/index.ts +++ b/yarn-project/foundation/src/config/index.ts @@ -72,7 +72,7 @@ export function numberConfigHelper(defaultVal: number): Pick { +export function bigintConfigHelper(defaultVal: bigint): Pick { return { parseEnv: (val: string) => BigInt(val), defaultValue: defaultVal, diff --git a/yarn-project/l1-artifacts/scripts/generate-artifacts.sh b/yarn-project/l1-artifacts/scripts/generate-artifacts.sh index 6728a894d1d..2903b4ca429 100755 --- a/yarn-project/l1-artifacts/scripts/generate-artifacts.sh +++ b/yarn-project/l1-artifacts/scripts/generate-artifacts.sh @@ -21,9 +21,6 @@ CONTRACTS=( "l1-contracts:FeeJuicePortal" "l1-contracts:MockVerifier" "l1-contracts:IVerifier" - "l1-contracts:IProofCommitmentEscrow" - "l1-contracts:ProofCommitmentEscrow" - "l1-contracts:MockProofCommitmentEscrow" ) diff --git a/yarn-project/prover-node/package.json b/yarn-project/prover-node/package.json index b7130d53215..590166c5c42 100644 --- a/yarn-project/prover-node/package.json +++ b/yarn-project/prover-node/package.json @@ -89,4 +89,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/yarn-project/prover-node/src/bond/bond-manager.test.ts b/yarn-project/prover-node/src/bond/bond-manager.test.ts deleted file mode 100644 index e2d6b14eb6d..00000000000 --- a/yarn-project/prover-node/src/bond/bond-manager.test.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { EthAddress } from '@aztec/circuits.js'; - -import { type MockProxy, mock } from 'jest-mock-extended'; - -import { BondManager } from '../bond/bond-manager.js'; -import { type EscrowContract } from '../bond/escrow-contract.js'; -import { type TokenContract } from '../bond/token-contract.js'; - -describe('BondManager', () => { - let bondManager: BondManager; - - let tokenContract: MockProxy; - let escrowContract: MockProxy; - - beforeEach(() => { - tokenContract = mock(); - escrowContract = mock(); - - escrowContract.getEscrowAddress.mockReturnValue(EthAddress.random()); - tokenContract.getBalance.mockResolvedValue(10000n); - bondManager = new BondManager(tokenContract, escrowContract, 100n, 1000n); - }); - - it('ensures bond if current bond is below minimum', async () => { - escrowContract.getProverDeposit.mockResolvedValue(50n); - - await bondManager.ensureBond(); - - expect(escrowContract.getProverDeposit).toHaveBeenCalled(); - expect(tokenContract.ensureAllowance).toHaveBeenCalledWith(escrowContract.getEscrowAddress()); - expect(escrowContract.depositProverBond).toHaveBeenCalledWith(950n); - }); - - it('does not ensure bond if current bond is above minimum', async () => { - escrowContract.getProverDeposit.mockResolvedValue(200n); - - await bondManager.ensureBond(); - - expect(escrowContract.getProverDeposit).toHaveBeenCalled(); - expect(tokenContract.ensureAllowance).not.toHaveBeenCalled(); - expect(escrowContract.depositProverBond).not.toHaveBeenCalled(); - }); - - it('throws error if not enough balance to top-up bond', async () => { - escrowContract.getProverDeposit.mockResolvedValue(50n); - tokenContract.getBalance.mockResolvedValue(100n); - - await expect(bondManager.ensureBond()).rejects.toThrow(/Not enough balance/i); - }); - - it('overrides minimum bond threshold', async () => { - escrowContract.getProverDeposit.mockResolvedValue(150n); - - await bondManager.ensureBond(); - expect(escrowContract.depositProverBond).not.toHaveBeenCalled(); - - await bondManager.ensureBond(200n); - expect(escrowContract.getProverDeposit).toHaveBeenCalled(); - expect(tokenContract.ensureAllowance).toHaveBeenCalled(); - expect(escrowContract.depositProverBond).toHaveBeenCalledWith(850n); - }); - - it('overrides target bond threshold', async () => { - escrowContract.getProverDeposit.mockResolvedValue(150n); - - await bondManager.ensureBond(); - expect(escrowContract.depositProverBond).not.toHaveBeenCalled(); - - await bondManager.ensureBond(2000n); - expect(escrowContract.getProverDeposit).toHaveBeenCalled(); - expect(tokenContract.ensureAllowance).toHaveBeenCalled(); - expect(escrowContract.depositProverBond).toHaveBeenCalledWith(1850n); - }); -}); diff --git a/yarn-project/prover-node/src/bond/bond-manager.ts b/yarn-project/prover-node/src/bond/bond-manager.ts deleted file mode 100644 index 1f2c8e6bd99..00000000000 --- a/yarn-project/prover-node/src/bond/bond-manager.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { createDebugLogger } from '@aztec/foundation/log'; - -import { type EscrowContract } from './escrow-contract.js'; -import { type TokenContract } from './token-contract.js'; - -export class BondManager { - private logger = createDebugLogger('aztec:prover-node:bond-manager'); - - constructor( - private readonly tokenContract: TokenContract, - private readonly escrowContract: EscrowContract, - /** Minimum escrowed bond. A top-up will be issued once this threshold is hit. */ - public minimumAmount: bigint, - /** Target escrowed bond. Top-up will target this value. */ - public targetAmount: bigint, - ) {} - - /** - * Ensures the bond is at least minimumBond, or sends a tx to deposit the remaining to reach targetBond. - * @param overrideMinimum - Override the minimum bond threshold. Also overrides target if it is higher. - */ - public async ensureBond(overrideMinimum?: bigint) { - const minimum = overrideMinimum ?? this.minimumAmount; - const target = overrideMinimum && overrideMinimum > this.targetAmount ? overrideMinimum : this.targetAmount; - - try { - const current = await this.escrowContract.getProverDeposit(); - if (current > minimum) { - this.logger.debug(`Current prover bond ${current} is above minimum ${minimum}`); - return; - } - - const topUpAmount = target - current; - this.logger.verbose(`Prover bond top-up ${topUpAmount} required to get ${current} to target ${target}`); - - const balance = await this.tokenContract.getBalance(); - if (balance < topUpAmount) { - throw new Error(`Not enough balance to top-up prover bond: ${balance} < ${topUpAmount}`); - } - - await this.tokenContract.ensureAllowance(this.escrowContract.getEscrowAddress()); - await this.escrowContract.depositProverBond(topUpAmount); - this.logger.verbose(`Prover bond top-up of ${topUpAmount} completed`); - } catch (err) { - throw new Error(`Could not set prover bond: ${err}`); - } - } -} diff --git a/yarn-project/prover-node/src/bond/config.ts b/yarn-project/prover-node/src/bond/config.ts deleted file mode 100644 index d6a465f89ba..00000000000 --- a/yarn-project/prover-node/src/bond/config.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { type ConfigMappingsType, bigintConfigHelper, getConfigFromMappings } from '@aztec/foundation/config'; - -export type ProverBondManagerConfig = { - proverMinimumStakeAmount: bigint; - proverTargetStakeAmount?: bigint; -}; - -export const proverBondManagerConfigMappings: ConfigMappingsType = { - proverMinimumStakeAmount: { - env: 'PROVER_MINIMUM_STAKE_AMOUNT', - description: - 'Minimum amount to ensure is staked in the escrow contract for this prover. Prover node will top up whenever escrow falls below this number.', - ...bigintConfigHelper(100000n), - }, - proverTargetStakeAmount: { - env: 'PROVER_TARGET_STAKE_AMOUNT', - description: - 'Target amount to ensure is staked in the escrow contract for this prover. Prover node will top up to this value. Defaults to the minimum amount.', - ...bigintConfigHelper(), - }, -}; - -export function getProverBondManagerConfigFromEnv(): ProverBondManagerConfig { - return getConfigFromMappings(proverBondManagerConfigMappings); -} diff --git a/yarn-project/prover-node/src/bond/escrow-contract.ts b/yarn-project/prover-node/src/bond/escrow-contract.ts deleted file mode 100644 index 362059babd7..00000000000 --- a/yarn-project/prover-node/src/bond/escrow-contract.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { EthAddress } from '@aztec/circuits.js'; -import { IProofCommitmentEscrowAbi } from '@aztec/l1-artifacts'; - -import { - type Chain, - type Client, - type GetContractReturnType, - type HttpTransport, - type PrivateKeyAccount, - type PublicActions, - type PublicRpcSchema, - type WalletActions, - type WalletClient, - type WalletRpcSchema, - getContract, -} from 'viem'; - -export class EscrowContract { - private escrow: GetContractReturnType< - typeof IProofCommitmentEscrowAbi, - WalletClient - >; - - constructor( - private readonly client: Client< - HttpTransport, - Chain, - PrivateKeyAccount, - [...WalletRpcSchema, ...PublicRpcSchema], - PublicActions & WalletActions - >, - address: EthAddress, - ) { - this.escrow = getContract({ address: address.toString(), abi: IProofCommitmentEscrowAbi, client }); - } - - /** Returns the deposit of the publisher sender address on the proof commitment escrow contract. */ - public async getProverDeposit() { - return await this.escrow.read.deposits([this.getSenderAddress().toString()]); - } - - /** - * Deposits the given amount of tokens into the proof commitment escrow contract. Returns once the tx is mined. - * @param amount - The amount to deposit. - */ - public async depositProverBond(amount: bigint) { - const hash = await this.escrow.write.deposit([amount]); - await this.client.waitForTransactionReceipt({ hash }); - } - - /** Returns the sender address for the client. */ - public getSenderAddress(): EthAddress { - return EthAddress.fromString(this.client.account.address); - } - - public getEscrowAddress(): EthAddress { - return EthAddress.fromString(this.escrow.address); - } - - public async getTokenAddress(): Promise { - return EthAddress.fromString(await this.escrow.read.token()); - } -} diff --git a/yarn-project/prover-node/src/bond/factory.ts b/yarn-project/prover-node/src/bond/factory.ts deleted file mode 100644 index 0925c5ceefc..00000000000 --- a/yarn-project/prover-node/src/bond/factory.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { EthAddress } from '@aztec/circuits.js'; -import { compact } from '@aztec/foundation/collection'; -import { type RollupAbi } from '@aztec/l1-artifacts'; - -import { - type Chain, - type Client, - type GetContractReturnType, - type HttpTransport, - type PrivateKeyAccount, - type PublicActions, - type PublicClient, - type PublicRpcSchema, - type WalletActions, - type WalletRpcSchema, -} from 'viem'; - -import { BondManager } from './bond-manager.js'; -import { type ProverBondManagerConfig, getProverBondManagerConfigFromEnv } from './config.js'; -import { EscrowContract } from './escrow-contract.js'; -import { TokenContract } from './token-contract.js'; - -export async function createBondManager( - rollupContract: GetContractReturnType, - client: Client< - HttpTransport, - Chain, - PrivateKeyAccount, - [...WalletRpcSchema, ...PublicRpcSchema], - PublicActions & WalletActions - >, - overrides: Partial = {}, -) { - const config = { ...getProverBondManagerConfigFromEnv(), ...compact(overrides) }; - const { proverMinimumStakeAmount: minimumStake, proverTargetStakeAmount: targetStake } = config; - - const escrowContractAddress = EthAddress.fromString(await rollupContract.read.PROOF_COMMITMENT_ESCROW()); - const escrow = new EscrowContract(client, escrowContractAddress); - - const tokenContractAddress = await escrow.getTokenAddress(); - const token = new TokenContract(client, tokenContractAddress); - - return new BondManager(token, escrow, minimumStake, targetStake ?? minimumStake); -} diff --git a/yarn-project/prover-node/src/bond/index.ts b/yarn-project/prover-node/src/bond/index.ts deleted file mode 100644 index 0a1e5ba57fe..00000000000 --- a/yarn-project/prover-node/src/bond/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { BondManager } from './bond-manager.js'; -export * from './factory.js'; diff --git a/yarn-project/prover-node/src/bond/token-contract.ts b/yarn-project/prover-node/src/bond/token-contract.ts deleted file mode 100644 index f9b89094b4d..00000000000 --- a/yarn-project/prover-node/src/bond/token-contract.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { EthAddress } from '@aztec/circuits.js'; -import { createDebugLogger } from '@aztec/foundation/log'; -import { IERC20Abi } from '@aztec/l1-artifacts'; - -import { - type Chain, - type Client, - type GetContractReturnType, - type HttpTransport, - type PrivateKeyAccount, - type PublicActions, - type PublicRpcSchema, - type WalletActions, - type WalletClient, - type WalletRpcSchema, - getContract, -} from 'viem'; - -const MAX_ALLOWANCE = (1n << 256n) - 1n; -const MIN_ALLOWANCE = 1n << 255n; - -export class TokenContract { - private token: GetContractReturnType>; - private logger = createDebugLogger('aztec:prover-node:token-contract'); - - constructor( - private readonly client: Client< - HttpTransport, - Chain, - PrivateKeyAccount, - [...WalletRpcSchema, ...PublicRpcSchema], - PublicActions & WalletActions - >, - address: EthAddress, - ) { - this.token = getContract({ address: address.toString(), abi: IERC20Abi, client }); - } - - /** - * Ensures the allowed address has near-maximum allowance, or sets it otherwise. - * Returns once allowance tx is mined successfully. - * @param allowed - Who to allow. - */ - public async ensureAllowance(allowed: EthAddress) { - const allowance = await this.token.read.allowance([this.getSenderAddress().toString(), allowed.toString()]); - if (allowance < MIN_ALLOWANCE) { - this.logger.verbose(`Approving max allowance for ${allowed.toString()}`); - const hash = await this.token.write.approve([allowed.toString(), MAX_ALLOWANCE]); - await this.client.waitForTransactionReceipt({ hash }); - } - } - - /** Returns the sender address. */ - public getSenderAddress(): EthAddress { - return EthAddress.fromString(this.client.account.address); - } - - /** Returns the balance of the sender. */ - public async getBalance() { - return await this.token.read.balanceOf([this.getSenderAddress().toString()]); - } -} diff --git a/yarn-project/prover-node/src/config.ts b/yarn-project/prover-node/src/config.ts index 8049b0d494e..2a4d5a99ec5 100644 --- a/yarn-project/prover-node/src/config.ts +++ b/yarn-project/prover-node/src/config.ts @@ -16,7 +16,6 @@ import { } from '@aztec/sequencer-client'; import { type WorldStateConfig, getWorldStateConfigFromEnv, worldStateConfigMappings } from '@aztec/world-state'; -import { type ProverBondManagerConfig, proverBondManagerConfigMappings } from './bond/config.js'; import { type ProverCoordinationConfig, getTxProviderConfigFromEnv, @@ -29,7 +28,6 @@ export type ProverNodeConfig = ArchiverConfig & PublisherConfig & TxSenderConfig & ProverCoordinationConfig & - ProverBondManagerConfig & QuoteProviderConfig & { proverNodeMaxPendingJobs: number; proverNodePollingIntervalMs: number; @@ -82,7 +80,6 @@ export const proverNodeConfigMappings: ConfigMappingsType = { ...getTxSenderConfigMappings('PROVER'), ...proverCoordinationConfigMappings, ...quoteProviderConfigMappings, - ...proverBondManagerConfigMappings, ...specificProverNodeConfigMappings, }; @@ -96,6 +93,5 @@ export function getProverNodeConfigFromEnv(): ProverNodeConfig { ...getTxProviderConfigFromEnv(), ...getConfigFromMappings(quoteProviderConfigMappings), ...getConfigFromMappings(specificProverNodeConfigMappings), - ...getConfigFromMappings(proverBondManagerConfigMappings), }; } diff --git a/yarn-project/prover-node/src/factory.ts b/yarn-project/prover-node/src/factory.ts index 6d376676761..52b4431a958 100644 --- a/yarn-project/prover-node/src/factory.ts +++ b/yarn-project/prover-node/src/factory.ts @@ -13,7 +13,6 @@ import { createWorldStateSynchronizer } from '@aztec/world-state'; import { createPublicClient, getAddress, getContract, http } from 'viem'; -import { createBondManager } from './bond/factory.js'; import { type ProverNodeConfig, type QuoteProviderConfig } from './config.js'; import { ClaimsMonitor } from './monitors/claims-monitor.js'; import { EpochMonitor } from './monitors/epoch-monitor.js'; @@ -61,10 +60,6 @@ export async function createProverNode( const claimsMonitor = new ClaimsMonitor(publisher, proverNodeConfig); const epochMonitor = new EpochMonitor(archiver, proverNodeConfig); - const rollupContract = publisher.getRollupContract(); - const walletClient = publisher.getClient(); - const bondManager = await createBondManager(rollupContract, walletClient, config); - return new ProverNode( prover!, publisher, @@ -78,7 +73,6 @@ export async function createProverNode( quoteSigner, claimsMonitor, epochMonitor, - bondManager, telemetry, proverNodeConfig, ); diff --git a/yarn-project/prover-node/src/prover-node.test.ts b/yarn-project/prover-node/src/prover-node.test.ts index 55ba4578139..5e764ed73b4 100644 --- a/yarn-project/prover-node/src/prover-node.test.ts +++ b/yarn-project/prover-node/src/prover-node.test.ts @@ -22,7 +22,6 @@ import { type ContractDataSource } from '@aztec/types/contracts'; import { type MockProxy, mock } from 'jest-mock-extended'; -import { type BondManager } from './bond/bond-manager.js'; import { type EpochProvingJob } from './job/epoch-proving-job.js'; import { ClaimsMonitor } from './monitors/claims-monitor.js'; import { EpochMonitor } from './monitors/epoch-monitor.js'; @@ -42,7 +41,6 @@ describe('prover-node', () => { let simulator: MockProxy; let quoteProvider: MockProxy; let quoteSigner: MockProxy; - let bondManager: MockProxy; let telemetryClient: NoopTelemetryClient; let config: ProverNodeOptions; @@ -79,25 +77,6 @@ describe('prover-node', () => { quote: Pick = partialQuote, ) => expect.objectContaining({ payload: toQuotePayload(epoch, quote) }); - const createProverNode = (claimsMonitor: ClaimsMonitor, epochMonitor: EpochMonitor) => - new TestProverNode( - prover, - publisher, - l2BlockSource, - l1ToL2MessageSource, - contractDataSource, - worldState, - coordination, - simulator, - quoteProvider, - quoteSigner, - claimsMonitor, - epochMonitor, - bondManager, - telemetryClient, - config, - ); - beforeEach(() => { prover = mock(); publisher = mock(); @@ -109,7 +88,6 @@ describe('prover-node', () => { simulator = mock(); quoteProvider = mock(); quoteSigner = mock(); - bondManager = mock(); telemetryClient = new NoopTelemetryClient(); config = { maxPendingJobs: 3, pollingIntervalMs: 10 }; @@ -151,7 +129,22 @@ describe('prover-node', () => { claimsMonitor = mock(); epochMonitor = mock(); - proverNode = createProverNode(claimsMonitor, epochMonitor); + proverNode = new TestProverNode( + prover, + publisher, + l2BlockSource, + l1ToL2MessageSource, + contractDataSource, + worldState, + coordination, + simulator, + quoteProvider, + quoteSigner, + claimsMonitor, + epochMonitor, + telemetryClient, + config, + ); }); it('sends a quote on a finished epoch', async () => { @@ -247,7 +240,22 @@ describe('prover-node', () => { Promise.resolve(epochNumber <= lastEpochComplete), ); - proverNode = createProverNode(claimsMonitor, epochMonitor); + proverNode = new TestProverNode( + prover, + publisher, + l2BlockSource, + l1ToL2MessageSource, + contractDataSource, + worldState, + coordination, + simulator, + quoteProvider, + quoteSigner, + claimsMonitor, + epochMonitor, + telemetryClient, + config, + ); }); it('sends a quote on initial sync', async () => { diff --git a/yarn-project/prover-node/src/prover-node.ts b/yarn-project/prover-node/src/prover-node.ts index 0327a22af93..80650603043 100644 --- a/yarn-project/prover-node/src/prover-node.ts +++ b/yarn-project/prover-node/src/prover-node.ts @@ -17,7 +17,6 @@ import { PublicProcessorFactory, type SimulationProvider } from '@aztec/simulato import { type TelemetryClient } from '@aztec/telemetry-client'; import { type ContractDataSource } from '@aztec/types/contracts'; -import { type BondManager } from './bond/bond-manager.js'; import { EpochProvingJob, type EpochProvingJobState } from './job/epoch-proving-job.js'; import { ProverNodeMetrics } from './metrics.js'; import { type ClaimsMonitor, type ClaimsMonitorHandler } from './monitors/claims-monitor.js'; @@ -57,7 +56,6 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler { private readonly quoteSigner: QuoteSigner, private readonly claimsMonitor: ClaimsMonitor, private readonly epochsMonitor: EpochMonitor, - private readonly bondManager: BondManager, private readonly telemetryClient: TelemetryClient, options: Partial = {}, ) { @@ -70,6 +68,12 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler { this.metrics = new ProverNodeMetrics(telemetryClient, 'ProverNode'); } + async ensureBond() { + // Ensure the prover has enough bond to submit proofs + // Can we just run this at the beginning and forget about it? + // Or do we need to check periodically? Or only when we get slashed? How do we know we got slashed? + } + async handleClaim(proofClaim: EpochProofClaim): Promise { if (proofClaim.epochToProve === this.latestEpochWeAreProving) { this.log.verbose(`Already proving claim for epoch ${proofClaim.epochToProve}`); @@ -82,13 +86,6 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler { } catch (err) { this.log.error(`Error handling claim for epoch ${proofClaim.epochToProve}`, err); } - - try { - // Staked amounts are lowered after a claim, so this is a good time for doing a top-up if needed - await this.bondManager.ensureBond(); - } catch (err) { - this.log.error(`Error ensuring prover bond after handling claim for epoch ${proofClaim.epochToProve}`, err); - } } /** @@ -118,7 +115,6 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler { */ async handleEpochCompleted(epochNumber: bigint): Promise { try { - // Construct a quote for the epoch const blocks = await this.l2BlockSource.getBlocksForEpoch(epochNumber); const partialQuote = await this.quoteProvider.getQuote(Number(epochNumber), blocks); if (!partialQuote) { @@ -126,10 +122,6 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler { return; } - // Ensure we have deposited enough funds for sending this quote - await this.bondManager.ensureBond(partialQuote.bondAmount); - - // Assemble and sign full quote const quote = EpochProofQuotePayload.from({ ...partialQuote, epochToProve: BigInt(epochNumber), @@ -137,8 +129,6 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler { validUntilSlot: partialQuote.validUntilSlot ?? BigInt(Number.MAX_SAFE_INTEGER), // Should we constrain this? }); const signed = await this.quoteSigner.sign(quote); - - // Send it to the coordinator await this.sendEpochProofQuote(signed); } catch (err) { this.log.error(`Error handling epoch completed`, err); @@ -146,12 +136,11 @@ export class ProverNode implements ClaimsMonitorHandler, EpochMonitorHandler { } /** - * Starts the prover node so it periodically checks for unproven epochs in the unfinalised chain from L1 and sends - * quotes for them, as well as monitors the claims for the epochs it has sent quotes for and starts proving jobs. - * This method returns once the prover node has deposited an initial bond into the escrow contract. + * Starts the prover node so it periodically checks for unproven blocks in the unfinalised chain from L1 and proves them. + * This may change once we implement a prover coordination mechanism. */ async start() { - await this.bondManager.ensureBond(); + await this.ensureBond(); this.epochsMonitor.start(this); this.claimsMonitor.start(this); this.log.info('Started ProverNode', this.options); diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index adbf05e29dd..79ea85ffae0 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -32,19 +32,13 @@ import pick from 'lodash.pick'; import { inspect } from 'util'; import { type BaseError, - type Chain, - type Client, ContractFunctionRevertedError, type GetContractReturnType, type Hex, type HttpTransport, type PrivateKeyAccount, - type PublicActions, type PublicClient, - type PublicRpcSchema, - type WalletActions, type WalletClient, - type WalletRpcSchema, createPublicClient, createWalletClient, encodeFunctionData, @@ -53,7 +47,6 @@ import { getContract, hexToBytes, http, - publicActions, } from 'viem'; import { privateKeyToAccount } from 'viem/accounts'; import type * as chains from 'viem/chains'; @@ -139,9 +132,7 @@ export class L1Publisher { typeof RollupAbi, WalletClient >; - private publicClient: PublicClient; - private walletClient: WalletClient; private account: PrivateKeyAccount; public static PROPOSE_GAS_GUESS: bigint = 500_000n; @@ -155,8 +146,7 @@ export class L1Publisher { const chain = createEthereumChain(rpcUrl, chainId); this.account = privateKeyToAccount(publisherPrivateKey); this.log.debug(`Publishing from address ${this.account.address}`); - - this.walletClient = createWalletClient({ + const walletClient = createWalletClient({ account: this.account, chain: chain.chainInfo, transport: http(chain.rpcUrl), @@ -170,7 +160,7 @@ export class L1Publisher { this.rollupContract = getContract({ address: getAddress(l1Contracts.rollupAddress.toString()), abi: RollupAbi, - client: this.walletClient, + client: walletClient, }); } @@ -178,23 +168,6 @@ export class L1Publisher { return EthAddress.fromString(this.account.address); } - public getClient(): Client< - HttpTransport, - Chain, - PrivateKeyAccount, - [...WalletRpcSchema, ...PublicRpcSchema], - PublicActions & WalletActions - > { - return this.walletClient.extend(publicActions); - } - - public getRollupContract(): GetContractReturnType< - typeof RollupAbi, - WalletClient - > { - return this.rollupContract; - } - /** * @notice Calls `canProposeAtTime` with the time of the next Ethereum block and the sender address *