@aztec/stdlib 0.0.1-commit.f5d02921e → 0.0.1-commit.f7ea82942

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.
Files changed (267) hide show
  1. package/dest/abi/authorization_selector.d.ts +3 -6
  2. package/dest/abi/authorization_selector.d.ts.map +1 -1
  3. package/dest/abi/encoder.d.ts +1 -1
  4. package/dest/abi/encoder.d.ts.map +1 -1
  5. package/dest/abi/encoder.js +32 -6
  6. package/dest/abi/event_selector.d.ts +3 -6
  7. package/dest/abi/event_selector.d.ts.map +1 -1
  8. package/dest/abi/function_selector.d.ts +3 -6
  9. package/dest/abi/function_selector.d.ts.map +1 -1
  10. package/dest/abi/function_selector.js +1 -3
  11. package/dest/abi/note_selector.d.ts +3 -6
  12. package/dest/abi/note_selector.d.ts.map +1 -1
  13. package/dest/abi/note_selector.js +1 -3
  14. package/dest/abi/selector.d.ts +2 -2
  15. package/dest/abi/selector.d.ts.map +1 -1
  16. package/dest/abi/selector.js +1 -1
  17. package/dest/avm/avm.d.ts +300 -300
  18. package/dest/avm/revert_code.d.ts +8 -18
  19. package/dest/avm/revert_code.d.ts.map +1 -1
  20. package/dest/avm/revert_code.js +15 -30
  21. package/dest/aztec-address/index.d.ts +3 -6
  22. package/dest/aztec-address/index.d.ts.map +1 -1
  23. package/dest/aztec-address/index.js +2 -4
  24. package/dest/block/block_data.d.ts +8 -8
  25. package/dest/block/block_data.d.ts.map +1 -1
  26. package/dest/block/block_data.js +2 -2
  27. package/dest/block/block_hash.d.ts +11 -10
  28. package/dest/block/block_hash.d.ts.map +1 -1
  29. package/dest/block/block_hash.js +10 -9
  30. package/dest/block/l2_block_info.d.ts +6 -5
  31. package/dest/block/l2_block_info.d.ts.map +1 -1
  32. package/dest/block/l2_block_info.js +6 -5
  33. package/dest/block/l2_block_stream/interfaces.d.ts +6 -3
  34. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  35. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
  36. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  37. package/dest/block/l2_block_stream/l2_tips_store_base.js +1 -1
  38. package/dest/block/test/l2_tips_store_test_suite.js +1 -1
  39. package/dest/config/chain-config.d.ts +1 -1
  40. package/dest/config/chain-config.d.ts.map +1 -1
  41. package/dest/config/chain-config.js +7 -1
  42. package/dest/config/sequencer-config.d.ts +2 -2
  43. package/dest/config/sequencer-config.d.ts.map +1 -1
  44. package/dest/config/sequencer-config.js +10 -3
  45. package/dest/contract/private_function.d.ts +1 -1
  46. package/dest/contract/private_function.d.ts.map +1 -1
  47. package/dest/contract/private_function.js +2 -4
  48. package/dest/gas/fee_math.d.ts +49 -0
  49. package/dest/gas/fee_math.d.ts.map +1 -0
  50. package/dest/gas/fee_math.js +80 -0
  51. package/dest/gas/gas_fees.d.ts +5 -1
  52. package/dest/gas/gas_fees.d.ts.map +1 -1
  53. package/dest/gas/gas_fees.js +10 -1
  54. package/dest/gas/gas_settings.d.ts +40 -3
  55. package/dest/gas/gas_settings.d.ts.map +1 -1
  56. package/dest/gas/gas_settings.js +50 -6
  57. package/dest/gas/index.d.ts +2 -1
  58. package/dest/gas/index.d.ts.map +1 -1
  59. package/dest/gas/index.js +1 -0
  60. package/dest/ha-signing/config.d.ts +6 -6
  61. package/dest/ha-signing/config.d.ts.map +1 -1
  62. package/dest/ha-signing/config.js +4 -3
  63. package/dest/ha-signing/index.d.ts +2 -2
  64. package/dest/ha-signing/index.d.ts.map +1 -1
  65. package/dest/ha-signing/index.js +1 -1
  66. package/dest/ha-signing/local_config.js +1 -1
  67. package/dest/ha-signing/types.d.ts +37 -32
  68. package/dest/ha-signing/types.d.ts.map +1 -1
  69. package/dest/ha-signing/types.js +13 -6
  70. package/dest/hash/hash.d.ts +16 -1
  71. package/dest/hash/hash.d.ts.map +1 -1
  72. package/dest/hash/hash.js +32 -0
  73. package/dest/interfaces/archiver.d.ts +11 -1
  74. package/dest/interfaces/archiver.d.ts.map +1 -1
  75. package/dest/interfaces/archiver.js +3 -1
  76. package/dest/interfaces/aztec-node-admin.d.ts +9 -14
  77. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  78. package/dest/interfaces/aztec-node-admin.js +3 -3
  79. package/dest/interfaces/aztec-node-debug.d.ts +21 -0
  80. package/dest/interfaces/aztec-node-debug.d.ts.map +1 -0
  81. package/dest/interfaces/aztec-node-debug.js +18 -0
  82. package/dest/interfaces/aztec-node.d.ts +10 -1
  83. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  84. package/dest/interfaces/aztec-node.js +2 -0
  85. package/dest/interfaces/client.d.ts +2 -1
  86. package/dest/interfaces/client.d.ts.map +1 -1
  87. package/dest/interfaces/client.js +1 -0
  88. package/dest/interfaces/merkle_tree_operations.d.ts +4 -3
  89. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  90. package/dest/interfaces/prover-client.d.ts +1 -1
  91. package/dest/interfaces/prover-client.d.ts.map +1 -1
  92. package/dest/interfaces/prover-client.js +0 -3
  93. package/dest/interfaces/slasher.d.ts +1 -10
  94. package/dest/interfaces/slasher.d.ts.map +1 -1
  95. package/dest/interfaces/slasher.js +0 -2
  96. package/dest/interfaces/validator.d.ts +14 -17
  97. package/dest/interfaces/validator.d.ts.map +1 -1
  98. package/dest/l1-contracts/index.d.ts +2 -2
  99. package/dest/l1-contracts/index.d.ts.map +1 -1
  100. package/dest/l1-contracts/index.js +1 -1
  101. package/dest/logs/extended_directional_app_tagging_secret.d.ts +4 -4
  102. package/dest/logs/extended_directional_app_tagging_secret.d.ts.map +1 -1
  103. package/dest/logs/extended_directional_app_tagging_secret.js +12 -5
  104. package/dest/logs/log_id.d.ts +1 -1
  105. package/dest/logs/log_id.d.ts.map +1 -1
  106. package/dest/logs/log_id.js +1 -2
  107. package/dest/logs/siloed_tag.d.ts +5 -7
  108. package/dest/logs/siloed_tag.d.ts.map +1 -1
  109. package/dest/logs/siloed_tag.js +4 -0
  110. package/dest/logs/tag.d.ts +5 -6
  111. package/dest/logs/tag.d.ts.map +1 -1
  112. package/dest/logs/tag.js +4 -0
  113. package/dest/p2p/block_proposal.d.ts +6 -8
  114. package/dest/p2p/block_proposal.d.ts.map +1 -1
  115. package/dest/p2p/block_proposal.js +4 -9
  116. package/dest/p2p/checkpoint_attestation.d.ts +4 -6
  117. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
  118. package/dest/p2p/checkpoint_attestation.js +2 -7
  119. package/dest/p2p/checkpoint_proposal.d.ts +8 -10
  120. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  121. package/dest/p2p/checkpoint_proposal.js +5 -24
  122. package/dest/p2p/gossipable.d.ts +4 -4
  123. package/dest/p2p/gossipable.d.ts.map +1 -1
  124. package/dest/rollup/block_headers_hash.d.ts +1 -1
  125. package/dest/rollup/block_headers_hash.d.ts.map +1 -1
  126. package/dest/rollup/block_headers_hash.js +8 -2
  127. package/dest/slashing/index.d.ts +2 -3
  128. package/dest/slashing/index.d.ts.map +1 -1
  129. package/dest/slashing/index.js +1 -2
  130. package/dest/slashing/serialization.d.ts +2 -6
  131. package/dest/slashing/serialization.d.ts.map +1 -1
  132. package/dest/slashing/serialization.js +0 -60
  133. package/dest/slashing/types.d.ts +4 -90
  134. package/dest/slashing/types.d.ts.map +1 -1
  135. package/dest/slashing/types.js +0 -14
  136. package/dest/slashing/{tally.d.ts → votes.d.ts} +1 -1
  137. package/dest/slashing/{tally.d.ts.map → votes.d.ts.map} +1 -1
  138. package/dest/slashing/{tally.js → votes.js} +1 -1
  139. package/dest/tests/factories.d.ts +2 -7
  140. package/dest/tests/factories.d.ts.map +1 -1
  141. package/dest/tests/factories.js +2 -8
  142. package/dest/tests/mocks.d.ts +1 -1
  143. package/dest/tests/mocks.d.ts.map +1 -1
  144. package/dest/tests/mocks.js +14 -19
  145. package/dest/timetable/index.d.ts +51 -1
  146. package/dest/timetable/index.d.ts.map +1 -1
  147. package/dest/timetable/index.js +204 -14
  148. package/dest/trees/nullifier_leaf.d.ts +2 -1
  149. package/dest/trees/nullifier_leaf.d.ts.map +1 -1
  150. package/dest/trees/nullifier_leaf.js +3 -0
  151. package/dest/tx/block_header.d.ts +2 -2
  152. package/dest/tx/block_header.d.ts.map +1 -1
  153. package/dest/tx/block_header.js +1 -1
  154. package/dest/tx/fee_provider.d.ts +10 -0
  155. package/dest/tx/fee_provider.d.ts.map +1 -0
  156. package/dest/tx/fee_provider.js +1 -0
  157. package/dest/tx/global_variable_builder.d.ts +3 -16
  158. package/dest/tx/global_variable_builder.d.ts.map +1 -1
  159. package/dest/tx/index.d.ts +2 -1
  160. package/dest/tx/index.d.ts.map +1 -1
  161. package/dest/tx/index.js +1 -0
  162. package/dest/tx/indexed_tx_effect.d.ts +1 -1
  163. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  164. package/dest/tx/indexed_tx_effect.js +1 -2
  165. package/dest/tx/simulated_tx.d.ts +4 -4
  166. package/dest/tx/simulated_tx.d.ts.map +1 -1
  167. package/dest/tx/simulated_tx.js +3 -3
  168. package/dest/tx/tx.d.ts +3 -3
  169. package/dest/tx/tx.d.ts.map +1 -1
  170. package/dest/tx/tx_receipt.d.ts +8 -4
  171. package/dest/tx/tx_receipt.d.ts.map +1 -1
  172. package/dest/tx/tx_receipt.js +8 -15
  173. package/dest/types/shared.d.ts +1 -10
  174. package/dest/types/shared.d.ts.map +1 -1
  175. package/dest/types/shared.js +0 -9
  176. package/dest/vks/verification_key.d.ts +2 -137
  177. package/dest/vks/verification_key.d.ts.map +1 -1
  178. package/dest/vks/verification_key.js +5 -126
  179. package/dest/world-state/genesis_data.d.ts +11 -0
  180. package/dest/world-state/genesis_data.d.ts.map +1 -0
  181. package/dest/world-state/genesis_data.js +4 -0
  182. package/dest/world-state/index.d.ts +2 -1
  183. package/dest/world-state/index.d.ts.map +1 -1
  184. package/dest/world-state/index.js +1 -0
  185. package/dest/world-state/world_state_revision.d.ts +8 -1
  186. package/dest/world-state/world_state_revision.d.ts.map +1 -1
  187. package/dest/world-state/world_state_revision.js +7 -1
  188. package/package.json +8 -8
  189. package/src/abi/authorization_selector.ts +2 -8
  190. package/src/abi/encoder.ts +42 -6
  191. package/src/abi/event_selector.ts +2 -8
  192. package/src/abi/function_selector.ts +3 -12
  193. package/src/abi/note_selector.ts +3 -12
  194. package/src/abi/selector.ts +1 -1
  195. package/src/avm/revert_code.ts +25 -39
  196. package/src/aztec-address/index.ts +4 -10
  197. package/src/block/block_data.ts +3 -4
  198. package/src/block/block_hash.ts +21 -14
  199. package/src/block/l2_block_info.ts +8 -6
  200. package/src/block/l2_block_stream/interfaces.ts +6 -2
  201. package/src/block/l2_block_stream/l2_tips_store_base.ts +1 -1
  202. package/src/block/test/l2_tips_store_test_suite.ts +1 -1
  203. package/src/config/chain-config.ts +7 -1
  204. package/src/config/sequencer-config.ts +14 -4
  205. package/src/contract/private_function.ts +3 -1
  206. package/src/gas/README.md +31 -0
  207. package/src/gas/fee_math.ts +120 -0
  208. package/src/gas/gas_fees.ts +17 -4
  209. package/src/gas/gas_settings.ts +65 -12
  210. package/src/gas/index.ts +1 -0
  211. package/src/ha-signing/config.ts +5 -2
  212. package/src/ha-signing/index.ts +3 -1
  213. package/src/ha-signing/local_config.ts +1 -1
  214. package/src/ha-signing/types.ts +48 -34
  215. package/src/hash/hash.ts +27 -0
  216. package/src/interfaces/archiver.ts +8 -0
  217. package/src/interfaces/aztec-node-admin.ts +5 -7
  218. package/src/interfaces/aztec-node-debug.ts +40 -0
  219. package/src/interfaces/aztec-node.ts +15 -0
  220. package/src/interfaces/client.ts +1 -0
  221. package/src/interfaces/merkle_tree_operations.ts +3 -2
  222. package/src/interfaces/prover-client.ts +2 -5
  223. package/src/interfaces/slasher.ts +0 -6
  224. package/src/interfaces/validator.ts +15 -8
  225. package/src/l1-contracts/index.ts +1 -1
  226. package/src/logs/extended_directional_app_tagging_secret.ts +19 -8
  227. package/src/logs/log_id.ts +1 -2
  228. package/src/logs/siloed_tag.ts +8 -9
  229. package/src/logs/tag.ts +8 -8
  230. package/src/p2p/block_proposal.ts +13 -9
  231. package/src/p2p/checkpoint_attestation.ts +5 -9
  232. package/src/p2p/checkpoint_proposal.ts +21 -36
  233. package/src/p2p/gossipable.ts +4 -4
  234. package/src/rollup/block_headers_hash.ts +11 -2
  235. package/src/slashing/index.ts +1 -2
  236. package/src/slashing/serialization.ts +1 -81
  237. package/src/slashing/types.ts +3 -35
  238. package/src/slashing/{tally.ts → votes.ts} +1 -1
  239. package/src/tests/factories.ts +2 -10
  240. package/src/tests/mocks.ts +16 -12
  241. package/src/timetable/index.ts +293 -13
  242. package/src/trees/nullifier_leaf.ts +4 -0
  243. package/src/tx/block_header.ts +2 -2
  244. package/src/tx/fee_provider.ts +10 -0
  245. package/src/tx/global_variable_builder.ts +2 -18
  246. package/src/tx/index.ts +1 -0
  247. package/src/tx/indexed_tx_effect.ts +1 -2
  248. package/src/tx/simulated_tx.ts +6 -2
  249. package/src/tx/tx.ts +2 -2
  250. package/src/tx/tx_receipt.ts +11 -14
  251. package/src/types/shared.ts +0 -10
  252. package/src/vks/verification_key.ts +5 -184
  253. package/src/world-state/genesis_data.ts +15 -0
  254. package/src/world-state/index.ts +1 -0
  255. package/src/world-state/world_state_revision.ts +9 -1
  256. package/dest/abi/mocked_keys.d.ts +0 -2
  257. package/dest/abi/mocked_keys.d.ts.map +0 -1
  258. package/dest/abi/mocked_keys.js +0 -1
  259. package/dest/l1-contracts/slash_factory.d.ts +0 -45
  260. package/dest/l1-contracts/slash_factory.d.ts.map +0 -1
  261. package/dest/l1-contracts/slash_factory.js +0 -158
  262. package/dest/slashing/empire.d.ts +0 -31
  263. package/dest/slashing/empire.d.ts.map +0 -1
  264. package/dest/slashing/empire.js +0 -87
  265. package/src/abi/mocked_keys.ts +0 -2
  266. package/src/l1-contracts/slash_factory.ts +0 -180
  267. package/src/slashing/empire.ts +0 -104
