Skip to content

Commit 6064832

Browse files
authored
feat: add optimistic v3 types (#719)
## 📝 Summary Add types for optimistic V3. ## ✅ I have completed the following steps: * [x] Run `make lint` * [x] Run `make test` * [ ] Added tests (if applicable)
1 parent 3f14f82 commit 6064832

File tree

12 files changed

+622
-325
lines changed

12 files changed

+622
-325
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ alloy-signer-local = { version = "1.0.27" }
129129
alloy-rpc-client = { version = "1.0.27" }
130130
alloy-genesis = { version = "1.0.27" }
131131

132+
# Version required by ethereum-consensus beacon-api-client
133+
mev-share-sse = { git = "https://github.com/paradigmxyz/mev-share-rs", rev = "9eb2b0138ab3202b9eb3af4b19c7b3bf40b0faa8", default-features = false }
134+
beacon-api-client = { git = "https://github.com/ralexstokes/ethereum-consensus/", rev = "5031d31e318dd861cf3373702c5d92f085d926e4" }
135+
ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus/", rev = "5031d31e318dd861cf3373702c5d92f085d926e4" }
136+
132137
async-trait = { version = "0.1.83" }
133138
clap = { version = "4.4.3", features = ["derive", "env"] }
134139
clap_builder = { version = "4.5.19" }
@@ -152,6 +157,7 @@ warp = "0.3.7"
152157
flate2 = "1.0.35"
153158
prometheus = "0.13.4"
154159
ctor = "0.2"
160+
rand = "0.8"
155161

156162
libc = { version = "0.2.161" }
157163
lazy_static = "1.4.0"

crates/bid-scraper/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ serde_with = { version = "3.9.0", features = ["time_0_3"] }
2121
chrono = "^0.4"
2222
futures = "^0.3"
2323
futures-retry = "0.6"
24-
rand = "^0.8"
24+
rand.workspace = true
2525
runng = "^0.3"
2626
reqwest = { version = "^0.11", default-features = false, features = ["rustls", "gzip", "brotli", "deflate", "json", "rustls-tls"] }
2727
lru = "^0.10"

crates/eth-sparse-mpt/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ benchmark-utils = ["dep:hash-db", "dep:triehash", "dep:flate2"]
5151

5252
[dev-dependencies]
5353
criterion = { version = "0.4", features = ["html_reports"] }
54-
rand = { version = "0.8.5", features = ["small_rng"] }
54+
rand = { workspace = true, features = ["small_rng"] }
5555
proptest = "1.5.0"
5656
eth-sparse-mpt = { path = ".", features = ["benchmark-utils"] }
5757

crates/rbuilder-primitives/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ alloy-rpc-types-eth.workspace = true
2222
revm.workspace = true
2323
revm-inspectors.workspace = true
2424

25+
ethereum-consensus.workspace = true
26+
2527
# misc
2628
derivative = "2.2.0"
2729
integer-encoding = "4.0.0"
@@ -49,3 +51,6 @@ reth-primitives.workspace = true
4951
reth-ethereum-primitives.workspace = true
5052
reth-node-core.workspace = true
5153
reth.workspace = true
54+
55+
[dev-dependencies]
56+
rand.workspace = true
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
use alloy_primitives::{Address, Bloom, Bytes, B256};
2+
3+
/// The type representing UltraSound bid adjustments.
4+
#[derive(
5+
PartialEq,
6+
Eq,
7+
Clone,
8+
Debug,
9+
serde::Serialize,
10+
serde::Deserialize,
11+
ssz_derive::Encode,
12+
ssz_derive::Decode,
13+
)]
14+
pub struct BidAdjustmentData {
15+
/// State root of the payload.
16+
pub state_root: B256,
17+
/// Transactions root of the payload.
18+
pub transactions_root: B256,
19+
/// Receipts root of the payload.
20+
pub receipts_root: B256,
21+
/// The usual builder address that pays the proposer in the last transaction of the block.
22+
/// When we adjust a bid, this transaction is overwritten by a transaction from the collateral
23+
/// account `fee_payer_address`. If we don't adjust the bid, `builder_address` pays the
24+
/// proposer as per usual.
25+
pub builder_address: Address,
26+
/// The state proof for the builder account.
27+
pub builder_proof: Vec<Bytes>,
28+
/// The proposer's fee recipient.
29+
pub fee_recipient_address: Address,
30+
/// The state proof for the fee recipient account.
31+
pub fee_recipient_proof: Vec<Bytes>,
32+
/// The fee payer address that is custodied by the relay.
33+
pub fee_payer_address: Address,
34+
/// The state proof for the fee payer account.
35+
pub fee_payer_proof: Vec<Bytes>,
36+
/// The merkle proof for the last transaction in the block, which will be overwritten with a
37+
/// payment from `fee_payer` to `fee_recipient` if we adjust the bid.
38+
pub placeholder_transaction_proof: Vec<Bytes>,
39+
/// The merkle proof for the receipt of the placeholder transaction. It's required for
40+
/// adjusting payments to contract addresses.
41+
pub placeholder_receipt_proof: Vec<Bytes>,
42+
}
43+
44+
/// The type for bid adjustments in optimistic v3.
45+
/// Ref: <https://github.com/ultrasoundmoney/docs/blob/main/optimistic-v3.md#optimistic-v3>
46+
#[derive(
47+
PartialEq,
48+
Eq,
49+
Clone,
50+
Debug,
51+
serde::Serialize,
52+
serde::Deserialize,
53+
ssz_derive::Encode,
54+
ssz_derive::Decode,
55+
)]
56+
pub struct BidAdjustmentDataV2 {
57+
/// Transactions root of the payload.
58+
pub el_transactions_root: B256,
59+
/// Withdrawals root of the payload.
60+
pub el_withdrawals_root: B256,
61+
/// The usual builder address that pays the proposer in the last transaction of the block.
62+
/// When we adjust a bid, this transaction is overwritten by a transaction from the collateral
63+
/// account `fee_payer_address`. If we don't adjust the bid, `builder_address` pays the
64+
/// proposer as per usual.
65+
pub builder_address: Address,
66+
/// The state proof for the builder account.
67+
pub builder_proof: Vec<Bytes>,
68+
/// The proposer's fee recipient.
69+
pub fee_recipient_address: Address,
70+
/// The state proof for the fee recipient account.
71+
pub fee_recipient_proof: Vec<Bytes>,
72+
/// The fee payer address that is custodied by the relay.
73+
pub fee_payer_address: Address,
74+
/// The state proof for the fee payer account.
75+
pub fee_payer_proof: Vec<Bytes>,
76+
/// The merkle proof for the last transaction in the block, which will be overwritten with a
77+
/// payment from `fee_payer` to `fee_recipient` if we adjust the bid.
78+
pub el_placeholder_transaction_proof: Vec<Bytes>,
79+
/// New in V2: SSZ merkle proof for last transaction
80+
pub cl_placeholder_transaction_proof: Vec<B256>,
81+
/// The merkle proof for the receipt of the placeholder transaction. It's required for
82+
/// adjusting payments to contract addresses.
83+
pub placeholder_receipt_proof: Vec<Bytes>,
84+
/// New in V2: Logs bloom accrued until but not including the last (payment) transaction.
85+
pub pre_payment_logs_bloom: Bloom,
86+
}

0 commit comments

Comments
 (0)