@aztec/stdlib 0.0.1-commit.d1da697d6 → 0.0.1-commit.d20b825a7
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/abi/authorization_selector.d.ts +3 -6
- package/dest/abi/authorization_selector.d.ts.map +1 -1
- package/dest/abi/encoder.d.ts +1 -1
- package/dest/abi/encoder.d.ts.map +1 -1
- package/dest/abi/encoder.js +32 -6
- package/dest/abi/event_selector.d.ts +3 -6
- package/dest/abi/event_selector.d.ts.map +1 -1
- package/dest/abi/function_selector.d.ts +3 -6
- package/dest/abi/function_selector.d.ts.map +1 -1
- package/dest/abi/function_selector.js +1 -3
- package/dest/abi/note_selector.d.ts +3 -6
- package/dest/abi/note_selector.d.ts.map +1 -1
- package/dest/abi/note_selector.js +1 -3
- package/dest/avm/avm.d.ts +300 -300
- package/dest/aztec-address/index.d.ts +3 -6
- package/dest/aztec-address/index.d.ts.map +1 -1
- package/dest/aztec-address/index.js +2 -4
- package/dest/block/block_data.d.ts +8 -8
- package/dest/block/block_data.d.ts.map +1 -1
- package/dest/block/block_data.js +2 -2
- package/dest/block/block_hash.d.ts +11 -10
- package/dest/block/block_hash.d.ts.map +1 -1
- package/dest/block/block_hash.js +10 -9
- package/dest/block/l2_block_info.d.ts +6 -5
- package/dest/block/l2_block_info.d.ts.map +1 -1
- package/dest/block/l2_block_info.js +6 -5
- package/dest/block/l2_block_stream/interfaces.d.ts +6 -3
- package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.js +1 -1
- package/dest/block/test/l2_tips_store_test_suite.js +1 -1
- package/dest/config/chain-config.d.ts +1 -1
- package/dest/config/chain-config.d.ts.map +1 -1
- package/dest/config/chain-config.js +7 -1
- package/dest/config/sequencer-config.d.ts +2 -2
- package/dest/config/sequencer-config.d.ts.map +1 -1
- package/dest/config/sequencer-config.js +10 -3
- package/dest/contract/contract_address.d.ts +1 -1
- package/dest/contract/contract_address.js +2 -2
- 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 -4
- package/dest/gas/fee_math.d.ts +49 -0
- package/dest/gas/fee_math.d.ts.map +1 -0
- package/dest/gas/fee_math.js +80 -0
- package/dest/gas/gas_fees.d.ts +5 -1
- package/dest/gas/gas_fees.d.ts.map +1 -1
- package/dest/gas/gas_fees.js +10 -1
- package/dest/gas/index.d.ts +2 -1
- package/dest/gas/index.d.ts.map +1 -1
- package/dest/gas/index.js +1 -0
- package/dest/ha-signing/config.d.ts +6 -6
- package/dest/ha-signing/config.d.ts.map +1 -1
- package/dest/ha-signing/config.js +4 -3
- package/dest/ha-signing/index.d.ts +2 -2
- package/dest/ha-signing/index.d.ts.map +1 -1
- package/dest/ha-signing/index.js +1 -1
- package/dest/ha-signing/local_config.js +1 -1
- package/dest/ha-signing/types.d.ts +37 -32
- package/dest/ha-signing/types.d.ts.map +1 -1
- package/dest/ha-signing/types.js +13 -6
- package/dest/hash/hash.d.ts +16 -1
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +32 -0
- package/dest/interfaces/archiver.d.ts +11 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +3 -1
- package/dest/interfaces/aztec-node-admin.d.ts +8 -14
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +1 -2
- package/dest/interfaces/aztec-node-debug.d.ts +21 -0
- package/dest/interfaces/aztec-node-debug.d.ts.map +1 -0
- package/dest/interfaces/aztec-node-debug.js +18 -0
- package/dest/interfaces/aztec-node.d.ts +10 -1
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +2 -0
- package/dest/interfaces/client.d.ts +2 -1
- package/dest/interfaces/client.d.ts.map +1 -1
- package/dest/interfaces/client.js +1 -0
- package/dest/interfaces/merkle_tree_operations.d.ts +4 -3
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/prover-client.d.ts +1 -1
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +0 -3
- package/dest/interfaces/slasher.d.ts +1 -10
- package/dest/interfaces/slasher.d.ts.map +1 -1
- package/dest/interfaces/slasher.js +0 -2
- package/dest/interfaces/validator.d.ts +14 -17
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/l1-contracts/index.d.ts +2 -2
- package/dest/l1-contracts/index.d.ts.map +1 -1
- package/dest/l1-contracts/index.js +1 -1
- package/dest/logs/log_id.d.ts +1 -1
- package/dest/logs/log_id.d.ts.map +1 -1
- package/dest/logs/log_id.js +1 -2
- package/dest/logs/siloed_tag.d.ts +5 -7
- package/dest/logs/siloed_tag.d.ts.map +1 -1
- package/dest/logs/siloed_tag.js +4 -0
- package/dest/logs/tag.d.ts +5 -6
- package/dest/logs/tag.d.ts.map +1 -1
- package/dest/logs/tag.js +4 -0
- package/dest/p2p/block_proposal.d.ts +6 -8
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +4 -9
- package/dest/p2p/checkpoint_attestation.d.ts +4 -6
- package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
- package/dest/p2p/checkpoint_attestation.js +2 -7
- package/dest/p2p/checkpoint_proposal.d.ts +8 -10
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +5 -24
- package/dest/p2p/gossipable.d.ts +4 -4
- package/dest/p2p/gossipable.d.ts.map +1 -1
- package/dest/parity/parity_base_private_inputs.d.ts +7 -3
- package/dest/parity/parity_base_private_inputs.d.ts.map +1 -1
- package/dest/parity/parity_base_private_inputs.js +7 -5
- package/dest/parity/parity_public_inputs.d.ts +7 -3
- package/dest/parity/parity_public_inputs.d.ts.map +1 -1
- package/dest/parity/parity_public_inputs.js +6 -3
- package/dest/rollup/block_headers_hash.d.ts +1 -1
- package/dest/rollup/block_headers_hash.d.ts.map +1 -1
- package/dest/rollup/block_headers_hash.js +8 -2
- package/dest/slashing/index.d.ts +2 -3
- package/dest/slashing/index.d.ts.map +1 -1
- package/dest/slashing/index.js +1 -2
- package/dest/slashing/serialization.d.ts +2 -6
- package/dest/slashing/serialization.d.ts.map +1 -1
- package/dest/slashing/serialization.js +0 -60
- package/dest/slashing/types.d.ts +4 -90
- package/dest/slashing/types.d.ts.map +1 -1
- package/dest/slashing/types.js +0 -14
- package/dest/slashing/{tally.d.ts → votes.d.ts} +1 -1
- package/dest/slashing/{tally.d.ts.map → votes.d.ts.map} +1 -1
- package/dest/slashing/{tally.js → votes.js} +1 -1
- package/dest/tests/factories.d.ts +2 -7
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +8 -18
- package/dest/tests/mocks.d.ts +1 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +12 -17
- package/dest/timetable/index.d.ts +51 -1
- package/dest/timetable/index.d.ts.map +1 -1
- package/dest/timetable/index.js +204 -14
- package/dest/trees/nullifier_leaf.d.ts +2 -1
- package/dest/trees/nullifier_leaf.d.ts.map +1 -1
- package/dest/trees/nullifier_leaf.js +3 -0
- package/dest/tx/block_header.d.ts +2 -2
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +1 -1
- package/dest/tx/fee_provider.d.ts +10 -0
- package/dest/tx/fee_provider.d.ts.map +1 -0
- package/dest/tx/fee_provider.js +1 -0
- package/dest/tx/global_variable_builder.d.ts +3 -16
- package/dest/tx/global_variable_builder.d.ts.map +1 -1
- package/dest/tx/index.d.ts +2 -1
- package/dest/tx/index.d.ts.map +1 -1
- package/dest/tx/index.js +1 -0
- package/dest/tx/indexed_tx_effect.d.ts +1 -1
- package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
- package/dest/tx/indexed_tx_effect.js +1 -2
- package/dest/tx/simulated_tx.d.ts +1 -1
- package/dest/tx/simulated_tx.js +1 -1
- package/dest/tx/tx.d.ts +3 -3
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/types/shared.d.ts +1 -10
- package/dest/types/shared.d.ts.map +1 -1
- package/dest/types/shared.js +0 -9
- package/dest/vks/verification_key.d.ts +2 -137
- package/dest/vks/verification_key.d.ts.map +1 -1
- package/dest/vks/verification_key.js +5 -126
- package/dest/world-state/genesis_data.d.ts +11 -0
- package/dest/world-state/genesis_data.d.ts.map +1 -0
- package/dest/world-state/genesis_data.js +4 -0
- package/dest/world-state/index.d.ts +2 -1
- package/dest/world-state/index.d.ts.map +1 -1
- package/dest/world-state/index.js +1 -0
- package/dest/world-state/world_state_revision.d.ts +8 -1
- package/dest/world-state/world_state_revision.d.ts.map +1 -1
- package/dest/world-state/world_state_revision.js +7 -1
- package/package.json +8 -8
- package/src/abi/authorization_selector.ts +2 -8
- package/src/abi/encoder.ts +42 -6
- package/src/abi/event_selector.ts +2 -8
- package/src/abi/function_selector.ts +3 -12
- package/src/abi/note_selector.ts +3 -12
- package/src/aztec-address/index.ts +4 -10
- package/src/block/block_data.ts +3 -4
- package/src/block/block_hash.ts +21 -14
- package/src/block/l2_block_info.ts +8 -6
- package/src/block/l2_block_stream/interfaces.ts +6 -2
- package/src/block/l2_block_stream/l2_tips_store_base.ts +1 -1
- package/src/block/test/l2_tips_store_test_suite.ts +1 -1
- package/src/config/chain-config.ts +7 -1
- package/src/config/sequencer-config.ts +14 -4
- package/src/contract/contract_address.ts +2 -2
- package/src/contract/private_function.ts +3 -1
- package/src/gas/README.md +31 -0
- package/src/gas/fee_math.ts +120 -0
- package/src/gas/gas_fees.ts +17 -4
- package/src/gas/index.ts +1 -0
- package/src/ha-signing/config.ts +5 -2
- package/src/ha-signing/index.ts +3 -1
- package/src/ha-signing/local_config.ts +1 -1
- package/src/ha-signing/types.ts +48 -34
- package/src/hash/hash.ts +27 -0
- package/src/interfaces/archiver.ts +8 -0
- package/src/interfaces/aztec-node-admin.ts +3 -6
- package/src/interfaces/aztec-node-debug.ts +40 -0
- package/src/interfaces/aztec-node.ts +15 -0
- package/src/interfaces/client.ts +1 -0
- package/src/interfaces/merkle_tree_operations.ts +3 -2
- package/src/interfaces/prover-client.ts +2 -5
- package/src/interfaces/slasher.ts +0 -6
- package/src/interfaces/validator.ts +15 -8
- package/src/l1-contracts/index.ts +1 -1
- package/src/logs/log_id.ts +1 -2
- package/src/logs/siloed_tag.ts +8 -9
- package/src/logs/tag.ts +8 -8
- package/src/p2p/block_proposal.ts +13 -9
- package/src/p2p/checkpoint_attestation.ts +5 -9
- package/src/p2p/checkpoint_proposal.ts +21 -36
- package/src/p2p/gossipable.ts +4 -4
- package/src/parity/parity_base_private_inputs.ts +10 -4
- package/src/parity/parity_public_inputs.ts +9 -2
- package/src/rollup/block_headers_hash.ts +11 -2
- package/src/slashing/index.ts +1 -2
- package/src/slashing/serialization.ts +1 -81
- package/src/slashing/types.ts +3 -35
- package/src/slashing/{tally.ts → votes.ts} +1 -1
- package/src/tests/factories.ts +14 -20
- package/src/tests/mocks.ts +14 -10
- package/src/timetable/index.ts +293 -13
- package/src/trees/nullifier_leaf.ts +4 -0
- package/src/tx/block_header.ts +2 -2
- package/src/tx/fee_provider.ts +10 -0
- package/src/tx/global_variable_builder.ts +2 -18
- package/src/tx/index.ts +1 -0
- package/src/tx/indexed_tx_effect.ts +1 -2
- package/src/tx/simulated_tx.ts +1 -1
- package/src/tx/tx.ts +2 -2
- package/src/types/shared.ts +0 -10
- package/src/vks/verification_key.ts +5 -184
- package/src/world-state/genesis_data.ts +15 -0
- package/src/world-state/index.ts +1 -0
- package/src/world-state/world_state_revision.ts +9 -1
- package/dest/abi/mocked_keys.d.ts +0 -2
- package/dest/abi/mocked_keys.d.ts.map +0 -1
- package/dest/abi/mocked_keys.js +0 -1
- package/dest/l1-contracts/slash_factory.d.ts +0 -45
- package/dest/l1-contracts/slash_factory.d.ts.map +0 -1
- package/dest/l1-contracts/slash_factory.js +0 -158
- package/dest/slashing/empire.d.ts +0 -31
- package/dest/slashing/empire.d.ts.map +0 -1
- package/dest/slashing/empire.js +0 -87
- package/src/abi/mocked_keys.ts +0 -2
- package/src/l1-contracts/slash_factory.ts +0 -180
- package/src/slashing/empire.ts +0 -104
package/src/timetable/index.ts
CHANGED
|
@@ -25,6 +25,219 @@ export const DEFAULT_L1_PUBLISHING_TIME = 12;
|
|
|
25
25
|
/** Minimum execution time for building a block in seconds */
|
|
26
26
|
export const MIN_EXECUTION_TIME = 2;
|
|
27
27
|
|
|
28
|
+
export type CheckpointTimingConfig = {
|
|
29
|
+
aztecSlotDuration: number;
|
|
30
|
+
ethereumSlotDuration?: number;
|
|
31
|
+
blockDuration?: number;
|
|
32
|
+
checkpointAssembleTime?: number;
|
|
33
|
+
checkpointInitializationTime?: number;
|
|
34
|
+
l1PublishingTime?: number;
|
|
35
|
+
minExecutionTime?: number;
|
|
36
|
+
p2pPropagationTime?: number;
|
|
37
|
+
pipelining?: boolean;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export interface CheckpointTiming {
|
|
41
|
+
readonly aztecSlotDuration: number;
|
|
42
|
+
readonly blockDuration: number | undefined;
|
|
43
|
+
readonly checkpointAssembleTime: number;
|
|
44
|
+
readonly checkpointInitializationTime: number;
|
|
45
|
+
readonly l1PublishingTime: number;
|
|
46
|
+
readonly minExecutionTime: number;
|
|
47
|
+
readonly p2pPropagationTime: number;
|
|
48
|
+
readonly checkpointFinalizationTime: number;
|
|
49
|
+
readonly pipeliningAttestationGracePeriod: number;
|
|
50
|
+
readonly timeReservedAtEnd: number;
|
|
51
|
+
readonly minimumBuildSlotWork: number;
|
|
52
|
+
readonly initializeDeadline: number;
|
|
53
|
+
readonly checkpointAssemblyDeadline: number;
|
|
54
|
+
readonly checkpointAttestationStartDeadline: number;
|
|
55
|
+
readonly checkpointAttestationDeadline: number;
|
|
56
|
+
readonly checkpointPublishingDeadline: number;
|
|
57
|
+
|
|
58
|
+
calculateMaxBlocksPerSlot(): number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface PipelinedCheckpointTiming extends CheckpointTiming {
|
|
62
|
+
readonly proposalWindowIntoTargetSlot: number;
|
|
63
|
+
readonly attestationWindowIntoTargetSlot: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Shared base for checkpoint timing implementations.
|
|
68
|
+
*
|
|
69
|
+
* This class owns the common inputs and formulas used by both pipelined and
|
|
70
|
+
* non-pipelined scheduling. Variant-specific deadline math is delegated to the
|
|
71
|
+
* concrete subclasses below.
|
|
72
|
+
*/
|
|
73
|
+
abstract class BaseCheckpointTiming implements CheckpointTiming {
|
|
74
|
+
public readonly aztecSlotDuration: number;
|
|
75
|
+
public readonly blockDuration: number | undefined;
|
|
76
|
+
public readonly checkpointAssembleTime: number;
|
|
77
|
+
public readonly checkpointInitializationTime: number;
|
|
78
|
+
public readonly l1PublishingTime: number;
|
|
79
|
+
public readonly minExecutionTime: number;
|
|
80
|
+
public readonly p2pPropagationTime: number;
|
|
81
|
+
|
|
82
|
+
constructor(opts: CheckpointTimingConfig) {
|
|
83
|
+
this.aztecSlotDuration = opts.aztecSlotDuration;
|
|
84
|
+
this.blockDuration = opts.blockDuration;
|
|
85
|
+
|
|
86
|
+
this.checkpointAssembleTime = opts.checkpointAssembleTime ?? CHECKPOINT_ASSEMBLE_TIME;
|
|
87
|
+
this.checkpointInitializationTime = opts.checkpointInitializationTime ?? CHECKPOINT_INITIALIZATION_TIME;
|
|
88
|
+
this.l1PublishingTime = opts.l1PublishingTime ?? DEFAULT_L1_PUBLISHING_TIME;
|
|
89
|
+
this.minExecutionTime = opts.minExecutionTime ?? MIN_EXECUTION_TIME;
|
|
90
|
+
this.p2pPropagationTime = opts.p2pPropagationTime ?? DEFAULT_P2P_PROPAGATION_TIME;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public get checkpointFinalizationTime(): number {
|
|
94
|
+
// Allow enough time to
|
|
95
|
+
// - build the checkpoint
|
|
96
|
+
// - Round-trip over p2p
|
|
97
|
+
// - Publish to L1
|
|
98
|
+
return this.checkpointAssembleTime + this.p2pPropagationTime * 2 + this.l1PublishingTime;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public get pipeliningAttestationGracePeriod(): number {
|
|
102
|
+
// Allow enough time to
|
|
103
|
+
// - build the block
|
|
104
|
+
// - pass it back over p2p
|
|
105
|
+
return (this.blockDuration ?? 0) + this.p2pPropagationTime;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public abstract get timeReservedAtEnd(): number;
|
|
109
|
+
public abstract get minimumBuildSlotWork(): number;
|
|
110
|
+
|
|
111
|
+
public get initializeDeadline(): number {
|
|
112
|
+
return this.aztecSlotDuration - this.minimumBuildSlotWork;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
public abstract get checkpointAssemblyDeadline(): number;
|
|
116
|
+
|
|
117
|
+
public get checkpointAttestationStartDeadline(): number {
|
|
118
|
+
return this.checkpointAssemblyDeadline;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public abstract get checkpointAttestationDeadline(): number;
|
|
122
|
+
public abstract get checkpointPublishingDeadline(): number;
|
|
123
|
+
|
|
124
|
+
public calculateMaxBlocksPerSlot(): number {
|
|
125
|
+
if (!this.blockDuration) {
|
|
126
|
+
return 1;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const timeAvailableForBlocks = this.aztecSlotDuration - this.checkpointInitializationTime - this.timeReservedAtEnd;
|
|
130
|
+
return Math.floor(timeAvailableForBlocks / this.blockDuration);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Checkpoint timing model for the non-pipelined sequencer flow.
|
|
136
|
+
*
|
|
137
|
+
* In this mode, checkpoint assembly, attestation collection, and L1 publishing
|
|
138
|
+
* must all complete within the current Aztec slot.
|
|
139
|
+
*/
|
|
140
|
+
class StandardCheckpointTimingModel extends BaseCheckpointTiming {
|
|
141
|
+
public get timeReservedAtEnd(): number {
|
|
142
|
+
return (this.blockDuration ?? 0) + this.checkpointFinalizationTime;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public get minimumBuildSlotWork(): number {
|
|
146
|
+
return this.checkpointInitializationTime + this.minExecutionTime * 2 + this.checkpointFinalizationTime;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public get checkpointAssemblyDeadline(): number {
|
|
150
|
+
return this.aztecSlotDuration - this.l1PublishingTime - 2 * this.p2pPropagationTime;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public get checkpointAttestationDeadline(): number {
|
|
154
|
+
return this.aztecSlotDuration - this.l1PublishingTime;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public get checkpointPublishingDeadline(): number {
|
|
158
|
+
return this.aztecSlotDuration - this.l1PublishingTime;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Checkpoint timing model for proposer pipelining.
|
|
164
|
+
*
|
|
165
|
+
* In this mode, the build work still starts in the current slot, but checkpoint
|
|
166
|
+
* assembly and attestation collection can extend into the target slot. The extra
|
|
167
|
+
* target-slot window getters are intended for consumers such as P2P validators
|
|
168
|
+
* that need to validate pipelined messages against wallclock time.
|
|
169
|
+
*/
|
|
170
|
+
class PipelinedCheckpointTimingModel extends BaseCheckpointTiming implements PipelinedCheckpointTiming {
|
|
171
|
+
public get proposalWindowIntoTargetSlot(): number {
|
|
172
|
+
// Allow the p2p propagation time to receive a checkpoint proposal from leader
|
|
173
|
+
return this.p2pPropagationTime;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public get attestationWindowIntoTargetSlot(): number {
|
|
177
|
+
return this.aztecSlotDuration - this.l1PublishingTime;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public get timeReservedAtEnd(): number {
|
|
181
|
+
return this.checkpointAssembleTime + this.p2pPropagationTime;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
public get minimumBuildSlotWork(): number {
|
|
185
|
+
return this.checkpointInitializationTime + this.minExecutionTime * 2;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
public get checkpointAssemblyDeadline(): number {
|
|
189
|
+
// Allow enough time to
|
|
190
|
+
// - build all blocks
|
|
191
|
+
// - receive attestations
|
|
192
|
+
return this.aztecSlotDuration + this.pipeliningAttestationGracePeriod;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
public get checkpointAttestationDeadline(): number {
|
|
196
|
+
// Allowed to be into the next wallclock slot minus the allocated l1 publishing time
|
|
197
|
+
return this.aztecSlotDuration * 2 - this.l1PublishingTime;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
public get checkpointPublishingDeadline(): number {
|
|
201
|
+
// Allowed to be into the next wallclock slot minus the allocated l1 Publishing time
|
|
202
|
+
return this.aztecSlotDuration * 2 - this.l1PublishingTime;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Creates a checkpoint timing model for the requested scheduling mode.
|
|
208
|
+
*
|
|
209
|
+
* Most callers should use this factory and depend only on the shared
|
|
210
|
+
* `CheckpointTiming` interface. The returned implementation is selected from
|
|
211
|
+
* `opts.pipelining`.
|
|
212
|
+
*/
|
|
213
|
+
export function createCheckpointTimingModel(opts: CheckpointTimingConfig): CheckpointTiming {
|
|
214
|
+
validateCheckpointTimingConfig(opts);
|
|
215
|
+
const normalizedOpts = normalizeCheckpointTimingConfig(opts);
|
|
216
|
+
|
|
217
|
+
const timing = normalizedOpts.pipelining
|
|
218
|
+
? new PipelinedCheckpointTimingModel(normalizedOpts)
|
|
219
|
+
: new StandardCheckpointTimingModel(normalizedOpts);
|
|
220
|
+
validateCheckpointTimingModel(timing);
|
|
221
|
+
return timing;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Creates a pipelined checkpoint timing model with target-slot window accessors.
|
|
226
|
+
*
|
|
227
|
+
* Use this when the caller specifically needs the pipelined-only timing surface,
|
|
228
|
+
* such as proposal or attestation acceptance windows into the target slot.
|
|
229
|
+
*/
|
|
230
|
+
export function createPipelinedCheckpointTimingModel(
|
|
231
|
+
opts: Omit<CheckpointTimingConfig, 'pipelining'>,
|
|
232
|
+
): PipelinedCheckpointTiming {
|
|
233
|
+
validateCheckpointTimingConfig(opts);
|
|
234
|
+
const normalizedOpts = normalizeCheckpointTimingConfig(opts);
|
|
235
|
+
|
|
236
|
+
const timing = new PipelinedCheckpointTimingModel(normalizedOpts);
|
|
237
|
+
validateCheckpointTimingModel(timing);
|
|
238
|
+
return timing;
|
|
239
|
+
}
|
|
240
|
+
|
|
28
241
|
/**
|
|
29
242
|
* Calculates the maximum number of blocks that can be built in a slot.
|
|
30
243
|
* Used by both the sequencer timetable and p2p gossipsub scoring.
|
|
@@ -42,25 +255,92 @@ export function calculateMaxBlocksPerSlot(
|
|
|
42
255
|
checkpointAssembleTime?: number;
|
|
43
256
|
p2pPropagationTime?: number;
|
|
44
257
|
l1PublishingTime?: number;
|
|
258
|
+
pipelining?: boolean;
|
|
45
259
|
} = {},
|
|
46
260
|
): number {
|
|
47
|
-
|
|
48
|
-
|
|
261
|
+
return createCheckpointTimingModel({
|
|
262
|
+
aztecSlotDuration: aztecSlotDurationSec,
|
|
263
|
+
blockDuration: blockDurationSec,
|
|
264
|
+
checkpointAssembleTime: opts.checkpointAssembleTime,
|
|
265
|
+
checkpointInitializationTime: opts.checkpointInitializationTime,
|
|
266
|
+
l1PublishingTime: opts.l1PublishingTime,
|
|
267
|
+
p2pPropagationTime: opts.p2pPropagationTime,
|
|
268
|
+
pipelining: opts.pipelining,
|
|
269
|
+
}).calculateMaxBlocksPerSlot();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function assertNonNegative(name: string, value: number): void {
|
|
273
|
+
if (value < 0) {
|
|
274
|
+
throw new Error(`${name} must be non-negative (got ${value})`);
|
|
49
275
|
}
|
|
276
|
+
}
|
|
50
277
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
278
|
+
function validateCheckpointTimingConfig(opts: CheckpointTimingConfig): void {
|
|
279
|
+
if (opts.aztecSlotDuration <= 0) {
|
|
280
|
+
throw new Error(`aztecSlotDuration must be positive (got ${opts.aztecSlotDuration})`);
|
|
281
|
+
}
|
|
55
282
|
|
|
56
|
-
|
|
57
|
-
|
|
283
|
+
if (opts.ethereumSlotDuration !== undefined && opts.ethereumSlotDuration <= 0) {
|
|
284
|
+
throw new Error(`ethereumSlotDuration must be positive when provided (got ${opts.ethereumSlotDuration})`);
|
|
285
|
+
}
|
|
58
286
|
|
|
59
|
-
|
|
60
|
-
|
|
287
|
+
if (opts.blockDuration !== undefined && opts.blockDuration <= 0) {
|
|
288
|
+
throw new Error(`blockDuration must be positive when provided (got ${opts.blockDuration})`);
|
|
289
|
+
}
|
|
61
290
|
|
|
62
|
-
|
|
63
|
-
|
|
291
|
+
if (opts.minExecutionTime !== undefined && opts.minExecutionTime <= 0) {
|
|
292
|
+
throw new Error(`minExecutionTime must be positive when provided (got ${opts.minExecutionTime})`);
|
|
293
|
+
}
|
|
64
294
|
|
|
65
|
-
|
|
295
|
+
if (opts.checkpointAssembleTime !== undefined) {
|
|
296
|
+
assertNonNegative('checkpointAssembleTime', opts.checkpointAssembleTime);
|
|
297
|
+
}
|
|
298
|
+
if (opts.checkpointInitializationTime !== undefined) {
|
|
299
|
+
assertNonNegative('checkpointInitializationTime', opts.checkpointInitializationTime);
|
|
300
|
+
}
|
|
301
|
+
if (opts.l1PublishingTime !== undefined) {
|
|
302
|
+
assertNonNegative('l1PublishingTime', opts.l1PublishingTime);
|
|
303
|
+
}
|
|
304
|
+
if (opts.p2pPropagationTime !== undefined) {
|
|
305
|
+
assertNonNegative('p2pPropagationTime', opts.p2pPropagationTime);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function normalizeCheckpointTimingConfig(opts: CheckpointTimingConfig): CheckpointTimingConfig {
|
|
310
|
+
let checkpointAssembleTime = opts.checkpointAssembleTime ?? CHECKPOINT_ASSEMBLE_TIME;
|
|
311
|
+
let checkpointInitializationTime = opts.checkpointInitializationTime ?? CHECKPOINT_INITIALIZATION_TIME;
|
|
312
|
+
let minExecutionTime = opts.minExecutionTime ?? MIN_EXECUTION_TIME;
|
|
313
|
+
let p2pPropagationTime = opts.p2pPropagationTime ?? DEFAULT_P2P_PROPAGATION_TIME;
|
|
314
|
+
|
|
315
|
+
if (opts.ethereumSlotDuration !== undefined && opts.ethereumSlotDuration < 8) {
|
|
316
|
+
p2pPropagationTime = 0;
|
|
317
|
+
checkpointAssembleTime = 0.5;
|
|
318
|
+
checkpointInitializationTime = 0.5;
|
|
319
|
+
minExecutionTime = 1;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (opts.blockDuration !== undefined && minExecutionTime > opts.blockDuration) {
|
|
323
|
+
minExecutionTime = opts.blockDuration;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return {
|
|
327
|
+
...opts,
|
|
328
|
+
checkpointAssembleTime,
|
|
329
|
+
checkpointInitializationTime,
|
|
330
|
+
minExecutionTime,
|
|
331
|
+
p2pPropagationTime,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function validateCheckpointTimingModel(model: CheckpointTiming): void {
|
|
336
|
+
if (model.blockDuration === undefined) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const timeAvailableForBlocks = model.aztecSlotDuration - model.checkpointInitializationTime - model.timeReservedAtEnd;
|
|
341
|
+
if (timeAvailableForBlocks < model.blockDuration) {
|
|
342
|
+
throw new Error(
|
|
343
|
+
`Invalid timing configuration: only ${timeAvailableForBlocks}s available for block building, which is less than one blockDuration (${model.blockDuration}s).`,
|
|
344
|
+
);
|
|
345
|
+
}
|
|
66
346
|
}
|
|
@@ -86,6 +86,10 @@ export class NullifierLeafPreimage implements IndexedTreeLeafPreimage {
|
|
|
86
86
|
];
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
isEmpty(): boolean {
|
|
90
|
+
return this.leaf.isEmpty() && this.nextKey.isZero() && this.nextIndex === 0n;
|
|
91
|
+
}
|
|
92
|
+
|
|
89
93
|
toFields(): Fr[] {
|
|
90
94
|
return this.toHashInputs().map(buf => Fr.fromBuffer(buf));
|
|
91
95
|
}
|
package/src/tx/block_header.ts
CHANGED
|
@@ -172,8 +172,8 @@ export class BlockHeader {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
/** Manually set the hash for this block header if already computed */
|
|
175
|
-
setHash(hashed:
|
|
176
|
-
this._cachedHash = Promise.resolve(
|
|
175
|
+
setHash(hashed: BlockHash) {
|
|
176
|
+
this._cachedHash = Promise.resolve(hashed);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
/** Recomputes the cached hash. Used for testing when header fields are mutated via unfreeze. */
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ManaUsageEstimate } from '../gas/fee_math.js';
|
|
2
|
+
import type { GasFees } from '../gas/gas_fees.js';
|
|
3
|
+
|
|
4
|
+
/** Provides current and predicted fee information for transaction pricing. */
|
|
5
|
+
export interface FeeProvider {
|
|
6
|
+
/** Returns the current minimum fees for inclusion in the next block. */
|
|
7
|
+
getCurrentMinFees(): Promise<GasFees>;
|
|
8
|
+
/** Returns predicted min fees for each slot in the prediction window. */
|
|
9
|
+
getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]>;
|
|
10
|
+
}
|
|
@@ -1,31 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import type { SimulationOverridesPlan } from '@aztec/ethereum/contracts';
|
|
3
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
3
|
import type { SlotNumber } from '@aztec/foundation/schemas';
|
|
5
4
|
|
|
6
5
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
7
|
-
import type { GasFees } from '../gas/gas_fees.js';
|
|
8
6
|
import type { UInt32 } from '../types/index.js';
|
|
9
7
|
import type { CheckpointGlobalVariables, GlobalVariables } from './global_variables.js';
|
|
10
8
|
|
|
11
|
-
/** Fee header fields needed for pipelining overrides. */
|
|
12
|
-
export type ForceProposedFeeHeader = {
|
|
13
|
-
checkpointNumber: CheckpointNumber;
|
|
14
|
-
feeHeader: FeeHeader;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/** Options for building checkpoint global variables during pipelining. */
|
|
18
|
-
export type BuildCheckpointGlobalVariablesOpts = {
|
|
19
|
-
forcePendingCheckpointNumber?: CheckpointNumber;
|
|
20
|
-
forceProposedFeeHeader?: ForceProposedFeeHeader;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
9
|
/**
|
|
24
10
|
* Interface for building global variables for Aztec blocks.
|
|
25
11
|
*/
|
|
26
12
|
export interface GlobalVariableBuilder {
|
|
27
|
-
getCurrentMinFees(): Promise<GasFees>;
|
|
28
|
-
|
|
29
13
|
/**
|
|
30
14
|
* Builds global variables for a given block.
|
|
31
15
|
* @param blockNumber - The block number to build global variables for.
|
|
@@ -46,6 +30,6 @@ export interface GlobalVariableBuilder {
|
|
|
46
30
|
coinbase: EthAddress,
|
|
47
31
|
feeRecipient: AztecAddress,
|
|
48
32
|
slotNumber: SlotNumber,
|
|
49
|
-
|
|
33
|
+
simulationOverridesPlan?: SimulationOverridesPlan,
|
|
50
34
|
): Promise<CheckpointGlobalVariables>;
|
|
51
35
|
}
|
package/src/tx/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ export * from './validator/tx_validator.js';
|
|
|
24
24
|
export * from './validator/empty_validator.js';
|
|
25
25
|
export * from './validator/error_texts.js';
|
|
26
26
|
export * from './capsule.js';
|
|
27
|
+
export * from './fee_provider.js';
|
|
27
28
|
export * from './global_variable_builder.js';
|
|
28
29
|
export * from './hashed_values.js';
|
|
29
30
|
export * from './indexed_tx_effect.js';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
2
|
import { schemas } from '@aztec/foundation/schemas';
|
|
4
3
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
4
|
|
|
@@ -27,7 +26,7 @@ export function serializeIndexedTxEffect(effect: IndexedTxEffect): Buffer {
|
|
|
27
26
|
export function deserializeIndexedTxEffect(buffer: Buffer): IndexedTxEffect {
|
|
28
27
|
const reader = BufferReader.asReader(buffer);
|
|
29
28
|
|
|
30
|
-
const l2BlockHash =
|
|
29
|
+
const l2BlockHash = BlockHash.fromBuffer(reader);
|
|
31
30
|
const l2BlockNumber = BlockNumber(reader.readNumber());
|
|
32
31
|
const txIndexInBlock = reader.readNumber();
|
|
33
32
|
const data = reader.readObject(TxEffect);
|
package/src/tx/simulated_tx.ts
CHANGED
|
@@ -161,7 +161,7 @@ export class TxSimulationResult {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
|
-
* Recursively
|
|
164
|
+
* Recursively accumulate the return values of a call result and its nested executions,
|
|
165
165
|
* so they can be retrieved in order.
|
|
166
166
|
* @param executionResult
|
|
167
167
|
* @returns
|
package/src/tx/tx.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DA_GAS_PER_FIELD, TX_DA_GAS_OVERHEAD } from '@aztec/constants';
|
|
2
|
-
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
+
import { type BaseBuffer32, Buffer32 } from '@aztec/foundation/buffer';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import type { ZodFor } from '@aztec/foundation/schemas';
|
|
5
5
|
import { BufferReader, serializeArrayOfBufferableToVector, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
@@ -64,7 +64,7 @@ export class Tx extends Gossipable {
|
|
|
64
64
|
// docs:end:tx_class
|
|
65
65
|
|
|
66
66
|
// Gossipable method
|
|
67
|
-
override generateP2PMessageIdentifier(): Promise<
|
|
67
|
+
override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
|
|
68
68
|
return Promise.resolve(new Buffer32(this.getTxHash().toBuffer()));
|
|
69
69
|
}
|
|
70
70
|
|
package/src/types/shared.ts
CHANGED
|
@@ -34,13 +34,3 @@ export type UInt64 = bigint;
|
|
|
34
34
|
* A type alias for a 128-bit unsigned integer.
|
|
35
35
|
*/
|
|
36
36
|
export type UInt128 = bigint;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* CircuitType replaces ComposerType for now. When using Plonk, CircuitType is equivalent to the information of the proving system that will be used
|
|
40
|
-
* to construct a proof. In the future Aztec zk stack, more information must be specified (e.g., the curve over which circuits are constructed;
|
|
41
|
-
* Plonk vs Honk; zk-SNARK or just SNARK; etc).
|
|
42
|
-
*/
|
|
43
|
-
export enum CircuitType {
|
|
44
|
-
STANDARD = 0,
|
|
45
|
-
ULTRA = 1,
|
|
46
|
-
}
|