@@ -126,45 +126,13 @@ export type ValidatorSlash = {
126
126
  offenses: ValidatorSlashOffense[];
127
127
  };
128
128
 
129
- /** Slash payload as published by the empire slash proposer */
130
- export type SlashPayload = {
131
- address: EthAddress;
132
- slashes: ValidatorSlash[];
133
- timestamp: bigint;
134
- };
135
-
136
- /** Slash payload with round information from empire slash proposer */
137
- export type SlashPayloadRound = SlashPayload & { votes: bigint; round: bigint };
138
-
139
- export const SlashPayloadRoundSchema = zodFor<SlashPayloadRound>()(
140
- z.object({
141
- address: schemas.EthAddress,
142
- timestamp: schemas.BigInt,
143
- votes: schemas.BigInt,
144
- round: schemas.BigInt,
145
- slashes: z.array(
146
- z.object({
147
- validator: schemas.EthAddress,
148
- amount: schemas.BigInt,
149
- offenses: z.array(z.object({ offenseType: OffenseTypeSchema, epochOrSlot: schemas.BigInt })),
150
- }),
151
- ),
152
- }),
153
- );
154
-
155
- /** Votes for a validator slash in the consensus slash proposer */
129
+ /** Votes for a validator slash in the slashing proposer */
156
130
  export type ValidatorSlashVote = number;
