Repository navigation
Commit e73c72f
autobahn/evmonlyapp: prepare block n+1 while block n executes (#4260)
Second half of the sender-recovery pipelining, after #4259's
measurement. Every block a validator executes arrives as raw tx bytes
that must be RLP-decoded and ECDSA-recovered before the EVM can run
them; CheckTx caches the sender only for txs this node admitted (~1/40
at 40 validators), so the rest is recovered inline in `FinalizeBlock` on
the single-threaded Autobahn main loop (#4259's `prepare` phase). That
work depends only on the bytes, not on state, so it does not have to
wait its turn in the serial loop.
The router's `runExecute` (`giga_router_common.go`) becomes a two-stage
`scope.Run`: a fetcher task fetches `GlobalBlock(n)`, builds the
state-independent part of the FinalizeBlock request (`finalizeRequest`:
txs, hash, chain id, height, time), calls the new optional
`app.PrepareBlock`, and hands the block over an unbuffered channel, so
it is exactly one block ahead; the execute loop keeps `FinalizeBlock`,
hash-vault commit, `Commit`, `PushAppHash` and prune in their existing
order. `Header.ProposerAddress` is deliberately filled in by
`executeBlock` (`proposerAddress()`) immediately before `FinalizeBlock`,
because on the non-EVM-only path `GetValidators()` reads
`BaseApp.checkState`, which `Commit` replaces; it must not be read from
the fetcher. The proxy exposes `Proxy.PrepareBlock` through an optional
`blockPreparer` interface (same pattern as `commitSettler`), a no-op for
applications that do not implement it.
In `evmonlyapp`, `PrepareBlock` reads the executor from `settler` (no
executor lock, so it runs concurrently with `FinalizeBlock`), peeks the
CheckTx sender cache without consuming it, runs
`evmonly.Executor.PrepareBlock` (context validation + parse, touches no
state) and stores `{height, hash, txs}` in a one-slot `prepared` mutex.
`FinalizeBlock` uses the slot only when height and hash match, then
forgets the cached senders and goes straight to `ExecutePreparedBlock`;
on a mismatch the slot is left alone and the existing
`take_senders`/`prepare`/`execute` path runs. `PrepareBlock` returns
nothing but `ctx.Err()`, so any error that would fail the block is
reproduced by `FinalizeBlock` and the failure path (`abandonPending`,
router error) is unchanged. Only `Number`/`Time` reach the decoded txs
(via the signer); the parent-derived block context (`ParentHash`,
`PrevRandao`, `GasLimit`) is still filled in by `FinalizeBlock`, so
preparing ahead cannot bake in stale cursor state.
Invariants kept: block order, one commit in flight, background-commit
failure surfacing on the next state-touching call, `PhaseTimer` touched
only under the executor lock. Hits and misses are counted in
`evmonly_finalize_prepared_blocks_total{prepared}`; the rollout check is
that `prepared="true"` ≈ blocks/s and the main loop's `execution` share
drops by roughly the former `prepare` phase; also watch the per-block
`execution` phase itself, since block n+1's ECDSA recovery now competes
for cores with block n's OCC workers and could offset part of the gain
(the `consensus` slice now measures waiting on the fetcher, ~0 when the
next block is already prepared). Validated with new `evmonlyapp` tests —
prepared and unprepared blocks finalize to the same app hash and tx
results, a wrong-hash preparation is bypassed and kept, an undecodable
block prepared ahead is still reported by `FinalizeBlock`, preparing
before InitChain is a no-op, and `PrepareBlock(n+1)` racing
`FinalizeBlock(n)` over several blocks under `-race` matches a
sequential run — plus the proxy and p2p suites, where `TestGigaRouter`
now asserts the delivered blocks are contiguous and every header's
`ProposerAddress` is a current validator, scoped golangci-lint and `make
fmtcheck`.
Link to Devin session:
https://app.devin.ai/sessions/ff612badcded4aa5914ea408dbb41888
Open in Devin Desktop:
https://app.devin.ai/desktop/session/ff612badcded4aa5914ea408dbb41888?variant=devin
Requested by: @bdchatham
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>1 parent 5565a61 commit e73c72f
6 files changed
Lines changed: 463 additions & 77 deletions
File tree
- sei-tendermint/internal
- evmonlyapp
- p2p
- proxy
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
85 | 100 | | |
86 | 101 | | |
87 | 102 | | |
88 | 103 | | |
89 | 104 | | |
90 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
91 | 117 | | |
92 | 118 | | |
93 | 119 | | |
| |||
124 | 150 | | |
125 | 151 | | |
126 | 152 | | |
| 153 | + | |
| 154 | + | |
127 | 155 | | |
128 | 156 | | |
129 | 157 | | |
| |||
351 | 379 | | |
352 | 380 | | |
353 | 381 | | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
354 | 396 | | |
355 | 397 | | |
356 | 398 | | |
357 | 399 | | |
358 | 400 | | |
359 | 401 | | |
360 | 402 | | |
361 | | - | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
362 | 406 | | |
363 | 407 | | |
364 | 408 | | |
| |||
556 | 600 | | |
557 | 601 | | |
558 | 602 | | |
559 | | - | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
560 | 612 | | |
561 | 613 | | |
562 | | - | |
| 614 | + | |
563 | 615 | | |
564 | 616 | | |
565 | 617 | | |
566 | | - | |
| 618 | + | |
567 | 619 | | |
568 | 620 | | |
569 | 621 | | |
570 | | - | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
571 | 694 | | |
572 | | - | |
573 | 695 | | |
574 | 696 | | |
575 | 697 | | |
576 | 698 | | |
577 | 699 | | |
578 | | - | |
| 700 | + | |
579 | 701 | | |
580 | 702 | | |
581 | 703 | | |
| |||
586 | 708 | | |
587 | 709 | | |
588 | 710 | | |
589 | | - | |
590 | | - | |
| 711 | + | |
591 | 712 | | |
592 | | - | |
593 | | - | |
| 713 | + | |
594 | 714 | | |
595 | 715 | | |
596 | 716 | | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
597 | 728 | | |
598 | 729 | | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
616 | 747 | | |
617 | | - | |
| 748 | + | |
618 | 749 | | |
619 | 750 | | |
620 | | - | |
| 751 | + | |
621 | 752 | | |
622 | 753 | | |
623 | 754 | | |
| |||
0 commit comments