Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bump fuel-core to 0.22 #52

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ concurrency:

env:
DASEL_VERSION: https://github.com/TomWright/dasel/releases/download/v1.24.3/dasel_linux_amd64
RUST_VERSION: 1.70.0
FUEL_CORE_VERSION: 0.20.4
RUST_VERSION: 1.73.0
FUEL_CORE_VERSION: 0.22.0
IMAGE_NAME: ${{ github.repository }}

jobs:
Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
homepage = "https://fuel.network/"
license = "Apache-2.0"
repository = "https://github.com/FuelLabs/fuel-block-committer"
rust-version = "1.70.0"
rust-version = "1.73.0"
version = "0.1.0"
name = "fuel-block-committer"

Expand All @@ -16,7 +16,7 @@ path = "tests/harness.rs"
[dependencies]
actix-web = "4"
async-trait = "0.1.68"
fuel-core-client = "0.20.4"
fuel-core-client = "0.22.0"
prometheus = "0.13.3"
serde = { version = "1.0", features = ["derive"] }
ethers = { version = "2.0", features = ["ws"] }
Expand All @@ -25,14 +25,15 @@ tokio-util = { version = "0.7.8" }
thiserror = "1.0.40"
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17", features = ["json"] }
clap = { version ="4.3", features =["derive", "env"] }
clap = { version = "4.3", features = ["derive", "env"] }
url = "2.3"
serde_json = "1.0.96"
rusqlite = { version = "0.29", features = ["bundled"] }
rusqlite = { version = "0.30", features = ["bundled"] }
futures = "0.3.28"

[dev-dependencies]
fuels-test-helpers="0.45.1"
#Disabled until the SDK gets a non RC version of fuel-core deps
#fuels-test-helpers = "0.51.0"
rand = "0.8.5"
mockall = "0.11.4"
anyhow = "1.0.71"
4 changes: 2 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ services:
build:
context: fuel_node
args:
fuel_core_version: "v${FUEL_CORE_VERSION:-0.20.4}"
fuel_core_version: "v${FUEL_CORE_VERSION:-0.21.0}"
container_name: fuel-node
environment:
- PORT=4000
- IP=0.0.0.0
- DATABASE_TYPE=in-memory
- MANUAL_BLOCKS_ENABLED=true
- INSTANT=true
- DEBUG=true
# - PERIOD=6s
ports:
- "4000:4000"
Expand Down
2 changes: 1 addition & 1 deletion deployment/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Stage 1: Build
FROM lukemathwalker/cargo-chef:latest-rust-1.70 as chef
FROM lukemathwalker/cargo-chef:latest-rust-1.73 as chef
WORKDIR /build/
# hadolint ignore=DL3008

Expand Down
2 changes: 1 addition & 1 deletion eth_node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine:3.18 AS fetcher
RUN apk add --no-cache git
RUN git clone --no-checkout https://github.com/FuelLabs/fuel-v2-contracts
RUN cd fuel-v2-contracts && git checkout a83444964db35cc1b93ee7a81d5f47d771083966
RUN cd fuel-v2-contracts && git checkout 81b35368764e6f83969e502812e14baa30b20f95
RUN sed 's/\(BLOCKS_PER_COMMIT_INTERVAL\) = 10800/\1 = 3/g' -i fuel-v2-contracts/contracts/fuelchain/FuelChainState.sol
RUN sed 's/\(TIME_TO_FINALIZE\) = 10800/\1 = 1/g' -i fuel-v2-contracts/contracts/fuelchain/FuelChainState.sol

Expand Down
4 changes: 2 additions & 2 deletions fuel-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
channel = "latest-2023-07-05"

