Skip to content

Commit a02020e

Browse files
authored
chore: better state relay log (#3618)
* relay log & logic * fmt * revert bad relay logic change
1 parent 701b37a commit a02020e

File tree

3 files changed

+30
-39
lines changed

3 files changed

+30
-39
lines changed

sequencer/src/state_signature/relay_server/lcv1_relay.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ pub struct LCV1StateRelayServerState {
3535
/// Bundles for light client V1
3636
bundles: HashMap<u64, HashMap<LightClientState, LCV1StateSignaturesBundle>>,
3737

38-
/// The latest state signatures bundle for legacy light client
38+
/// The latest state signatures bundle for LCV1 light client
3939
latest_available_bundle: Option<LCV1StateSignaturesBundle>,
40-
/// The block height of the latest available legacy state signature bundle
40+
/// The block height of the latest available LCV1 state signature bundle
4141
latest_block_height: Option<u64>,
4242

43-
/// A ordered queue of block heights for legacy light client state, used for garbage collection.
43+
/// A ordered queue of block heights for V1 light client state, used for garbage collection.
4444
gc_queue: BTreeSet<u64>,
4545

4646
/// Stake table tracker
@@ -75,13 +75,10 @@ impl LCV1StateRelayServerDataSource for LCV1StateRelayServerState {
7575
ServerError::catch_all(StatusCode::INTERNAL_SERVER_ERROR, e.to_string())
7676
})?;
7777
let Some(weight) = stake_table.known_nodes.get(&req.key) else {
78-
tracing::warn!(
79-
"Received invalid legacy signature from unknown node: {:?}",
80-
req
81-
);
78+
tracing::warn!("Received LCV1 signature from unknown node: {req}");
8279
return Err(ServerError::catch_all(
8380
StatusCode::UNAUTHORIZED,
84-
"Legacy signature posted by nodes not on the stake table".to_owned(),
81+
"LCV1 signature posted by nodes not on the stake table".to_owned(),
8582
));
8683
};
8784

@@ -91,10 +88,10 @@ impl LCV1StateRelayServerDataSource for LCV1StateRelayServerState {
9188
&req.signature,
9289
&req.state,
9390
) {
94-
tracing::warn!("Received invalid legacy signature: {:?}", req);
91+
tracing::warn!("Couldn't verify the received LCV1 signature: {req}");
9592
return Err(ServerError::catch_all(
9693
StatusCode::BAD_REQUEST,
97-
"The posted legacy signature is not valid.".to_owned(),
94+
"The posted LCV1 signature is not valid.".to_owned(),
9895
));
9996
}
10097

@@ -109,7 +106,7 @@ impl LCV1StateRelayServerDataSource for LCV1StateRelayServerState {
109106
accumulated_weight: U256::from(0),
110107
});
111108
tracing::debug!(
112-
"Accepting new legacy signature for block height {} from {}.",
109+
"Accepting new LCV1 signature for block height {} from {}.",
113110
block_height,
114111
req.key
115112
);
@@ -118,8 +115,8 @@ impl LCV1StateRelayServerDataSource for LCV1StateRelayServerState {
118115
// A signature is already posted for this key with this state
119116
return Err(ServerError::catch_all(
120117
StatusCode::BAD_REQUEST,
121-
"A legacy signature of this light client state is already posted at this \
122-
block height for this key."
118+
"A LCV1 signature of this light client state is already posted at this block \
119+
height for this key."
123120
.to_owned(),
124121
));
125122
},

sequencer/src/state_signature/relay_server/lcv2_relay.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ pub struct LCV2StateRelayServerState {
3535
/// Bundles for light client V2
3636
bundles: HashMap<u64, HashMap<LightClientState, LCV2StateSignaturesBundle>>,
3737

38-
/// The latest state signatures bundle for legacy light client
38+
/// The latest state signatures bundle for LCV2 light client
3939
latest_available_bundle: Option<LCV2StateSignaturesBundle>,
40-
/// The block height of the latest available legacy state signature bundle
40+
/// The block height of the latest available LCV2 state signature bundle
4141
latest_block_height: Option<u64>,
4242

43-
/// A ordered queue of block heights for legacy light client state, used for garbage collection.
43+
/// A ordered queue of block heights for V2 light client state, used for garbage collection.
4444
gc_queue: BTreeSet<u64>,
4545

4646
/// Stake table tracker
@@ -75,13 +75,10 @@ impl LCV2StateRelayServerDataSource for LCV2StateRelayServerState {
7575
ServerError::catch_all(StatusCode::INTERNAL_SERVER_ERROR, e.to_string())
7676
})?;
7777
let Some(weight) = stake_table.known_nodes.get(&req.key) else {
78-
tracing::warn!(
79-
"Received invalid legacy signature from unknown node: {:?}",
80-
req
81-
);
78+
tracing::warn!("Received LCV2 signature from unknown node: {req}");
8279
return Err(ServerError::catch_all(
8380
StatusCode::UNAUTHORIZED,
84-
"Legacy signature posted by nodes not on the stake table".to_owned(),
81+
"LCV2 signature posted by nodes not on the stake table".to_owned(),
8582
));
8683
};
8784