157
131
 
158
132
  export type ProposerSlashAction =
159
- /** Create a new slash payload on an empire-based slash proposer */
160
- | { type: 'create-empire-payload'; data: ValidatorSlash[] }
161
- /** Vote for a slashing payload on an empire-based slash proposer */
162
- | { type: 'vote-empire-payload'; payload: EthAddress }
163
- /** Execute a slashing payload on an empire-based slash proposer */
164
- | { type: 'execute-empire-payload'; round: bigint }
165
- /** Vote for offenses on a consensus slashing proposer */
133
+ /** Vote for offenses on the slashing proposer */
166
134
  | { type: 'vote-offenses'; votes: ValidatorSlashVote[]; committees: EthAddress[][]; round: bigint }
167
- /** Execute a slashing round on a consensus slashing proposer */
135
+ /** Execute a slashing round on the slashing proposer */
168
136
  | { type: 'execute-slash'; committees: EthAddress[][]; round: bigint };
169
137
 
170
138
  export type ProposerSlashActionType = ProposerSlashAction['type'];
@@ -28,7 +28,7 @@ export function getSlashConsensusVotesFromOffenses(
28
28
  targetCommitteeSize: number;
29
29
  maxSlashedValidators?: number;
30
30
  },
31
- logger: Logger = createLogger('slasher:tally'),
31
+ logger: Logger = createLogger('slasher:votes'),
32
32
  ): ValidatorSlashVote[] {
33
33
  const { slashingAmounts, targetCommitteeSize, maxSlashedValidators } = settings;
34
34
 
@@ -176,7 +176,7 @@ import { TxHash } from '../tx/tx_hash.js';
176
176
  import { TxRequest } from '../tx/tx_request.js';
177
177
  import { Vector } from '../types/index.js';
178
178
  import { VkData } from '../vks/index.js';
179
- import { VerificationKey, VerificationKeyAsFields, VerificationKeyData } from '../vks/verification_key.js';
179
+ import { VerificationKeyAsFields, VerificationKeyData } from '../vks/verification_key.js';
180
180
 
181
181
  /**
182
182
  * Creates an arbitrary side effect object with the given seed.
@@ -232,7 +232,7 @@ export function makeTxContext(seed: number = 1): TxContext {
232
232
  * Creates a default instance of gas settings. No seed value is used to ensure we allocate a sensible amount of gas for testing.
233
233
  */
234
234
  export function makeGasSettings() {
235
- return GasSettings.default({ maxFeesPerGas: new GasFees(10, 10) });
235
+ return GasSettings.fallback({ maxFeesPerGas: new GasFees(10, 10) });
236
236
  }
237
237
 
238
238
  /**
@@ -573,14 +573,6 @@ export function makeVerificationKeyAsFields(size: number): VerificationKeyAsFiel
573
573
  return VerificationKeyAsFields.makeFake(size);
574
574
  }
575
575
 
576
- /**
577
- * Creates arbitrary/mocked verification key.
578
- * @returns A verification key object
579
- */
580
- export function makeVerificationKey(): VerificationKey {
581
- return VerificationKey.makeFake();
582
- }
583
-
584
576
  /**
585
577
  * Creates an arbitrary point in a curve.
586
578
  * @param seed - Seed to generate the point values.
@@ -134,7 +134,7 @@ export const mockTx = async (
134
134
  const data = PrivateKernelTailCircuitPublicInputs.empty();
135
135
  const firstNullifier = new Nullifier(new Fr(seed + 1), Fr.ZERO, 0);
136
136
  data.constants.anchorBlockHeader = anchorBlockHeader;
137
- data.constants.txContext.gasSettings = GasSettings.default({ gasLimits, maxFeesPerGas, maxPriorityFeesPerGas });
137
+ data.constants.txContext.gasSettings = GasSettings.fallback({ gasLimits, maxFeesPerGas, maxPriorityFeesPerGas });
138
138
  data.feePayer = feePayer ?? (await AztecAddress.random());
139
139
  data.gasUsed = gasUsed;
140
140
  data.constants.txContext.chainId = chainId;
@@ -200,7 +200,7 @@ export async function mockProcessedTx({
200
200
  db,
201
201
  chainId = Fr.ZERO,
202
202
  version = Fr.ZERO,
203
- gasSettings = GasSettings.default({ maxFeesPerGas: new GasFees(10, 10) }),
203
+ gasSettings = GasSettings.fallback({ maxFeesPerGas: new GasFees(10, 10) }),
204
204
  vkTreeRoot = Fr.ZERO,
205
205
  protocolContracts = makeProtocolContracts(seed + 0x100),
206
206
  globalVariables = GlobalVariables.empty(),
@@ -587,6 +587,7 @@ export const makeBlockProposal = (options?: MakeBlockProposalOptions): Promise<B
587
587
 
588
588
  return BlockProposal.createProposalFromSigner(
589
589
  blockHeader,
590
+ CheckpointNumber(1),
590
591
  indexWithinCheckpoint,
591
592
  inHash,
592
593
  archiveRoot,
@@ -596,28 +597,31 @@ export const makeBlockProposal = (options?: MakeBlockProposalOptions): Promise<B
596
597
  );
597
598
  };
598
599
 
599
- export const makeCheckpointProposal = (options?: MakeCheckpointProposalOptions): Promise<CheckpointProposal> => {
600
- const blockHeader = options?.lastBlock?.blockHeader ?? makeBlockHeader(1);
600
+ export const makeCheckpointProposal = async (options?: MakeCheckpointProposalOptions): Promise<CheckpointProposal> => {
601
601
  const checkpointHeader = options?.checkpointHeader ?? makeCheckpointHeader(1);
602
602
  const archiveRoot = options?.archiveRoot ?? Fr.random();
603
603
  const feeAssetPriceModifier = options?.feeAssetPriceModifier ?? 0n;
604
604
  const signer = options?.signer ?? Secp256k1Signer.random();
605
605
 
606
- // Build lastBlock info if provided
607
- const lastBlockInfo = options?.lastBlock
608
- ? {
609
- blockHeader,
610
- indexWithinCheckpoint: options.lastBlock.indexWithinCheckpoint ?? IndexWithinCheckpoint(4), // Last block in a 5-block checkpoint
611
- txHashes: options.lastBlock.txHashes ?? [0, 1, 2, 3, 4, 5].map(() => TxHash.random()),
606
+ // Build a signed block proposal if lastBlock options are provided
607
+ const lastBlockProposal = options?.lastBlock
608
+ ? await makeBlockProposal({
609
+ blockHeader: options.lastBlock.blockHeader,
610
+ indexWithinCheckpoint: options.lastBlock.indexWithinCheckpoint ?? IndexWithinCheckpoint(4),
611
+ inHash: checkpointHeader.inHash,
612
+ archiveRoot,
613
+ txHashes: options.lastBlock.txHashes,
612
614
  txs: options.lastBlock.txs,
613
- }
615
+ signer,
616
+ })
614
617
  : undefined;
615
618
 
616
619
  return CheckpointProposal.createProposalFromSigner(
617
620
  checkpointHeader,
618
621
  archiveRoot,
622
+ CheckpointNumber(1),
619
623
  feeAssetPriceModifier,
620
- lastBlockInfo,
624
+ lastBlockProposal,
621
625
  payload => Promise.resolve(signer.signMessage(payload)),
622
626
  );
623
627
  };
@@ -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
- if (!blockDurationSec) {
48
- return 1; // Single block per slot
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
- const initOffset = opts.checkpointInitializationTime ?? CHECKPOINT_INITIALIZATION_TIME;
52
- const assembleTime = opts.checkpointAssembleTime ?? CHECKPOINT_ASSEMBLE_TIME;
53
- const p2pTime = opts.p2pPropagationTime ?? DEFAULT_P2P_PROPAGATION_TIME;
54
- const l1Time = opts.l1PublishingTime ?? DEFAULT_L1_PUBLISHING_TIME;
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
- // Calculate checkpoint finalization time (assembly + round-trip propagation + L1 publishing)
57
- const checkpointFinalizationTime = assembleTime + p2pTime * 2 + l1Time;
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
- // Time reserved at end for last sub-slot (validator re-execution) + finalization
60
- const timeReservedAtEnd = blockDurationSec + checkpointFinalizationTime;
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
- // Time available for building blocks
63
- const timeAvailableForBlocks = aztecSlotDurationSec - initOffset - timeReservedAtEnd;
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
- return Math.max(1, Math.floor(timeAvailableForBlocks / blockDurationSec));
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
  }
@@ -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: Fr) {
176
- this._cachedHash = Promise.resolve(new BlockHash(hashed));
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 { FeeHeader } from '@aztec/ethereum/contracts';
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
- opts?: BuildCheckpointGlobalVariablesOpts,
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 = new BlockHash(reader.readObject(Fr));
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);
@@ -38,7 +38,11 @@ export type ContractOverrides = Record<
38
38
  * set, it *must* be run without the kernel circuits, or validations will fail
39
39
  */
40
40
  export class SimulationOverrides {
41
- constructor(public contracts?: ContractOverrides) {}
41
+ public contracts?: ContractOverrides;
42
+
43
+ constructor(contracts: ContractOverrides = {}) {
44
+ this.contracts = Object.keys(contracts).length > 0 ? contracts : undefined;
45
+ }
42
46
 
43
47
  static get schema() {
44
48
  return z
@@ -157,7 +161,7 @@ export class TxSimulationResult {
157
161
  }
158
162
 
159
163
  /**
160
- * Recursively accummulate the return values of a call result and its nested executions,
164
+ * Recursively accumulate the return values of a call result and its nested executions,
161
165
  * so they can be retrieved in order.
162
166
  * @param executionResult
163
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<Buffer32> {
67
+ override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
68
68
  return Promise.resolve(new Buffer32(this.getTxHash().toBuffer()));
69
69
  }
70
70
 
@@ -31,9 +31,16 @@ export const SortedTxStatuses: TxStatus[] = [
31
31
  /** Execution result - only set when tx is in a block. */
32
32
  export enum TxExecutionResult {
33
33
  SUCCESS = 'success',
34
- APP_LOGIC_REVERTED = 'app_logic_reverted',
35
- TEARDOWN_REVERTED = 'teardown_reverted',
36
- BOTH_REVERTED = 'both_reverted',
34
+ REVERTED = 'reverted',
35
+ /** @deprecated Use REVERTED instead. */
36
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
37
+ APP_LOGIC_REVERTED = 'reverted',
38
+ /** @deprecated Use REVERTED instead. */
39
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
40
+ TEARDOWN_REVERTED = 'reverted',
41
+ /** @deprecated Use REVERTED instead. */
42
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
43
+ BOTH_REVERTED = 'reverted',
37
44
  }
38
45
 
39
46
  /**
@@ -143,16 +150,6 @@ export class TxReceipt {
143
150
  }
144
151
 
145
152
  public static executionResultFromRevertCode(revertCode: RevertCode): TxExecutionResult {
146
- if (revertCode.equals(RevertCode.OK)) {
147
- return TxExecutionResult.SUCCESS;
148
- } else if (revertCode.equals(RevertCode.APP_LOGIC_REVERTED)) {
149
- return TxExecutionResult.APP_LOGIC_REVERTED;
150
- } else if (revertCode.equals(RevertCode.TEARDOWN_REVERTED)) {
151
- return TxExecutionResult.TEARDOWN_REVERTED;
152
- } else if (revertCode.equals(RevertCode.BOTH_REVERTED)) {
153
- return TxExecutionResult.BOTH_REVERTED;
154
- } else {
155
- throw new Error(`Unknown revert code: ${revertCode.getCode()}`);
156
- }
153
+ return revertCode.isOK() ? TxExecutionResult.SUCCESS : TxExecutionResult.REVERTED;
157
154
  }
158
155
  }