Skip to content

Commit 5444151

Browse files
committed
Update for Capella
1 parent a317b49 commit 5444151

File tree

13 files changed

+66
-29
lines changed

13 files changed

+66
-29
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE beacon_blocks
2+
DROP COLUMN withdrawal_count;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE beacon_blocks
2+
ADD COLUMN withdrawal_count integer;
3+

watch/src/blockprint/server.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@ pub async fn get_blockprint(
2828

2929
pub fn blockprint_routes() -> Router {
3030
Router::new().route("/v1/blocks/:block/blockprint", get(get_blockprint))
31-
//.route("/v1/blockprint/test/:slot", get(get_all_validators))
3231
}

watch/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl Default for Config {
4242
impl Config {
4343
pub fn load_from_file(path_to_file: String) -> Result<Config, String> {
4444
let file =
45-
File::open(&path_to_file).map_err(|e| format!("Error reading config file: {:?}", e))?;
45+
File::open(path_to_file).map_err(|e| format!("Error reading config file: {:?}", e))?;
4646
let config: Config = serde_yaml::from_reader(file)
4747
.map_err(|e| format!("Error parsing config file: {:?}", e))?;
4848
Ok(config)

watch/src/database/mod.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,32 @@ pub fn insert_beacon_block<T: EthSpec>(
138138
let proposer_index = block_message.proposer_index() as i32;
139139
let graffiti = block_message.body().graffiti().as_utf8_lossy();
140140
let attestation_count = block_message.body().attestations().len() as i32;
141-
let transaction_count = block_message
142-
.execution_payload()
143-
.ok()
144-
.map(|payload| payload.execution_payload.transactions.len() as i32);
141+
142+
let full_payload = block_message.execution_payload().ok();
143+
144+
let transaction_count: Option<i32> = if let Some(bellatrix_payload) =
145+
full_payload.and_then(|payload| payload.execution_payload_merge().ok())
146+
{
147+
Some(bellatrix_payload.transactions.len() as i32)
148+
} else {
149+
full_payload
150+
.and_then(|payload| payload.execution_payload_capella().ok())
151+
.map(|payload| payload.transactions.len() as i32)
152+
};
153+
154+
let withdrawal_count: Option<i32> = full_payload
155+
.and_then(|payload| payload.execution_payload_capella().ok())
156+
.map(|payload| payload.withdrawals.len() as i32);
145157

146158
let block_to_add = WatchBeaconBlock {
147159
slot,
148160
root,
149161
parent_root,
150162
attestation_count,
151163
transaction_count,
164+
withdrawal_count,
152165
};
166+
153167
let proposer_info_to_add = WatchProposerInfo {
154168
slot,
155169
proposer_index,

watch/src/database/models.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub struct WatchBeaconBlock {
2525
pub parent_root: WatchHash,
2626
pub attestation_count: i32,
2727
pub transaction_count: Option<i32>,
28+
pub withdrawal_count: Option<i32>,
2829
}
2930

3031
#[derive(Clone, Debug, Queryable, Insertable, Serialize, Deserialize)]

watch/src/database/schema.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ diesel::table! {
1515
parent_root -> Bytea,
1616
attestation_count -> Int4,
1717
transaction_count -> Nullable<Int4>,
18+
withdrawal_count -> Nullable<Int4>,
1819
}
1920
}
2021

watch/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ async fn main() {
2525
}
2626

2727
#[cfg(windows)]
28-
fn main() {}
28+
fn main() {
29+
eprintln!("Windows is not supported. Exiting.");
30+
}

watch/src/server/error.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::database::Error as DbError;
2-
//use warp::{http::Error as HttpError, Error as WarpError};
32
use axum::Error as AxumError;
43
use axum::{http::StatusCode, response::IntoResponse, Json};
54
use hyper::Error as HyperError;

watch/src/server/handler.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,18 @@ pub async fn get_validator_latest_proposal(
207207
let mut conn = database::get_connection(&pool).map_err(Error::Database)?;
208208
if validator_query.starts_with("0x") {
209209
let pubkey = WatchPK::from_str(&validator_query).map_err(|_| Error::BadRequest)?;
210-
let validator = database::get_validator_by_public_key(&mut conn, pubkey)?.ok_or(Error::NotFound)?;
211-
Ok(Json(database::get_validators_latest_proposer_info(&mut conn, vec![validator.index])?))
210+
let validator =
211+
database::get_validator_by_public_key(&mut conn, pubkey)?.ok_or(Error::NotFound)?;
212+
Ok(Json(database::get_validators_latest_proposer_info(
213+
&mut conn,
214+
vec![validator.index],
215+
)?))
212216
} else {
213217
let index = i32::from_str(&validator_query).map_err(|_| Error::BadRequest)?;
214-
Ok(Json(database::get_validators_latest_proposer_info(&mut conn, vec![index])?))
218+
Ok(Json(database::get_validators_latest_proposer_info(
219+
&mut conn,
220+
vec![index],
221+
)?))
215222
}
216223
}
217224

0 commit comments

Comments
 (0)