mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 02:12:33 +00:00
Append client version info to graffiti (#7558)
* #7201 Co-Authored-By: Tan Chee Keong <tanck@sigmaprime.io> Co-Authored-By: chonghe <44791194+chong-he@users.noreply.github.com> Co-Authored-By: Jimmy Chen <jimmy@sigmaprime.io> Co-Authored-By: Tan Chee Keong <tanck2005@gmail.com>
This commit is contained in:
@@ -3681,7 +3681,7 @@ impl ApiTester {
|
||||
|
||||
let (response, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3_ssz::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3_ssz::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -4646,7 +4646,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -4673,7 +4673,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, Some(0))
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, Some(0), None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -4701,7 +4701,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, Some(u64::MAX))
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, Some(u64::MAX), None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -4858,7 +4858,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -4939,7 +4939,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -5034,7 +5034,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -5125,7 +5125,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -5216,7 +5216,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -5305,7 +5305,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -5366,7 +5366,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -5437,7 +5437,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -5552,7 +5552,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(next_slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(next_slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -5573,7 +5573,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(next_slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(next_slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -5708,7 +5708,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(next_slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(next_slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -5739,7 +5739,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(next_slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(next_slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -5821,7 +5821,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -5895,7 +5895,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -5964,7 +5964,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -6033,7 +6033,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -6100,7 +6100,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -6174,7 +6174,7 @@ impl ApiTester {
|
||||
|
||||
let (payload_type, metadata) = self
|
||||
.client
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None)
|
||||
.get_validator_blocks_v3::<E>(slot, &randao_reveal, None, None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
Self::check_block_v3_metadata(&metadata, &payload_type);
|
||||
@@ -6864,6 +6864,82 @@ impl ApiTester {
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
async fn get_validator_blocks_v3_path_graffiti_policy(self) -> Self {
|
||||
let slot = self.chain.slot().unwrap();
|
||||
let epoch = self.chain.epoch().unwrap();
|
||||
let (_, randao_reveal) = self.get_test_randao(slot, epoch).await;
|
||||
let graffiti = Some(Graffiti::from([0; GRAFFITI_BYTES_LEN]));
|
||||
let builder_boost_factor = None;
|
||||
|
||||
// Default case where GraffitiPolicy is None
|
||||
let default_path = self
|
||||
.client
|
||||
.get_validator_blocks_v3_path(
|
||||
slot,
|
||||
&randao_reveal,
|
||||
graffiti.as_ref(),
|
||||
SkipRandaoVerification::Yes,
|
||||
builder_boost_factor,
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let query_default_path = default_path.query().unwrap_or("");
|
||||
// When GraffitiPolicy is None, the HTTP API query path should not contain "graffiti_policy"
|
||||
assert!(
|
||||
!query_default_path.contains("graffiti_policy"),
|
||||
"URL should not contain graffiti_policy parameter (same as PreserveUserGraffiti). URL is: {}",
|
||||
query_default_path
|
||||
);
|
||||
|
||||
let preserve_path = self
|
||||
.client
|
||||
.get_validator_blocks_v3_path(
|
||||
slot,
|
||||
&randao_reveal,
|
||||
graffiti.as_ref(),
|
||||
SkipRandaoVerification::Yes,
|
||||
builder_boost_factor,
|
||||
Some(GraffitiPolicy::PreserveUserGraffiti),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let query_preserve_path = preserve_path.query().unwrap_or("");
|
||||
// When GraffitiPolicy is set to PreserveUserGraffiti, the HTTP API query path should not contain "graffiti_policy"
|
||||
assert!(
|
||||
!query_preserve_path.contains("graffiti_policy"),
|
||||
"URL should not contain graffiti_policy parameter when using PreserveUserGraffiti. URL is: {}",
|
||||
query_preserve_path
|
||||
);
|
||||
|
||||
// The HTTP API query path for PreserveUserGraffiti should be the same as the default
|
||||
assert_eq!(query_default_path, query_preserve_path);
|
||||
|
||||
let append_path = self
|
||||
.client
|
||||
.get_validator_blocks_v3_path(
|
||||
slot,
|
||||
&randao_reveal,
|
||||
graffiti.as_ref(),
|
||||
SkipRandaoVerification::No,
|
||||
builder_boost_factor,
|
||||
Some(GraffitiPolicy::AppendClientVersions),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let query_append_path = append_path.query().unwrap_or("");
|
||||
// When GraffitiPolicy is AppendClientVersions, the HTTP API query path should contain "graffiti_policy"
|
||||
assert!(
|
||||
query_append_path.contains("graffiti_policy"),
|
||||
"URL should contain graffiti_policy=AppendClientVersions parameter. URL is: {}",
|
||||
query_append_path
|
||||
);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
async fn poll_events<S: Stream<Item = Result<EventKind<E>, eth2::Error>> + Unpin, E: EthSpec>(
|
||||
@@ -8054,3 +8130,11 @@ async fn get_beacon_rewards_blocks_electra() {
|
||||
.test_beacon_block_rewards_electra()
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn get_validator_blocks_v3_http_api_path() {
|
||||
ApiTester::new()
|
||||
.await
|
||||
.get_validator_blocks_v3_path_graffiti_policy()
|
||||
.await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user