1
1
#!/usr/bin/env -S node --no-warnings
2
2
import { type AztecNodeConfig , AztecNodeService , getConfigEnvVars } from '@aztec/aztec-node' ;
3
- import { AnvilTestWatcher , EthCheatCodes , SignerlessWallet , retryUntil } from '@aztec/aztec.js' ;
3
+ import { AnvilTestWatcher , EthCheatCodes , SignerlessWallet } from '@aztec/aztec.js' ;
4
4
import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint' ;
5
5
import { type BlobSinkClientInterface , createBlobSinkClient } from '@aztec/blob-sink/client' ;
6
6
import { type AztecNode } from '@aztec/circuit-types' ;
7
7
import { setupCanonicalL2FeeJuice } from '@aztec/cli/setup-contracts' ;
8
8
import {
9
- type DeployL1Contracts ,
10
9
NULL_KEY ,
11
10
createEthereumChain ,
12
11
deployL1Contracts ,
13
12
getL1ContractsConfigEnvVars ,
13
+ waitForPublicClient ,
14
14
} from '@aztec/ethereum' ;
15
15
import { createLogger } from '@aztec/foundation/log' ;
16
16
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vks' ;
@@ -32,39 +32,6 @@ const logger = createLogger('sandbox');
32
32
33
33
const localAnvil = foundry ;
34
34
35
- /**
36
- * Helper function that waits for the Ethereum RPC server to respond before deploying L1 contracts.
37
- */
38
- async function waitThenDeploy ( config : AztecNodeConfig , deployFunction : ( ) = > Promise < DeployL1Contracts > ) {
39
- const chain = createEthereumChain ( config . l1RpcUrl , config . l1ChainId ) ;
40
- // wait for ETH RPC to respond to a request.
41
- const publicClient = createPublicClient ( {
42
- chain : chain . chainInfo ,
43
- transport : httpViemTransport ( chain . rpcUrl ) ,
44
- } ) ;
45
- const l1ChainID = await retryUntil (
46
- async ( ) => {
47
- let chainId = 0 ;
48
- try {
49
- chainId = await publicClient . getChainId ( ) ;
50
- } catch ( err ) {
51
- logger . warn ( `Failed to connect to Ethereum node at ${ chain . rpcUrl } . Retrying...` ) ;
52
- }
53
- return chainId ;
54
- } ,
55
- 'isEthRpcReady' ,
56
- 600 ,
57
- 1 ,
58
- ) ;
59
-
60
- if ( ! l1ChainID ) {
61
- throw Error ( `Ethereum node unresponsive at ${ chain . rpcUrl } .` ) ;
62
- }
63
-
64
- // Deploy L1 contracts
65
- return await deployFunction ( ) ;
66
- }
67
-
68
35
/**
69
36
* Function to deploy our L1 contracts to the sandbox L1
70
37
* @param aztecNodeConfig - The Aztec Node Config
@@ -80,15 +47,22 @@ export async function deployContractsToL1(
80
47
? createEthereumChain ( aztecNodeConfig . l1RpcUrl , aztecNodeConfig . l1ChainId )
81
48
: { chainInfo : localAnvil } ;
82
49
83
- const l1Contracts = await waitThenDeploy ( aztecNodeConfig , async ( ) =>
84
- deployL1Contracts ( aztecNodeConfig . l1RpcUrl , hdAccount , chain . chainInfo , contractDeployLogger , {
50
+ await waitForPublicClient ( aztecNodeConfig ) ;
51
+
52
+ const l1Contracts = await deployL1Contracts (
53
+ aztecNodeConfig . l1RpcUrl ,
54
+ hdAccount ,
55
+ chain . chainInfo ,
56
+ contractDeployLogger ,
57
+ {
58
+ ...getL1ContractsConfigEnvVars ( ) , // TODO: We should not need to be loading config from env again, caller should handle this
59
+ ...aztecNodeConfig ,
85
60
l2FeeJuiceAddress : ProtocolContractAddress . FeeJuice ,
86
61
vkTreeRoot : await getVKTreeRoot ( ) ,
87
62
protocolContractTreeRoot,
88
63
assumeProvenThrough : opts . assumeProvenThroughBlockNumber ,
89
64
salt : opts . salt ,
90
- ...getL1ContractsConfigEnvVars ( ) ,
91
- } ) ,
65
+ } ,
92
66
) ;
93
67
94
68
aztecNodeConfig . l1Contracts = l1Contracts . l1ContractAddresses ;
0 commit comments