Skip to content

Commit ecef689

Browse files
authored
First pass at documenting API behavior (#17)
1 parent 746f3d7 commit ecef689

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

docs/API.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# API
2+
3+
## Overview
4+
5+
TIPS only processes bundles. Transactions sent via `eth_sendRawTransaction` are wrapped into a bundle (see: [EthSendBundle](https://github.com/alloy-rs/alloy/blob/25019adf54272a3372d75c6c44a6185e4be9dfa2/crates/rpc-types-mev/src/eth_calls.rs#L252))
6+
with a single transaction and sensible defaults.
7+
8+
Bundles can be identified in two ways:
9+
- Bundle UUID: Generated server-side on submission of a new bundle, globally unique
10+
- Bundle Hash: `keccak(..bundle.txns)`, unique per set of transactions
11+
12+
### Bundle Creates
13+
Any bundle that's created as part of TIPS, will be deduplicated by bundle hash in the TIPS bundle store with the latest bundle
14+
defining the fields. For example:
15+
```
16+
Multiple Bundles inserted in the order of A, B, C, D
17+
18+
# Single bundle transction
19+
bundleA = (txA)
20+
bundleStore = {bundleA}
21+
22+
# Bundle with overlapping transactions
23+
bundleB = (txA, txB)
24+
bundleStore = {bundleA, bundleB}
25+
26+
# Bundle with identical bundle hash
27+
bundleC = (txA, txB)
28+
bundleStore = {bundleA, bundleC}
29+
30+
# Bundle with overlapping transactions
31+
bundleD = (txC, txA)
32+
bundleStore = {bundleA, bundleC, bundleD}
33+
```
34+
35+
### Bundle Updates
36+
There are two ways bundles can be updated, either via `eth_sendRawTransaction` (address, nonce) or `eth_sendBundle` (UUID), see below for more details.
37+
38+
Bundle updates are **best effort**. For example:
39+
```
40+
bundleA = createBundle(txA)
41+
# In parrallel
42+
includedByBuilder(bundleA) # bundleA is included in the current Flashblock
43+
updateBundle(bundleA, [txB, txC]) # bundleA is updated to bundleA`
44+
# Bundle A will have been removed from the bundle store
45+
```
46+
47+
### Bundle Cancellation:
48+
Bundles can be cancelled via `eth_cancelBundle`. Similar to bundle updates, cancellations are processed as **best effort**.
49+
50+
## RPC Methods
51+
52+
### eth_sendRawTransaction(Bytes) -> Hash
53+
Transactions provided to this endpoint, are validated and then wrapped in a bundle (with defaults) and added to the bundle store.
54+
Previously submitted transactions can be replaced by submitting a new transaction from the same address and nonce. These will
55+
replace bundles with the same bundle hash submitted via this endpoint or `eth_sendBundle`.
56+
57+
**Limitations:**
58+
- 25 million gas per transaction
59+
60+
### eth_sendBundle([EthSendBundle](https://github.com/alloy-rs/alloy/blob/25019adf54272a3372d75c6c44a6185e4be9dfa2/crates/rpc-types-mev/src/eth_calls.rs#L252)) -> UUID
61+
If a replacement UUID is not provided, this will attempt to insert the bundle. If a bundle with the same bundle hash already exists
62+
the bundle will be combined with the existing one.
63+
64+
If a UUID is provided, this endpoint will only attempt to update a bundle, if that bundle is no longer in the bundle store, the
65+
update will be dropped.
66+
67+
**Limitations**
68+
- 25 million gas per bundle
69+
- Can only provide three transactions at once
70+
- Revert protection is not supported, all transaction hashes must be in `reverting_tx_hashes`
71+
- Partial transaction dropping is not supported, `dropping_tx_hashes` must be empty
72+
- Refunds are not initially supported
73+
- `refund_percent` must not be set
74+
- `refund_receipient` must not be set
75+
- `refund_tx_hashes` must be empty
76+
- extra_fields must be empty
77+
78+
### eth_cancelBundle([EthCancelBundle](https://github.com/alloy-rs/alloy/blob/25019adf54272a3372d75c6c44a6185e4be9dfa2/crates/rpc-types-mev/src/eth_calls.rs#L216))
79+
- Will cancel the bundle matching the UUID
80+
- Cancellation is the best effort, if the builder has already included it is will go through

0 commit comments

Comments
 (0)