@aztec/stdlib 0.0.1-commit.d1f2d6c → 0.0.1-commit.d431d1c
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/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} +9 -5
- 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/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/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} +11 -6
- 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/tx_receipt.ts +15 -72
- package/dest/block/l2_block.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { L2BlockNew } from '../block/l2_block_new.js';
|
|
5
5
|
import type { ChainConfig, SequencerConfig } from '../config/chain-config.js';
|
|
6
6
|
import type { L1RollupConstants } from '../epoch-helpers/index.js';
|
|
7
7
|
import type { Gas } from '../gas/gas.js';
|
|
@@ -31,7 +31,7 @@ export interface IBlockFactory extends ProcessedTxHandler {
|
|
|
31
31
|
/**
|
|
32
32
|
* Assembles the block and updates the archive tree.
|
|
33
33
|
*/
|
|
34
|
-
setBlockCompleted(expectedBlockHeader?: BlockHeader): Promise<
|
|
34
|
+
setBlockCompleted(expectedBlockHeader?: BlockHeader): Promise<L2BlockNew>;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export interface PublicProcessorLimits {
|
|
@@ -63,7 +63,7 @@ export const FullNodeBlockBuilderConfigKeys: (keyof FullNodeBlockBuilderConfig)[
|
|
|
63
63
|
|
|
64
64
|
/** Result of building a block within a checkpoint. */
|
|
65
65
|
export interface BuildBlockInCheckpointResult {
|
|
66
|
-
block:
|
|
66
|
+
block: L2BlockNew;
|
|
67
67
|
publicGas: Gas;
|
|
68
68
|
publicProcessorDuration: number;
|
|
69
69
|
numTxs: number;
|
|
@@ -67,7 +67,9 @@ export interface SequencerConfig {
|
|
|
67
67
|
blockDurationMs?: number;
|
|
68
68
|
/** Have sequencer build and publish an empty checkpoint if there are no txs */
|
|
69
69
|
buildCheckpointIfEmpty?: boolean;
|
|
70
|
-
|
|
70
|
+
|
|
71
|
+
// TODO(palla/mbps): Change default to false once block sync is stable
|
|
72
|
+
/** Skip pushing proposed blocks to archiver (default: true) */
|
|
71
73
|
skipPushProposedBlocksToArchiver?: boolean;
|
|
72
74
|
}
|
|
73
75
|
|
|
@@ -17,12 +17,6 @@ export type ActualProverConfig = {
|
|
|
17
17
|
proverTestDelayMs: number;
|
|
18
18
|
/** If using realistic delays, what percentage of realistic times to apply. */
|
|
19
19
|
proverTestDelayFactor: number;
|
|
20
|
-
/**
|
|
21
|
-
* Whether to abort pending proving jobs when the orchestrator is cancelled.
|
|
22
|
-
* When false (default), jobs remain in the broker queue and can be reused on restart/reorg.
|
|
23
|
-
* When true, jobs are explicitly cancelled with the broker, which prevents reuse.
|
|
24
|
-
*/
|
|
25
|
-
cancelJobsOnStop: boolean;
|
|
26
20
|
};
|
|
27
21
|
|
|
28
22
|
/**
|
|
@@ -49,7 +43,6 @@ export const ProverConfigSchema = zodFor<ProverConfig>()(
|
|
|
49
43
|
proverTestDelayFactor: z.number(),
|
|
50
44
|
proverAgentCount: z.number(),
|
|
51
45
|
failedProofStore: z.string().optional(),
|
|
52
|
-
cancelJobsOnStop: z.boolean(),
|
|
53
46
|
}),
|
|
54
47
|
);
|
|
55
48
|
|
|
@@ -92,14 +85,6 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
|
|
|
92
85
|
description:
|
|
93
86
|
'Store for failed proof inputs. Google cloud storage is only supported at the moment. Set this value as gs://bucket-name/path/to/store.',
|
|
94
87
|
},
|
|
95
|
-
cancelJobsOnStop: {
|
|
96
|
-
env: 'PROVER_CANCEL_JOBS_ON_STOP',
|
|
97
|
-
description:
|
|
98
|
-
'Whether to abort pending proving jobs when the orchestrator is cancelled. ' +
|
|
99
|
-
'When false (default), jobs remain in the broker queue and can be reused on restart/reorg. ' +
|
|
100
|
-
'When true, jobs are explicitly cancelled with the broker, which prevents reuse.',
|
|
101
|
-
...booleanConfigHelper(false),
|
|
102
|
-
},
|
|
103
88
|
};
|
|
104
89
|
|
|
105
90
|
function parseProverId(str?: string) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { L2BlockNew } from '@aztec/stdlib/block';
|
|
2
2
|
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
3
3
|
import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
@@ -13,5 +13,5 @@ export interface ITxProvider {
|
|
|
13
13
|
opts: { pinnedPeer: PeerId | undefined; deadline: Date },
|
|
14
14
|
): Promise<{ txs: Tx[]; missingTxs: TxHash[] }>;
|
|
15
15
|
|
|
16
|
-
getTxsForBlock(block:
|
|
16
|
+
getTxsForBlock(block: L2BlockNew, opts: { deadline: Date }): Promise<{ txs: Tx[]; missingTxs: TxHash[] }>;
|
|
17
17
|
}
|
|
@@ -55,7 +55,8 @@ export type ValidatorClientConfig = ValidatorHASignerConfig & {
|
|
|
55
55
|
/** Skip checkpoint proposal validation and always attest (default: true) */
|
|
56
56
|
skipCheckpointProposalValidation?: boolean;
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
// TODO(palla/mbps): Change default to false once block sync is stable
|
|
59
|
+
/** Skip pushing re-executed blocks to archiver (default: true) */
|
|
59
60
|
skipPushProposedBlocksToArchiver?: boolean;
|
|
60
61
|
};
|
|
61
62
|
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
7
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
8
8
|
|
|
9
|
+
import { siloNullifier } from '../../hash/hash.js';
|
|
9
10
|
import type { NullifierLeafPreimage } from '../../trees/nullifier_leaf.js';
|
|
10
11
|
import type { ClaimedLengthArray } from '../claimed_length_array.js';
|
|
11
12
|
import type { ScopedNullifier } from '../nullifier.js';
|
|
@@ -73,6 +74,7 @@ export async function buildNullifierReadRequestHintsFromResetActions<PENDING ext
|
|
|
73
74
|
resetActions: ReadRequestResetActions<typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
|
|
74
75
|
maxPending: PENDING = MAX_NULLIFIER_READ_REQUESTS_PER_TX as PENDING,
|
|
75
76
|
maxSettled: SETTLED = MAX_NULLIFIER_READ_REQUESTS_PER_TX as SETTLED,
|
|
77
|
+
siloed = false,
|
|
76
78
|
) {
|
|
77
79
|
const builder = new NullifierReadRequestHintsBuilder(maxPending, maxSettled);
|
|
78
80
|
|
|
@@ -88,7 +90,12 @@ export async function buildNullifierReadRequestHintsFromResetActions<PENDING ext
|
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
|
|
93
|
+
// Compute siloed values in parallel (if not already siloed)
|
|
94
|
+
const siloedValues = siloed
|
|
95
|
+
? settledRequests.map(({ readRequest }) => readRequest.value)
|
|
96
|
+
: await Promise.all(
|
|
97
|
+
settledRequests.map(({ readRequest }) => siloNullifier(readRequest.contractAddress, readRequest.value)),
|
|
98
|
+
);
|
|
92
99
|
|
|
93
100
|
// Fetch all membership witnesses in parallel
|
|
94
101
|
const membershipWitnesses = await Promise.all(siloedValues.map(value => oracle.getNullifierMembershipWitness(value)));
|
|
@@ -114,6 +121,7 @@ export async function buildNullifierReadRequestHints<PENDING extends number, SET
|
|
|
114
121
|
futureNullifiers: ScopedNullifier[],
|
|
115
122
|
maxPending: PENDING = MAX_NULLIFIER_READ_REQUESTS_PER_TX as PENDING,
|
|
116
123
|
maxSettled: SETTLED = MAX_NULLIFIER_READ_REQUESTS_PER_TX as SETTLED,
|
|
124
|
+
siloed = false,
|
|
117
125
|
) {
|
|
118
126
|
const resetActions = getNullifierReadRequestResetActions(nullifierReadRequests, nullifiers, futureNullifiers);
|
|
119
127
|
return await buildNullifierReadRequestHintsFromResetActions(
|
|
@@ -122,5 +130,6 @@ export async function buildNullifierReadRequestHints<PENDING extends number, SET
|
|
|
122
130
|
resetActions,
|
|
123
131
|
maxPending,
|
|
124
132
|
maxSettled,
|
|
133
|
+
siloed,
|
|
125
134
|
);
|
|
126
135
|
}
|
|
@@ -8,8 +8,8 @@ import { Signature } from '@aztec/foundation/eth-signature';
|
|
|
8
8
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
9
9
|
import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
|
|
10
10
|
|
|
11
|
-
import type { L2Block } from '../block/l2_block.js';
|
|
12
11
|
import type { L2BlockInfo } from '../block/l2_block_info.js';
|
|
12
|
+
import type { L2BlockNew } from '../block/l2_block_new.js';
|
|
13
13
|
import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
|
|
14
14
|
import { BlockHeader } from '../tx/block_header.js';
|
|
15
15
|
import { TxHash } from '../tx/index.js';
|
|
@@ -284,10 +284,10 @@ export class BlockProposal extends Gossipable {
|
|
|
284
284
|
/**
|
|
285
285
|
* Check if this proposal matches the given block.
|
|
286
286
|
* Compares the archive root and block header.
|
|
287
|
-
* @param block - The
|
|
287
|
+
* @param block - The L2BlockNew to compare against
|
|
288
288
|
* @returns True if the proposal matches the block
|
|
289
289
|
*/
|
|
290
|
-
matchesBlock(block:
|
|
290
|
+
matchesBlock(block: L2BlockNew): boolean {
|
|
291
291
|
return this.archiveRoot.equals(block.archive.root) && this.blockHeader.equals(block.header);
|
|
292
292
|
}
|
|
293
293
|
|
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
import type { PeerErrorSeverity } from './peer_error.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Result of validating a P2P message.
|
|
5
|
-
* - 'accept': Message is valid and should be accepted and processed
|
|
6
|
-
* - 'ignore': Message should be ignored (not propagated or processed, but sender not penalized)
|
|
7
|
-
* - 'reject': Message is invalid (rejected and sender penalized)
|
|
8
|
-
*/
|
|
9
|
-
export type ValidationResult =
|
|
10
|
-
| { result: 'accept' }
|
|
11
|
-
| { result: 'ignore' }
|
|
12
|
-
| { result: 'reject'; severity: PeerErrorSeverity };
|
|
13
|
-
|
|
14
3
|
/**
|
|
15
4
|
* P2PValidator
|
|
16
5
|
*
|
|
17
|
-
* A validator for P2P messages, which returns a
|
|
18
|
-
* whether to accept, ignore, or reject the message
|
|
6
|
+
* A validator for P2P messages, which returns a severity of error to be applied to the peer
|
|
19
7
|
*/
|
|
20
8
|
export interface P2PValidator<T> {
|
|
21
|
-
validate(message: T): Promise<
|
|
9
|
+
validate(message: T): Promise<PeerErrorSeverity | undefined>;
|
|
22
10
|
}
|
package/src/tests/factories.ts
CHANGED
|
@@ -1739,7 +1739,7 @@ export function makeL2Tips(
|
|
|
1739
1739
|
? typeof checkpointNumber === 'number'
|
|
1740
1740
|
? CheckpointNumber(checkpointNumber)
|
|
1741
1741
|
: checkpointNumber
|
|
1742
|
-
: CheckpointNumber
|
|
1742
|
+
: CheckpointNumber(bn);
|
|
1743
1743
|
const cph = checkpointHash ?? hash;
|
|
1744
1744
|
return {
|
|
1745
1745
|
proposed: { number: bn, hash },
|
package/src/tests/jest.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L2BlockNew } from '../block/l2_block_new.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Checks if two objects are the same
|
|
4
|
+
* Checks if two objects are the same L2BlockNew.
|
|
5
5
|
*
|
|
6
|
-
* Sometimes we might be comparing two
|
|
6
|
+
* Sometimes we might be comparing two L2BlockNew instances that represent the same block but one of them might not have
|
|
7
7
|
* calculated and filled its `blockHash` property (which is computed on demand). This function ensures both objects
|
|
8
|
-
* are really the same
|
|
8
|
+
* are really the same L2BlockNew.
|
|
9
9
|
*
|
|
10
10
|
* @param a - An object
|
|
11
11
|
* @param b - Another object
|
|
12
|
-
* @returns True if both a and b are the same
|
|
12
|
+
* @returns True if both a and b are the same L2BlockNew
|
|
13
13
|
*/
|
|
14
14
|
export function equalL2Blocks(a: any, b: any) {
|
|
15
|
-
const aAsL2Block = a && a instanceof
|
|
16
|
-
const bAsL2Block = b && b instanceof
|
|
15
|
+
const aAsL2Block = a && a instanceof L2BlockNew ? a : undefined;
|
|
16
|
+
const bAsL2Block = b && b instanceof L2BlockNew ? b : undefined;
|
|
17
17
|
|
|
18
18
|
if (aAsL2Block && bAsL2Block) {
|
|
19
|
-
// we got two
|
|
19
|
+
// we got two L2BlockNew instances, so we can compare them
|
|
20
20
|
// use a custom comparator because the blockHash property is lazily computed and one instance might not have it
|
|
21
21
|
return aAsL2Block.toBuffer().equals(bAsL2Block.toBuffer());
|
|
22
22
|
} else if (aAsL2Block || bAsL2Block) {
|
|
23
|
-
// one value is an
|
|
23
|
+
// one value is an L2BlockNew and the other isn't. Definitely not equal.
|
|
24
24
|
return false;
|
|
25
25
|
} else {
|
|
26
26
|
// we don't know what they are, tell Jest to keep looking
|
package/src/tests/mocks.ts
CHANGED
|
@@ -22,7 +22,7 @@ import { AvmCircuitPublicInputs } from '../avm/avm_circuit_public_inputs.js';
|
|
|
22
22
|
import { PublicDataWrite } from '../avm/public_data_write.js';
|
|
23
23
|
import { RevertCode } from '../avm/revert_code.js';
|
|
24
24
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
25
|
-
import { CheckpointedL2Block, CommitteeAttestation,
|
|
25
|
+
import { CheckpointedL2Block, CommitteeAttestation, L2BlockNew } from '../block/index.js';
|
|
26
26
|
import type { CommitteeAttestationsAndSigners } from '../block/proposal/attestations_and_signers.js';
|
|
27
27
|
import { Checkpoint } from '../checkpoint/checkpoint.js';
|
|
28
28
|
import { L1PublishedData } from '../checkpoint/published_checkpoint.js';
|
|
@@ -404,37 +404,32 @@ export async function mockCheckpointAndMessages(
|
|
|
404
404
|
numL1ToL2Messages = 1,
|
|
405
405
|
makeBlockOptions = () => ({}),
|
|
406
406
|
previousArchive,
|
|
407
|
-
maxEffects,
|
|
408
407
|
...options
|
|
409
408
|
}: {
|
|
410
409
|
startBlockNumber?: BlockNumber;
|
|
411
410
|
numBlocks?: number;
|
|
412
411
|
numTxsPerBlock?: number;
|
|
413
412
|
numL1ToL2Messages?: number;
|
|
414
|
-
makeBlockOptions?: (blockNumber: BlockNumber) => Partial<Parameters<typeof
|
|
413
|
+
makeBlockOptions?: (blockNumber: BlockNumber) => Partial<Parameters<typeof L2BlockNew.random>[1]>;
|
|
415
414
|
previousArchive?: AppendOnlyTreeSnapshot;
|
|
416
|
-
blocks?:
|
|
417
|
-
maxEffects?: number;
|
|
415
|
+
blocks?: L2BlockNew[];
|
|
418
416
|
} & Partial<Parameters<typeof Checkpoint.random>[1]> &
|
|
419
|
-
Partial<Parameters<typeof
|
|
417
|
+
Partial<Parameters<typeof L2BlockNew.random>[1]> = {},
|
|
420
418
|
) {
|
|
421
|
-
const slotNumber = options.slotNumber ?? SlotNumber(
|
|
419
|
+
const slotNumber = options.slotNumber ?? SlotNumber(checkpointNumber * 10);
|
|
422
420
|
const blocksAndMessages = [];
|
|
423
421
|
// Track the previous block's archive to ensure consecutive blocks have consistent archive roots.
|
|
424
422
|
// The current block's header.lastArchive must equal the previous block's archive.
|
|
425
423
|
let lastArchive: AppendOnlyTreeSnapshot | undefined = previousArchive;
|
|
426
|
-
// Pass maxEffects via txOptions so it reaches TxEffect.random
|
|
427
|
-
const txOptions = maxEffects !== undefined ? { maxEffects } : {};
|
|
428
424
|
for (let i = 0; i < (blocks?.length ?? numBlocks); i++) {
|
|
429
425
|
const blockNumber = BlockNumber(startBlockNumber + i);
|
|
430
426
|
const { block, messages } = {
|
|
431
427
|
block:
|
|
432
428
|
blocks?.[i] ??
|
|
433
|
-
(await
|
|
429
|
+
(await L2BlockNew.random(blockNumber, {
|
|
434
430
|
checkpointNumber,
|
|
435
431
|
indexWithinCheckpoint: IndexWithinCheckpoint(i),
|
|
436
432
|
txsPerBlock: numTxsPerBlock,
|
|
437
|
-
txOptions,
|
|
438
433
|
slotNumber,
|
|
439
434
|
...options,
|
|
440
435
|
...makeBlockOptions(blockNumber),
|
|
@@ -675,15 +670,15 @@ export const makeCheckpointAttestationFromCheckpoint = (
|
|
|
675
670
|
};
|
|
676
671
|
|
|
677
672
|
/**
|
|
678
|
-
* Create a checkpoint attestation from an
|
|
679
|
-
* Note: This is a compatibility function for tests.
|
|
673
|
+
* Create a checkpoint attestation from an L2BlockNew
|
|
674
|
+
* Note: This is a compatibility function for tests. L2BlockNew doesn't have a checkpoint header directly.
|
|
680
675
|
*/
|
|
681
676
|
export const makeCheckpointAttestationFromBlock = (
|
|
682
|
-
block:
|
|
677
|
+
block: L2BlockNew,
|
|
683
678
|
attesterSigner?: Secp256k1Signer,
|
|
684
679
|
proposerSigner?: Secp256k1Signer,
|
|
685
680
|
): CheckpointAttestation => {
|
|
686
|
-
// For
|
|
681
|
+
// For L2BlockNew, we create a minimal checkpoint header for testing purposes
|
|
687
682
|
const header = CheckpointHeader.empty({
|
|
688
683
|
lastArchiveRoot: block.header.lastArchive.root,
|
|
689
684
|
slotNumber: block.slot,
|
|
@@ -699,7 +694,7 @@ export async function randomPublishedL2Block(
|
|
|
699
694
|
l2BlockNumber: number,
|
|
700
695
|
opts: { signers?: Secp256k1Signer[] } = {},
|
|
701
696
|
): Promise<CheckpointedL2Block> {
|
|
702
|
-
const block = await
|
|
697
|
+
const block = await L2BlockNew.random(BlockNumber(l2BlockNumber));
|
|
703
698
|
const l1 = L1PublishedData.fromFields({
|
|
704
699
|
blockNumber: BigInt(block.number),
|
|
705
700
|
timestamp: block.header.globalVariables.timestamp,
|
|
@@ -707,9 +702,7 @@ export async function randomPublishedL2Block(
|
|
|
707
702
|
});
|
|
708
703
|
|
|
709
704
|
const signers = opts.signers ?? times(3, () => Secp256k1Signer.random());
|
|
710
|
-
const checkpoint = await Checkpoint.random(CheckpointNumber
|
|
711
|
-
numBlocks: 0,
|
|
712
|
-
});
|
|
705
|
+
const checkpoint = await Checkpoint.random(CheckpointNumber(l2BlockNumber), { numBlocks: 0 });
|
|
713
706
|
checkpoint.blocks = [block];
|
|
714
707
|
const atts = signers.map(signer =>
|
|
715
708
|
makeCheckpointAttestation({
|
|
@@ -721,5 +714,5 @@ export async function randomPublishedL2Block(
|
|
|
721
714
|
const attestations = atts.map(
|
|
722
715
|
(attestation, i) => new CommitteeAttestation(signers[i].address, attestation.signature),
|
|
723
716
|
);
|
|
724
|
-
return new CheckpointedL2Block(CheckpointNumber
|
|
717
|
+
return new CheckpointedL2Block(CheckpointNumber(l2BlockNumber), block, l1, attestations);
|
|
725
718
|
}
|
package/src/tx/tx_receipt.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
3
|
|
|
3
4
|
import { z } from 'zod';
|
|
4
5
|
|
|
@@ -7,28 +8,12 @@ import { L2BlockHash } from '../block/block_hash.js';
|
|
|
7
8
|
import { type ZodFor, schemas } from '../schemas/schemas.js';
|
|
8
9
|
import { TxHash } from './tx_hash.js';
|
|
9
10
|
|
|
10
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Possible status of a transaction.
|
|
13
|
+
*/
|
|
11
14
|
export enum TxStatus {
|
|
12
15
|
DROPPED = 'dropped',
|
|
13
16
|
PENDING = 'pending',
|
|
14
|
-
PROPOSED = 'proposed',
|
|
15
|
-
CHECKPOINTED = 'checkpointed',
|
|
16
|
-
PROVEN = 'proven',
|
|
17
|
-
FINALIZED = 'finalized', // TODO(#13569): Implement finalized status properly
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** Tx status sorted by finalization progress. */
|
|
21
|
-
export const SortedTxStatuses: TxStatus[] = [
|
|
22
|
-
TxStatus.DROPPED,
|
|
23
|
-
TxStatus.PENDING,
|
|
24
|
-
TxStatus.PROPOSED,
|
|
25
|
-
TxStatus.CHECKPOINTED,
|
|
26
|
-
TxStatus.PROVEN,
|
|
27
|
-
TxStatus.FINALIZED,
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
/** Execution result - only set when tx is in a block. */
|
|
31
|
-
export enum TxExecutionResult {
|
|
32
17
|
SUCCESS = 'success',
|
|
33
18
|
APP_LOGIC_REVERTED = 'app_logic_reverted',
|
|
34
19
|
TEARDOWN_REVERTED = 'teardown_reverted',
|
|
@@ -45,12 +30,10 @@ export class TxReceipt {
|
|
|
45
30
|
constructor(
|
|
46
31
|
/** A unique identifier for a transaction. */
|
|
47
32
|
public txHash: TxHash,
|
|
48
|
-
/** The transaction's
|
|
33
|
+
/** The transaction's status. */
|
|
49
34
|
public status: TxStatus,
|
|
50
|
-
/** The execution result of the transaction, only set when tx is in a block. */
|
|
51
|
-
public executionResult: TxExecutionResult | undefined,
|
|
52
35
|
/** Description of transaction error, if any. */
|
|
53
|
-
public error: string
|
|
36
|
+
public error: string,
|
|
54
37
|
/** The transaction fee paid for the transaction. */
|
|
55
38
|
public transactionFee?: bigint,
|
|
56
39
|
/** The hash of the block containing the transaction. */
|
|
@@ -59,38 +42,8 @@ export class TxReceipt {
|
|
|
59
42
|
public blockNumber?: BlockNumber,
|
|
60
43
|
) {}
|
|
61
44
|
|
|
62
|
-
/** Returns true if the transaction was executed successfully. */
|
|
63
|
-
hasExecutionSucceeded(): boolean {
|
|
64
|
-
return this.executionResult === TxExecutionResult.SUCCESS;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Returns true if the transaction execution reverted. */
|
|
68
|
-
hasExecutionReverted(): boolean {
|
|
69
|
-
return this.executionResult !== undefined && this.executionResult !== TxExecutionResult.SUCCESS;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** Returns true if the transaction has been included in a block (proposed, checkpointed, proven, or finalized). */
|
|
73
|
-
isMined(): boolean {
|
|
74
|
-
return (
|
|
75
|
-
this.status === TxStatus.PROPOSED ||
|
|
76
|
-
this.status === TxStatus.CHECKPOINTED ||
|
|
77
|
-
this.status === TxStatus.PROVEN ||
|
|
78
|
-
this.status === TxStatus.FINALIZED
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** Returns true if the transaction is pending. */
|
|
83
|
-
isPending(): boolean {
|
|
84
|
-
return this.status === TxStatus.PENDING;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** Returns true if the transaction was dropped. */
|
|
88
|
-
isDropped(): boolean {
|
|
89
|
-
return this.status === TxStatus.DROPPED;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
45
|
static empty() {
|
|
93
|
-
return new TxReceipt(TxHash.zero(), TxStatus.DROPPED,
|
|
46
|
+
return new TxReceipt(TxHash.zero(), TxStatus.DROPPED, '');
|
|
94
47
|
}
|
|
95
48
|
|
|
96
49
|
static get schema(): ZodFor<TxReceipt> {
|
|
@@ -98,28 +51,18 @@ export class TxReceipt {
|
|
|
98
51
|
.object({
|
|
99
52
|
txHash: TxHash.schema,
|
|
100
53
|
status: z.nativeEnum(TxStatus),
|
|
101
|
-
|
|
102
|
-
error: z.string().optional(),
|
|
54
|
+
error: z.string(),
|
|
103
55
|
blockHash: L2BlockHash.schema.optional(),
|
|
104
56
|
blockNumber: BlockNumberSchema.optional(),
|
|
105
57
|
transactionFee: schemas.BigInt.optional(),
|
|
106
58
|
})
|
|
107
|
-
.transform(
|
|
59
|
+
.transform(TxReceipt.from);
|
|
108
60
|
}
|
|
109
61
|
|
|
110
|
-
static from(fields: {
|
|
111
|
-
txHash: TxHash;
|
|
112
|
-
status: TxStatus;
|
|
113
|
-
executionResult?: TxExecutionResult;
|
|
114
|
-
error?: string;
|
|
115
|
-
transactionFee?: bigint;
|
|
116
|
-
blockHash?: L2BlockHash;
|
|
117
|
-
blockNumber?: BlockNumber;
|
|
118
|
-
}) {
|
|
62
|
+
static from(fields: FieldsOf<TxReceipt>) {
|
|
119
63
|
return new TxReceipt(
|
|
120
64
|
fields.txHash,
|
|
121
65
|
fields.status,
|
|
122
|
-
fields.executionResult,
|
|
123
66
|
fields.error,
|
|
124
67
|
fields.transactionFee,
|
|
125
68
|
fields.blockHash,
|
|
@@ -127,15 +70,15 @@ export class TxReceipt {
|
|
|
127
70
|
);
|
|
128
71
|
}
|
|
129
72
|
|
|
130
|
-
public static
|
|
73
|
+
public static statusFromRevertCode(revertCode: RevertCode) {
|
|
131
74
|
if (revertCode.equals(RevertCode.OK)) {
|
|
132
|
-
return
|
|
75
|
+
return TxStatus.SUCCESS;
|
|
133
76
|
} else if (revertCode.equals(RevertCode.APP_LOGIC_REVERTED)) {
|
|
134
|
-
return
|
|
77
|
+
return TxStatus.APP_LOGIC_REVERTED;
|
|
135
78
|
} else if (revertCode.equals(RevertCode.TEARDOWN_REVERTED)) {
|
|
136
|
-
return
|
|
79
|
+
return TxStatus.TEARDOWN_REVERTED;
|
|
137
80
|
} else if (revertCode.equals(RevertCode.BOTH_REVERTED)) {
|
|
138
|
-
return
|
|
81
|
+
return TxStatus.BOTH_REVERTED;
|
|
139
82
|
} else {
|
|
140
83
|
throw new Error(`Unknown revert code: ${revertCode.getCode()}`);
|
|
141
84
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"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