Skip to content

Commit

Permalink
chore: solve upstream conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
merklefruit committed Sep 18, 2024
1 parent ea37421 commit 8f6bf3e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 26 deletions.
12 changes: 0 additions & 12 deletions bolt-sidecar/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ pub struct Opts {
/// URL for the beacon client
#[clap(long, env = "BOLT_SIDECAR_BEACON_API_URL")]
pub(super) beacon_api_url: String,
<<<<<<< HEAD
/// URL for the Constraint sidecar client to use
=======
/// URL for the MEV-Boost sidecar client to use
>>>>>>> b15f3a6 (chore(sidecar): rename to constraints client, remove digest)
#[clap(long, env = "BOLT_SIDECAR_CONSTRAINTS_URL")]
pub(super) constraints_url: String,
/// Execution client API URL
Expand All @@ -50,11 +46,7 @@ pub struct Opts {
/// Execution client Engine API URL
#[clap(long, env = "BOLT_SIDECAR_ENGINE_API_URL")]
pub(super) engine_api_url: String,
<<<<<<< HEAD
/// Constraint proxy server port to use
=======
/// MEV-Boost proxy server port to use
>>>>>>> b15f3a6 (chore(sidecar): rename to constraints client, remove digest)
#[clap(long, env = "BOLT_SIDECAR_CONSTRAINTS_PROXY_PORT")]
pub(super) constraints_proxy_port: u16,
/// Max number of commitments to accept per block
Expand Down Expand Up @@ -140,11 +132,7 @@ impl Default for Config {
fn default() -> Self {
Self {
rpc_port: DEFAULT_RPC_PORT,
<<<<<<< HEAD
constraints_proxy_port: DEFAULT_CONSTRAINTS_PROXY_PORT,
=======
constraints_proxy_port: DEFAULT_MEV_BOOST_PROXY_PORT,
>>>>>>> b15f3a6 (chore(sidecar): rename to constraints client, remove digest)
commit_boost_address: None,
commit_boost_jwt_hex: None,
constraints_url: "http://localhost:3030".parse().expect("Valid URL"),
Expand Down
10 changes: 5 additions & 5 deletions bolt-sidecar/src/crypto/bls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ pub type BLSSig = FixedBytes<96>;
/// Trait for any types that can be signed and verified with BLS.
/// This trait is used to abstract over the signing and verification of different types.
pub trait SignableBLS {
/// Creates SSZ tree hash root of the object.
fn tree_hash_root(&self) -> [u8; 32];
/// Returns the digest of the object.
fn digest(&self) -> [u8; 32];

/// Sign the object with the given key. Returns the signature.
///
/// Note: The default implementation should be used where possible.
#[allow(dead_code)]
fn sign(&self, key: &BlsSecretKey) -> Signature {
sign_with_prefix(key, &self.tree_hash_root())
sign_with_prefix(key, &self.digest())
}

/// Verify the signature of the object with the given public key.
///
/// Note: The default implementation should be used where possible.
fn verify(&self, signature: &Signature, pubkey: &BlsPublicKey) -> bool {
signature.verify(false, &self.tree_hash_root(), BLS_DST_PREFIX, &[], pubkey, true) ==
signature.verify(false, &self.digest(), BLS_DST_PREFIX, &[], pubkey, true) ==
BLST_ERROR::BLST_SUCCESS
}
}
Expand Down Expand Up @@ -120,7 +120,7 @@ mod tests {
rng.fill(&mut data);
let msg = TestSignableData { data };

let signature = SignerBLS::sign(&signer, &msg.tree_hash_root()).await.unwrap();
let signature = SignerBLS::sign(&signer, &msg.digest()).await.unwrap();
let sig = blst::min_pk::Signature::from_bytes(signature.as_ref()).unwrap();
assert!(signer.verify(&msg, &sig, &pubkey));
}
Expand Down
13 changes: 5 additions & 8 deletions bolt-sidecar/src/primitives/constraint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,11 @@ impl ConstraintsMessage {
}

impl SignableBLS for ConstraintsMessage {
fn tree_hash_root(&self) -> [u8; 32] {
let mut hasher = MerkleHasher::with_leaves(self.total_leaves());

hasher
.write(&self.validator_index.to_le_bytes())
.expect("Should write validator index bytes");
hasher.write(&self.slot.to_le_bytes()).expect("Should write slot bytes");
hasher.write(&(self.top as u8).to_le_bytes()).expect("Should write top flag");
fn digest(&self) -> [u8; 32] {
let mut hasher = Sha256::new();
hasher.update(self.validator_index.to_le_bytes());
hasher.update(self.slot.to_le_bytes());
hasher.update((self.top as u8).to_le_bytes());

for constraint in &self.constraints {
hasher.update(constraint.hash());
Expand Down
2 changes: 1 addition & 1 deletion bolt-sidecar/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub(crate) struct TestSignableData {
}

impl SignableBLS for TestSignableData {
fn tree_hash_root(&self) -> [u8; 32] {
fn digest(&self) -> [u8; 32] {
self.data
}
}
Expand Down

0 comments on commit 8f6bf3e

Please sign in to comment.