-
Notifications
You must be signed in to change notification settings - Fork 2
Open
0 / 70 of 7 issues completedDescription
Port DTR functionality from origin/dtr branch to current OmniProtocol-based architecture.
Background
DTR allows non-validator RPCs to forward transactions to the validation shard instead of processing locally. This improves network efficiency by routing transactions directly to validators.
Source Reference
- Branch:
origin/dtr - Key files to port:
src/libs/network/dtr/dtrmanager.ts(699 lines)src/libs/consensus/v2/routines/isValidator.ts(26 lines)- Changes in
src/libs/network/endpointHandlers.ts - Changes in
src/libs/network/manageNodeCall.ts(RELAY_TX handler)
- Documentation:
dtr_implementation/DTR_MINIMAL_IMPLEMENTATION.md
Architecture
The DTR branch uses HTTP-based peer.longCall() which must be replaced with OmniProtocol binary communication:
- Add new opcode:
RELAY_TX = 0x17(in 0x1X transaction range) - Create handler following existing pattern in
src/libs/omniprotocol/protocol/handlers/transaction.ts - Register in
src/libs/omniprotocol/protocol/registry.ts
Key Components
- DTRManager - Singleton managing transaction relay with:
validityDataCache- Map storing ValidityData for retry- Background retry service (10-second interval)
- Block-aware optimization (recalculate validators only when block changes)
- isValidatorForNextBlock() - Check if current node is validator for next block
- Integration Points:
- After validation in endpointHandlers, check if validator
- If not validator → relay to all validators
- Fallback to local mempool if all relays fail
Design
New Opcode
// In src/libs/omniprotocol/protocol/opcodes.ts
RELAY_TX = 0x17 // After BROADCAST = 0x16Handler Pattern (following existing transaction.ts)
// In src/libs/omniprotocol/protocol/handlers/transaction.ts
export const handleRelayTx: OmniHandler<Buffer> = async ({ message, context }) => {
const request = decodeJsonRequest<RelayTxRequest>(message.payload)
return await DTRManager.receiveRelayedTransactions(request.transactions)
}Transport Replacement
OLD (HTTP):
await validator.longCall({ method: "nodeCall", params: [{ message: "RELAY_TX", data: payload }] })NEW (OmniProtocol):
await validator.omniSend(OmniOpcode.RELAY_TX, encodeJsonRequest({ transactions: payload }))Acceptance Criteria
- RELAY_TX opcode (0x17) added to opcodes.ts
- Handler registered in registry.ts
- DTRManager ported with OmniProtocol transport
- isValidatorForNextBlock() available
- endpointHandlers.ts integrates DTR check after validation
- Background retry service functional
- Fallback to local mempool works when all validators fail
- PROD flag check preserved (DTR only in production)
- Tests passing
[Beads: node-abn]
coderabbitai
Sub-issues
Metadata
Metadata
Assignees
Labels
No labels