Skip to content

Commit

Permalink
fix: client version compiler error (#419)
Browse files Browse the repository at this point in the history
* fix: client version compiler error

* fixes
  • Loading branch information
ncitron authored Oct 31, 2024
1 parent dcda271 commit 0629457
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion core/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl<N: NetworkSpec, C: Consensus<N::TransactionResponse>> Client<N, C> {
self.node.get_block_number().await
}

pub async fn client_version(&self) -> Result<String> {
pub async fn client_version(&self) -> String {
self.node.client_version().await
}

Expand Down
5 changes: 3 additions & 2 deletions core/src/client/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ impl<N: NetworkSpec, C: Consensus<N::TransactionResponse>> Node<N, C> {
self.execution.get_logs(filter).await
}

pub async fn client_version(&self) -> Result<String> {
self.execution.get_client_version().await
pub async fn client_version(&self) -> String {
let helios_version = std::env!("CARGO_PKG_VERSION");
format!("helios-{}", helios_version)
}

pub async fn get_filter_changes(&self, filter_id: U256) -> Result<Vec<Log>> {
Expand Down
2 changes: 1 addition & 1 deletion core/src/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ impl<N: NetworkSpec, C: Consensus<N::TransactionResponse>> NetRpcServer for RpcI
#[async_trait]
impl<N: NetworkSpec, C: Consensus<N::TransactionResponse>> Web3RpcServer for RpcInner<N, C> {
async fn client_version(&self) -> Result<String, ErrorObjectOwned> {
convert_err(self.node.client_version().await)
Ok(self.node.client_version().await)
}
}

Expand Down
5 changes: 0 additions & 5 deletions core/src/execution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,6 @@ impl<N: NetworkSpec, R: ExecutionRpc<N>> ExecutionClient<N, R> {
.await
}

pub async fn get_client_version(&self) -> Result<String> {
let helios_version = std::env!("CARGO_PKG_VERSION");
Ok(format!("helios-{}", helios_version))
}

pub async fn get_transaction_receipt(
&self,
tx_hash: B256,
Expand Down
6 changes: 2 additions & 4 deletions ethereum/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ pub struct ConsensusClient<S: ConsensusSpec, R: ConsensusRpc<S>, DB: Database> {
pub finalized_block_recv: Option<watch::Receiver<Option<Block<Transaction>>>>,
pub checkpoint_recv: watch::Receiver<Option<B256>>,
genesis_time: u64,
db: Arc<DB>,
config: Arc<Config>,
phantom: PhantomData<(S, R)>,
phantom: PhantomData<(S, R, DB)>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -162,7 +161,6 @@ impl<S: ConsensusSpec, R: ConsensusRpc<S>, DB: Database> ConsensusClient<S, R, D
finalized_block_recv: Some(finalized_block_recv),
checkpoint_recv,
genesis_time,
db,
config: config_clone,
phantom: PhantomData,
})
Expand Down Expand Up @@ -699,7 +697,7 @@ mod tests {
use helios_consensus_core::consensus_spec::MainnetConsensusSpec;
use helios_consensus_core::errors::ConsensusError;
use helios_consensus_core::types::bls::{PublicKey, Signature};
use helios_consensus_core::types::{LightClientHeader, Update};
use helios_consensus_core::types::Update;

use crate::{
config::{networks, Config},
Expand Down
2 changes: 1 addition & 1 deletion examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async fn main() -> Result<()> {
client.start().await?;
client.wait_synced().await;

let client_version = client.client_version().await?;
let client_version = client.client_version().await;
let head_block_num = client.get_block_number().await?;
let addr = Address::from_str("0x00000000219ab540356cBB839Cbe05303d7705Fa")?;
let block = BlockTag::Latest;
Expand Down
2 changes: 1 addition & 1 deletion helios-ts/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class HeliosProvider {
return this.#client.get_block_by_number(req.params[0], req.params[1]);
}
case "web3_clientVersion": {
return this.#client.get_client_version();
return this.#client.client_version();
}
default: {
throw `method not implemented: ${req.method}`;
Expand Down
4 changes: 2 additions & 2 deletions helios-ts/src/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl EthereumClient {
}

#[wasm_bindgen]
pub async fn get_client_version(&self) -> Result<String, JsError> {
map_err(self.inner.get_client_version().await)
pub async fn client_version(&self) -> String {
self.inner.client_version().await
}
}
5 changes: 2 additions & 3 deletions helios-ts/src/opstack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ impl OpStackClient {
}

#[wasm_bindgen]
pub async fn get_client_version(&self) -> Result<String, JsError> {
let version = map_err(self.inner.get_client_version().await)?;
Ok(version)
pub async fn client_version(&self) -> String {
self.inner.client_version().await
}
}

0 comments on commit 0629457

Please sign in to comment.