Skip to content
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

fix: updated devnet #285

Merged
merged 66 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
51d9b81
fix: updated devnet
merklefruit Oct 8, 2024
fa0bd30
fix(builder): runtime err in commit-transaction
merklefruit Oct 8, 2024
cf90e16
fix(builder): golang strikes again
merklefruit Oct 8, 2024
11cd077
chore(stash): bolt-boost fixes
merklefruit Oct 9, 2024
cb72c20
feat(mev-boost): update ConstraintMessage
namn-grg Oct 7, 2024
7c77455
feat(mev-boost): add delegate, revoke
namn-grg Oct 7, 2024
d678b3f
feat(mev-boost): versioned signed builder bid
namn-grg Oct 7, 2024
6578337
fix(mev-boost): mock relay - rm bid with inclusion proof
namn-grg Oct 7, 2024
8074c7d
misc(mev-boost): address review
namn-grg Oct 8, 2024
53579f6
chore(mev-boost): rm bolt demo events
namn-grg Oct 8, 2024
4a675c9
fix(mev-boost): pubkey log display
namn-grg Oct 8, 2024
ea2f6b1
test(mev-boost): add logs, nits
namn-grg Oct 8, 2024
ed3af99
chore(mev-boost): unmarshal json builder bid with proof
namn-grg Oct 8, 2024
b09363b
test(mev-boost): delegation revocation
namn-grg Oct 8, 2024
eb47e26
Update mev-boost/server/service.go
thedevbirb Oct 8, 2024
d48011b
chore: addressed review
merklefruit Oct 10, 2024
ac83904
Merge branch 'nico/devnet-fix' of github.com:chainbound/bolt into nic…
merklefruit Oct 10, 2024
601f8d6
feat: signed message actions (with runtime check)
merklefruit Oct 10, 2024
482b850
feat(mev-boost): add delegation action to api
merklefruit Oct 11, 2024
345c109
feat(bolt-boost): added action to delegation api
merklefruit Oct 11, 2024
bc77dee
fix(builder): re-add constraint pubkey validation
merklefruit Oct 11, 2024
83f2dee
feat(sidecar): keys dir for ERC-2335 keystore
thedevbirb Oct 8, 2024
dffe0fa
chore(sidecar): lighthouse dependencies for keystore
thedevbirb Oct 8, 2024
7fcfa88
chore(sidecar): custom Debug for SigningOpts with the keystore_passwo…
thedevbirb Oct 8, 2024
c6f4535
chore(sidecar): readme in keys folder
thedevbirb Oct 9, 2024
5421b48
chore(sidecar): keys folder readme
thedevbirb Oct 10, 2024
b842800
feat(sidecar): keystore signer stub
thedevbirb Oct 9, 2024
d71dfe1
refactor(sidecar): config struct
thedevbirb Oct 9, 2024
44624ae
chore(sidecar): lighthouse deps revision
thedevbirb Oct 9, 2024
53ee181
refactor(sidecar): move commit boost signer to signer folder
thedevbirb Oct 9, 2024
f93425f
refactor,feat(sidecar): SignerBLS is now Enum, sign with keystore wip
thedevbirb Oct 9, 2024
4b71447
fix(sidecar): imports, errors
thedevbirb Oct 10, 2024
22b7a47
chore(sidecar): Signer -> LocalSigner
thedevbirb Oct 10, 2024
c6d2f6f
chore(sidecar): just fmt
thedevbirb Oct 10, 2024
aad480f
chore(sidecar): Debug for SignerBLSEnum
thedevbirb Oct 10, 2024
fa286d9
chore(sidecar): SignerBLSEnum -> SignerBLS
thedevbirb Oct 10, 2024
94d7a15
fix(sidecar): warnings
thedevbirb Oct 10, 2024
c6d3dac
feat(sidecar): add keystore signer to driver
thedevbirb Oct 10, 2024
fdeec0b
chore(sidecar): jwt validation in opts
thedevbirb Oct 10, 2024
094dee3
fix(sidecar): tests
thedevbirb Oct 10, 2024
5527336
chore(sidecar): less verbose opts
thedevbirb Oct 10, 2024
06dc1a0
refactor(sidecar): cleanup between different bls signers
thedevbirb Oct 10, 2024
d3d7a80
fix(sidecar): revert LimitOpts alias
thedevbirb Oct 10, 2024
6bade57
fix(sidecar): keystore validation logic
thedevbirb Oct 10, 2024
9db5347
fix(sidecar): restore Copy to Limits
thedevbirb Oct 10, 2024
59a0836
test(sidecar): fix some of the test after rebase
thedevbirb Oct 10, 2024
7c82e69
dep(sidecar): add tempfile
thedevbirb Oct 10, 2024
d558754
feat(sidecar): add sign with domain method to keystore signer
thedevbirb Oct 10, 2024
5356c8f
test(sidecar): add e2e test for keystore signer
thedevbirb Oct 10, 2024
1de7d09
chore(sidecar): KeystoreError
thedevbirb Oct 11, 2024
b60efa9
refactor(sidecar): error handling
thedevbirb Oct 11, 2024
80a0d35
config(sidecar): add keystores path
thedevbirb Oct 11, 2024
2ceb704
fix(sidecar): dockerfile
thedevbirb Oct 11, 2024
a3f971e
chore(sidecar): .dockerignore
thedevbirb Oct 11, 2024
d3883fb
feat(justfile): just bash and small refactor of commands
thedevbirb Oct 11, 2024
7a4fd66
test(sidecar): updated keystore test wip; devnet keystore is failing
thedevbirb Oct 11, 2024
34ae469
fix(justfile): just bash {{ service }} had hardcoded helix
thedevbirb Oct 13, 2024
c5ac649
test(sidecar): another keystore test, but temporary
thedevbirb Oct 13, 2024
60a9e47
test(sidecar): keep only erc-2335 canonical tests
thedevbirb Oct 13, 2024
ba91b23
chore(sidecar): remove TODO comment
thedevbirb Oct 14, 2024
a07452d
chore(sidecar): imports
thedevbirb Oct 14, 2024
5ced625
fix,test(sidecar): fix tests not working with cargo nextest. Now extr…
thedevbirb Oct 14, 2024
ddaedb5
refactor(sidecar): signer errors
thedevbirb Oct 14, 2024
cd105ea
Merge pull request #287 from chainbound/lore/feat/sidecar/keystore
merklefruit Oct 14, 2024
bc7e629
fmt: sidecar
thedevbirb Oct 14, 2024
7c7d677
fmt: bolt-boost
thedevbirb Oct 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target
.git
Dockerfile
.dockerignore
1 change: 1 addition & 0 deletions bolt-boost/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bolt-boost/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ alloy = { version = "0.3.6", features = [
"rpc-types-beacon",
"rpc-types-engine",
] }
alloy-rlp = "0.3.8"

