Commit 96d47a0
authored
fix(aztec-node): pipelining-aware slot and fee simulation in simulatePublicCalls (#24031)
## Motivation
`AztecNodeService.simulatePublicCalls` built globals for a fictional
next block using "the L2 slot at the next L1 slot" with no pipelining
offset and no L1 state overrides. Under proposer pipelining this
simulates one slot too early and computes the mana min fee against the
current L1 state, ignoring the gossiped proposed checkpoint that will
land before the simulated block does — producing wrong L1-to-L2 message
sets and wrong fees for wallet-side estimation.
## Approach
The simulation now mirrors how the sequencer picks the build slot and
fee inputs (`sequencer.ts` / `checkpoint_proposal_job.ts` / the
checkpoint simulation overrides builder), split into two cases:
- **Mid-checkpoint continuation** (proposed blocks past the last
checkpoint proposal): every block in a checkpoint shares the same
checkpoint-wide globals, so the next block's globals are copied verbatim
from the latest proposed block header with only the block number bumped.
No L1 reads, no L1-to-L2 message insertion. A missing header fails the
request rather than falling through, since the fork already contains the
ongoing checkpoint's messages and a fall-through would insert them
twice.
- **Opening a new checkpoint**: the target slot is the sequencer's
formula (`next-L1-slot L2 slot + PROPOSER_PIPELINING_SLOT_OFFSET`),
maxed with `proposedCheckpointSlot + 1` when a checkpoint proposal is
pending L1. The same `SimulationOverridesPlan` the sequencer uses is
always applied: parent archive/temp-log/fee-header overrides derived
from the proposed checkpoint when pipelining, tips pinned to the
rollback target when the pending chain is invalid, and tips pinned to
the checkpointed tip otherwise (neutralizing prunes in fee computation).
Both the target slot and the plan derive from a single
`ProposedCheckpointData` read so they cannot disagree about the parent.
The simulator trusts archiver tips verbatim — no staleness guards. Stale
proposed blocks and checkpoints are the archiver's responsibility
(orphan pruning and L1-authoritative eviction), so a stale tip
mis-simulates only transiently.
The logic moves out of `AztecNodeService` into a new
`NodePublicCallsSimulator` class so the slot/globals selection is
unit-testable without standing up a node. Supersedes #23389.
Caching of the L1 fee queries introduced here is tracked separately in
A-1208.
**Structured for commit-by-commit review:**
1. `refactor(aztec-node)`: pure move of the existing
`simulatePublicCalls` code (and its tests) into
`NodePublicCallsSimulator` — no behavior change.
2. `fix(aztec-node)`: the actual behavior changes described above.
3. `refactor`: moves the checkpoint simulation overrides builder from
sequencer-client to `@aztec/stdlib/checkpoint` so the node consumes it
from a shared home.
## API changes
- `GlobalVariableBuilder.buildGlobalVariables` is removed from the
stdlib interface and its implementations (sequencer-client, TXE); slot
selection is now the caller's job and only
`buildCheckpointGlobalVariables` remains.
- `buildCheckpointSimulationOverridesPlan` and
`computePipelinedParentFeeHeader` move from sequencer-client internals
to `@aztec/stdlib/checkpoint`, shared by the sequencer and the node
simulator.
- `AztecNodeService` constructor takes an optional `RollupContract`;
environments that never see a proposed checkpoint or an invalid pending
chain (TXE) may omit it, and the simulator fails loudly if those paths
are reached without it.
## Changes
- **aztec-node**: new `NodePublicCallsSimulator` with the two-case
globals selection and always-on overrides plan; `simulatePublicCalls`
reduced to a thin delegate.
- **aztec-node (tests)**: 12 unit tests covering verbatim mid-checkpoint
continuation, the missing-header guard, the pipelining offset,
parent-slot/override derivation from the proposed checkpoint data,
torn-snapshot fallback, invalid-pending-chain tips pinning, message
insertion semantics, and the rollup-contract invariant.
- **stdlib**: gains `checkpoint/simulation_overrides.ts` (moved from
sequencer-client, with its unit tests); `buildGlobalVariables` removed
from the `GlobalVariableBuilder` interface.
- **sequencer-client**: imports the overrides builder from stdlib;
`buildGlobalVariables` removed from the implementation.
- **txe**: `buildGlobalVariables` removed; TXE node construction passes
no rollup contract.
Fixes A-10631 parent 15f769d commit 96d47a0
15 files changed
Lines changed: 1130 additions & 681 deletions
File tree
- yarn-project
- aztec-node/src/aztec-node
- sequencer-client/src
- global_variable_builder
- sequencer
- stdlib/src
- checkpoint
- tx
- txe/src/state_machine
Lines changed: 457 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 383 additions & 0 deletions
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| 245 | + | |
245 | 246 | | |
246 | 247 | | |
247 | 248 | | |
| |||
709 | 710 | | |
710 | 711 | | |
711 | 712 | | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
744 | | - | |
745 | | - | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | | - | |
813 | | - | |
814 | | - | |
815 | | - | |
816 | | - | |
817 | | - | |
818 | | - | |
819 | | - | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
824 | | - | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | | - | |
878 | | - | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
893 | | - | |
894 | | - | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
900 | | - | |
901 | | - | |
902 | | - | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
915 | | - | |
916 | | - | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | | - | |
922 | | - | |
923 | | - | |
924 | | - | |
925 | | - | |
926 | 713 | | |
927 | 714 | | |
928 | 715 | | |
| |||
985 | 772 | | |
986 | 773 | | |
987 | 774 | | |
| 775 | + | |
988 | 776 | | |
989 | 777 | | |
990 | 778 | | |
| |||
1175 | 963 | | |
1176 | 964 | | |
1177 | 965 | | |
| 966 | + | |
1178 | 967 | | |
1179 | 968 | | |
1180 | 969 | | |
| |||
1246 | 1035 | | |
1247 | 1036 | | |
1248 | 1037 | | |
| 1038 | + | |
1249 | 1039 | | |
1250 | 1040 | | |
1251 | 1041 | | |
| |||
1299 | 1089 | | |
1300 | 1090 | | |
1301 | 1091 | | |
| 1092 | + | |
1302 | 1093 | | |
1303 | 1094 | | |
1304 | 1095 | | |
| |||
1411 | 1202 | | |
1412 | 1203 | | |
1413 | 1204 | | |
1414 | | - | |
1415 | | - | |
1416 | | - | |
1417 | | - | |
1418 | | - | |
1419 | | - | |
1420 | | - | |
1421 | | - | |
1422 | | - | |
1423 | | - | |
1424 | | - | |
1425 | | - | |
1426 | | - | |
1427 | | - | |
1428 | | - | |
1429 | | - | |
1430 | | - | |
1431 | | - | |
1432 | 1205 | | |
1433 | 1206 | | |
1434 | 1207 | | |
| |||
0 commit comments