(feat): preconf + private tx relay#2004
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #2004 +/- ##
===========================================
+ Coverage 50.36% 50.57% +0.21%
===========================================
Files 871 875 +4
Lines 150924 151690 +766
===========================================
+ Hits 76009 76717 +708
- Misses 69852 69902 +50
- Partials 5063 5071 +8
... and 14 files with indirect coverage changes
🚀 New features to boost your workflow:
|
cffls
left a comment
There was a problem hiding this comment.
A question about a hypothetical scenario - if somehow a node receives a transaction but got killed before it broadcasts the txn, that txn will get lost. It seems like a hard edge case where we need to persist the txn data on disk?
Code ReviewFound 3 issues during code review. Issues
Checked for bugs and CLAUDE.md compliance. |
Great point. Yeah, I've kept a note of this to add persistence for storing transactions / preconf tasks. Due to the Amoy rollout next week, I am planning to add this in next iteration. Although, I've discussed the approach to use when restarting bor w/ Devops. It doesn't require persistence and can still ensure that no tx submission requests are dropped. Thanks! |
Code ReviewFound 4 issues during code review. Issue 1: Missing nil check in
|
This reverts commit a33980b.
|
@claude, can you review this PR, focusing on safety and performance? Please add a comment summarising any concerns about these changes. |
|
Claude finished @kamuikatsurgi's task in 1m 53s —— View job Safety & Performance Review
SummaryThis PR introduces a well-architected relay system for preconfirmations and private transactions. I've reviewed the implementation with a focus on safety and performance. Below are my findings. Safety Concerns1.
|
|
@claude can you review this PR, focusing on safety and performance? focus more on commits done after the last review (last few ones). Provide a summary as a comment highlighting any concerns related to these changes. |
|
Claude finished @manav2401's task in 1m 53s —— View job Safety & Performance Review
SummaryI've reviewed the changes since the last review (2026-02-03), focusing on the following key commits:
The recent changes demonstrate strong attention to reliability and safety. Below are my findings. Improvements Since Last Review ✓1. Graceful Shutdown (Good ✓)Commits: The service now properly tracks all goroutines and waits for them during shutdown: // eth/relay/service.go:91-94
s.wg.Add(2)
go func() { defer s.wg.Done(); s.processPreconfTasks() }()
go func() { defer s.wg.Done(); s.cleanup() }()And each spawned task goroutine is tracked: // eth/relay/service.go:148-152
s.wg.Add(1)
go func(task TxTask) {
defer s.wg.Done()
defer func() { <-s.semaphore }()
s.processPreconfTask(task)
}(task)Important: The // eth/relay/service.go:327-334
func (s *Service) close() {
close(s.closeCh)
if s.multiclient != nil {
s.multiclient.close()
}
s.wg.Wait() // <-- Ensures clean shutdown
}2. Non-Blocking Semaphore Acquisition (Good ✓)Commit: The semaphore acquisition is now context-aware and won't block during shutdown: // eth/relay/service.go:142-147
select {
case s.semaphore <- struct{}{}:
case <-s.closeCh:
log.Info("[tx-relay] Stopping preconf task processing, service closing")
return
}3. Background Retry Cancellation (Good ✓)The // eth/relay/multiclient.go:226-229
for retry := 0; retry < privateTxMaxRetries; retry++ {
if mc.closed.Load() {
return
}
// ...
}And retry goroutines are not spawned if the client is closing: // eth/relay/multiclient.go:211
if retry && !mc.closed.Load() {4. Private Tx Store Cleanup Respects Shutdown (Good ✓)Location: The cleanup loop now checks for shutdown signal instead of unconditionally sleeping: select {
case <-s.closeCh:
return
case <-time.After(time.Second):
}5. Error Handling Consistency (Good ✓)The setError.Do(func() {
firstErr = err
})6. Comprehensive Test Coverage (Good ✓)New tests added:
Remaining Concerns1.
|
|
* (feat): new approach for private tx relay and preconfs * (feat): refactor relay service * small nit * eth/relay: fix lint * eth: add tests for disable tx propagation * eth: add tests for private transactions * eth/relay: small fixes * eth/relay: small fixes * eth/relay: add tests for private tx store * eth/relay: add tests for multiclient * eth/relay: fix call to send private tx * eth/relay: add a sub test for multiclient * eth/relay: add tests for relay service * address claude comments, fix non-deterministic tests * eth/relay: update relay to server preconf for any tx hash, update tests * eth: close relay service in backend * eth: disable tx propagation for rebroadcast * eth/relay: handle 'already known' errors * eth/relay: small nits * internal/ethapi: update txpool_txStatus api comment * eth: check tx status in local db * eth/relay: fix tests * address claude comments * eth/relay: handle race condition for updating task in cache * internal/ethapi: ignore already known error for preconfs * eth/relay: add CLAUDE.md with some context * internal/ethapi: update hash when tx is already known * eth/relay: fix lint * eth/relay: small delay before task being consumed in test * internal/ethapi: lint fix * internal/ethapi: use tx subscription for offering preconf * Revert "internal/ethapi: use tx subscription for offering preconf" This reverts commit a33980b. * eth: move log to debug * eth/relay: add private tx store metrics * eth/relay: add more metrics * eth/relay, internal/ethapi: handle private tx via new rpc endpoint * internal/ethapi, eth/relay: address security comments * eth/relay: wait for go routines to exit for clean shutdown * eth/relay: add more tests for relay * eth/relay: address blocking semaphore * internal/ethapi: add tests for rpc methods * eth: test backend method wiring * eth: add tests for graceful shutdown * docs/cli: update cli flags * update all config.toml files for packages with new flags
* (feat): new approach for private tx relay and preconfs * (feat): refactor relay service * small nit * eth/relay: fix lint * eth: add tests for disable tx propagation * eth: add tests for private transactions * eth/relay: small fixes * eth/relay: small fixes * eth/relay: add tests for private tx store * eth/relay: add tests for multiclient * eth/relay: fix call to send private tx * eth/relay: add a sub test for multiclient * eth/relay: add tests for relay service * address claude comments, fix non-deterministic tests * eth/relay: update relay to server preconf for any tx hash, update tests * eth: close relay service in backend * eth: disable tx propagation for rebroadcast * eth/relay: handle 'already known' errors * eth/relay: small nits * internal/ethapi: update txpool_txStatus api comment * eth: check tx status in local db * eth/relay: fix tests * address claude comments * eth/relay: handle race condition for updating task in cache * internal/ethapi: ignore already known error for preconfs * eth/relay: add CLAUDE.md with some context * internal/ethapi: update hash when tx is already known * eth/relay: fix lint * eth/relay: small delay before task being consumed in test * internal/ethapi: lint fix * internal/ethapi: use tx subscription for offering preconf * Revert "internal/ethapi: use tx subscription for offering preconf" This reverts commit a33980b. * eth: move log to debug * eth/relay: add private tx store metrics * eth/relay: add more metrics * eth/relay, internal/ethapi: handle private tx via new rpc endpoint * internal/ethapi, eth/relay: address security comments * eth/relay: wait for go routines to exit for clean shutdown * eth/relay: add more tests for relay * eth/relay: address blocking semaphore * internal/ethapi: add tests for rpc methods * eth: test backend method wiring * eth: add tests for graceful shutdown * docs/cli: update cli flags * update all config.toml files for packages with new flags
This reverts commit ba9c9bd.
|
Will addresses of "public" relays be annonced anywhere? |


Description
This PR introduces a new relay architecture for enabling preconfirmations and private transactions. The relay is intended to act as a middleware between end users / wallets and block producers. It will be able to route transactions for specific purpose directly to block producers. More details below:
Newly introduced flags:
--relay.enable-preconfs: Enables relay to offer preconfirmations--relay.enable-private-tx: Enables relay to route transactions privately--relay-bp-rpc-endpoints: RPC endpoints of all active block producers for transaction submission--accept-preconf-tx: Enables block producers to accept transactions for preconfirmation--accept-private-tx: Enables block producers to accept private txs--disable-tx-propagation: Disables transaction announcement / broadcast in public p2p networkGeneral transaction flow:
eth_sendRawTransactionendpoint.eth_sendRawTransactionPrivateendpoint.Preconf flow:
eth_sendTransactionForPreconfin all block producers. This is an internal endpoint and won't be exposed to user.{ "hash": "0x...00", "preconfirmed": true }eth_checkPreconfStatustxpool_txStatusPrivate tx flow:
eth_sendTransactionPrivatein all block producers. This is an internal endpoint and won't be exposed to user. Although the same endpoint will be exposed by the relay to end users.-disable-tx-propagationflag which ensures that no transactions are gossiped in the public p2p network.General nuances of the feature:
Changes
Breaking changes
Please complete this section if any breaking changes have been made, otherwise delete it
Nodes audience
In case this PR includes changes that must be applied only to a subset of nodes, please specify how you handled it (e.g. by adding a flag with a default value...)
Checklist
Cross repository changes
Testing
Manual tests
Please complete this section with the steps you performed if you ran manual tests for this functionality, otherwise delete it
Additional comments
Please post additional comments in this section if you have them, otherwise delete it