Commit 7c4c428
authored
feat(api): add EIP-7966 eth_sendRawTransactionSync method (#4565)
## What ❔
Implement `eth_sendRawTransactionSync` API method to add
[EIP-7966](https://eips.ethereum.org/EIPS/eip-7966) support to zksync
era API.
`sendRawTransactionSync` uses the existing new block pubsub broadcast
under the hood to check for transaction inclusion, on new blocks, while
racing a user specified timeout (with default and node-configurable max)
for inclusion.
<!-- What are the changes this PR brings about? -->
<!-- Example: This PR adds a PR template to the repo. -->
<!-- (For bigger PRs adding more context is appreciated) -->
## Why ❔
With the v29 release and fast (200ms) blocks, dapps can benefit greatly
by using synchronous calls for transaction submission to receipt,
instead of having to poll for the receipt.
EIP-7966 has clear benefits for a number of onchain use cases:
- Trading. DEXs, CLOBs, and other trading apps can double their fee
revenue by processing twice as many transactions per second, with no
modification to block times or gas limits. The increased speed also
allows these apps to offer tighter spreads, reduce stale quotes, and
increase order execution probability – all of these improve UX.
- Gaming. Many onchain games translate rapid, repeated in-game actions
(e.g. moves, item trades, crafting, etc.) into individual transactions,
each of which generates a polling loop under today’s
eth_sendRawTransaction paradigm. EIP-7966’s introduction of synchronous
receipts reduces the load on RPCs by eliminating those loops and
provides smoother gameplay for users.
- Payments. Onchain payments apps with high volumes can process more
payments – and therefore generate more fees – with EIP-7966’s
eth_sendRawTransactionSync method. This method also allows them to
confirm payments faster and eliminate the anxiety users get waiting for
a big transfer to be confirmed – a huge UX win.
<!-- Why are these changes done? What goal do they contribute to? What
are the principles behind them? -->
<!-- The `Why` has to be clear to non-Matter Labs entities running their
own ZK Chain -->
<!-- Example: PR templates ensure PR reviewers, observers, and future
iterators are in context about the evolution of repos. -->
## Is this a breaking change?
- [ ] Yes
- [x] No
## Operational changes
<!-- Any config changes? Any new flags? Any changes to any scripts? -->
<!-- Please add anything that non-Matter Labs entities running their own
ZK Chain may need to know -->
Two new configuration values:
- `send_raw_tx_sync_default_timeout_ms`: default 2000 (2 seconds) per
recommendation in EIP
- `send_raw_tx_sync_max_timeout_ms`: default 10000 (10 seconds) -
prevents callers from very-long/infinite duration calls by specifying an
unreasonable transaction inclusion timeout
## Checklist
<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->
- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zkstack dev fmt` and `zkstack dev
lint`.1 parent 42c3f0f commit 7c4c428
File tree
18 files changed
+542
-29
lines changed- core
- bin
- external_node/src/config
- tests
- zksync_server/src
- lib
- config/src/configs
- web3_decl/src
- namespaces
- node
- api_server/src/web3
- backend_jsonrpsee
- namespaces
- namespaces
- tests
- consensus/src
- state_keeper/src/seal_criteria
18 files changed
+542
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| 206 | + | |
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
| |||
216 | 217 | | |
217 | 218 | | |
218 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
219 | 225 | | |
220 | 226 | | |
221 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| |||
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| 98 | + | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| 260 | + | |
260 | 261 | | |
261 | 262 | | |
262 | 263 | | |
| |||
305 | 306 | | |
306 | 307 | | |
307 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
308 | 312 | | |
309 | 313 | | |
310 | 314 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
465 | | - | |
466 | | - | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
467 | 468 | | |
468 | 469 | | |
469 | 470 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
405 | 411 | | |
406 | 412 | | |
407 | 413 | | |
| |||
546 | 552 | | |
547 | 553 | | |
548 | 554 | | |
| 555 | + | |
| 556 | + | |
549 | 557 | | |
550 | 558 | | |
551 | 559 | | |
| |||
592 | 600 | | |
593 | 601 | | |
594 | 602 | | |
| 603 | + | |
| 604 | + | |
595 | 605 | | |
596 | 606 | | |
597 | 607 | | |
| |||
658 | 668 | | |
659 | 669 | | |
660 | 670 | | |
| 671 | + | |
| 672 | + | |
661 | 673 | | |
662 | 674 | | |
663 | 675 | | |
| |||
721 | 733 | | |
722 | 734 | | |
723 | 735 | | |
| 736 | + | |
| 737 | + | |
724 | 738 | | |
725 | 739 | | |
726 | 740 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
| |||
127 | 132 | | |
128 | 133 | | |
129 | 134 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| |||
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
180 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
181 | 184 | | |
182 | 185 | | |
183 | | - | |
184 | 186 | | |
185 | 187 | | |
186 | 188 | | |
| |||
281 | 283 | | |
282 | 284 | | |
283 | 285 | | |
| 286 | + | |
284 | 287 | | |
285 | 288 | | |
286 | 289 | | |
| |||
296 | 299 | | |
297 | 300 | | |
298 | 301 | | |
299 | | - | |
300 | 302 | | |
301 | 303 | | |
302 | 304 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
53 | 59 | | |
54 | 60 | | |
55 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
156 | 163 | | |
157 | 164 | | |
158 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
228 | 238 | | |
229 | 239 | | |
230 | 240 | | |
| |||
0 commit comments