@@ -469,6 +469,12 @@ export async function setupAnvilTestStack(): Promise<AnvilTestStack> {
469469 parentChainBeaconRpcUrl : sepoliaBeaconRpc ,
470470 } ) ;
471471
472+ if ( l2NodeConfig . execution === undefined || l2NodeConfig . execution . sequencer === undefined ) {
473+ throw new Error ( 'L2 node config execution is undefined' ) ;
474+ }
475+
476+ l2NodeConfig . execution . sequencer [ 'max-block-speed' ] = '100ms' ;
477+
472478 if (
473479 l2NodeConfig . node === undefined ||
474480 l2NodeConfig . node [ 'batch-poster' ] === undefined ||
@@ -558,6 +564,15 @@ export async function setupAnvilTestStack(): Promise<AnvilTestStack> {
558564 } ) ,
559565 account : l2BlockAdvancerAccount ,
560566 } ) ;
567+ const fundL2BlockAdvancerTxHash = await l2WalletClient . sendTransaction ( {
568+ account : harnessDeployer ,
569+ chain : l2BootstrapChain ,
570+ to : l2BlockAdvancerAccount . address ,
571+ value : parseEther ( '1' ) ,
572+ } ) ;
573+ await l2Client . waitForTransactionReceipt ( { hash : fundL2BlockAdvancerTxHash } ) ;
574+ startBlockAdvancing ( l2BlockAdvancer ) ;
575+ persistentBlockAdvancers . push ( l2BlockAdvancer ) ;
561576
562577 console . log ( 'Configuring L2 fee settings...' ) ;
563578 await configureL2Fees ( l2Client , l2WalletClient , harnessDeployer ) ;
@@ -584,13 +599,6 @@ export async function setupAnvilTestStack(): Promise<AnvilTestStack> {
584599
585600 console . log ( 'L2 custom gas token deployed\n' ) ;
586601
587- const tx = await l2Signer . sendTransaction ( {
588- to : l2BlockAdvancerAccount . address ,
589- value : parseEther ( '1' ) ,
590- ...testConstants . LOW_L2_FEE_OVERRIDES ,
591- } ) ;
592- await tx . wait ( ) ;
593-
594602 console . log ( 'Deploying L2 rollup creator...' ) ;
595603 const l2RollupCreator = await deployRollupCreator ( {
596604 rpcUrl : l2RpcUrl ,
@@ -691,6 +699,12 @@ export async function setupAnvilTestStack(): Promise<AnvilTestStack> {
691699 parentChainRpcUrl : `http://${ l2ContainerName } :${ l2RpcPort } ` ,
692700 } ) ;
693701
702+ if ( l3NodeConfig . execution === undefined || l3NodeConfig . execution . sequencer === undefined ) {
703+ throw new Error ( 'L3 node config execution is undefined' ) ;
704+ }
705+
706+ l3NodeConfig . execution . sequencer [ 'max-block-speed' ] = '100ms' ;
707+
694708 if (
695709 l3NodeConfig . node === undefined ||
696710 l3NodeConfig . node [ 'batch-poster' ] === undefined ||
@@ -743,11 +757,13 @@ export async function setupAnvilTestStack(): Promise<AnvilTestStack> {
743757 failIfContainerExited : l3ContainerName ,
744758 } ) ;
745759 console . log ( 'L3 Nitro node is ready\n' ) ;
760+
746761 const l3Client = createPublicClient ( {
747762 chain : l3Chain ,
748763 transport : http ( l3RpcUrl ) ,
749764 pollingInterval : testConstants . POLLING_INTERVAL ,
750765 } ) ;
766+
751767 const l3WalletClient = createWalletClient ( {
752768 chain : l3Chain ,
753769 transport : http ( l3RpcUrl ) ,
@@ -774,6 +790,17 @@ export async function setupAnvilTestStack(): Promise<AnvilTestStack> {
774790 } ) ;
775791 console . log ( 'Deployer funded on L3\n' ) ;
776792
793+ const l3BlockAdvancer = createBlockAdvancer ( {
794+ publicClient : l3Client ,
795+ walletClient : createWalletClient ( {
796+ chain : l3Chain ,
797+ transport : http ( l3RpcUrl ) ,
798+ account : l3BlockAdvancerAccount ,
799+ pollingInterval : testConstants . POLLING_INTERVAL ,
800+ } ) ,
801+ account : l3BlockAdvancerAccount ,
802+ } ) ;
803+
777804 console . log ( 'Funding block advancer on L3...' ) ;
778805 const fundL3BlockAdvancerTxHash = await l3WalletClient . sendTransaction ( {
779806 account : harnessDeployer ,
@@ -784,6 +811,9 @@ export async function setupAnvilTestStack(): Promise<AnvilTestStack> {
784811 await l3Client . waitForTransactionReceipt ( { hash : fundL3BlockAdvancerTxHash } ) ;
785812 console . log ( 'Block advancer funded on L3\n' ) ;
786813
814+ startBlockAdvancing ( l3BlockAdvancer ) ;
815+ persistentBlockAdvancers . push ( l3BlockAdvancer ) ;
816+
787817 console . log ( 'Deploying L3 token bridge contracts on L2...' ) ;
788818 const { tokenBridgeContracts } = await createTokenBridge ( {
789819 rollupOwner : harnessDeployer . address ,
@@ -820,29 +850,6 @@ export async function setupAnvilTestStack(): Promise<AnvilTestStack> {
820850 } ) ;
821851 console . log ( 'L3 token bridge contracts deployed on L2\n' ) ;
822852
823- l2BlockAdvancer . publicClient = l2Client ;
824- l2BlockAdvancer . walletClient = createWalletClient ( {
825- chain : l2Chain ,
826- transport : http ( l2RpcUrl ) ,
827- account : l2BlockAdvancerAccount ,
828- pollingInterval : testConstants . POLLING_INTERVAL ,
829- } ) ;
830-
831- const l3BlockAdvancer = createBlockAdvancer ( {
832- publicClient : l3Client ,
833- walletClient : createWalletClient ( {
834- chain : l3Chain ,
835- transport : http ( l3RpcUrl ) ,
836- account : l3BlockAdvancerAccount ,
837- pollingInterval : testConstants . POLLING_INTERVAL ,
838- } ) ,
839- account : l3BlockAdvancerAccount ,
840- } ) ;
841-
842- startBlockAdvancing ( l2BlockAdvancer ) ;
843- startBlockAdvancing ( l3BlockAdvancer ) ;
844- persistentBlockAdvancers . push ( l2BlockAdvancer , l3BlockAdvancer ) ;
845-
846853 initializedEnv = {
847854 l1 : {
848855 rpcUrl : l1RpcUrl ,
@@ -896,23 +903,24 @@ export function getInitializedAnvilTestStackEnv(): AnvilTestStack {
896903 return initializedEnv ;
897904}
898905
899- export function teardownAnvilTestStack ( ) {
906+ export async function teardownAnvilTestStack ( ) {
900907 if ( teardownStarted ) {
901908 return ;
902909 }
903910 teardownStarted = true ;
904911
905- for ( const blockAdvancer of persistentBlockAdvancers ) {
906- void blockAdvancer . stop ( ) ;
907- }
912+ const blockAdvancers = persistentBlockAdvancers ;
908913 persistentBlockAdvancers = [ ] ;
909914
915+ await Promise . all ( blockAdvancers . map ( ( blockAdvancer ) => blockAdvancer . stop ( ) ) ) ;
916+
910917 if ( l1RpcCachingProxy ) {
911918 for ( const line of l1RpcCachingProxy . getSummaryLines ( ) ) {
912919 console . log ( line ) ;
913920 }
914921
915- l1RpcCachingProxy . close ( ) ;
922+ await l1RpcCachingProxy . close ( ) ;
923+ l1RpcCachingProxy = undefined ;
916924 }
917925
918926 cleanupCurrentHarnessResources ( {
0 commit comments