[components]
forc = "0.44.0"
fuel-core = "0.20.3"
forc = "0.47.0"
fuel-core = "0.22.0"
22 changes: 11 additions & 11 deletions src/adapters/ethereum_adapter/monitored_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<T> MonitoredEthAdapter<T> {
Ok(_val) => {
self.health_tracker.note_success();
}
Err(Error::NetworkError(..)) => {
Err(Error::Network(..)) => {
self.metrics.eth_network_errors.inc();
self.health_tracker.note_failure();
}
Expand Down Expand Up @@ -101,7 +101,7 @@ impl Default for Metrics {

#[cfg(test)]
mod tests {
use prometheus::Registry;
use prometheus::{proto::Metric, Registry};

use super::*;
use crate::adapters::ethereum_adapter::MockEthereumAdapter;
Expand All @@ -112,7 +112,7 @@ mod tests {
let mut eth_adapter = MockEthereumAdapter::new();
eth_adapter
.expect_submit()
.returning(|_| Err(Error::NetworkError("An error".into())));
.returning(|_| Err(Error::Network("An error".into())));

eth_adapter.expect_get_block_number().returning(|| Ok(10));

Expand Down Expand Up @@ -157,11 +157,11 @@ mod tests {
let mut eth_adapter = MockEthereumAdapter::new();
eth_adapter
.expect_submit()
.returning(|_| Err(Error::NetworkError("An error".into())));
.returning(|_| Err(Error::Network("An error".into())));

eth_adapter
.expect_get_block_number()
.returning(|| Err(Error::NetworkError("An error".into())));
.returning(|| Err(Error::Network("An error".into())));

let adapter = MonitoredEthAdapter::new(eth_adapter, 3);
let health_check = adapter.connection_health_checker();
Expand All @@ -182,11 +182,11 @@ mod tests {
let mut eth_adapter = MockEthereumAdapter::new();
eth_adapter
.expect_submit()
.returning(|_| Err(Error::NetworkError("An error".into())));
.returning(|_| Err(Error::Network("An error".into())));

eth_adapter
.expect_get_block_number()
.returning(|| Err(Error::NetworkError("An error".into())));
.returning(|| Err(Error::Network("An error".into())));

let registry = Registry::new();
let adapter = MonitoredEthAdapter::new(eth_adapter, 3);
Expand All @@ -196,14 +196,14 @@ mod tests {
let _ = adapter.get_block_number().await;

let metrics = registry.gather();
let latest_block_metric = metrics
let eth_network_err_metric = metrics
.iter()
.find(|metric| metric.get_name() == "eth_network_errors")
.and_then(|metric| metric.get_metric().get(0))
.map(|metric| metric.get_counter())
.and_then(|metric| metric.get_metric().first())
.map(Metric::get_counter)
.unwrap();

assert_eq!(latest_block_metric.get_value(), 2f64);
assert_eq!(eth_network_err_metric.get_value(), 2f64);
}

fn given_a_block(block_height: u32) -> FuelBlock {
Expand Down
10 changes: 5 additions & 5 deletions src/adapters/ethereum_adapter/websocket/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl EthereumWs {
) -> Result<Self> {
let provider = Provider::<Ws>::connect(ethereum_rpc.to_string())
.await
.map_err(|e| Error::NetworkError(e.to_string()))?;
.map_err(|e| Error::Network(e.to_string()))?;

let wallet = LocalWallet::from_str(ethereum_wallet_key)?.with_chain_id(chain_id);

Expand Down Expand Up @@ -76,8 +76,8 @@ impl EthereumAdapter for EthereumWs {
.send()
.await
.map_err(|contract_err| match contract_err {
ContractError::ProviderError { e } => Error::NetworkError(e.to_string()),
ContractError::MiddlewareError { e } => Error::NetworkError(e.to_string()),
ContractError::ProviderError { e } => Error::Network(e.to_string()),
ContractError::MiddlewareError { e } => Error::Network(e.to_string()),
_ => Error::Other(contract_err.to_string()),
})?;

Expand All @@ -94,7 +94,7 @@ impl EthereumAdapter for EthereumWs {
self.provider
.request("eth_blockNumber", Value::Array(vec![]))
.await
.map_err(|err| Error::NetworkError(err.to_string()))
.map_err(|err| Error::Network(err.to_string()))
.map(|height: U64| height.as_u64())
}

Expand All @@ -111,7 +111,7 @@ impl EthereumAdapter for EthereumWs {
self.provider
.get_balance(address, None)
.await
.map_err(|err| Error::NetworkError(err.to_string()))
.map_err(|err| Error::Network(err.to_string()))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl EventStreamer for EthEventStreamer {
self.events
.subscribe()
.await
.map_err(|e| Error::NetworkError(e.to_string()))?
.map_err(|e| Error::Network(e.to_string()))?
.map_ok(|event| {
let fuel_block_hash = event.block_hash;
let commit_height = event.commit_height;
Expand Down
109 changes: 56 additions & 53 deletions src/adapters/fuel_adapter/fuel_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl FuelClient {

impl From<FuelGqlBlock> for FuelBlock {
fn from(value: FuelGqlBlock) -> Self {
FuelBlock {
Self {
hash: *value.id,
height: value.header.height,
}
Expand All @@ -57,9 +57,9 @@ impl FuelAdapter for FuelClient {
async fn block_at_height(&self, height: u32) -> Result<Option<FuelBlock>> {
let maybe_block = self
.client
.block_by_height(height as u64)
.block_by_height(height)
.await
.map_err(|e| Error::NetworkError(e.to_string()))?;
.map_err(|e| Error::Network(e.to_string()))?;

Ok(maybe_block.map(Into::into))
}
Expand All @@ -72,64 +72,67 @@ impl FuelAdapter for FuelClient {
}
Err(err) => {
self.handle_network_error();
Err(Error::NetworkError(err.to_string()))
Err(Error::Network(err.to_string()))
}
}
}
}

#[cfg(test)]
mod tests {
use fuels_test_helpers::{setup_test_provider, Config};
use prometheus::Registry;
use prometheus::{proto::Metric, Registry};

use super::*;

#[tokio::test]
async fn can_fetch_latest_block() {
// given
let node_config = Config {
manual_blocks_enabled: true,
..Config::local_node()
};

let (provider, addr) =
setup_test_provider(vec![], vec![], Some(node_config), Some(Default::default())).await;
provider.produce_blocks(5, None).await.unwrap();

let url = Url::parse(&format!("http://{addr}")).unwrap();

let fuel_adapter = FuelClient::new(&url, 1);

// when
let result = fuel_adapter.latest_block().await.unwrap();

// then
assert_eq!(result.height, 5);
}

#[tokio::test]
async fn can_fetch_block_at_height() {
// given
let node_config = Config {
manual_blocks_enabled: true,
..Config::local_node()
};

let (provider, addr) =
setup_test_provider(vec![], vec![], Some(node_config), Some(Default::default())).await;
provider.produce_blocks(5, None).await.unwrap();

let url = Url::parse(&format!("http://{addr}")).unwrap();

let fuel_adapter = FuelClient::new(&url, 1);

// when
let result = fuel_adapter.block_at_height(3).await.unwrap().unwrap();

// then
assert_eq!(result.height, 3);
}
// TODO: Disabled until the SDK is updated with a non rc version of fuel-core. Conflict between
// versions of fuel-types used.
// #[tokio::test]
// async fn can_fetch_latest_block() {
// // given
// let node_config = Config {
// manual_blocks_enabled: true,
// ..Config::local_node()
// };
//
// let (provider, addr) =
// setup_test_provider(vec![], vec![], Some(node_config), Some(Default::default())).await;
// provider.produce_blocks(5, None).await.unwrap();
//
// let url = Url::parse(&format!("http://{addr}")).unwrap();
//
// let fuel_adapter = FuelClient::new(&url, 1);
//
// // when
// let result = fuel_adapter.latest_block().await.unwrap();
//
// // then
// assert_eq!(result.height, 5);
// }

// TODO: Disabled until the SDK is updated with a non rc version of fuel-core. Conflict between
// versions of fuel-types used.
// #[tokio::test]
// async fn can_fetch_block_at_height() {
// // given
// let node_config = Config {
// manual_blocks_enabled: true,
// ..Config::local_node()
// };
//
// let (provider, addr) =
// setup_test_provider(vec![], vec![], Some(node_config), Some(Default::default())).await;
// provider.produce_blocks(5, None).await.unwrap();
//
// let url = Url::parse(&format!("http://{addr}")).unwrap();
//
// let fuel_adapter = FuelClient::new(&url, 1);
//
// // when
// let result = fuel_adapter.block_at_height(3).await.unwrap().unwrap();
//
// // then
// assert_eq!(result.height, 3);
// }

#[tokio::test]
async fn updates_metrics_in_case_of_network_err() {
Expand All @@ -151,8 +154,8 @@ mod tests {
let network_errors_metric = metrics
.iter()
.find(|metric| metric.get_name() == "fuel_network_errors")
.and_then(|metric| metric.get_metric().get(0))
.map(|metric| metric.get_counter())
.and_then(|metric| metric.get_metric().first())
.map(Metric::get_counter)
.unwrap();

assert_eq!(network_errors_metric.get_value(), 1f64);
Expand Down
Loading
Loading