-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Add EIP: eth_sendRawTransactionSync Method #9890
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
SmoothBot
wants to merge
20
commits into
ethereum:master
Choose a base branch
from
SmoothBot:sync_send_method
base: master
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.
+193
−0
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
80db588
drafting eth_sendRawTransactionSync eip
SmoothBot 54bdc19
fix: broken author format
SmoothBot 2f14e75
Correcting return payloads
SmoothBot 51ca25f
chore: update EIP-sync send method
LampardNguyen234 036cc7b
chore: change Reth to reth
LampardNguyen234 5978a48
Merge pull request #2 from SmoothBot/thanh/sync_send_method
SmoothBot 153b695
Update and rename eip-sync_send_method.md to eip-7966.md
SamWilsn 914cca1
Rename sync-vs-async.png to sync-vs-async.png
SamWilsn e4dc00a
Rename sync-vs-async.png to sync-vs-async.png
SamWilsn 4258ff1
chore: change file names to match EIP number
LampardNguyen234 0fe1425
chore: fix typos
LampardNguyen234 56a439a
chore: address comments
LampardNguyen234 43fe02b
Merge branch 'sync_send_method' into thanh/sync_send_method
LampardNguyen234 a659946
chore: change to normative form
LampardNguyen234 c04e491
chore: fix typo
LampardNguyen234 774ae78
Merge pull request #3 from SmoothBot/thanh/sync_send_method
SmoothBot 3f74e21
chore: fix lint issues
LampardNguyen234 dc7a68c
chore: fix lint issues
LampardNguyen234 a51cd65
chore: update discussions-to link
LampardNguyen234 316cf05
chore: update timeout specs
LampardNguyen234 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
--- | ||
eip: 7966 | ||
title: eth_sendRawTransactionSync Method | ||
description: A JSON-RPC method to reduce transaction submission latency by allowing synchronous receipt of transaction hash and block inclusion. | ||
author: Sam Battenally (@SmoothBot), Hai Nguyen (@hai-rise), Thanh Nguyen (@LampardNguyen234) | ||
discussions-to: https://ethereum-magicians.org/t/eip-7966-eth-sendrawtransactionsync-method/24640 | ||
status: Draft | ||
type: Standards Track | ||
category: Interface | ||
created: 2025-06-11 | ||
--- | ||
|
||
## Abstract | ||
|
||
This EIP proposes a new JSON-RPC method, `eth_sendRawTransactionSync`, which submits a signed raw transaction and waits synchronously for the transaction receipt or a configurable timeout before returning. This method addresses the user experience gap in high-frequency applications by offering stronger delivery guarantees than `eth_sendRawTransaction`. | ||
|
||
## Motivation | ||
|
||
Currently, Ethereum clients submit signed transactions asynchronously using `eth_sendRawTransaction`. Clients receive a transaction hash immediately but must poll repeatedly for the transaction receipt, which increases latency and complicates client-side logic. | ||
|
||
This asynchronous approach is not efficient for high-frequency blockchains or Layer 2 solutions with fast block times and low latency, where rapid transaction throughput and quick confirmation feedback are critical. The need to separately poll for receipts results in increased network overhead, slower overall transaction confirmation feedback, and more complex client implementations. | ||
|
||
 | ||
