@aztec/sequencer-client 0.1.0-alpha23 → 0.1.0-alpha40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.tsbuildinfo +1 -1
- package/dest/block_builder/index.d.ts +2 -2
- package/dest/block_builder/index.d.ts.map +1 -1
- package/dest/block_builder/solo_block_builder.d.ts +7 -7
- package/dest/block_builder/solo_block_builder.d.ts.map +1 -1
- package/dest/block_builder/solo_block_builder.js +49 -53
- package/dest/block_builder/solo_block_builder.test.d.ts +2 -2
- package/dest/block_builder/solo_block_builder.test.d.ts.map +1 -1
- package/dest/block_builder/solo_block_builder.test.js +27 -26
- package/dest/block_builder/types.d.ts +1 -1
- package/dest/block_builder/types.d.ts.map +1 -1
- package/dest/client/sequencer-client.d.ts +1 -1
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +3 -3
- package/dest/config.d.ts +2 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +8 -5
- package/dest/global_variable_builder/global_builder.d.ts +17 -0
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +1 -1
- package/dest/global_variable_builder/viem-reader.d.ts +0 -12
- package/dest/global_variable_builder/viem-reader.d.ts.map +1 -1
- package/dest/global_variable_builder/viem-reader.js +2 -14
- package/dest/prover/empty.d.ts.map +1 -1
- package/dest/prover/empty.js +1 -1
- package/dest/prover/index.d.ts +23 -0
- package/dest/prover/index.d.ts.map +1 -1
- package/dest/publisher/config.d.ts +3 -3
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.d.ts +3 -3
- package/dest/publisher/l1-publisher.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.js +5 -3
- package/dest/publisher/l1-publisher.test.js +2 -2
- package/dest/publisher/viem-tx-sender.d.ts +4 -4
- package/dest/publisher/viem-tx-sender.d.ts.map +1 -1
- package/dest/publisher/viem-tx-sender.js +11 -11
- package/dest/sequencer/config.d.ts +1 -1
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/processed_tx.d.ts +2 -2
- package/dest/sequencer/processed_tx.d.ts.map +1 -1
- package/dest/sequencer/processed_tx.js +3 -3
- package/dest/sequencer/public_processor.d.ts +11 -10
- package/dest/sequencer/public_processor.d.ts.map +1 -1
- package/dest/sequencer/public_processor.js +24 -22
- package/dest/sequencer/public_processor.test.js +15 -17
- package/dest/sequencer/sequencer.d.ts +4 -4
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +18 -15
- package/dest/sequencer/sequencer.test.js +5 -5
- package/dest/sequencer/utils.d.ts +2 -2
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +8 -5
- package/dest/simulator/index.d.ts +2 -2
- package/dest/simulator/public_executor.d.ts +3 -20
- package/dest/simulator/public_executor.d.ts.map +1 -1
- package/dest/simulator/public_executor.js +16 -35
- package/dest/simulator/public_kernel.d.ts.map +1 -1
- package/dest/simulator/public_kernel.js +1 -1
- package/dest/simulator/rollup.d.ts.map +1 -1
- package/dest/simulator/rollup.js +1 -1
- package/package.json +10 -10
- package/src/block_builder/index.ts +3 -2
- package/src/block_builder/solo_block_builder.test.ts +46 -38
- package/src/block_builder/solo_block_builder.ts +79 -88
- package/src/block_builder/types.ts +1 -1
- package/src/client/sequencer-client.ts +3 -3
- package/src/config.ts +11 -7
- package/src/global_variable_builder/global_builder.ts +17 -0
- package/src/global_variable_builder/viem-reader.ts +5 -15
- package/src/prover/empty.ts +1 -0
- package/src/prover/index.ts +26 -0
- package/src/publisher/config.ts +3 -2
- package/src/publisher/l1-publisher.test.ts +3 -2
- package/src/publisher/l1-publisher.ts +18 -8
- package/src/publisher/viem-tx-sender.ts +14 -13
- package/src/sequencer/config.ts +1 -1
- package/src/sequencer/processed_tx.ts +3 -3
- package/src/sequencer/public_processor.test.ts +38 -18
- package/src/sequencer/public_processor.ts +33 -25
- package/src/sequencer/sequencer.test.ts +7 -5
- package/src/sequencer/sequencer.ts +20 -16
- package/src/sequencer/utils.ts +19 -11
- package/src/simulator/index.ts +2 -2
- package/src/simulator/public_executor.ts +15 -34
- package/src/simulator/public_kernel.ts +1 -0
- package/src/simulator/rollup.ts +1 -0
package/src/config.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PublisherConfig, TxSenderConfig } from './publisher/config.js';
|
|
1
|
+
import { PrivateKey } from '@aztec/circuits.js';
|
|
3
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
|
|
4
4
|
import { GlobalReaderConfig } from './global_variable_builder/index.js';
|
|
5
|
+
import { PublisherConfig, TxSenderConfig } from './publisher/config.js';
|
|
6
|
+
import { SequencerConfig } from './sequencer/config.js';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Configuration settings for the SequencerClient.
|
|
@@ -19,8 +21,8 @@ export function getConfigEnvVars(): SequencerClientConfig {
|
|
|
19
21
|
VERSION,
|
|
20
22
|
API_KEY,
|
|
21
23
|
SEQ_REQUIRED_CONFS,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
SEQ_PUBLISH_RETRY_INTERVAL_MS,
|
|
25
|
+
SEQ_TX_POLLING_INTERVAL_MS,
|
|
24
26
|
SEQ_MAX_TX_PER_BLOCK,
|
|
25
27
|
SEQ_MIN_TX_PER_BLOCK,
|
|
26
28
|
ROLLUP_CONTRACT_ADDRESS,
|
|
@@ -34,14 +36,16 @@ export function getConfigEnvVars(): SequencerClientConfig {
|
|
|
34
36
|
version: VERSION ? +VERSION : 1, // 1 is our default version
|
|
35
37
|
apiKey: API_KEY,
|
|
36
38
|
requiredConfirmations: SEQ_REQUIRED_CONFS ? +SEQ_REQUIRED_CONFS : 1,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
l1BlockPublishRetryIntervalMS: SEQ_PUBLISH_RETRY_INTERVAL_MS ? +SEQ_PUBLISH_RETRY_INTERVAL_MS : 1_000,
|
|
40
|
+
transactionPollingIntervalMS: SEQ_TX_POLLING_INTERVAL_MS ? +SEQ_TX_POLLING_INTERVAL_MS : 1_000,
|
|
39
41
|
rollupContract: ROLLUP_CONTRACT_ADDRESS ? EthAddress.fromString(ROLLUP_CONTRACT_ADDRESS) : EthAddress.ZERO,
|
|
40
42
|
inboxContract: INBOX_CONTRACT_ADDRESS ? EthAddress.fromString(INBOX_CONTRACT_ADDRESS) : EthAddress.ZERO,
|
|
41
43
|
contractDeploymentEmitterContract: CONTRACT_DEPLOYMENT_EMITTER_ADDRESS
|
|
42
44
|
? EthAddress.fromString(CONTRACT_DEPLOYMENT_EMITTER_ADDRESS)
|
|
43
45
|
: EthAddress.ZERO,
|
|
44
|
-
publisherPrivateKey:
|
|
46
|
+
publisherPrivateKey: SEQ_PUBLISHER_PRIVATE_KEY
|
|
47
|
+
? PrivateKey.fromString(SEQ_PUBLISHER_PRIVATE_KEY)
|
|
48
|
+
: new PrivateKey(Buffer.alloc(32)),
|
|
45
49
|
maxTxsPerBlock: SEQ_MAX_TX_PER_BLOCK ? +SEQ_MAX_TX_PER_BLOCK : 32,
|
|
46
50
|
minTxsPerBlock: SEQ_MIN_TX_PER_BLOCK ? +SEQ_MIN_TX_PER_BLOCK : 1,
|
|
47
51
|
};
|
|
@@ -5,8 +5,20 @@ import { createDebugLogger } from '@aztec/foundation/log';
|
|
|
5
5
|
* Reads values from L1 state that is used for the global values.
|
|
6
6
|
*/
|
|
7
7
|
export interface L1GlobalReader {
|
|
8
|
+
/**
|
|
9
|
+
* Fetches the last timestamp that a block was processed by the contract.
|
|
10
|
+
* @returns The last timestamp that a block was processed by the contract.
|
|
11
|
+
*/
|
|
8
12
|
getLastTimestamp(): Promise<bigint>;
|
|
13
|
+
/**
|
|
14
|
+
* Fetches the version of the rollup contract.
|
|
15
|
+
* @returns The version of the rollup contract.
|
|
16
|
+
*/
|
|
9
17
|
getVersion(): Promise<bigint>;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the chain id.
|
|
20
|
+
* @returns The chain id.
|
|
21
|
+
*/
|
|
10
22
|
getChainId(): Promise<bigint>;
|
|
11
23
|
}
|
|
12
24
|
|
|
@@ -14,6 +26,11 @@ export interface L1GlobalReader {
|
|
|
14
26
|
* Builds global variables from L1 state.
|
|
15
27
|
*/
|
|
16
28
|
export interface GlobalVariableBuilder {
|
|
29
|
+
/**
|
|
30
|
+
* Builds global variables.
|
|
31
|
+
* @param blockNumber - The block number to build global variables for.
|
|
32
|
+
* @returns The global variables for the given block number.
|
|
33
|
+
*/
|
|
17
34
|
buildGlobalVariables(blockNumber: Fr): Promise<GlobalVariables>;
|
|
18
35
|
}
|
|
19
36
|
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { createEthereumChain } from '@aztec/ethereum';
|
|
2
2
|
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
3
|
+
|
|
3
4
|
import {
|
|
4
5
|
GetContractReturnType,
|
|
5
|
-
PublicClient,
|
|
6
6
|
HttpTransport,
|
|
7
|
+
PublicClient,
|
|
7
8
|
createPublicClient,
|
|
8
|
-
http,
|
|
9
|
-
getContract,
|
|
10
9
|
getAddress,
|
|
10
|
+
getContract,
|
|
11
|
+
http,
|
|
11
12
|
} from 'viem';
|
|
12
13
|
import * as chains from 'viem/chains';
|
|
14
|
+
|
|
13
15
|
import { GlobalReaderConfig } from './config.js';
|
|
14
16
|
import { L1GlobalReader } from './global_builder.js';
|
|
15
17
|
|
|
@@ -37,26 +39,14 @@ export class ViemReader implements L1GlobalReader {
|
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
/**
|
|
41
|
-
* Fetches the last timestamp that a block was processed by the contract.
|
|
42
|
-
* @returns The last timestamp that a block was processed by the contract.
|
|
43
|
-
*/
|
|
44
42
|
public async getLastTimestamp(): Promise<bigint> {
|
|
45
43
|
return BigInt(await this.rollupContract.read.lastBlockTs());
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
/**
|
|
49
|
-
* Fetches the version of the rollup contract.
|
|
50
|
-
* @returns The version of the rollup contract.
|
|
51
|
-
*/
|
|
52
46
|
public async getVersion(): Promise<bigint> {
|
|
53
47
|
return BigInt(await this.rollupContract.read.VERSION());
|
|
54
48
|
}
|
|
55
49
|
|
|
56
|
-
/**
|
|
57
|
-
* Gets the chain id.
|
|
58
|
-
* @returns The chain id.
|
|
59
|
-
*/
|
|
60
50
|
public async getChainId(): Promise<bigint> {
|
|
61
51
|
return await Promise.resolve(BigInt(this.publicClient.chain.id));
|
|
62
52
|
}
|
package/src/prover/empty.ts
CHANGED
package/src/prover/index.ts
CHANGED
|
@@ -13,8 +13,25 @@ import {
|
|
|
13
13
|
* Generates proofs for the base, merge, and root rollup circuits.
|
|
14
14
|
*/
|
|
15
15
|
export interface RollupProver {
|
|
16
|
+
/**
|
|
17
|
+
* Creates a proof for the given input.
|
|
18
|
+
* @param input - Input to the circuit.
|
|
19
|
+
* @param publicInputs - Public inputs of the circuit obtained via simulation, modified by this call.
|
|
20
|
+
*/
|
|
16
21
|
getBaseRollupProof(input: BaseRollupInputs, publicInputs: BaseOrMergeRollupPublicInputs): Promise<Proof>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates a proof for the given input.
|
|
25
|
+
* @param input - Input to the circuit.
|
|
26
|
+
* @param publicInputs - Public inputs of the circuit obtained via simulation, modified by this call.
|
|
27
|
+
*/
|
|
17
28
|
getMergeRollupProof(input: MergeRollupInputs, publicInputs: BaseOrMergeRollupPublicInputs): Promise<Proof>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Creates a proof for the given input.
|
|
32
|
+
* @param input - Input to the circuit.
|
|
33
|
+
* @param publicInputs - Public inputs of the circuit obtained via simulation, modified by this call.
|
|
34
|
+
*/
|
|
18
35
|
getRootRollupProof(input: RootRollupInputs, publicInputs: RootRollupPublicInputs): Promise<Proof>;
|
|
19
36
|
}
|
|
20
37
|
|
|
@@ -22,6 +39,15 @@ export interface RollupProver {
|
|
|
22
39
|
* Generates proofs for the public and public kernel circuits.
|
|
23
40
|
*/
|
|
24
41
|
export interface PublicProver {
|
|
42
|
+
/**
|
|
43
|
+
* Creates a proof for the given input.
|
|
44
|
+
* @param publicInputs - Public inputs obtained via simulation.
|
|
45
|
+
*/
|
|
25
46
|
getPublicCircuitProof(publicInputs: PublicCircuitPublicInputs): Promise<Proof>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Creates a proof for the given input.
|
|
50
|
+
* @param publicInputs - Public inputs obtained via simulation.
|
|
51
|
+
*/
|
|
26
52
|
getPublicKernelCircuitProof(publicInputs: PublicKernelPublicInputs): Promise<Proof>;
|
|
27
53
|
}
|
package/src/publisher/config.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PrivateKey } from '@aztec/circuits.js';
|
|
1
2
|
import { L1Addresses } from '@aztec/types';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -7,7 +8,7 @@ export interface TxSenderConfig extends L1Addresses {
|
|
|
7
8
|
/**
|
|
8
9
|
* The private key to be used by the publisher.
|
|
9
10
|
*/
|
|
10
|
-
publisherPrivateKey:
|
|
11
|
+
publisherPrivateKey: PrivateKey;
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* The RPC Url of the ethereum host.
|
|
@@ -32,5 +33,5 @@ export interface PublisherConfig {
|
|
|
32
33
|
/**
|
|
33
34
|
* The interval to wait between publish retries.
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
+
l1BlockPublishRetryIntervalMS: number;
|
|
36
37
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { L2Block } from '@aztec/types';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { MockProxy, mock } from 'jest-mock-extended';
|
|
3
4
|
|
|
4
5
|
import { sleep } from '../utils.js';
|
|
5
6
|
import { L1Publisher, L1PublisherTxSender, MinimalTransactionReceipt } from './l1-publisher.js';
|
|
@@ -24,7 +25,7 @@ describe('L1Publisher', () => {
|
|
|
24
25
|
txSender.sendProcessTx.mockResolvedValueOnce(txHash);
|
|
25
26
|
txSender.getTransactionReceipt.mockResolvedValueOnce(txReceipt);
|
|
26
27
|
|
|
27
|
-
publisher = new L1Publisher(txSender, {
|
|
28
|
+
publisher = new L1Publisher(txSender, { l1BlockPublishRetryIntervalMS: 1 });
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
it('publishes l2 block to l1', async () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createDebugLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { InterruptableSleep } from '@aztec/foundation/sleep';
|
|
3
|
+
import { ContractDataAndBytecode, L2Block } from '@aztec/types';
|
|
2
4
|
|
|
3
5
|
import { L2BlockReceiver } from '../receiver.js';
|
|
4
6
|
import { PublisherConfig } from './config.js';
|
|
5
|
-
import { InterruptableSleep } from '@aztec/foundation/sleep';
|
|
6
|
-
import { createDebugLogger } from '@aztec/foundation/log';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Minimal information from a tx receipt returned by an L1PublisherTxSender.
|
|
@@ -40,7 +40,7 @@ export interface L1PublisherTxSender {
|
|
|
40
40
|
sendEmitContractDeploymentTx(
|
|
41
41
|
l2BlockNum: number,
|
|
42
42
|
l2BlockHash: Buffer,
|
|
43
|
-
contractData:
|
|
43
|
+
contractData: ContractDataAndBytecode[],
|
|
44
44
|
): Promise<(string | undefined)[]>;
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -90,7 +90,7 @@ export class L1Publisher implements L2BlockReceiver {
|
|
|
90
90
|
private log = createDebugLogger('aztec:sequencer');
|
|
91
91
|
|
|
92
92
|
constructor(private txSender: L1PublisherTxSender, config?: PublisherConfig) {
|
|
93
|
-
this.sleepTimeMs = config?.
|
|
93
|
+
this.sleepTimeMs = config?.l1BlockPublishRetryIntervalMS ?? 60_000;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|
|
@@ -139,8 +139,12 @@ export class L1Publisher implements L2BlockReceiver {
|
|
|
139
139
|
* @param contractData - The new contract data to publish.
|
|
140
140
|
* @returns True once the tx has been confirmed and is successful, false on revert or interrupt, blocks otherwise.
|
|
141
141
|
*/
|
|
142
|
-
public async processNewContractData(
|
|
143
|
-
|
|
142
|
+
public async processNewContractData(
|
|
143
|
+
l2BlockNum: number,
|
|
144
|
+
l2BlockHash: Buffer,
|
|
145
|
+
contractData: ContractDataAndBytecode[],
|
|
146
|
+
) {
|
|
147
|
+
let _contractData: ContractDataAndBytecode[] = [];
|
|
144
148
|
while (!this.interrupted) {
|
|
145
149
|
if (!(await this.checkFeeDistributorBalance())) {
|
|
146
150
|
this.log(`Fee distributor ETH balance too low, awaiting top up...`);
|
|
@@ -187,12 +191,14 @@ export class L1Publisher implements L2BlockReceiver {
|
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
// TODO: Check fee distributor has at least 0.5 ETH.
|
|
194
|
+
// Related to https://github.com/AztecProtocol/aztec-packages/issues/1588
|
|
190
195
|
// eslint-disable-next-line require-await
|
|
191
196
|
private async checkFeeDistributorBalance(): Promise<boolean> {
|
|
192
197
|
return true;
|
|
193
198
|
}
|
|
194
199
|
|
|
195
200
|
// TODO: Fail if blockchainStatus.nextBlockNum > thisBlockNum.
|
|
201
|
+
// Related to https://github.com/AztecProtocol/aztec-packages/issues/1588
|
|
196
202
|
private checkNextL2BlockNum(_thisBlockNum: number): Promise<boolean> {
|
|
197
203
|
return Promise.resolve(true);
|
|
198
204
|
}
|
|
@@ -208,7 +214,11 @@ export class L1Publisher implements L2BlockReceiver {
|
|
|
208
214
|
}
|
|
209
215
|
}
|
|
210
216
|
|
|
211
|
-
private async sendEmitNewContractDataTx(
|
|
217
|
+
private async sendEmitNewContractDataTx(
|
|
218
|
+
l2BlockNum: number,
|
|
219
|
+
l2BlockHash: Buffer,
|
|
220
|
+
contractData: ContractDataAndBytecode[],
|
|
221
|
+
) {
|
|
212
222
|
while (!this.interrupted) {
|
|
213
223
|
try {
|
|
214
224
|
return await this.txSender.sendEmitContractDeploymentTx(l2BlockNum, l2BlockHash, contractData);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { createEthereumChain } from '@aztec/ethereum';
|
|
2
|
+
import { createDebugLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { ContractDeploymentEmitterAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
4
|
+
import { ContractDataAndBytecode } from '@aztec/types';
|
|
4
5
|
|
|
5
6
|
import {
|
|
6
7
|
GetContractReturnType,
|
|
@@ -14,11 +15,11 @@ import {
|
|
|
14
15
|
getContract,
|
|
15
16
|
http,
|
|
16
17
|
} from 'viem';
|
|
17
|
-
import { RollupAbi, ContractDeploymentEmitterAbi } from '@aztec/l1-artifacts';
|
|
18
18
|
import { PrivateKeyAccount, privateKeyToAccount } from 'viem/accounts';
|
|
19
19
|
import * as chains from 'viem/chains';
|
|
20
|
-
|
|
21
|
-
import {
|
|
20
|
+
|
|
21
|
+
import { TxSenderConfig } from './config.js';
|
|
22
|
+
import { L1PublisherTxSender, MinimalTransactionReceipt, L1ProcessArgs as ProcessTxArgs } from './l1-publisher.js';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Pushes transactions to the L1 rollup contract using viem.
|
|
@@ -48,7 +49,7 @@ export class ViemTxSender implements L1PublisherTxSender {
|
|
|
48
49
|
contractDeploymentEmitterContract: contractDeploymentEmitterContractAddress,
|
|
49
50
|
} = config;
|
|
50
51
|
const chain = createEthereumChain(rpcUrl, apiKey);
|
|
51
|
-
this.account = privateKeyToAccount(`0x${publisherPrivateKey.toString(
|
|
52
|
+
this.account = privateKeyToAccount(`0x${publisherPrivateKey.toString()}`);
|
|
52
53
|
const walletClient = createWalletClient({
|
|
53
54
|
account: this.account,
|
|
54
55
|
chain: chain.chainInfo,
|
|
@@ -119,22 +120,22 @@ export class ViemTxSender implements L1PublisherTxSender {
|
|
|
119
120
|
* Sends a tx to the contract deployment emitter contract with contract deployment data such as bytecode. Returns once the tx has been mined.
|
|
120
121
|
* @param l2BlockNum - Number of the L2 block that owns this encrypted logs.
|
|
121
122
|
* @param l2BlockHash - The hash of the block corresponding to this data.
|
|
122
|
-
* @param
|
|
123
|
+
* @param newContractDataAndBytecode - Data to publish.
|
|
123
124
|
* @returns The hash of the mined tx.
|
|
124
125
|
*/
|
|
125
126
|
async sendEmitContractDeploymentTx(
|
|
126
127
|
l2BlockNum: number,
|
|
127
128
|
l2BlockHash: Buffer,
|
|
128
|
-
|
|
129
|
+
newContractDataAndBytecode: ContractDataAndBytecode[],
|
|
129
130
|
): Promise<(string | undefined)[]> {
|
|
130
131
|
const hashes: string[] = [];
|
|
131
|
-
for (const
|
|
132
|
+
for (const contractDataAndBytecode of newContractDataAndBytecode) {
|
|
132
133
|
const args = [
|
|
133
134
|
BigInt(l2BlockNum),
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
contractDataAndBytecode.contractData.contractAddress.toString() as Hex,
|
|
136
|
+
contractDataAndBytecode.contractData.portalContractAddress.toString() as Hex,
|
|
136
137
|
`0x${l2BlockHash.toString('hex')}`,
|
|
137
|
-
`0x${
|
|
138
|
+
`0x${contractDataAndBytecode.bytecode.toString('hex')}`,
|
|
138
139
|
] as const;
|
|
139
140
|
|
|
140
141
|
const gas = await this.contractDeploymentEmitterContract.estimateGas.emitContractDeployment(args, {
|
package/src/sequencer/config.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fr, HistoricBlockData, KernelCircuitPublicInputs, Proof, makeEmptyProof } from '@aztec/circuits.js';
|
|
2
2
|
import { Tx, TxHash, TxL2Logs } from '@aztec/types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -60,12 +60,12 @@ export async function makeProcessedTx(
|
|
|
60
60
|
* @returns A processed empty tx.
|
|
61
61
|
*/
|
|
62
62
|
export function makeEmptyProcessedTx(
|
|
63
|
-
historicTreeRoots:
|
|
63
|
+
historicTreeRoots: HistoricBlockData,
|
|
64
64
|
chainId: Fr,
|
|
65
65
|
version: Fr,
|
|
66
66
|
): Promise<ProcessedTx> {
|
|
67
67
|
const emptyKernelOutput = KernelCircuitPublicInputs.empty();
|
|
68
|
-
emptyKernelOutput.constants.
|
|
68
|
+
emptyKernelOutput.constants.blockData = historicTreeRoots;
|
|
69
69
|
emptyKernelOutput.constants.txContext.chainId = chainId;
|
|
70
70
|
emptyKernelOutput.constants.txContext.version = version;
|
|
71
71
|
const emptyProof = makeEmptyProof();
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { PublicExecution, PublicExecutionResult, PublicExecutor } from '@aztec/acir-simulator';
|
|
2
2
|
import {
|
|
3
3
|
ARGS_LENGTH,
|
|
4
|
+
AztecAddress,
|
|
4
5
|
CallContext,
|
|
5
6
|
CircuitsWasm,
|
|
6
7
|
EthAddress,
|
|
7
8
|
Fr,
|
|
8
9
|
FunctionData,
|
|
9
10
|
GlobalVariables,
|
|
11
|
+
HistoricBlockData,
|
|
10
12
|
MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX,
|
|
11
13
|
MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX,
|
|
12
14
|
PUBLIC_DATA_TREE_HEIGHT,
|
|
@@ -23,21 +25,23 @@ import {
|
|
|
23
25
|
makeSelector,
|
|
24
26
|
} from '@aztec/circuits.js/factories';
|
|
25
27
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
26
|
-
import { SiblingPath } from '@aztec/merkle-tree';
|
|
27
28
|
import {
|
|
29
|
+
ContractDataAndBytecode,
|
|
28
30
|
ContractDataSource,
|
|
29
|
-
ContractPublicData,
|
|
30
31
|
EncodedContractFunction,
|
|
31
|
-
|
|
32
|
+
FunctionCall,
|
|
32
33
|
FunctionL2Logs,
|
|
33
|
-
|
|
34
|
+
SiblingPath,
|
|
34
35
|
Tx,
|
|
35
36
|
TxL2Logs,
|
|
37
|
+
mockTx,
|
|
36
38
|
} from '@aztec/types';
|
|
37
39
|
import { MerkleTreeOperations, TreeInfo } from '@aztec/world-state';
|
|
40
|
+
|
|
38
41
|
import { MockProxy, mock } from 'jest-mock-extended';
|
|
39
42
|
import pick from 'lodash.pick';
|
|
40
43
|
import times from 'lodash.times';
|
|
44
|
+
|
|
41
45
|
import { PublicProver } from '../prover/index.js';
|
|
42
46
|
import { PublicKernelCircuitSimulator } from '../simulator/index.js';
|
|
43
47
|
import { WasmPublicKernelCircuitSimulator } from '../simulator/public_kernel.js';
|
|
@@ -50,7 +54,7 @@ describe('public_processor', () => {
|
|
|
50
54
|
let contractDataSource: MockProxy<ContractDataSource>;
|
|
51
55
|
|
|
52
56
|
let publicFunction: EncodedContractFunction;
|
|
53
|
-
let contractData:
|
|
57
|
+
let contractData: ContractDataAndBytecode;
|
|
54
58
|
let proof: Proof;
|
|
55
59
|
let root: Buffer;
|
|
56
60
|
|
|
@@ -62,7 +66,7 @@ describe('public_processor', () => {
|
|
|
62
66
|
publicProver = mock<PublicProver>();
|
|
63
67
|
contractDataSource = mock<ContractDataSource>();
|
|
64
68
|
|
|
65
|
-
contractData =
|
|
69
|
+
contractData = ContractDataAndBytecode.random();
|
|
66
70
|
publicFunction = EncodedContractFunction.random();
|
|
67
71
|
proof = makeEmptyProof();
|
|
68
72
|
root = Buffer.alloc(32, 5);
|
|
@@ -70,7 +74,7 @@ describe('public_processor', () => {
|
|
|
70
74
|
publicProver.getPublicCircuitProof.mockResolvedValue(proof);
|
|
71
75
|
publicProver.getPublicKernelCircuitProof.mockResolvedValue(proof);
|
|
72
76
|
db.getTreeInfo.mockResolvedValue({ root } as TreeInfo);
|
|
73
|
-
contractDataSource.
|
|
77
|
+
contractDataSource.getContractDataAndBytecode.mockResolvedValue(contractData);
|
|
74
78
|
contractDataSource.getPublicFunction.mockResolvedValue(publicFunction);
|
|
75
79
|
});
|
|
76
80
|
|
|
@@ -79,14 +83,22 @@ describe('public_processor', () => {
|
|
|
79
83
|
|
|
80
84
|
beforeEach(() => {
|
|
81
85
|
publicKernel = mock<PublicKernelCircuitSimulator>();
|
|
82
|
-
processor = new PublicProcessor(
|
|
86
|
+
processor = new PublicProcessor(
|
|
87
|
+
db,
|
|
88
|
+
publicExecutor,
|
|
89
|
+
publicKernel,
|
|
90
|
+
publicProver,
|
|
91
|
+
contractDataSource,
|
|
92
|
+
GlobalVariables.empty(),
|
|
93
|
+
HistoricBlockData.empty(),
|
|
94
|
+
);
|
|
83
95
|
});
|
|
84
96
|
|
|
85
97
|
it('skips txs without public execution requests', async function () {
|
|
86
98
|
const tx = mockTx();
|
|
87
99
|
tx.data.end.publicCallStack = makeTuple(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, Fr.zero);
|
|
88
100
|
const hash = await tx.getTxHash();
|
|
89
|
-
const [processed, failed] = await processor.process([tx]
|
|
101
|
+
const [processed, failed] = await processor.process([tx]);
|
|
90
102
|
|
|
91
103
|
expect(processed).toEqual([
|
|
92
104
|
{ isEmpty: false, hash, ...pick(tx, 'data', 'proof', 'encryptedLogs', 'unencryptedLogs') },
|
|
@@ -98,7 +110,7 @@ describe('public_processor', () => {
|
|
|
98
110
|
publicExecutor.execute.mockRejectedValue(new Error(`Failed`));
|
|
99
111
|
|
|
100
112
|
const tx = mockTx();
|
|
101
|
-
const [processed, failed] = await processor.process([tx]
|
|
113
|
+
const [processed, failed] = await processor.process([tx]);
|
|
102
114
|
|
|
103
115
|
expect(processed).toEqual([]);
|
|
104
116
|
expect(failed).toEqual([tx]);
|
|
@@ -117,7 +129,15 @@ describe('public_processor', () => {
|
|
|
117
129
|
const path = times(PUBLIC_DATA_TREE_HEIGHT, i => Buffer.alloc(32, i));
|
|
118
130
|
db.getSiblingPath.mockResolvedValue(new SiblingPath<number>(PUBLIC_DATA_TREE_HEIGHT, path));
|
|
119
131
|
publicKernel = new WasmPublicKernelCircuitSimulator();
|
|
120
|
-
processor = new PublicProcessor(
|
|
132
|
+
processor = new PublicProcessor(
|
|
133
|
+
db,
|
|
134
|
+
publicExecutor,
|
|
135
|
+
publicKernel,
|
|
136
|
+
publicProver,
|
|
137
|
+
contractDataSource,
|
|
138
|
+
GlobalVariables.empty(),
|
|
139
|
+
HistoricBlockData.empty(),
|
|
140
|
+
);
|
|
121
141
|
});
|
|
122
142
|
|
|
123
143
|
const expectedTxByHash = async (tx: Tx) =>
|
|
@@ -146,7 +166,7 @@ describe('public_processor', () => {
|
|
|
146
166
|
throw new Error(`Unexpected execution request: ${execution}`);
|
|
147
167
|
});
|
|
148
168
|
|
|
149
|
-
const [processed, failed] = await processor.process([tx]
|
|
169
|
+
const [processed, failed] = await processor.process([tx]);
|
|
150
170
|
|
|
151
171
|
expect(processed).toHaveLength(1);
|
|
152
172
|
expect(processed).toEqual([await expectedTxByHash(tx)]);
|
|
@@ -167,16 +187,15 @@ describe('public_processor', () => {
|
|
|
167
187
|
|
|
168
188
|
const publicExecutionResult = makePublicExecutionResultFromRequest(callRequest);
|
|
169
189
|
publicExecutionResult.nestedExecutions = [
|
|
170
|
-
makePublicExecutionResult({
|
|
171
|
-
from: publicExecutionResult.execution.contractAddress,
|
|
190
|
+
makePublicExecutionResult(publicExecutionResult.execution.contractAddress, {
|
|
172
191
|
to: makeAztecAddress(30),
|
|
173
|
-
functionData: new FunctionData(makeSelector(5), false, false),
|
|
192
|
+
functionData: new FunctionData(makeSelector(5), false, false, false),
|
|
174
193
|
args: new Array(ARGS_LENGTH).fill(Fr.ZERO),
|
|
175
194
|
}),
|
|
176
195
|
];
|
|
177
196
|
publicExecutor.execute.mockResolvedValue(publicExecutionResult);
|
|
178
197
|
|
|
179
|
-
const [processed, failed] = await processor.process([tx]
|
|
198
|
+
const [processed, failed] = await processor.process([tx]);
|
|
180
199
|
|
|
181
200
|
expect(processed).toHaveLength(1);
|
|
182
201
|
expect(processed).toEqual([await expectedTxByHash(tx)]);
|
|
@@ -201,10 +220,11 @@ function makePublicExecutionResultFromRequest(item: PublicCallRequest): PublicEx
|
|
|
201
220
|
}
|
|
202
221
|
|
|
203
222
|
function makePublicExecutionResult(
|
|
204
|
-
|
|
223
|
+
from: AztecAddress,
|
|
224
|
+
tx: FunctionCall,
|
|
205
225
|
nestedExecutions: PublicExecutionResult[] = [],
|
|
206
226
|
): PublicExecutionResult {
|
|
207
|
-
const callContext = new CallContext(
|
|
227
|
+
const callContext = new CallContext(from, tx.to, EthAddress.ZERO, false, false, false);
|
|
208
228
|
const execution: PublicExecution = {
|
|
209
229
|
callContext,
|
|
210
230
|
contractAddress: tx.to,
|