@aztec/sequencer-client 0.26.6 → 0.27.0
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/dest/block_builder/solo_block_builder.d.ts.map +1 -1
- package/dest/block_builder/solo_block_builder.js +6 -25
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +2 -5
- package/dest/publisher/l1-publisher.d.ts +1 -21
- package/dest/publisher/l1-publisher.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.js +1 -55
- package/dest/publisher/viem-tx-sender.d.ts +1 -10
- package/dest/publisher/viem-tx-sender.d.ts.map +1 -1
- package/dest/publisher/viem-tx-sender.js +2 -41
- package/dest/sequencer/processed_tx.d.ts +1 -1
- package/dest/sequencer/processed_tx.d.ts.map +1 -1
- package/dest/sequencer/processed_tx.js +3 -5
- package/dest/sequencer/sequencer.d.ts +0 -6
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +1 -26
- package/dest/simulator/public_executor.d.ts.map +1 -1
- package/dest/simulator/public_executor.js +1 -15
- package/package.json +13 -13
- package/src/block_builder/solo_block_builder.ts +11 -45
- package/src/config.ts +0 -4
- package/src/publisher/l1-publisher.ts +1 -85
- package/src/publisher/viem-tx-sender.ts +2 -52
- package/src/sequencer/processed_tx.ts +2 -18
- package/src/sequencer/sequencer.ts +0 -35
- package/src/simulator/public_executor.ts +0 -20
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BLOB_SIZE_IN_BYTES } from '@aztec/circuits.js/constants';
|
|
1
|
+
import { L2Block } from '@aztec/circuit-types';
|
|
3
2
|
import { createEthereumChain } from '@aztec/ethereum';
|
|
4
3
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
5
|
-
import { AvailabilityOracleAbi,
|
|
4
|
+
import { AvailabilityOracleAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
6
5
|
|
|
7
6
|
import {
|
|
8
7
|
GetContractReturnType,
|
|
@@ -40,10 +39,6 @@ export class ViemTxSender implements L1PublisherTxSender {
|
|
|
40
39
|
typeof RollupAbi,
|
|
41
40
|
WalletClient<HttpTransport, chains.Chain, PrivateKeyAccount>
|
|
42
41
|
>;
|
|
43
|
-
private contractDeploymentEmitterContract: GetContractReturnType<
|
|
44
|
-
typeof ContractDeploymentEmitterAbi,
|
|
45
|
-
WalletClient<HttpTransport, chains.Chain, PrivateKeyAccount>
|
|
46
|
-
>;
|
|
47
42
|
|
|
48
43
|
private log = createDebugLogger('aztec:sequencer:viem-tx-sender');
|
|
49
44
|
private publicClient: PublicClient<HttpTransport, chains.Chain>;
|
|
@@ -74,11 +69,6 @@ export class ViemTxSender implements L1PublisherTxSender {
|
|
|
74
69
|
abi: RollupAbi,
|
|
75
70
|
client: walletClient,
|
|
76
71
|
});
|
|
77
|
-
this.contractDeploymentEmitterContract = getContract({
|
|
78
|
-
address: getAddress(l1Contracts.contractDeploymentEmitterAddress.toString()),
|
|
79
|
-
abi: ContractDeploymentEmitterAbi,
|
|
80
|
-
client: walletClient,
|
|
81
|
-
});
|
|
82
72
|
}
|
|
83
73
|
|
|
84
74
|
async getCurrentArchive(): Promise<Buffer> {
|
|
@@ -169,46 +159,6 @@ export class ViemTxSender implements L1PublisherTxSender {
|
|
|
169
159
|
return hash;
|
|
170
160
|
}
|
|
171
161
|
|
|
172
|
-
/**
|
|
173
|
-
* Sends a tx to the contract deployment emitter contract with contract deployment data such as bytecode. Returns once the tx has been mined.
|
|
174
|
-
* @param l2BlockNum - Number of the L2 block that owns this encrypted logs.
|
|
175
|
-
* @param l2BlockHash - The hash of the block corresponding to this data.
|
|
176
|
-
* @param newExtendedContractData - Data to publish.
|
|
177
|
-
* @returns The hash of the mined tx.
|
|
178
|
-
*/
|
|
179
|
-
async sendEmitContractDeploymentTx(
|
|
180
|
-
l2BlockNum: number,
|
|
181
|
-
l2BlockHash: Buffer,
|
|
182
|
-
newExtendedContractData: ExtendedContractData[],
|
|
183
|
-
): Promise<(string | undefined)[]> {
|
|
184
|
-
const hashes: string[] = [];
|
|
185
|
-
for (const extendedContractData of newExtendedContractData) {
|
|
186
|
-
const args = [
|
|
187
|
-
BigInt(l2BlockNum),
|
|
188
|
-
extendedContractData.contractData.contractAddress.toString() as Hex,
|
|
189
|
-
extendedContractData.contractData.portalContractAddress.toString() as Hex,
|
|
190
|
-
`0x${l2BlockHash.toString('hex')}`,
|
|
191
|
-
extendedContractData.contractClassId.toString(),
|
|
192
|
-
extendedContractData.saltedInitializationHash.toString(),
|
|
193
|
-
extendedContractData.publicKeyHash.toString(),
|
|
194
|
-
`0x${extendedContractData.bytecode.toString('hex')}`,
|
|
195
|
-
] as const;
|
|
196
|
-
|
|
197
|
-
const codeSize = extendedContractData.bytecode.length;
|
|
198
|
-
this.log(`Bytecode is ${codeSize} bytes and require ${codeSize / BLOB_SIZE_IN_BYTES} blobs`);
|
|
199
|
-
|
|
200
|
-
const gas = await this.contractDeploymentEmitterContract.estimateGas.emitContractDeployment(args, {
|
|
201
|
-
account: this.account,
|
|
202
|
-
});
|
|
203
|
-
const hash = await this.contractDeploymentEmitterContract.write.emitContractDeployment(args, {
|
|
204
|
-
gas,
|
|
205
|
-
account: this.account,
|
|
206
|
-
});
|
|
207
|
-
hashes.push(hash);
|
|
208
|
-
}
|
|
209
|
-
return hashes;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
162
|
/**
|
|
213
163
|
* Gets the chain object for the given chain id.
|
|
214
164
|
* @param chainId - Chain id of the target EVM chain.
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ContractData,
|
|
3
|
-
ExtendedContractData,
|
|
4
|
-
PublicDataWrite,
|
|
5
|
-
SimulationError,
|
|
6
|
-
Tx,
|
|
7
|
-
TxEffect,
|
|
8
|
-
TxHash,
|
|
9
|
-
TxL2Logs,
|
|
10
|
-
} from '@aztec/circuit-types';
|
|
1
|
+
import { PublicDataWrite, SimulationError, Tx, TxEffect, TxHash, TxL2Logs } from '@aztec/circuit-types';
|
|
11
2
|
import {
|
|
12
3
|
Fr,
|
|
13
4
|
Header,
|
|
14
|
-
MAX_NEW_CONTRACTS_PER_TX,
|
|
15
5
|
MAX_NEW_NOTE_HASHES_PER_TX,
|
|
16
6
|
MAX_NEW_NULLIFIERS_PER_TX,
|
|
17
7
|
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
@@ -29,7 +19,7 @@ import { Tuple, fromFieldsTuple } from '@aztec/foundation/serialize';
|
|
|
29
19
|
* Represents a tx that has been processed by the sequencer public processor,
|
|
30
20
|
* so its kernel circuit public inputs are filled in.
|
|
31
21
|
*/
|
|
32
|
-
export type ProcessedTx = Pick<Tx, 'proof' | 'encryptedLogs' | 'unencryptedLogs'
|
|
22
|
+
export type ProcessedTx = Pick<Tx, 'proof' | 'encryptedLogs' | 'unencryptedLogs'> & {
|
|
33
23
|
/**
|
|
34
24
|
* Output of the public kernel circuit for this tx.
|
|
35
25
|
*/
|
|
@@ -153,7 +143,6 @@ export function makeProcessedTx(
|
|
|
153
143
|
proof: previousProof,
|
|
154
144
|
encryptedLogs: revertReason ? new TxL2Logs([]) : tx.encryptedLogs,
|
|
155
145
|
unencryptedLogs: revertReason ? new TxL2Logs([]) : tx.unencryptedLogs,
|
|
156
|
-
newContracts: revertReason ? [ExtendedContractData.empty()] : tx.newContracts,
|
|
157
146
|
isEmpty: false,
|
|
158
147
|
revertReason,
|
|
159
148
|
};
|
|
@@ -177,7 +166,6 @@ export function makeEmptyProcessedTx(header: Header, chainId: Fr, version: Fr):
|
|
|
177
166
|
unencryptedLogs: new TxL2Logs([]),
|
|
178
167
|
data: emptyKernelOutput,
|
|
179
168
|
proof: emptyProof,
|
|
180
|
-
newContracts: [ExtendedContractData.empty()],
|
|
181
169
|
isEmpty: true,
|
|
182
170
|
revertReason: undefined,
|
|
183
171
|
};
|
|
@@ -195,10 +183,6 @@ export function toTxEffect(tx: ProcessedTx): TxEffect {
|
|
|
195
183
|
PublicDataWrite,
|
|
196
184
|
typeof MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
|
|
197
185
|
>,
|
|
198
|
-
tx.data.combinedData.newContracts.map(cd => cd.hash()) as Tuple<Fr, typeof MAX_NEW_CONTRACTS_PER_TX>,
|
|
199
|
-
tx.data.combinedData.newContracts.map(
|
|
200
|
-
cd => new ContractData(cd.contractAddress, cd.portalContractAddress),
|
|
201
|
-
) as Tuple<ContractData, typeof MAX_NEW_CONTRACTS_PER_TX>,
|
|
202
186
|
tx.encryptedLogs || new TxL2Logs([]),
|
|
203
187
|
tx.unencryptedLogs || new TxL2Logs([]),
|
|
204
188
|
);
|
|
@@ -227,10 +227,6 @@ export class Sequencer {
|
|
|
227
227
|
|
|
228
228
|
await assertBlockHeight();
|
|
229
229
|
|
|
230
|
-
await this.publishExtendedContractData(processedValidTxs, block);
|
|
231
|
-
|
|
232
|
-
await assertBlockHeight();
|
|
233
|
-
|
|
234
230
|
await this.publishL2Block(block);
|
|
235
231
|
this.log.info(`Submitted rollup block ${block.number} with ${processedValidTxs.length} transactions`);
|
|
236
232
|
} catch (err) {
|
|
@@ -239,37 +235,6 @@ export class Sequencer {
|
|
|
239
235
|
}
|
|
240
236
|
}
|
|
241
237
|
|
|
242
|
-
/**
|
|
243
|
-
* Gets new extended contract data from the txs and publishes it on chain.
|
|
244
|
-
* @param validTxs - The set of real transactions being published as part of the block.
|
|
245
|
-
* @param block - The L2Block to be published.
|
|
246
|
-
*/
|
|
247
|
-
protected async publishExtendedContractData(validTxs: ProcessedTx[], block: L2Block) {
|
|
248
|
-
// Publishes contract data for txs to the network and awaits the tx to be mined
|
|
249
|
-
this.state = SequencerState.PUBLISHING_CONTRACT_DATA;
|
|
250
|
-
const newContracts = validTxs.flatMap(tx => tx.newContracts).filter(cd => !cd.isEmpty());
|
|
251
|
-
|
|
252
|
-
if (newContracts.length === 0) {
|
|
253
|
-
this.log.debug(`No new contracts to publish in block ${block.number}`);
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const txsEffectsHash = block.body.getTxsEffectsHash();
|
|
258
|
-
this.log.info(`Publishing ${newContracts.length} contracts in block ${block.number}`);
|
|
259
|
-
|
|
260
|
-
const publishedContractData = await this.publisher.processNewContractData(
|
|
261
|
-
block.number,
|
|
262
|
-
txsEffectsHash,
|
|
263
|
-
newContracts,
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
if (publishedContractData) {
|
|
267
|
-
this.log(`Successfully published new contract data for block ${block.number}`);
|
|
268
|
-
} else if (!publishedContractData && newContracts.length) {
|
|
269
|
-
this.log(`Failed to publish new contract data for block ${block.number}`);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
238
|
/**
|
|
274
239
|
* Publishes the L2Block to the rollup contract.
|
|
275
240
|
* @param block - The L2Block to be published.
|
|
@@ -45,16 +45,6 @@ export class ContractsDataSourcePublicDB implements PublicContractsDB {
|
|
|
45
45
|
* @param tx - The transaction to add contracts from.
|
|
46
46
|
*/
|
|
47
47
|
public addNewContracts(tx: Tx): Promise<void> {
|
|
48
|
-
for (const contract of tx.newContracts) {
|
|
49
|
-
const contractAddress = contract.contractData.contractAddress;
|
|
50
|
-
|
|
51
|
-
if (contractAddress.isZero()) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
this.cache.set(contractAddress.toString(), contract);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
48
|
// Extract contract class and instance data from logs and add to cache for this block
|
|
59
49
|
const logs = tx.unencryptedLogs.unrollLogs().map(UnencryptedL2Log.fromBuffer);
|
|
60
50
|
ContractClassRegisteredEvent.fromLogs(logs, ClassRegistererAddress).forEach(e => {
|
|
@@ -76,16 +66,6 @@ export class ContractsDataSourcePublicDB implements PublicContractsDB {
|
|
|
76
66
|
* @param tx - The tx's contracts to be removed
|
|
77
67
|
*/
|
|
78
68
|
public removeNewContracts(tx: Tx): Promise<void> {
|
|
79
|
-
for (const contract of tx.newContracts) {
|
|
80
|
-
const contractAddress = contract.contractData.contractAddress;
|
|
81
|
-
|
|
82
|
-
if (contractAddress.isZero()) {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
this.cache.delete(contractAddress.toString());
|
|
87
|
-
}
|
|
88
|
-
|
|
89
69
|
// TODO(@spalladino): Can this inadvertently delete a valid contract added by another tx?
|
|
90
70
|
// Let's say we have two txs adding the same contract on the same block. If the 2nd one reverts,
|
|
91
71
|
// wouldn't that accidentally remove the contract added on the first one?
|