-
Notifications
You must be signed in to change notification settings - Fork 2
Added Petri Consensus #692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tcsenpai
wants to merge
69
commits into
stabilisation
Choose a base branch
from
petri
base: stabilisation
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
8c83db5
petri pitch
tcsenpai 85bc90a
petri: add consensus integration plan, codebase mapping, and risk ana…
tcsenpai beffddd
Merge remote-tracking branch 'origin/stabilisation' into petri
tcsenpai 76f4b9a
petri: revise planning docs after stabilisation merge
tcsenpai d714c16
petri: add Phase 8 (Soft Finality SDK Endpoint) to plan
tcsenpai 6e16478
petri: implement Phase 0 — foundation types and feature flag
tcsenpai 73ee96e
petri: implement Phase 1 — transaction classification
tcsenpai ca7d45c
petri: update architecture diagram for Phase 1
tcsenpai 8886756
petri: fix classification timing — classify at mempool insertion, not…
tcsenpai e25d2d4
petri: implement Phase 2 — Continuous Forge loop
tcsenpai 807e3c9
petri: update architecture diagram for Phase 2
tcsenpai 79fd7e6
petri: implement Phase 3 — Block Finalization
tcsenpai 2f5740e
petri: update architecture diagram for Phase 3
tcsenpai 04df594
petri: implement Phase 4 — RPC Routing Refactor
tcsenpai 7c1de05
petri: update architecture diagram for Phase 4
tcsenpai 9f29730
petri: add reflexion review comments for P3/P4 clarity
tcsenpai 17cb4fd
petri: implement Phase 5 — Finality & Status API
tcsenpai f3d5ea7
petri: update architecture diagram for Phase 5
tcsenpai c5baadb
petri: guard soft_finality_at to preserve first-set semantics
tcsenpai c9c13d7
petri: implement Phase 6 — Integration Testing & Hardening
tcsenpai e72c6b9
petri: update architecture diagram for Phase 6
tcsenpai 0b043f6
petri: implement Phase 7 — Secretary Deprecation (markers only)
tcsenpai 334426a
petri: update architecture diagram for Phase 7
tcsenpai 7892972
petri: add missing @deprecated marker on getBlockTimestamp RPC
tcsenpai e59090b
petri: integrate Petri tests into better_testing harness
tcsenpai b09f2cb
petri: add configurable Petri params via env/config and devnet wiring
tcsenpai e63b034
petri: add devnet scenarios for block production and tx inclusion
tcsenpai 64bbc50
petri: add relay flow e2e devnet scenario
tcsenpai c45d87a
petri: add Petri consensus metrics to MetricsCollector
tcsenpai 6eaedbf
petri: add soak run + performance baseline scenario
tcsenpai 0b78d2f
petri: add Config.petri accessor and fix docker-compose indentation
tcsenpai 4cda553
fix: use getLastBlockNumber RPC in petri soak scenario
tcsenpai 8efa4e7
fix: gate PoRBFT Secretary flow when Petri consensus is active
tcsenpai 758eb68
fix: deterministic block compilation and reentrance guard for Petri c…
tcsenpai 0024c9f
fix: Petri accept-and-sign model for block hash voting
tcsenpai 472cb56
feat: Petri consensus fully working — make default, fix DB poisoning,…
tcsenpai de52d29
docs: add petri/consensus.md, deprecate PoRBFT, guard L2PS SecretaryM…
tcsenpai 8751305
ignores
tcsenpai 5e9ded4
Merge branch 'stabilisation' into petri
tcsenpai 7f492f5
refactor: complete better_testing/ → testing/ migration for Petri tests
tcsenpai 5d2fffd
fix: use localeCompare in sort() calls for reliable alphabetical orde…
tcsenpai 1f4c3ee
docs: add missing Petri config keys to .env.example files
tcsenpai 6c6872a
docs: fix StateDelta hash comment to reflect normalized field set
tcsenpai dc02d10
fix: require softFinalityObserved in petri_tx_inclusion test
tcsenpai 62a7a7a
fix: validate Petri config invariants before freezing
tcsenpai aaa561c
fix: use strict undefined check for blockNumber in mempool queries
tcsenpai 567848d
fix: expose tracker count via public accessor, fix broken metric
tcsenpai 27a1fa1
fix: deduplicate transactions in petriBlockCompiler before ordering
tcsenpai 4dbd532
fix: reset startingConsensus on preflight error via try/finally
tcsenpai f1fc78f
fix: only remove committed TXs from mempool after block insertion
tcsenpai 73a6863
fix: add try/catch to getTransactionFinality RPC handler
tcsenpai ab5b63d
fix: clear currentRoundDeltas at start of each forge round
tcsenpai 4ae0734
fix: prevent double-counting mismatched submissions in collectBlockHa…
tcsenpai 7f6ce72
fix: add local mempool fallback when Petri relay fails
tcsenpai 6682606
fix: address minor review feedback from CodeRabbit
tcsenpai d41a902
fix: align block wait to global boundary instead of fixed sleep
tcsenpai b155aec
fix: use Petri config-driven wait window in ensureCandidateBlockFormed
tcsenpai 87d2304
fix: use real election logic in secretaryCoordination test suite
tcsenpai 784ddcc
fix: add timeout on delta exchange and validate peer response structure
tcsenpai 353644b
fix: add failure reason when soft finality is not observed
tcsenpai 7f07a0b
fix: mark TX as FAILED when speculative execution fails
tcsenpai 1b02c40
fix: drain in-flight forge round before block compilation
tcsenpai 6d8c770
fix: lazily classify unclassified mempool TXs at start of forge round
tcsenpai 1db79d7
fix: use explicit null check for currentRoundPromise in drain()
tcsenpai de41db8
ignores and memory
tcsenpai 79a51dd
Merge remote-tracking branch 'origin/stabilisation' into merge/stabil…
claude 083ada5
fix: update speculativeExecutor to use new in-memory GCR API + add me…
claude aa7663e
fix: update omni gcr handler to new in-memory GCR API + gitignore mer…
claude 9e8e557
Merge pull request #755 from kynesyslabs/merge/stabilisation-into-petri
tcsenpai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| # Merge Report: Stabilisation Hotfixes into Petri | ||
|
|
||
| **Date:** 2026-04-01 | ||
| **Branch:** `merge/stabilisation-into-petri` (transient) | ||
| **Base:** `petri` ← `stabilisation` | ||
|
|
||
| --- | ||
|
|
||
| ## 1. Stabilisation Hotfixes Summary | ||
|
|
||
| 9 commits merged from `stabilisation` that were not in `petri`: | ||
|
|
||
| | Commit | Description | Risk to Petri | | ||
| |--------|-------------|---------------| | ||
| | `979eb8c` | **GCR in-memory edit refactor** — routines now take `GCRMain` entity instead of `Repository` | **CRITICAL** | | ||
| | `628937b` | **L2PSConsensus refactor** — updated to use new GCR `prepareAccounts`/`applyTransaction` API | HIGH | | ||
| | `5dd0a9b` | LLM-suggested fixes on GCR routines (cleanup pass) | MEDIUM | | ||
| | `fdd86f0` | **Port staggering** — RPC/Omni ports now interleaved (53551/53552, 53553/53554, ...) | LOW | | ||
| | `74a4a6e` + `f29e49d` | **TX count inversion bug fix** — success/fail arrays were swapped + Set dedup | CRITICAL | | ||
| | `b9f62d4` | GCR edit timing instrumentation | LOW | | ||
| | `b57292a` | Omni reconnection test fix | LOW | | ||
| | `e82ce9b` | Merge commit aggregating all above | — | | ||
|
|
||
| --- | ||
|
|
||
| ## 2. Merge Outcome | ||
|
|
||
| **Conflicts:** 1 file — `testing/devnet/docker-compose.yml` (port assignments) | ||
| **Resolution:** Accepted stabilisation's staggered port scheme, preserved petri env vars (`PETRI_CONSENSUS`) | ||
|
|
||
| **Auto-merged cleanly:** | ||
| - `src/libs/blockchain/mempool_v2.ts` — TX counting fix integrated | ||
| - `src/libs/consensus/v2/PoRBFT.ts` — new `applyTransactions` API already compatible | ||
| - `src/libs/network/endpointExecution.ts` — new GCR API adopted | ||
| - `testing/devnet/.env.example` — port defaults updated | ||
| - `testing/scripts/run-suite.ts` — test infra updates | ||
|
|
||
| --- | ||
|
|
||
| ## 3. Petri Code Requiring Adaptation | ||
|
|
||
| ### 3.1 FIXED: `speculativeExecutor.ts` (CRITICAL) | ||
|
|
||
| **File:** `src/libs/consensus/petri/execution/speculativeExecutor.ts` | ||
|
|
||
| **Problem:** Was calling old GCR routine API: | ||
| ```typescript | ||
| // OLD — broken after merge | ||
| GCRBalanceRoutines.apply(edit, gcrMainRepo, true) | ||
| GCRNonceRoutines.apply(edit, gcrMainRepo, true) | ||
| GCRIdentityRoutines.apply(edit, gcrMainRepo, true) | ||
| ``` | ||
|
|
||
| **Fix applied:** Refactored to use new in-memory pattern: | ||
| ```typescript | ||
| // NEW — uses batch account loading + unified applyTransaction | ||
| const accounts = await HandleGCR.prepareAccounts([tx]) | ||
| const applyResult = await HandleGCR.applyTransaction(accounts, tx, false, true) | ||
| ``` | ||
|
|
||
| **Benefits:** | ||
| - Consistent with all other GCR callers (L2PS, PoRBFT, endpoint execution, sync) | ||
| - Uses batch account loading (fewer DB queries) | ||
| - Proper snapshot/rollback support via `applyTransaction` internals | ||
| - Handles ALL edit types (not just balance/nonce/identity) through the unified dispatcher | ||
|
|
||
| ### 3.2 VERIFIED: No Other Petri Files Need Changes | ||
|
|
||
| All other GCR callers in the codebase are already using the new API: | ||
| - `L2PSConsensus.ts` — uses `prepareAccounts` + `applyTransaction` ✅ | ||
| - `PoRBFT.ts` — uses `applyTransactions` ✅ | ||
| - `endpointExecution.ts` — uses `prepareAccounts` + `applyTransaction` ✅ | ||
| - `Sync.ts` — uses `applyTransactions` ✅ | ||
|
|
||
| ### 3.3 VERIFIED: Port Configuration Consistent | ||
|
|
||
| All test/devnet configs verified consistent with the new staggered port scheme across: | ||
| - `.env.example` files | ||
| - `docker-compose.yml` | ||
| - `start-staggered.sh` | ||
| - All loadgen and test scripts | ||
|
|
||
| --- | ||
|
|
||
| ## 4. Action Plan | ||
|
|
||
| ### Completed | ||
| - [x] Merge stabilisation into petri (transient branch) | ||
| - [x] Resolve docker-compose.yml port conflicts (stabilisation priority) | ||
| - [x] Fix speculativeExecutor.ts to use new GCR in-memory API | ||
| - [x] Verify all GCR callers use new pattern | ||
| - [x] Verify port scheme consistency across configs | ||
|
|
||
| ### Recommended Follow-up | ||
| - [ ] **Run full test suite** to validate the merge doesn't break Petri consensus flows | ||
| - [ ] **Integration test speculativeExecutor** — the refactored code should produce identical delta hashes as before, but this needs devnet validation | ||
| - [ ] **Review `gcr.ts` helper methods** — some utility functions in `src/libs/blockchain/gcr/gcr.ts` still reference `gcrMainRepository` (lines ~579, 620, 716, 815). These appear to be in auxiliary/query paths, not core edit flow, but worth auditing. | ||
| - [ ] **Monitor TX counting** — the inverted success/fail fix from stabilisation is now in petri. Petri's forge loop in `petriBlockCompiler.ts` should benefit, but verify mempool metrics are correct after merge. | ||
|
|
||
| --- | ||
|
|
||
| ## 5. Key Architectural Insight | ||
|
|
||
| The GCR refactor is a **performance-critical change**: instead of N database round-trips per edit, entities are batch-loaded into a `Map<string, GCRMain>`, modified in-memory, and saved once at the end. This directly benefits Petri's continuous forge loop where many TXs are processed per round. The `speculativeExecutor` fix ensures Petri's simulation path also gets this performance improvement. | ||
|
|
||
| The TX count inversion bug (`74a4a6e`) was in shared code (`mempool_v2.ts`, `PoRBFT.ts`). Since Petri builds on these same code paths, this fix prevents incorrect transaction classification that could have caused consensus disagreements between nodes. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.