@@ -92,10 +89,10 @@ impl LCV2StateRelayServerDataSource for LCV2StateRelayServerState {
9289
&req.state,
9390
&req.next_stake,
9491
) {
95-
tracing::warn!("Received invalid legacy signature: {:?}", req);
92+
tracing::warn!("Couldn't verify the received LCV2 signature: {req}");
9693
return Err(ServerError::catch_all(
9794
StatusCode::BAD_REQUEST,
98-
"The posted legacy signature is not valid.".to_owned(),
95+
"The posted LCV2 signature is not valid.".to_owned(),
9996
));
10097
}
10198

@@ -111,7 +108,7 @@ impl LCV2StateRelayServerDataSource for LCV2StateRelayServerState {
111108
accumulated_weight: U256::from(0),
112109
});
113110
tracing::debug!(
114-
"Accepting new legacy signature for block height {} from {}.",
111+
"Accepting new LCV2 signature for block height {} from {}.",
115112
block_height,
116113
req.key
117114
);
@@ -120,8 +117,8 @@ impl LCV2StateRelayServerDataSource for LCV2StateRelayServerState {
120117
// A signature is already posted for this key with this state
121118
return Err(ServerError::catch_all(
122119
StatusCode::BAD_REQUEST,
123-
"A legacy signature of this light client state is already posted at this \
124-
block height for this key."
120+
"A LCV2 signature of this light client state is already posted at this block \
121+
height for this key."
125122
.to_owned(),
126123
));
127124
},

sequencer/src/state_signature/relay_server/lcv3_relay.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ pub struct LCV3StateRelayServerState {
3636
/// Bundles for light client V3
3737
bundles: HashMap<u64, HashMap<LightClientState, LCV3StateSignaturesBundle>>,
3838

39-
/// The latest state signatures bundle for legacy light client
39+
/// The latest state signatures bundle for LCV3 light client
4040
latest_available_bundle: Option<LCV3StateSignaturesBundle>,
41-
/// The block height of the latest available legacy state signature bundle
41+
/// The block height of the latest available LCV3 state signature bundle
4242
latest_block_height: Option<u64>,
4343

44-
/// A ordered queue of block heights for legacy light client state, used for garbage collection.
44+
/// A ordered queue of block heights for V3 light client state, used for garbage collection.
4545
gc_queue: BTreeSet<u64>,
4646

4747
/// Stake table tracker
@@ -76,13 +76,10 @@ impl LCV3StateRelayServerDataSource for LCV3StateRelayServerState {
7676
ServerError::catch_all(StatusCode::INTERNAL_SERVER_ERROR, e.to_string())
7777
})?;
7878
let Some(weight) = stake_table.known_nodes.get(&req.key) else {
79-
tracing::warn!(
80-
"Received invalid legacy signature from unknown node: {:?}",
81-
req
82-
);
79+
tracing::warn!("Received LCV3 signature from unknown node: {req}");
8380
return Err(ServerError::catch_all(
8481
StatusCode::UNAUTHORIZED,
85-
"Legacy signature posted by nodes not on the stake table".to_owned(),
82+
"LCV3 signature posted by nodes not on the stake table".to_owned(),
8683
));
8784
};
8885

@@ -94,10 +91,10 @@ impl LCV3StateRelayServerDataSource for LCV3StateRelayServerState {
9491
&req.signature,
9592
signed_state_digest,
9693
) {
97-
tracing::warn!("Received invalid legacy signature: {:?}", req);
94+
tracing::warn!("Couldn't verify the received LCV3 signature: {req}");
9895
return Err(ServerError::catch_all(
9996
StatusCode::BAD_REQUEST,
100-
"The posted legacy signature is not valid.".to_owned(),
97+
"The posted LCV3 signature is not valid.".to_owned(),
10198
));
10299
}
103100

@@ -114,7 +111,7 @@ impl LCV3StateRelayServerDataSource for LCV3StateRelayServerState {
114111
accumulated_weight: U256::from(0),
115112
});
116113
tracing::debug!(
117-
"Accepting new legacy signature for block height {} from {}.",
114+
"Accepting new LCV3 signature for block height {} from {}.",
118115
block_height,
119116
req.key
120117
);
@@ -123,8 +120,8 @@ impl LCV3StateRelayServerDataSource for LCV3StateRelayServerState {
123120
// A signature is already posted for this key with this state
124121
return Err(ServerError::catch_all(
125122
StatusCode::BAD_REQUEST,
126-
"A legacy signature of this light client state is already posted at this \
127-
block height for this key."
123+
"A LCV3 signature of this light client state is already posted at this block \
124+
height for this key."
128125
.to_owned(),
129126
));
130127
},

0 commit comments

Comments
 (0)