_In a low-latency blockchain, transaction receipts are often available right after the transactions land in the block producer’s mempool. Requiring an additional RPC call introduces unnecessary latency._ | ||
|
||
`eth_sendRawTransactionSync` addresses these issues by combining transaction submission and receipt retrieval into a single RPC call. This helps: | ||
|
||
- reduce total transaction submission and confirmation latency by approximately 50%; | ||
- simplify client implementations by eliminating the need for separate polling loops; | ||
- improve user experience by enabling more responsive dApps and wallets; | ||
- align blockchain interactions closer to traditional Web2 request-response patterns; | ||
- maintain backward compatibility and optionality, preserving existing RPC methods and semantics. | ||
|
||
## Specification | ||
|
||
### Method Name | ||
|
||
`eth_sendRawTransactionSync` | ||
|
||
### Parameters | ||
|
||
The parameters of this method MUST be identical to the `eth_sendRawTransaction` method, which contain a signed transaction data. | ||
|
||
- `DATA`. The signed transaction data. | ||
|
||
### Returns | ||
|
||
- **On success**. Clients MUST return the transaction receipt object as defined by the `eth_getTransactionReceipt` method. | ||
- **On timeout error**. Clients MUST return an error code `-32002` with a timeout message. | ||
- **On standard error**. Clients MUST return a JSON-RPC error object consistent with existing RPC error formats. | ||
|
||
### Timeout Configuration | ||
|
||
- The handler function of this RPC MUST incorporate a configurable timeout when waiting for receipts (RECOMMENDED: 2 seconds). | ||
- Implementations MUST provide a way to configure the timeout duration. | ||
- Node operators MAY implement dynamic timeout adjustment based on real-time network conditions. | ||
|
||
### Behavior | ||
|
||
Upon receiving an `eth_sendRawTransactionSync` request, the handler function performs the following tasks. | ||
|
||
- The handler function MUST submit the signed transaction to the network as per the existing `eth_sendRawTransaction` semantics. | ||
- The handler function MUST wait for the transaction receipt until the timeout elapses. | ||
- If the receipt is found within the specified timeout, the handler function MUST return it immediately. | ||
- If the timeout expires without obtaining a receipt, the handler function MUST return an error message with a timeout message. | ||
- If the transaction submission fails (e.g., due to invalid transaction data), the handler function MUST return an error immediately. | ||
|
||
### Example Request | ||
|
||
```json | ||
{ | ||
"jsonrpc": "2.0", | ||
"method": "eth_sendRawTransactionSync", | ||
"params": [ | ||
"0xf86c808504a817c80082520894ab... (signed tx hex)" | ||
], | ||
"id": 1 | ||
} | ||
``` | ||
|
||
### Example Response (Success) | ||
|
||
```json | ||
{ | ||
"jsonrpc": "2.0", | ||
"id": 1, | ||
"result": { | ||
"transactionHash": "0x1234abcd...", | ||
"blockHash": "0xabcd1234...", | ||
"blockNumber": "0x10d4f", | ||
"cumulativeGasUsed": "0x5208", | ||
"gasUsed": "0x5208", | ||
"contractAddress": null, | ||
"logs": [], | ||
"status": "0x1" | ||
} | ||
} | ||
``` | ||
|
||
### Example Response (Timeout) | ||
|
||
```json | ||
{ | ||
"jsonrpc": "2.0", | ||
"id": 1, | ||
"error": { | ||
"code": -32002, | ||
"message": "The transaction was added to the mempool but wasn't processed in 2s.", | ||
"data": "0x1234abcd..." | ||
} | ||
} | ||
``` | ||
|
||
### Example Response (Error) | ||
|
||
```json | ||
{ | ||
"jsonrpc": "2.0", | ||
"id": 1, | ||
"error": { | ||
"code": -32000, | ||
"message": "Invalid transaction" | ||
} | ||
} | ||
``` | ||
|
||
## Rationale | ||
|
||
### Why Not Extend Existing RPC? | ||
|
||
Modifying `eth_sendRawTransaction` to support this behavior would risk compatibility issues and ambiguity. A separate method makes the semantics explicit and opt-in. | ||
|
||
### Blocking Behavior and Timeouts | ||
|
||
Clients SHOULD allow configuration of the timeout period, defaulting to 2 seconds (depending on the implementation). This balances responsiveness and propagation guarantees without creating excessive overhead in node clients. | ||
|
||
### Optionality | ||
|
||
This method is optional and does not replace or change existing asynchronous transaction submission methods. Clients and servers that do not implement this method will continue to operate normally using the standard asynchronous RPC methods. | ||
|
||
This RPC method is particularly suitable for EVM-compatible blockchains or L2 solutions with fast block times and low network latency, where synchronous receipt retrieval can significantly improve responsiveness. On high-latency or slower blockchains (e.g., Ethereum mainnet pre-sharding), the synchronous wait may cause longer RPC call durations or timeouts, making the method less practical. | ||
|
||
### Improved UX | ||
|
||
The synchronous receipt retrieval reduces the complexity of client applications by eliminating the need for separate polling logic. | ||
|
||
## Backwards Compatibility | ||
|
||
This EIP introduces a new RPC method and does not modify or deprecate any existing methods. Clients and servers that do not implement this method will continue operating normally. Existing applications using `eth_sendRawTransaction` are unaffected. Clients that do not support the method will simply return `method not found`. | ||
|
||
## Reference Implementation | ||
|
||
A minimal reference implementation can be realized by wrapping existing `eth_sendRawTransaction` submission with a polling loop that queries `eth_getTransactionReceipt` at short intervals until a receipt is found or a timeout occurs. Polling intervals and timeout values can be tuned by client implementations to optimize performance. | ||
|
||
For example, in `reth`, we can implement the handler for `eth_sendRawTransactionSync` as follows. | ||
|
||
```rust | ||
async fn send_raw_transaction_sync(&self, tx: Bytes) -> RpcResult<OpTransactionReceipt> { | ||
const TIMEOUT_DURATION: Duration = Duration::from_secs(2); | ||
const POLL_INTERVAL: Duration = Duration::from_millis(1); | ||
|
||
let hash = self.inner.send_raw_transaction(tx).await?; | ||
|
||
let start = Instant::now(); | ||
while start.elapsed() < TIMEOUT_DURATION { | ||
if let Some(receipt) = self.pending_block.get_receipt(hash) { | ||
return Ok(receipt); | ||
} | ||
tokio::time::sleep(POLL_INTERVAL).await; | ||
} | ||
|
||
Err(ErrorObject::owned( | ||
-32002, | ||
format!( | ||
"The transaction was added to the mempool but wasn't processed in {TIMEOUT_DURATION:?}." | ||
), | ||
Some(hash), | ||
)) | ||
} | ||
``` | ||
|
||
Other implementations such as `go-ethereum` can utilize a channel to signify receipt availability instead of polling. | ||
|
||
## Security Considerations | ||
|
||
- This method does not introduce new security risks beyond those inherent in transaction submission. | ||
- The timeout prevents indefinite blocking of RPC calls, protecting clients and servers from hanging requests. | ||
- Clients should handle timeout responses gracefully and continue monitoring transaction status as needed. | ||
- Servers must ensure that the implementation does not degrade node performance or cause denial-of-service. | ||
|
||
## Copyright | ||
|
||
Copyright and related rights waived via [CC0](../LICENSE.md). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mention the timeout is specified but not how it is specified. Should it be a parameter to this function or should it be configured by the node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @wjmelements, thank you for the comment. We have addressed the timeout issue in 316cf05.