@aztec/stdlib 0.0.1-commit.2ed92850 → 0.0.1-commit.3469e52
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/block_hash.d.ts +2 -3
- package/dest/block/block_hash.d.ts.map +1 -1
- package/dest/block/block_hash.js +0 -3
- package/dest/block/checkpointed_l2_block.d.ts +6 -6
- package/dest/block/checkpointed_l2_block.d.ts.map +1 -1
- package/dest/block/checkpointed_l2_block.js +3 -3
- package/dest/block/in_block.d.ts +3 -3
- package/dest/block/in_block.d.ts.map +1 -1
- package/dest/block/index.d.ts +2 -2
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +1 -1
- package/dest/block/{l2_block.d.ts → l2_block_new.d.ts} +6 -6
- package/dest/block/l2_block_new.d.ts.map +1 -0
- package/dest/block/{l2_block.js → l2_block_new.js} +11 -8
- package/dest/block/l2_block_source.d.ts +29 -37
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_stream/interfaces.d.ts +3 -3
- package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +3 -2
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.js +4 -4
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +3 -3
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
- package/dest/block/test/l2_tips_store_test_suite.js +2 -2
- package/dest/checkpoint/checkpoint.d.ts +8 -8
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +4 -4
- package/dest/checkpoint/published_checkpoint.d.ts +2 -2
- package/dest/config/node-rpc-config.js +1 -1
- package/dest/contract/private_function.d.ts +1 -1
- package/dest/contract/private_function.d.ts.map +1 -1
- package/dest/contract/private_function.js +2 -1
- package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts +2 -2
- package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts.map +1 -1
- package/dest/delayed_public_mutable/delayed_public_mutable_values.js +10 -7
- package/dest/epoch-helpers/index.js +1 -1
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +15 -15
- package/dest/interfaces/aztec-node-admin.d.ts +1 -4
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.d.ts +9 -23
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +11 -11
- package/dest/interfaces/block-builder.d.ts +4 -4
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/configs.d.ts +2 -2
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/prover-client.d.ts +1 -10
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +1 -7
- package/dest/interfaces/tx_provider.d.ts +3 -3
- package/dest/interfaces/tx_provider.d.ts.map +1 -1
- package/dest/interfaces/validator.d.ts +2 -2
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +3 -3
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.js +6 -4
- package/dest/p2p/block_proposal.d.ts +4 -4
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +1 -1
- package/dest/p2p/message_validator.d.ts +3 -18
- package/dest/p2p/message_validator.d.ts.map +1 -1
- package/dest/p2p/message_validator.js +1 -2
- package/dest/tests/factories.js +1 -1
- package/dest/tests/jest.d.ts +4 -4
- package/dest/tests/jest.js +9 -9
- package/dest/tests/mocks.d.ts +9 -10
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +10 -15
- package/dest/tx/block_header.d.ts +2 -3
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +2 -3
- package/dest/tx/tx_receipt.d.ts +11 -39
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +13 -44
- package/package.json +9 -9
- package/src/block/block_hash.ts +1 -5
- package/src/block/checkpointed_l2_block.ts +4 -4
- package/src/block/in_block.ts +2 -2
- package/src/block/index.ts +1 -1
- package/src/block/{l2_block.ts → l2_block_new.ts} +13 -9
- package/src/block/l2_block_source.ts +30 -38
- package/src/block/l2_block_stream/interfaces.ts +2 -2
- package/src/block/l2_block_stream/l2_block_stream.ts +6 -5
- package/src/block/l2_block_stream/l2_tips_store_base.ts +2 -2
- package/src/block/test/l2_tips_store_test_suite.ts +4 -4
- package/src/checkpoint/checkpoint.ts +7 -7
- package/src/config/node-rpc-config.ts +1 -1
- package/src/contract/private_function.ts +2 -1
- package/src/delayed_public_mutable/delayed_public_mutable_values.ts +10 -9
- package/src/epoch-helpers/index.ts +1 -1
- package/src/interfaces/archiver.ts +24 -15
- package/src/interfaces/aztec-node.ts +31 -38
- package/src/interfaces/block-builder.ts +3 -3
- package/src/interfaces/configs.ts +3 -1
- package/src/interfaces/prover-client.ts +0 -15
- package/src/interfaces/tx_provider.ts +2 -2
- package/src/interfaces/validator.ts +2 -1
- package/src/kernel/hints/build_nullifier_read_request_hints.ts +10 -1
- package/src/p2p/block_proposal.ts +3 -3
- package/src/p2p/message_validator.ts +2 -14
- package/src/tests/factories.ts +1 -1
- package/src/tests/jest.ts +9 -9
- package/src/tests/mocks.ts +13 -20
- package/src/tx/block_header.ts +4 -7
- package/src/tx/tx_receipt.ts +15 -72
- package/dest/block/l2_block.d.ts.map +0 -1
package/dest/tx/tx_receipt.js
CHANGED
|
@@ -4,30 +4,17 @@ import { RevertCode } from '../avm/revert_code.js';
|
|
|
4
4
|
import { L2BlockHash } from '../block/block_hash.js';
|
|
5
5
|
import { schemas } from '../schemas/schemas.js';
|
|
6
6
|
import { TxHash } from './tx_hash.js';
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Possible status of a transaction.
|
|
9
|
+
*/ export var TxStatus = /*#__PURE__*/ function(TxStatus) {
|
|
8
10
|
TxStatus["DROPPED"] = "dropped";
|
|
9
11
|
TxStatus["PENDING"] = "pending";
|
|
10
|
-
TxStatus["
|
|
11
|
-
TxStatus["
|
|
12
|
-
TxStatus["
|
|
13
|
-
TxStatus["
|
|
12
|
+
TxStatus["SUCCESS"] = "success";
|
|
13
|
+
TxStatus["APP_LOGIC_REVERTED"] = "app_logic_reverted";
|
|
14
|
+
TxStatus["TEARDOWN_REVERTED"] = "teardown_reverted";
|
|
15
|
+
TxStatus["BOTH_REVERTED"] = "both_reverted";
|
|
14
16
|
return TxStatus;
|
|
15
17
|
}({});
|
|
16
|
-
/** Tx status sorted by finalization progress. */ export const SortedTxStatuses = [
|
|
17
|
-
"dropped",
|
|
18
|
-
"pending",
|
|
19
|
-
"proposed",
|
|
20
|
-
"checkpointed",
|
|
21
|
-
"proven",
|
|
22
|
-
"finalized"
|
|
23
|
-
];
|
|
24
|
-
/** Execution result - only set when tx is in a block. */ export var TxExecutionResult = /*#__PURE__*/ function(TxExecutionResult) {
|
|
25
|
-
TxExecutionResult["SUCCESS"] = "success";
|
|
26
|
-
TxExecutionResult["APP_LOGIC_REVERTED"] = "app_logic_reverted";
|
|
27
|
-
TxExecutionResult["TEARDOWN_REVERTED"] = "teardown_reverted";
|
|
28
|
-
TxExecutionResult["BOTH_REVERTED"] = "both_reverted";
|
|
29
|
-
return TxExecutionResult;
|
|
30
|
-
}({});
|
|
31
18
|
/**
|
|
32
19
|
* Represents a transaction receipt in the Aztec network.
|
|
33
20
|
* Contains essential information about the transaction including its status, origin, and associated addresses.
|
|
@@ -36,53 +23,35 @@ import { TxHash } from './tx_hash.js';
|
|
|
36
23
|
*/ export class TxReceipt {
|
|
37
24
|
txHash;
|
|
38
25
|
status;
|
|
39
|
-
executionResult;
|
|
40
26
|
error;
|
|
41
27
|
transactionFee;
|
|
42
28
|
blockHash;
|
|
43
29
|
blockNumber;
|
|
44
|
-
constructor(/** A unique identifier for a transaction. */ txHash, /** The transaction's
|
|
30
|
+
constructor(/** A unique identifier for a transaction. */ txHash, /** The transaction's status. */ status, /** Description of transaction error, if any. */ error, /** The transaction fee paid for the transaction. */ transactionFee, /** The hash of the block containing the transaction. */ blockHash, /** The block number in which the transaction was included. */ blockNumber){
|
|
45
31
|
this.txHash = txHash;
|
|
46
32
|
this.status = status;
|
|
47
|
-
this.executionResult = executionResult;
|
|
48
33
|
this.error = error;
|
|
49
34
|
this.transactionFee = transactionFee;
|
|
50
35
|
this.blockHash = blockHash;
|
|
51
36
|
this.blockNumber = blockNumber;
|
|
52
37
|
}
|
|
53
|
-
/** Returns true if the transaction was executed successfully. */ hasExecutionSucceeded() {
|
|
54
|
-
return this.executionResult === "success";
|
|
55
|
-
}
|
|
56
|
-
/** Returns true if the transaction execution reverted. */ hasExecutionReverted() {
|
|
57
|
-
return this.executionResult !== undefined && this.executionResult !== "success";
|
|
58
|
-
}
|
|
59
|
-
/** Returns true if the transaction has been included in a block (proposed, checkpointed, proven, or finalized). */ isMined() {
|
|
60
|
-
return this.status === "proposed" || this.status === "checkpointed" || this.status === "proven" || this.status === "finalized";
|
|
61
|
-
}
|
|
62
|
-
/** Returns true if the transaction is pending. */ isPending() {
|
|
63
|
-
return this.status === "pending";
|
|
64
|
-
}
|
|
65
|
-
/** Returns true if the transaction was dropped. */ isDropped() {
|
|
66
|
-
return this.status === "dropped";
|
|
67
|
-
}
|
|
68
38
|
static empty() {
|
|
69
|
-
return new TxReceipt(TxHash.zero(), "dropped",
|
|
39
|
+
return new TxReceipt(TxHash.zero(), "dropped", '');
|
|
70
40
|
}
|
|
71
41
|
static get schema() {
|
|
72
42
|
return z.object({
|
|
73
43
|
txHash: TxHash.schema,
|
|
74
44
|
status: z.nativeEnum(TxStatus),
|
|
75
|
-
|
|
76
|
-
error: z.string().optional(),
|
|
45
|
+
error: z.string(),
|
|
77
46
|
blockHash: L2BlockHash.schema.optional(),
|
|
78
47
|
blockNumber: BlockNumberSchema.optional(),
|
|
79
48
|
transactionFee: schemas.BigInt.optional()
|
|
80
|
-
}).transform(
|
|
49
|
+
}).transform(TxReceipt.from);
|
|
81
50
|
}
|
|
82
51
|
static from(fields) {
|
|
83
|
-
return new TxReceipt(fields.txHash, fields.status, fields.
|
|
52
|
+
return new TxReceipt(fields.txHash, fields.status, fields.error, fields.transactionFee, fields.blockHash, fields.blockNumber);
|
|
84
53
|
}
|
|
85
|
-
static
|
|
54
|
+
static statusFromRevertCode(revertCode) {
|
|
86
55
|
if (revertCode.equals(RevertCode.OK)) {
|
|
87
56
|
return "success";
|
|
88
57
|
} else if (revertCode.equals(RevertCode.APP_LOGIC_REVERTED)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.3469e52",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -78,14 +78,14 @@
|
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@aws-sdk/client-s3": "^3.892.0",
|
|
81
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
82
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
83
|
-
"@aztec/constants": "0.0.1-commit.
|
|
84
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
85
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
86
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
87
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
88
|
-
"@aztec/validator-ha-signer": "0.0.1-commit.
|
|
81
|
+
"@aztec/bb.js": "0.0.1-commit.3469e52",
|
|
82
|
+
"@aztec/blob-lib": "0.0.1-commit.3469e52",
|
|
83
|
+
"@aztec/constants": "0.0.1-commit.3469e52",
|
|
84
|
+
"@aztec/ethereum": "0.0.1-commit.3469e52",
|
|
85
|
+
"@aztec/foundation": "0.0.1-commit.3469e52",
|
|
86
|
+
"@aztec/l1-artifacts": "0.0.1-commit.3469e52",
|
|
87
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.3469e52",
|
|
88
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.3469e52",
|
|
89
89
|
"@google-cloud/storage": "^7.15.0",
|
|
90
90
|
"axios": "^1.12.0",
|
|
91
91
|
"json-stringify-deterministic": "1.0.12",
|
package/src/block/block_hash.ts
CHANGED
|
@@ -48,7 +48,7 @@ export class L2BlockHash extends Buffer32 {
|
|
|
48
48
|
return new L2BlockHash(reader.readBytes(L2BlockHash.SIZE));
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
static override fromString(str: string):
|
|
51
|
+
static override fromString(str: string): Buffer32 {
|
|
52
52
|
return new L2BlockHash(super.fromString(str).toBuffer());
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -63,8 +63,4 @@ export class L2BlockHash extends Buffer32 {
|
|
|
63
63
|
static override fromField(hash: Fr) {
|
|
64
64
|
return new L2BlockHash(hash.toBuffer());
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
toField(): Fr {
|
|
68
|
-
return Fr.fromBuffer(this.toBuffer());
|
|
69
|
-
}
|
|
70
66
|
}
|
|
@@ -7,7 +7,7 @@ import { z } from 'zod';
|
|
|
7
7
|
|
|
8
8
|
import { L1PublishedData } from '../checkpoint/published_checkpoint.js';
|
|
9
9
|
import { MAX_BLOCK_HASH_STRING_LENGTH, MAX_COMMITTEE_SIZE } from '../deserialization/index.js';
|
|
10
|
-
import {
|
|
10
|
+
import { L2BlockNew } from './l2_block_new.js';
|
|
11
11
|
import { CommitteeAttestation } from './proposal/committee_attestation.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -16,7 +16,7 @@ import { CommitteeAttestation } from './proposal/committee_attestation.js';
|
|
|
16
16
|
export class CheckpointedL2Block {
|
|
17
17
|
constructor(
|
|
18
18
|
public checkpointNumber: CheckpointNumber,
|
|
19
|
-
public block:
|
|
19
|
+
public block: L2BlockNew,
|
|
20
20
|
public l1: L1PublishedData,
|
|
21
21
|
public attestations: CommitteeAttestation[],
|
|
22
22
|
) {}
|
|
@@ -24,7 +24,7 @@ export class CheckpointedL2Block {
|
|
|
24
24
|
return z
|
|
25
25
|
.object({
|
|
26
26
|
checkpointNumber: CheckpointNumberSchema,
|
|
27
|
-
block:
|
|
27
|
+
block: L2BlockNew.schema,
|
|
28
28
|
l1: L1PublishedData.schema,
|
|
29
29
|
attestations: z.array(CommitteeAttestation.schema),
|
|
30
30
|
})
|
|
@@ -34,7 +34,7 @@ export class CheckpointedL2Block {
|
|
|
34
34
|
static fromBuffer(bufferOrReader: Buffer | BufferReader): CheckpointedL2Block {
|
|
35
35
|
const reader = BufferReader.asReader(bufferOrReader);
|
|
36
36
|
const checkpointNumber = reader.readNumber();
|
|
37
|
-
const block = reader.readObject(
|
|
37
|
+
const block = reader.readObject(L2BlockNew);
|
|
38
38
|
const l1BlockNumber = reader.readBigInt();
|
|
39
39
|
const l1BlockHash = reader.readString(MAX_BLOCK_HASH_STRING_LENGTH);
|
|
40
40
|
const l1Timestamp = reader.readBigInt();
|
package/src/block/in_block.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types'
|
|
|
3
3
|
import { type ZodTypeAny, z } from 'zod';
|
|
4
4
|
|
|
5
5
|
import { L2BlockHash } from './block_hash.js';
|
|
6
|
-
import type {
|
|
6
|
+
import type { L2BlockNew } from './l2_block_new.js';
|
|
7
7
|
|
|
8
8
|
export type InBlock = {
|
|
9
9
|
l2BlockNumber: BlockNumber;
|
|
@@ -29,7 +29,7 @@ export function randomDataInBlock<T>(data: T): DataInBlock<T> {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export async function wrapDataInBlock<T>(data: T, block:
|
|
32
|
+
export async function wrapDataInBlock<T>(data: T, block: L2BlockNew): Promise<DataInBlock<T>> {
|
|
33
33
|
return {
|
|
34
34
|
data,
|
|
35
35
|
l2BlockNumber: block.number,
|
package/src/block/index.ts
CHANGED
|
@@ -18,10 +18,15 @@ import { BlockHeader } from '../tx/block_header.js';
|
|
|
18
18
|
import { Body } from './body.js';
|
|
19
19
|
import type { L2BlockInfo } from './l2_block_info.js';
|
|
20
20
|
|
|
21
|
+
// TODO(palla/mbps): Delete the existing `L2Block` class and rename this to `L2Block`.
|
|
22
|
+
// TODO(palla/mbps): Consider moving the checkpointNumber and indexWithinCheckpoint to the header:
|
|
23
|
+
// if the blockNumber is there, why not these as well? Consider whether they should be part of the
|
|
24
|
+
// circuits structs though.
|
|
25
|
+
|
|
21
26
|
/**
|
|
22
27
|
* An L2 block with a header and a body.
|
|
23
28
|
*/
|
|
24
|
-
export class
|
|
29
|
+
export class L2BlockNew {
|
|
25
30
|
constructor(
|
|
26
31
|
/** Snapshot of archive tree after the block is applied. */
|
|
27
32
|
public archive: AppendOnlyTreeSnapshot,
|
|
@@ -58,7 +63,7 @@ export class L2Block {
|
|
|
58
63
|
})
|
|
59
64
|
.transform(
|
|
60
65
|
({ archive, header, body, checkpointNumber, indexWithinCheckpoint }) =>
|
|
61
|
-
new
|
|
66
|
+
new L2BlockNew(archive, header, body, checkpointNumber, indexWithinCheckpoint),
|
|
62
67
|
);
|
|
63
68
|
}
|
|
64
69
|
|
|
@@ -74,7 +79,7 @@ export class L2Block {
|
|
|
74
79
|
const checkpointNumber = CheckpointNumber(reader.readNumber());
|
|
75
80
|
const indexWithinCheckpoint = IndexWithinCheckpoint(reader.readNumber());
|
|
76
81
|
|
|
77
|
-
return new
|
|
82
|
+
return new L2BlockNew(archive, header, body, checkpointNumber, indexWithinCheckpoint);
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
/**
|
|
@@ -89,9 +94,8 @@ export class L2Block {
|
|
|
89
94
|
* Returns the block's hash (hash of block header).
|
|
90
95
|
* @returns The block's hash.
|
|
91
96
|
*/
|
|
92
|
-
public
|
|
93
|
-
|
|
94
|
-
return blockHash.toField();
|
|
97
|
+
public hash(): Promise<Fr> {
|
|
98
|
+
return this.header.hash();
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
/**
|
|
@@ -139,7 +143,7 @@ export class L2Block {
|
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
static empty(header?: BlockHeader) {
|
|
142
|
-
return new
|
|
146
|
+
return new L2BlockNew(
|
|
143
147
|
AppendOnlyTreeSnapshot.empty(),
|
|
144
148
|
header ?? BlockHeader.empty(),
|
|
145
149
|
Body.empty(),
|
|
@@ -173,11 +177,11 @@ export class L2Block {
|
|
|
173
177
|
txOptions?: Partial<Parameters<typeof Body.random>[0]>;
|
|
174
178
|
makeTxOptions?: (txIndex: number) => Partial<Parameters<typeof Body.random>[0]>;
|
|
175
179
|
} & Partial<Parameters<typeof BlockHeader.random>[0]> = {},
|
|
176
|
-
): Promise<
|
|
180
|
+
): Promise<L2BlockNew> {
|
|
177
181
|
const archive = new AppendOnlyTreeSnapshot(Fr.random(), blockNumber + 1);
|
|
178
182
|
const header = BlockHeader.random({ blockNumber, ...blockHeaderOverrides });
|
|
179
183
|
const body = await Body.random({ txsPerBlock, makeTxOptions, ...txOptions });
|
|
180
|
-
return new
|
|
184
|
+
return new L2BlockNew(archive, header, body, checkpointNumber, indexWithinCheckpoint);
|
|
181
185
|
}
|
|
182
186
|
|
|
183
187
|
/**
|
|
@@ -21,7 +21,7 @@ import type { IndexedTxEffect } from '../tx/indexed_tx_effect.js';
|
|
|
21
21
|
import type { TxHash } from '../tx/tx_hash.js';
|
|
22
22
|
import type { TxReceipt } from '../tx/tx_receipt.js';
|
|
23
23
|
import type { CheckpointedL2Block } from './checkpointed_l2_block.js';
|
|
24
|
-
import type {
|
|
24
|
+
import type { L2BlockNew } from './l2_block_new.js';
|
|
25
25
|
import type { ValidateCheckpointNegativeResult, ValidateCheckpointResult } from './validate_block_result.js';
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -52,20 +52,6 @@ export interface L2BlockSource {
|
|
|
52
52
|
*/
|
|
53
53
|
getProvenBlockNumber(): Promise<BlockNumber>;
|
|
54
54
|
|
|
55
|
-
/**
|
|
56
|
-
* Gets the number of the latest L2 block checkpointed seen by the block source implementation.
|
|
57
|
-
* @returns The number of the latest L2 block checkpointed seen by the block source implementation.
|
|
58
|
-
*/
|
|
59
|
-
getCheckpointedL2BlockNumber(): Promise<BlockNumber>;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Computes the finalized block number based on the proven block number.
|
|
63
|
-
* A block is considered finalized when it's 2 epochs behind the proven block.
|
|
64
|
-
* TODO(#13569): Compute proper finalized block number based on L1 finalized block.
|
|
65
|
-
* @returns The finalized block number.
|
|
66
|
-
*/
|
|
67
|
-
getFinalizedL2BlockNumber(): Promise<BlockNumber>;
|
|
68
|
-
|
|
69
55
|
/**
|
|
70
56
|
* Gets an l2 block header.
|
|
71
57
|
* @param number - The block number to return or 'latest' for the most recent one.
|
|
@@ -81,15 +67,15 @@ export interface L2BlockSource {
|
|
|
81
67
|
*/
|
|
82
68
|
getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined>;
|
|
83
69
|
|
|
84
|
-
getCheckpointedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]>;
|
|
70
|
+
getCheckpointedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<CheckpointedL2Block[]>;
|
|
85
71
|
|
|
86
72
|
/**
|
|
87
|
-
* Retrieves a collection of checkpoints
|
|
88
|
-
* @param checkpointNumber The first checkpoint to be retrieved
|
|
89
|
-
* @param limit The number of checkpoints to be retrieved
|
|
90
|
-
* @returns The collection of complete checkpoints
|
|
73
|
+
* Retrieves a collection of published checkpoints
|
|
74
|
+
* @param checkpointNumber The first checkpoint to be retrieved
|
|
75
|
+
* @param limit The number of checkpoints to be retrieved
|
|
76
|
+
* @returns The collection of complete checkpoints
|
|
91
77
|
*/
|
|
92
|
-
|
|
78
|
+
getPublishedCheckpoints(checkpointNumber: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]>;
|
|
93
79
|
|
|
94
80
|
/**
|
|
95
81
|
* Gets the checkpoints for a given epoch
|
|
@@ -116,21 +102,21 @@ export interface L2BlockSource {
|
|
|
116
102
|
* @param number - The block number to return.
|
|
117
103
|
* @returns The requested L2 block (or undefined if not found).
|
|
118
104
|
*/
|
|
119
|
-
|
|
105
|
+
getL2BlockNew(number: BlockNumber): Promise<L2BlockNew | undefined>;
|
|
120
106
|
|
|
121
107
|
/**
|
|
122
108
|
* Gets an L2 block by its hash.
|
|
123
109
|
* @param blockHash - The block hash to retrieve.
|
|
124
110
|
* @returns The requested L2 block (or undefined if not found).
|
|
125
111
|
*/
|
|
126
|
-
|
|
112
|
+
getL2BlockNewByHash(blockHash: Fr): Promise<L2BlockNew | undefined>;
|
|
127
113
|
|
|
128
114
|
/**
|
|
129
115
|
* Gets an L2 block by its archive root.
|
|
130
116
|
* @param archive - The archive root to retrieve.
|
|
131
117
|
* @returns The requested L2 block (or undefined if not found).
|
|
132
118
|
*/
|
|
133
|
-
|
|
119
|
+
getL2BlockNewByArchive(archive: Fr): Promise<L2BlockNew | undefined>;
|
|
134
120
|
|
|
135
121
|
/**
|
|
136
122
|
* Gets a tx effect.
|
|
@@ -157,11 +143,11 @@ export interface L2BlockSource {
|
|
|
157
143
|
getL2EpochNumber(): Promise<EpochNumber | undefined>;
|
|
158
144
|
|
|
159
145
|
/**
|
|
160
|
-
* Returns all
|
|
146
|
+
* Returns all block headers for a given epoch.
|
|
161
147
|
* @dev Use this method only with recent epochs, since it walks the block list backwards.
|
|
162
148
|
* @param epochNumber - The epoch number to return headers for.
|
|
163
149
|
*/
|
|
164
|
-
|
|
150
|
+
getBlockHeadersForEpoch(epochNumber: EpochNumber): Promise<BlockHeader[]>;
|
|
165
151
|
|
|
166
152
|
/**
|
|
167
153
|
* Returns whether the given epoch is completed on L1, based on the current L1 and L2 block numbers.
|
|
@@ -207,43 +193,49 @@ export interface L2BlockSource {
|
|
|
207
193
|
* @param number - The block number to return (inclusive).
|
|
208
194
|
* @returns The requested L2 block.
|
|
209
195
|
*/
|
|
210
|
-
getBlock(number: BlockNumber): Promise<
|
|
196
|
+
getBlock(number: BlockNumber): Promise<L2BlockNew | undefined>;
|
|
197
|
+
|
|
198
|
+
getL2BlocksNew(from: BlockNumber, limit: number, proven?: boolean): Promise<L2BlockNew[]>;
|
|
211
199
|
|
|
212
200
|
/**
|
|
213
|
-
* Returns all
|
|
201
|
+
* Returns all blocks for a given epoch.
|
|
214
202
|
* @dev Use this method only with recent epochs, since it walks the block list backwards.
|
|
215
203
|
* @param epochNumber - The epoch number to return blocks for.
|
|
216
204
|
*/
|
|
217
|
-
|
|
205
|
+
getBlocksForEpoch(epochNumber: EpochNumber): Promise<L2BlockNew[]>;
|
|
218
206
|
|
|
219
207
|
/**
|
|
220
208
|
* Returns all blocks for a given slot.
|
|
221
209
|
* @dev Use this method only with recent slots, since it walks the block list backwards.
|
|
222
210
|
* @param slotNumber - The slot number to return blocks for.
|
|
223
211
|
*/
|
|
224
|
-
getBlocksForSlot(slotNumber: SlotNumber): Promise<
|
|
212
|
+
getBlocksForSlot(slotNumber: SlotNumber): Promise<L2BlockNew[]>;
|
|
225
213
|
|
|
226
214
|
/**
|
|
227
|
-
* Gets a
|
|
215
|
+
* Gets a published block by its block hash.
|
|
228
216
|
* @param blockHash - The block hash to retrieve.
|
|
229
217
|
* @returns The requested block (or undefined if not found).
|
|
230
218
|
*/
|
|
231
|
-
|
|
219
|
+
getPublishedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined>;
|
|
232
220
|
|
|
233
221
|
/**
|
|
234
|
-
* Gets a
|
|
222
|
+
* Gets a published block by its archive root.
|
|
235
223
|
* @param archive - The archive root to retrieve.
|
|
236
224
|
* @returns The requested block (or undefined if not found).
|
|
237
225
|
*/
|
|
238
|
-
|
|
226
|
+
getPublishedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined>;
|
|
239
227
|
|
|
240
228
|
/**
|
|
241
229
|
* Gets up to `limit` amount of L2 blocks starting from `from`.
|
|
242
230
|
* @param from - Number of the first block to return (inclusive).
|
|
243
231
|
* @param limit - The maximum number of blocks to return.
|
|
232
|
+
* @param proven - If true, only return blocks that have been proven.
|
|
244
233
|
* @returns The requested L2 blocks.
|
|
245
234
|
*/
|
|
246
|
-
getBlocks(from: BlockNumber, limit: number): Promise<
|
|
235
|
+
getBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<L2BlockNew[]>;
|
|
236
|
+
|
|
237
|
+
/** Equivalent to getBlocks but includes publish data. */
|
|
238
|
+
getPublishedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<CheckpointedL2Block[]>;
|
|
247
239
|
}
|
|
248
240
|
|
|
249
241
|
/**
|
|
@@ -255,7 +247,7 @@ export interface L2BlockSink {
|
|
|
255
247
|
* @param block - The L2 block to add.
|
|
256
248
|
* @throws If block number is not incremental (i.e., not exactly one more than the last stored block).
|
|
257
249
|
*/
|
|
258
|
-
addBlock(block:
|
|
250
|
+
addBlock(block: L2BlockNew): Promise<void>;
|
|
259
251
|
}
|
|
260
252
|
|
|
261
253
|
/**
|
|
@@ -352,13 +344,13 @@ export type L2BlockProvenEvent = {
|
|
|
352
344
|
export type L2PruneUnprovenEvent = {
|
|
353
345
|
type: 'l2PruneUnproven';
|
|
354
346
|
epochNumber: EpochNumber;
|
|
355
|
-
blocks:
|
|
347
|
+
blocks: L2BlockNew[];
|
|
356
348
|
};
|
|
357
349
|
|
|
358
350
|
export type L2PruneUncheckpointedEvent = {
|
|
359
351
|
type: 'l2PruneUncheckpointed';
|
|
360
352
|
slotNumber: SlotNumber;
|
|
361
|
-
blocks:
|
|
353
|
+
blocks: L2BlockNew[];
|
|
362
354
|
};
|
|
363
355
|
|
|
364
356
|
export type L2CheckpointEvent = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PublishedCheckpoint } from '../../checkpoint/published_checkpoint.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { L2BlockNew } from '../l2_block_new.js';
|
|
3
3
|
import type { CheckpointId, L2BlockId, L2Tips } from '../l2_block_source.js';
|
|
4
4
|
|
|
5
5
|
/** Interface to the local view of the chain. Implemented by world-state and l2-tips-store. */
|
|
@@ -16,7 +16,7 @@ export interface L2BlockStreamEventHandler {
|
|
|
16
16
|
export type L2BlockStreamEvent =
|
|
17
17
|
| /** Emits blocks added to the chain. */ {
|
|
18
18
|
type: 'blocks-added';
|
|
19
|
-
blocks:
|
|
19
|
+
blocks: L2BlockNew[];
|
|
20
20
|
}
|
|
21
21
|
| /** Emits checkpoints published to L1. */ {
|
|
22
22
|
type: 'chain-checkpointed';
|
|
@@ -19,12 +19,13 @@ export class L2BlockStream {
|
|
|
19
19
|
constructor(
|
|
20
20
|
private l2BlockSource: Pick<
|
|
21
21
|
L2BlockSource,
|
|
22
|
-
'
|
|
22
|
+
'getL2BlocksNew' | 'getBlockHeader' | 'getL2Tips' | 'getPublishedCheckpoints' | 'getCheckpointedBlocks'
|
|
23
23
|
>,
|
|
24
24
|
private localData: L2BlockStreamLocalDataProvider,
|
|
25
25
|
private handler: L2BlockStreamEventHandler,
|
|
26
26
|
private readonly log = createLogger('types:block_stream'),
|
|
27
27
|
private opts: {
|
|
28
|
+
proven?: boolean;
|
|
28
29
|
pollIntervalMS?: number;
|
|
29
30
|
batchSize?: number;
|
|
30
31
|
startingBlock?: number;
|
|
@@ -128,7 +129,7 @@ export class L2BlockStream {
|
|
|
128
129
|
if (!this.opts.ignoreCheckpoints) {
|
|
129
130
|
let loop1Iterations = 0;
|
|
130
131
|
while (nextCheckpointToEmit <= sourceTips.checkpointed.checkpoint.number) {
|
|
131
|
-
const checkpoints = await this.l2BlockSource.
|
|
132
|
+
const checkpoints = await this.l2BlockSource.getPublishedCheckpoints(nextCheckpointToEmit, 1);
|
|
132
133
|
if (checkpoints.length === 0) {
|
|
133
134
|
break;
|
|
134
135
|
}
|
|
@@ -173,7 +174,7 @@ export class L2BlockStream {
|
|
|
173
174
|
// Refill the prefetch buffer when exhausted
|
|
174
175
|
if (prefetchIdx >= prefetchedCheckpoints.length) {
|
|
175
176
|
const prefetchLimit = this.opts.checkpointPrefetchLimit ?? CHECKPOINT_PREFETCH_LIMIT;
|
|
176
|
-
prefetchedCheckpoints = await this.l2BlockSource.
|
|
177
|
+
prefetchedCheckpoints = await this.l2BlockSource.getPublishedCheckpoints(nextCheckpointNumber, prefetchLimit);
|
|
177
178
|
prefetchIdx = 0;
|
|
178
179
|
if (prefetchedCheckpoints.length === 0) {
|
|
179
180
|
break;
|
|
@@ -212,8 +213,8 @@ export class L2BlockStream {
|
|
|
212
213
|
// Loop 3: Fetch any remaining uncheckpointed (proposed) blocks.
|
|
213
214
|
while (nextBlockNumber <= sourceTips.proposed.number) {
|
|
214
215
|
const limit = Math.min(this.opts.batchSize ?? 50, sourceTips.proposed.number - nextBlockNumber + 1);
|
|
215
|
-
this.log.trace(`Requesting blocks from ${nextBlockNumber} limit ${limit}`);
|
|
216
|
-
const blocks = await this.l2BlockSource.
|
|
216
|
+
this.log.trace(`Requesting blocks from ${nextBlockNumber} limit ${limit} proven=${this.opts.proven}`);
|
|
217
|
+
const blocks = await this.l2BlockSource.getL2BlocksNew(BlockNumber(nextBlockNumber), limit, this.opts.proven);
|
|
217
218
|
if (blocks.length === 0) {
|
|
218
219
|
break;
|
|
219
220
|
}
|
|
@@ -2,7 +2,7 @@ import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
|
2
2
|
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
|
|
4
4
|
import type { PublishedCheckpoint } from '../../checkpoint/published_checkpoint.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { L2BlockNew } from '../l2_block_new.js';
|
|
6
6
|
import {
|
|
7
7
|
type CheckpointId,
|
|
8
8
|
GENESIS_CHECKPOINT_HEADER_HASH,
|
|
@@ -109,7 +109,7 @@ export abstract class L2TipsStoreBase implements L2BlockStreamEventHandler, L2Bl
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
// Protected helper that subclasses can override for block hash computation
|
|
112
|
-
protected computeBlockHash(block:
|
|
112
|
+
protected computeBlockHash(block: L2BlockNew): Promise<string> {
|
|
113
113
|
return block.hash().then(hash => hash.toString());
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -5,8 +5,8 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
5
5
|
import {
|
|
6
6
|
type CheckpointId,
|
|
7
7
|
GENESIS_CHECKPOINT_HEADER_HASH,
|
|
8
|
-
L2Block,
|
|
9
8
|
type L2BlockId,
|
|
9
|
+
L2BlockNew,
|
|
10
10
|
type L2TipId,
|
|
11
11
|
} from '@aztec/stdlib/block';
|
|
12
12
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
@@ -31,8 +31,8 @@ export function testL2TipsStore(makeTipsStore: () => Promise<L2TipsStore>) {
|
|
|
31
31
|
blockToCheckpoint.clear();
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
const makeBlock = async (number: number): Promise<
|
|
35
|
-
const block = await
|
|
34
|
+
const makeBlock = async (number: number): Promise<L2BlockNew> => {
|
|
35
|
+
const block = await L2BlockNew.random(BlockNumber(number));
|
|
36
36
|
blockHashes.set(number, (await block.hash()).toString());
|
|
37
37
|
return block;
|
|
38
38
|
};
|
|
@@ -74,7 +74,7 @@ export function testL2TipsStore(makeTipsStore: () => Promise<L2TipsStore>) {
|
|
|
74
74
|
checkpointed: makeTipId(checkpointed),
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
const makeCheckpoint = async (checkpointNumber: number, blocks:
|
|
77
|
+
const makeCheckpoint = async (checkpointNumber: number, blocks: L2BlockNew[]): Promise<PublishedCheckpoint> => {
|
|
78
78
|
const checkpoint = await Checkpoint.random(CheckpointNumber(checkpointNumber), {
|
|
79
79
|
numBlocks: blocks.length,
|
|
80
80
|
startBlockNumber: blocks[0].number,
|
|
@@ -13,7 +13,7 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
13
13
|
|
|
14
14
|
import { z } from 'zod';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { L2BlockNew } from '../block/l2_block_new.js';
|
|
17
17
|
import { MAX_BLOCKS_PER_CHECKPOINT } from '../deserialization/index.js';
|
|
18
18
|
import { computeCheckpointOutHash } from '../messaging/out_hash.js';
|
|
19
19
|
import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
@@ -29,7 +29,7 @@ export class Checkpoint {
|
|
|
29
29
|
/** Header of the checkpoint. */
|
|
30
30
|
public header: CheckpointHeader,
|
|
31
31
|
/** L2 blocks in the checkpoint. */
|
|
32
|
-
public blocks:
|
|
32
|
+
public blocks: L2BlockNew[],
|
|
33
33
|
/** Number of the checkpoint. */
|
|
34
34
|
public number: CheckpointNumber,
|
|
35
35
|
) {}
|
|
@@ -43,7 +43,7 @@ export class Checkpoint {
|
|
|
43
43
|
.object({
|
|
44
44
|
archive: AppendOnlyTreeSnapshot.schema,
|
|
45
45
|
header: CheckpointHeader.schema,
|
|
46
|
-
blocks: z.array(
|
|
46
|
+
blocks: z.array(L2BlockNew.schema),
|
|
47
47
|
number: CheckpointNumberSchema,
|
|
48
48
|
})
|
|
49
49
|
.transform(({ archive, header, blocks, number }) => new Checkpoint(archive, header, blocks, number));
|
|
@@ -62,7 +62,7 @@ export class Checkpoint {
|
|
|
62
62
|
return new Checkpoint(
|
|
63
63
|
reader.readObject(AppendOnlyTreeSnapshot),
|
|
64
64
|
reader.readObject(CheckpointHeader),
|
|
65
|
-
reader.readVector(
|
|
65
|
+
reader.readVector(L2BlockNew, MAX_BLOCKS_PER_CHECKPOINT),
|
|
66
66
|
CheckpointNumber(reader.readNumber()),
|
|
67
67
|
);
|
|
68
68
|
}
|
|
@@ -135,16 +135,16 @@ export class Checkpoint {
|
|
|
135
135
|
startBlockNumber?: number;
|
|
136
136
|
previousArchive?: AppendOnlyTreeSnapshot;
|
|
137
137
|
} & Partial<Parameters<typeof CheckpointHeader.random>[0]> &
|
|
138
|
-
Partial<Parameters<typeof
|
|
138
|
+
Partial<Parameters<typeof L2BlockNew.random>[1]> = {},
|
|
139
139
|
) {
|
|
140
140
|
const header = CheckpointHeader.random(options);
|
|
141
141
|
|
|
142
142
|
// Create blocks sequentially to chain archive roots properly.
|
|
143
143
|
// Each block's header.lastArchive must equal the previous block's archive.
|
|
144
|
-
const blocks:
|
|
144
|
+
const blocks: L2BlockNew[] = [];
|
|
145
145
|
let lastArchive = previousArchive;
|
|
146
146
|
for (let i = 0; i < numBlocks; i++) {
|
|
147
|
-
const block = await
|
|
147
|
+
const block = await L2BlockNew.random(BlockNumber(startBlockNumber + i), {
|
|
148
148
|
indexWithinCheckpoint: IndexWithinCheckpoint(i),
|
|
149
149
|
...options,
|
|
150
150
|
...(lastArchive ? { lastArchive } : {}),
|
|
@@ -21,7 +21,7 @@ export const nodeRpcConfigMappings: ConfigMappingsType<NodeRPCConfig> = {
|
|
|
21
21
|
rpcMaxBodySize: {
|
|
22
22
|
env: 'RPC_MAX_BODY_SIZE',
|
|
23
23
|
description: 'Maximum allowed batch size for JSON RPC batch requests.',
|
|
24
|
-
defaultValue: '
|
|
24
|
+
defaultValue: '50mb',
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FUNCTION_TREE_HEIGHT, GeneratorIndex } from '@aztec/constants';
|
|
2
|
+
import { pedersenHash } from '@aztec/foundation/crypto/pedersen';
|
|
2
3
|
import { poseidon2Hash, poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
|
|
3
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
5
|
import { type MerkleTree, MerkleTreeCalculator } from '@aztec/foundation/trees';
|
|
@@ -37,7 +38,7 @@ export async function computePrivateFunctionLeaf(fn: PrivateFunction): Promise<B
|
|
|
37
38
|
async function getPrivateFunctionTreeCalculator(): Promise<MerkleTreeCalculator> {
|
|
38
39
|
if (!privateFunctionTreeCalculator) {
|
|
39
40
|
const functionTreeZeroLeaf = (
|
|
40
|
-
await
|
|
41
|
+
await pedersenHash(new Array(PRIVATE_FUNCTION_SIZE).fill(0))
|
|
41
42
|
).toBuffer() as Buffer<ArrayBuffer>;
|
|
42
43
|
privateFunctionTreeCalculator = await MerkleTreeCalculator.create(
|
|
43
44
|
FUNCTION_TREE_HEIGHT,
|