Skip to content

Commit bbb260b

Browse files
committed
fix tests
1 parent dc26eb3 commit bbb260b

15 files changed

Lines changed: 93 additions & 302 deletions

crates/common/src/config/mux.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use alloy::{
1414
};
1515
use eyre::{bail, ensure, Context};
1616
use reqwest::Client;
17-
use serde::{Deserialize, Serialize};
17+
use serde::{Deserialize, Deserializer, Serialize};
1818
use tracing::{debug, info, warn};
1919
use url::Url;
2020

@@ -393,12 +393,29 @@ struct SSVResponse {
393393
pagination: SSVPagination,
394394
}
395395

396-
#[derive(Deserialize)]
397396
struct SSVValidator {
398-
#[serde(rename = "public_key")]
399397
pubkey: BlsPublicKey,
400398
}
401399

400+
impl<'de> Deserialize<'de> for SSVValidator {
401+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
402+
where
403+
D: Deserializer<'de>,
404+
{
405+
#[derive(Deserialize)]
406+
struct SSVValidator {
407+
public_key: String,
408+
}
409+
410+
let s = SSVValidator::deserialize(deserializer)?;
411+
let bytes = alloy::hex::decode(&s.public_key).map_err(serde::de::Error::custom)?;
412+
let pubkey = BlsPublicKey::deserialize(&bytes)
413+
.map_err(|e| serde::de::Error::custom(format!("invalid BLS public key: {e:?}")))?;
414+
415+
Ok(Self { pubkey })
416+
}
417+
}
418+
402419
#[derive(Deserialize)]
403420
struct SSVPagination {
404421
total: usize,

crates/common/src/pbs/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub enum ValidationError {
6363
#[error("block hash mismatch: expected {expected} got {got}")]
6464
BlockHashMismatch { expected: B256, got: B256 },
6565

66-
#[error("mismatch in KZG commitments: exepcted_blobs: {expected_blobs} got_blobs: {got_blobs} got_commitments: {got_commitments} got_proofs: {got_proofs}")]
66+
#[error("mismatch in KZG commitments: expected_blobs: {expected_blobs} got_blobs: {got_blobs} got_commitments: {got_commitments} got_proofs: {got_proofs}")]
6767
KzgCommitments {
6868
expected_blobs: usize,
6969
got_blobs: usize,

crates/common/src/pbs/types/beacon_block.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ mod tests {
165165
assert!(matches!(block_json.message, BlindedBeaconBlock::Electra(_)));
166166

167167
let data_ssz = include_bytes!("testdata/signed-blinded-beacon-block-electra-2.ssz");
168-
let data_ssz = alloy::primitives::hex::decode(data_ssz).unwrap();
169-
let block_ssz = test_encode_decode_ssz::<SignedBlindedBeaconBlock>(&data_ssz);
168+
let block_ssz = test_encode_decode_ssz::<SignedBlindedBeaconBlock>(data_ssz);
170169
assert!(matches!(block_ssz.message, BlindedBeaconBlock::Electra(_)));
171170

172171
assert_eq!(block_json.as_ssz_bytes(), data_ssz);

crates/common/src/pbs/types/get_header.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ mod tests {
104104
};
105105

106106
#[test]
107-
// from the builder api spec, the signature is a dummy so it's not checked
107+
// from the builder api spec, with signature fixed to the correct pubkey
108108
fn test_get_header_electra() {
109109
let data = r#"{
110110
"version": "electra",
@@ -135,32 +135,32 @@ mod tests {
135135
"execution_requests": {
136136
"deposits": [
137137
{
138-
"pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a",
138+
"pubkey": "0x911f24ad11078aad2b28ff9dcb4651a0b686e3972b2b4190273f35d416bf057dbd95553d7a0edb107b1a5e1b211da8c4",
139139
"withdrawal_credentials": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
140140
"amount": "1",
141-
"signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505",
141+
"signature": "0xb4f92cd90de8e4b67debeb0379f08d0e6d3046e67e824e6ed63cd841abc9999c8b123a780e34a480d4ef13466b6241e30000b047d27de43fcf475fc4e69da2d26929cec97742892346f53e78f973bbe8095285f05a8ea60b118cdd1e6a704c94",
142142
"index": "1"
143143
}
144144
],
145145
"withdrawals": [
146146
{
147147
"source_address": "0xabcf8e0d4e9587369b2301d0790347320302cc09",
148-
"validator_pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a",
148+
"validator_pubkey": "0x911f24ad11078aad2b28ff9dcb4651a0b686e3972b2b4190273f35d416bf057dbd95553d7a0edb107b1a5e1b211da8c4",
149149
"amount": "1"
150150
}
151151
],
152152
"consolidations": [
153153
{
154154
"source_address": "0xabcf8e0d4e9587369b2301d0790347320302cc09",
155-
"source_pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a",
156-
"target_pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a"
155+
"source_pubkey": "0x911f24ad11078aad2b28ff9dcb4651a0b686e3972b2b4190273f35d416bf057dbd95553d7a0edb107b1a5e1b211da8c4",
156+
"target_pubkey": "0x911f24ad11078aad2b28ff9dcb4651a0b686e3972b2b4190273f35d416bf057dbd95553d7a0edb107b1a5e1b211da8c4"
157157
}
158158
]
159159
},
160160
"value": "1",
161-
"pubkey": "0x86b1cea87eed94cad99244356abcd83995947670f0553a1d3fe83c4a9e8116f4891fb1c51db232e736be1cb3327164bc"
161+
"pubkey": "0xac0a230bd98a766b8e4156f0626ee679dd280dee5b0eedc2b9455ca3dacc4c7618da5010b9db609450a712f095c9f7a5"
162162
},
163-
"signature": "0x8addecd35e0ffe27b74e41aff2836527e6fea0efdb46dbb0f7436f5087d0cd5665bd16d924f640fc928cdba0173971e400dc603dbd6310bfb6f249c1554b044fe06ae4cf5d5f452f3ff19d9d130809b34d3d3abdca3d192c839ba2ac91129c15"
163+
"signature": "0x8aeb4642fb2982039a43fd6a6d9cc0ebf7598dbf02343c4617d9a68d799393c162492add63f31099a25eacc2782ba27a190e977a8c58760b6636dccb503d528b3be9e885c93d5b79699e68fcca870b0c790cdb00d67604d8b4a3025ae75efa2f"
164164
}
165165
}"#;
166166

@@ -187,9 +187,8 @@ mod tests {
187187
>(&data_json);
188188

189189
let data_ssz = include_bytes!("testdata/get-header-response.ssz");
190-
let data_ssz = alloy::primitives::hex::decode(data_ssz).unwrap();
191190
test_encode_decode_ssz::<SignedExecutionPayloadHeader<ExecutionPayloadHeaderMessageElectra>>(
192-
&data_ssz,
191+
data_ssz,
193192
);
194193

195194
assert_eq!(block_json.as_ssz_bytes(), data_ssz);

crates/common/src/pbs/types/testdata/get-header-response.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,30 @@
2525
"execution_requests": {
2626
"deposits": [
2727
{
28-
"pubkey": "0x0e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
28+
"pubkey": "0xac0a230bd98a766b8e4156f0626ee679dd280dee5b0eedc2b9455ca3dacc4c7618da5010b9db609450a712f095c9f7a5",
2929
"withdrawal_credentials": "0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f",
3030
"amount": "100",
31-
"signature": "0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
31+
"signature": "0x8aeb4642fb2982039a43fd6a6d9cc0ebf7598dbf02343c4617d9a68d799393c162492add63f31099a25eacc2782ba27a190e977a8c58760b6636dccb503d528b3be9e885c93d5b79699e68fcca870b0c790cdb00d67604d8b4a3025ae75efa2f",
3232
"index": "1"
3333
}
3434
],
3535
"withdrawals": [
3636
{
3737
"source_address": "0x1100000000000000000000000000000000000000",
38-
"validator_pubkey": "0x120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
38+
"validator_pubkey": "0xac0a230bd98a766b8e4156f0626ee679dd280dee5b0eedc2b9455ca3dacc4c7618da5010b9db609450a712f095c9f7a5",
3939
"amount": "1"
4040
}
4141
],
4242
"consolidations": [
4343
{
4444
"source_address": "0x1200000000000000000000000000000000000000",
45-
"source_pubkey": "0x120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
46-
"target_pubkey": "0x110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
45+
"source_pubkey": "0xac0a230bd98a766b8e4156f0626ee679dd280dee5b0eedc2b9455ca3dacc4c7618da5010b9db609450a712f095c9f7a5",
46+
"target_pubkey": "0xac0a230bd98a766b8e4156f0626ee679dd280dee5b0eedc2b9455ca3dacc4c7618da5010b9db609450a712f095c9f7a5"
4747
}
4848
]
4949
},
5050
"value": "11",
51-
"pubkey": "0x120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
51+
"pubkey": "0xac0a230bd98a766b8e4156f0626ee679dd280dee5b0eedc2b9455ca3dacc4c7618da5010b9db609450a712f095c9f7a5"
5252
},
53-
"signature": "0x010203040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
53+
"signature": "0x8aeb4642fb2982039a43fd6a6d9cc0ebf7598dbf02343c4617d9a68d799393c162492add63f31099a25eacc2782ba27a190e977a8c58760b6636dccb503d528b3be9e885c93d5b79699e68fcca870b0c790cdb00d67604d8b4a3025ae75efa2f"
5454
}
-1.2 KB
Binary file not shown.

crates/common/src/pbs/types/testdata/signed-blinded-beacon-block-electra-2.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"root": "0x0200000000000000000000000000000000000000000000000000000000000000"
1919
}
2020
},
21-
"signature": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
21+
"signature": "0x8aeb4642fb2982039a43fd6a6d9cc0ebf7598dbf02343c4617d9a68d799393c162492add63f31099a25eacc2782ba27a190e977a8c58760b6636dccb503d528b3be9e885c93d5b79699e68fcca870b0c790cdb00d67604d8b4a3025ae75efa2f"
2222
}
2323
],
2424
"attester_slashings": [
@@ -42,7 +42,7 @@
4242
"root": "0x0100000000000000000000000000000000000000000000000000000000000000"
4343
}
4444
},
45-
"signature": "0x8c3095fd9d3a18e43ceeb7648281e16b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
45+
"signature": "0x8aeb4642fb2982039a43fd6a6d9cc0ebf7598dbf02343c4617d9a68d799393c162492add63f31099a25eacc2782ba27a190e977a8c58760b6636dccb503d528b3be9e885c93d5b79699e68fcca870b0c790cdb00d67604d8b4a3025ae75efa2f"
4646
},
4747
"attestation_2": {
4848
"attesting_indices": [
@@ -63,7 +63,7 @@
6363
"root": "0x0200000000000000000000000000000000000000000000000000000000000000"
6464
}
6565
},
66-
"signature": "0x8c3095fd9d3a18e43ceeb7648281e16b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
66+
"signature": "0x8aeb4642fb2982039a43fd6a6d9cc0ebf7598dbf02343c4617d9a68d799393c162492add63f31099a25eacc2782ba27a190e977a8c58760b6636dccb503d528b3be9e885c93d5b79699e68fcca870b0c790cdb00d67604d8b4a3025ae75efa2f"
6767
}
6868
}
6969
],
@@ -73,19 +73,19 @@
7373
"bls_to_execution_changes": [
7474
{
7575
"message": {
76-
"from_bls_pubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
76+
"from_bls_pubkey": "0xac0a230bd98a766b8e4156f0626ee679dd280dee5b0eedc2b9455ca3dacc4c7618da5010b9db609450a712f095c9f7a5",
7777
"to_execution_address": "0x0000000000000000000000000000000000000000",
7878
"validator_index": "1"
7979
},
80-
"signature": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
80+
"signature": "0x8aeb4642fb2982039a43fd6a6d9cc0ebf7598dbf02343c4617d9a68d799393c162492add63f31099a25eacc2782ba27a190e977a8c58760b6636dccb503d528b3be9e885c93d5b79699e68fcca870b0c790cdb00d67604d8b4a3025ae75efa2f"
8181
}
8282
],
8383
"deposits": [
8484
{
8585
"data": {
8686
"amount": "1",
87-
"pubkey": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2000000000000000000000000000000000",
88-
"signature": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
87+
"pubkey": "0xac0a230bd98a766b8e4156f0626ee679dd280dee5b0eedc2b9455ca3dacc4c7618da5010b9db609450a712f095c9f7a5",
88+
"signature": "0x8aeb4642fb2982039a43fd6a6d9cc0ebf7598dbf02343c4617d9a68d799393c162492add63f31099a25eacc2782ba27a190e977a8c58760b6636dccb503d528b3be9e885c93d5b79699e68fcca870b0c790cdb00d67604d8b4a3025ae75efa2f",
8989
"withdrawal_credentials": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20"
9090
},
9191
"proof": [
@@ -153,24 +153,24 @@
153153
"consolidations": [
154154
{
155155
"source_address": "0x0100000000000000000000000000000000000000",
156-
"source_pubkey": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2000000000000000000000000000000000",
157-
"target_pubkey": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2000000000000000000000000000000000"
156+
"source_pubkey": "0xac0a230bd98a766b8e4156f0626ee679dd280dee5b0eedc2b9455ca3dacc4c7618da5010b9db609450a712f095c9f7a5",
157+
"target_pubkey": "0xac0a230bd98a766b8e4156f0626ee679dd280dee5b0eedc2b9455ca3dacc4c7618da5010b9db609450a712f095c9f7a5"
158158
}
159159
],
160160
"deposits": [
161161
{
162162
"amount": "32000000000",
163163
"index": "0",
164-
"pubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
165-
"signature": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
164+
"pubkey": "0xac0a230bd98a766b8e4156f0626ee679dd280dee5b0eedc2b9455ca3dacc4c7618da5010b9db609450a712f095c9f7a5",
165+
"signature": "0x8aeb4642fb2982039a43fd6a6d9cc0ebf7598dbf02343c4617d9a68d799393c162492add63f31099a25eacc2782ba27a190e977a8c58760b6636dccb503d528b3be9e885c93d5b79699e68fcca870b0c790cdb00d67604d8b4a3025ae75efa2f",
166166
"withdrawal_credentials": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20"
167167
}
168168
],
169169
"withdrawals": [
170170
{
171171
"amount": "0",
172172
"source_address": "0x0100000000000000000000000000000000000000",
173-
"validator_pubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
173+
"validator_pubkey": "0xac0a230bd98a766b8e4156f0626ee679dd280dee5b0eedc2b9455ca3dacc4c7618da5010b9db609450a712f095c9f7a5"
174174
}
175175
]
176176
},
@@ -185,7 +185,7 @@
185185
"slot": "123",
186186
"state_root": "0x0000000000000000000000000000000000000000000000000000000000000000"
187187
},
188-
"signature": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
188+
"signature": "0x8aeb4642fb2982039a43fd6a6d9cc0ebf7598dbf02343c4617d9a68d799393c162492add63f31099a25eacc2782ba27a190e977a8c58760b6636dccb503d528b3be9e885c93d5b79699e68fcca870b0c790cdb00d67604d8b4a3025ae75efa2f"
189189
},
190190
"signed_header_2": {
191191
"message": {
@@ -195,11 +195,11 @@
195195
"slot": "123",
196196
"state_root": "0x0000000000000000000000000000000000000000000000000000000000000000"
197197
},
198-
"signature": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
198+
"signature": "0x8aeb4642fb2982039a43fd6a6d9cc0ebf7598dbf02343c4617d9a68d799393c162492add63f31099a25eacc2782ba27a190e977a8c58760b6636dccb503d528b3be9e885c93d5b79699e68fcca870b0c790cdb00d67604d8b4a3025ae75efa2f"
199199
}
200200
}
201201
],
202-
"randao_reveal": "0xa7a74e03d8ef909abc75b9452d167e150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
202+
"randao_reveal": "0x8aeb4642fb2982039a43fd6a6d9cc0ebf7598dbf02343c4617d9a68d799393c162492add63f31099a25eacc2782ba27a190e977a8c58760b6636dccb503d528b3be9e885c93d5b79699e68fcca870b0c790cdb00d67604d8b4a3025ae75efa2f",
203203
"sync_aggregate": {
204204
"sync_committee_bits": "0xff98b62322edaa4d9198b62322edaa4d9198b62322edaa4d91ff98b62322edaa4d9198b62322edaa4d9198b62322edaa4d912322edaa4d9198b62322edaa4d91",
205205
"sync_committee_signature": "0x8c3095fd9d3a18e43ceeb7648281e16b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
@@ -210,7 +210,7 @@
210210
"epoch": "123",
211211
"validator_index": "0"
212212
},
213-
"signature": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
213+
"signature": "0x8aeb4642fb2982039a43fd6a6d9cc0ebf7598dbf02343c4617d9a68d799393c162492add63f31099a25eacc2782ba27a190e977a8c58760b6636dccb503d528b3be9e885c93d5b79699e68fcca870b0c790cdb00d67604d8b4a3025ae75efa2f"
214214
}
215215
]
216216
},
@@ -219,5 +219,5 @@
219219
"slot": "252288",
220220
"state_root": "0x4c033e0b4a34c0eb8e0caba126fae3ed303a83254fe39f8daaa673125f4042cc"
221221
},
222-
"signature": "0x8c3095fd9d3a18e43ceeb7648281e16b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
222+
"signature": "0x8aeb4642fb2982039a43fd6a6d9cc0ebf7598dbf02343c4617d9a68d799393c162492add63f31099a25eacc2782ba27a190e977a8c58760b6636dccb503d528b3be9e885c93d5b79699e68fcca870b0c790cdb00d67604d8b4a3025ae75efa2f"
223223
}
Binary file not shown.

0 commit comments

Comments
 (0)