# commit-boost
cb-common = { git = "https://github.com/commit-boost/commit-boost-client", tag = "v0.3.0" }
Expand Down
4 changes: 2 additions & 2 deletions bolt-boost/src/proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ pub fn verify_multiproofs(
// Get all the leaves from the saved constraints
let mut leaves = Vec::with_capacity(proofs.total_leaves());

// NOTE: Get the leaves from the constraints cache by matching the saved hashes. We need the leaves
// in order to verify the multiproof.
// NOTE: Get the leaves from the constraints cache by matching the saved hashes. We need the
// leaves in order to verify the multiproof.
for hash in &proofs.transaction_hashes {
let mut found = false;
for constraint in constraints {
Expand Down
8 changes: 2 additions & 6 deletions bolt-boost/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,13 +543,9 @@ where
Ok(response) => {
let url = response.url().clone();
let status = response.status();
let body = response.text().await.ok();
if status != StatusCode::OK {
error!(
%status,
%url,
"Failed to POST to relay: {body:?}"
)
let body = response.text().await.ok();
error!(%status, %url, "Failed to POST to relay: {body:?}");
} else {
debug!(%url, "Successfully sent POST request to relay");
success = true;
Expand Down
120 changes: 106 additions & 14 deletions bolt-boost/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use alloy::{
consensus::TxEnvelope,
eips::eip2718::{Decodable2718, Eip2718Error},
consensus::{TxEip4844Variant, TxEnvelope},
eips::eip2718::{Decodable2718, Eip2718Error, Eip2718Result},
primitives::{Bytes, TxHash, B256},
rpc::types::beacon::{BlsPublicKey, BlsSignature},
signers::k256::sha2::{Digest, Sha256},
};
use alloy_rlp::{BufMut, Encodable};
use axum::http::HeaderMap;
use reqwest::Url;
use serde::{Deserialize, Serialize};
use ssz_derive::{Decode, Encode};
use std::ops::Deref;
use tracing::error;

use cb_common::{
constants::COMMIT_BOOST_DOMAIN,
Expand Down Expand Up @@ -44,8 +46,15 @@ impl SignedConstraints {
#[allow(unused)]
pub fn verify_signature(&self, chain: Chain, pubkey: &BlsPublicKey) -> bool {
let domain = compute_domain(chain, COMMIT_BOOST_DOMAIN);
let signing_root = compute_signing_root(self.message.digest(), domain);
let digest = match self.message.digest() {
Ok(digest) => digest,
Err(e) => {
error!(err = ?e, "Failed to compute digest");
return false;
}
};

let signing_root = compute_signing_root(digest, domain);
verify_bls_signature(pubkey, &signing_root, &self.signature).is_ok()
}
}
Expand All @@ -60,19 +69,18 @@ pub struct ConstraintsMessage {

impl ConstraintsMessage {
/// Returns the digest of this message.
pub fn digest(&self) -> [u8; 32] {
pub fn digest(&self) -> Eip2718Result<[u8; 32]> {
let mut hasher = Sha256::new();
hasher.update(self.pubkey);
hasher.update(self.slot.to_le_bytes());
hasher.update((self.top as u8).to_le_bytes());

for bytes in &self.transactions {
let tx = TxEnvelope::decode_2718(&mut bytes.as_ref()).expect("valid transaction");

let tx = TxEnvelope::decode_2718(&mut bytes.as_ref())?;
hasher.update(tx.tx_hash());
}

hasher.finalize().into()
Ok(hasher.finalize().into())
}
}

Expand All @@ -92,21 +100,53 @@ impl TryFrom<ConstraintsMessage> for ConstraintsWithProofData {
.transactions
.iter()
.map(|tx| {
let tx_hash = *TxEnvelope::decode_2718(&mut tx.as_ref())?.tx_hash();

let tx_root =
tree_hash::TreeHash::tree_hash_root(&Transaction::<
<DenebSpec as EthSpec>::MaxBytesPerTransaction,
>::from(tx.to_vec()));
let envelope = TxEnvelope::decode_2718(&mut tx.as_ref())?;
let tx_hash_tree_root = calculate_tx_hash_tree_root(&envelope, tx)?;

Ok((tx_hash, tx_root))
Ok((*envelope.tx_hash(), tx_hash_tree_root))
})
.collect::<Result<Vec<_>, Eip2718Error>>()?;

Ok(Self { message: value, proof_data: transactions })
}
}

/// Calculate the SSZ hash tree root of a transaction, starting from its enveloped form.
/// For type 3 transactions, the hash tree root of the inner transaction is taken (without blobs).
fn calculate_tx_hash_tree_root(
envelope: &TxEnvelope,
raw_tx: &Bytes,
) -> Result<B256, Eip2718Error> {
match envelope {
// For type 3 txs, take the hash tree root of the inner tx (EIP-4844)
TxEnvelope::Eip4844(tx) => match tx.tx() {
TxEip4844Variant::TxEip4844(tx) => {
let mut out = Vec::new();
out.put_u8(0x03);
tx.encode(&mut out);

Ok(tree_hash::TreeHash::tree_hash_root(&Transaction::<
<DenebSpec as EthSpec>::MaxBytesPerTransaction,
>::from(out)))
}
TxEip4844Variant::TxEip4844WithSidecar(tx) => {
use alloy_rlp::Encodable;
let mut out = Vec::new();
out.put_u8(0x03);
tx.tx.encode(&mut out);

Ok(tree_hash::TreeHash::tree_hash_root(&Transaction::<
<DenebSpec as EthSpec>::MaxBytesPerTransaction,
>::from(out)))
}
},
// For other transaction types, take the hash tree root of the whole tx
_ => Ok(tree_hash::TreeHash::tree_hash_root(&Transaction::<
<DenebSpec as EthSpec>::MaxBytesPerTransaction,
>::from(raw_tx.to_vec()))),
}
}

#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode)]
pub struct SignedDelegation {
pub message: DelegationMessage,
Expand All @@ -115,6 +155,7 @@ pub struct SignedDelegation {

#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode)]
pub struct DelegationMessage {
action: u8,
pub validator_pubkey: BlsPublicKey,
pub delegatee_pubkey: BlsPublicKey,
}
Expand All @@ -127,6 +168,7 @@ pub struct SignedRevocation {

#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode)]
pub struct RevocationMessage {
action: u8,
pub validator_pubkey: BlsPublicKey,
pub delegatee_pubkey: BlsPublicKey,
}
Expand Down Expand Up @@ -173,3 +215,53 @@ pub struct RequestConfig {
pub timeout_ms: u64,
pub headers: HeaderMap,
}

#[cfg(test)]
mod tests {
use alloy::{hex::FromHex, primitives::Bytes};

use super::ConstraintsWithProofData;
use crate::types::SignedConstraints;

#[test]
fn decode_constraints_test() {
let raw = r#"{
"message": {
"pubkey": "0xa695ad325dfc7e1191fbc9f186f58eff42a634029731b18380ff89bf42c464a42cb8ca55b200f051f57f1e1893c68759",
"slot": 32,
"top": true,
"transactions": [
"0x02f86c870c72dd9d5e883e4d0183408f2382520894d2e2adf7177b7a8afddbc12d1634cf23ea1a71020180c001a08556dcfea479b34675db3fe08e29486fe719c2b22f6b0c1741ecbbdce4575cc6a01cd48009ccafd6b9f1290bbe2ceea268f94101d1d322c787018423ebcbc87ab4"
]
},
"signature": "0xb8d50ee0d4b269db3d4658c1dac784d273a4160d769e16dce723a9684c390afe5865348416b3bf0f1a4f47098bec9024135d0d95f08bed18eb577a3d8a67f5dc78b13cc62515e280786a73fb267d35dfb7ab46a25ac29bf5bc2fa5b07b3e07a6"
}"#;

let mut c = serde_json::from_str::<SignedConstraints>(raw).unwrap();
let pd = ConstraintsWithProofData::try_from(c.message.clone()).unwrap().proof_data[0];

assert_eq!(
pd.0.to_string(),
"0x385b9f1ba5dbbe419dcbbbbf0840b76b941f3c216d383ec9deb9b1a323ee0cea".to_string()
);

assert_eq!(
pd.1.to_string(),
"0x02e383af0c34516ef38e13391d917d5b61b6f69e17d5234f77cb8cc3a1ae932e".to_string()
);

c.message.transactions[0] = Bytes::from_hex("0x03f9029c01830299f184b2d05e008507aef40a00832dc6c09468d30f47f19c07bccef4ac7fae2dc12fca3e0dc980b90204ef16e845000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000633b68f5d8d3a86593ebb815b4663bcbe0302e31382e302d64657600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004109de8da2a97e37f2e6dc9f7d50a408f9344d7aa1a925ae53daf7fbef43491a571960d76c0cb926190a9da10df7209fb1ba93cd98b1565a3a2368749d505f90c81c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0843b9aca00e1a00141e3a338e30c49ed0501e315bcc45e4edefebed43ab1368a1505461d9cf64901a01e8511e06b17683d89eb57b9869b96b8b611f969f7f56cbc0adc2df7c88a2a07a00910deacf91bba0d74e368d285d311dc5884e7cfe219d85aea5741b2b6e3a2fe").unwrap();

let pd = ConstraintsWithProofData::try_from(c.message).unwrap().proof_data[0];

assert_eq!(
pd.0.to_string(),
"0x15bd881daa1408b33f67fa4bdeb8acfb0a2289d9b4c6f81eef9bb2bb2e52e780".to_string()
);

assert_eq!(
pd.1.to_string(),
"0x0a637924b9f9b28a413b01cb543bcd688850b8964f77576fc71219448f7b4ab9".to_string()
);
}
}
9 changes: 7 additions & 2 deletions bolt-kurtosis-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async fn main() -> Result<()> {
);

info!("Transaction hash: {}", tx_hash);
info!("body: {}", serde_json::to_string(&request)?);
info!("body: {}", trim_zeroes(serde_json::to_string(&request)?));

let client = reqwest::Client::new();
let response = client
Expand All @@ -95,8 +95,13 @@ async fn main() -> Result<()> {
.send()
.await?;

info!("Response: {:?}", response.text().await?);
let res = trim_zeroes(response.text().await?);
info!("Response: {:?}", res);
}

Ok(())
}

fn trim_zeroes(s: impl Into<String>) -> String {
s.into().replace(&"0".repeat(32), ".").replace(&".".repeat(4), "")
}
2 changes: 1 addition & 1 deletion bolt-kurtosis-client/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn generate_random_blob_tx() -> TransactionRequest {
.with_value(U256::from(100))
.with_max_fee_per_blob_gas(100u128)
.max_fee_per_gas(NOICE_GAS_PRICE)
.max_priority_fee_per_gas(NOICE_GAS_PRICE / 10)
.max_priority_fee_per_gas(NOICE_GAS_PRICE)
.with_gas_limit(42_000u128)
.with_blob_sidecar(sidecar)
.with_input(random_bytes)
Expand Down
Loading