Skip to content
Draft
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
2 changes: 2 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[profile.default]
retries = { backoff = "exponential", count = 3, delay = "5s" }
21 changes: 9 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
override: true
- uses: taiki-e/install-action@nextest
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
Expand All @@ -53,12 +54,12 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --release --tests
args: --verbose --tests
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --verbose --release
command: nextest
args: run --verbose

test_coverage:
name: Code coverage in tests
Expand All @@ -69,16 +70,12 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
override: true
- name: Install cargo-binstall
uses: cargo-bins/[email protected]
- name: Install cargo-tarpaulin
uses: actions-rs/cargo@v1
with:
command: binstall
args: cargo-tarpaulin --no-confirm
components: llvm-tools-preview
- uses: taiki-e/install-action@cargo-llvm-cov
- uses: taiki-e/install-action@nextest
- name: Generate code coverage
run: |
cargo tarpaulin --avoid-cfg-tarpaulin --timeout=360 --out lcov --exclude-files 'bindings/**/*.*' --exclude-files 'ergo-rest/src/reqwest.rs' --exclude-files 'ergo-rest/src/reqwest/**/*.*' --exclude-files 'ergo-rest/src/wasm_timer.rs' --exclude-files 'ergo-rest/src/wasm_timer/**/*.*'
cargo llvm-cov --lcov --output-path lcov.info --ignore-filename-regex "bindings/.*|ergo-rest/src/reqwest.*|ergo-rest/src/wasm_timer.*" nextest
- name: Push code coverage results to coveralls.io
uses: coverallsapp/github-action@master
with:
Expand Down Expand Up @@ -238,7 +235,7 @@ jobs:

- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2025-03-28
toolchain: nightly-2025-11-10
override: true

- name: install deps
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ num-bigint = { version = "0.4.0", default-features = false }
lazy_static = { version = "1.4", features = ["spin_no_std"] }
bs58 = { version = "0.4.0", default-features = false, features = ["alloc"] }
base16 = { version = "0.2.1", default-features = false, features = ["alloc"] }
base64 = { version = "0.13.0", default-features = false, features = ["alloc"] }
base64 = { version = "0.22.1", default-features = false, features = ["alloc"] }
indexmap = { version = "2.6.0", default-features = false }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = { version = "1.0", default-features = false, features = [
Expand All @@ -82,15 +82,15 @@ serde_with = { version = "3.11.0", default-features = false, features = [
rand = "0.8.5"
bytes = { version = "1.1", default-features = false }
futures = "0.3"
tokio = { version = "1.15.0", features = ["full"] }
tokio = { version = "1.15.0", default-features = false, features = ["rt", "rt-multi-thread"] }
tokio-stream = { version = "0.1.8", features = ["sync", "time"] }
tokio-util = { version = "0.6.9", features = ["codec"] }
tokio-util = { version = "0.7.17", features = ["codec"] }
bounded-integer = { version = "^0.5", features = ["types"] }
url = "2.5.4"
getrandom = { version = "0.2.16" }
itertools = { version = "0.10.3", default-features = false }
miette = { version = "5", features = ["fancy"] }
hashbrown = { version = "0.14.3", features = ["serde"] }
miette = { version = "7.6.0", features = ["fancy"] }
hashbrown = { version = "0.16.1", features = ["serde"] }
core2 = { version = "0.4.0", default-features = false, features = ["alloc"] }
# dev-dependencies
proptest = { version = "=1.6.0", default-features = false, features = [
Expand Down
4 changes: 2 additions & 2 deletions bindings/ergo-lib-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ name = "ergo_lib_python"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.24.2", features = ["indexmap"] }
pyo3 = { version = "0.27.1", features = ["indexmap"] }
base16 = { workspace = true }
derive_more = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
ergo-lib = { workspace = true, features = ["mnemonic_gen"] }
sigma-ser = { workspace = true }
serde-pyobject = "0.6.1"
serde-pyobject = "0.8.0"
8 changes: 4 additions & 4 deletions bindings/ergo-lib-python/src/chain/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl SType {
tpes.bind(py)
.iter()
.map(|tpe| -> PyResult<stype::SType> {
tpe.downcast::<SType>()?.get().to_stype(py)
tpe.cast::<SType>()?.get().to_stype(py)
})
.collect::<PyResult<Vec<_>>>()?,
)
Expand Down Expand Up @@ -145,9 +145,9 @@ impl SType {
.iter()
.zip(t2.bind(py).iter())
.map(|(t1, t2)| -> PyResult<bool> {
t1.downcast_into::<SType>()?
t1.cast_into::<SType>()?
.get()
.__eq__(t2.downcast_into::<SType>()?.get(), py)
.__eq__(t2.cast_into::<SType>()?.get(), py)
})
.reduce(|res1, res2| res1.and_then(|res1| res2.map(|res2| res1 == res2)))
.transpose()?
Expand All @@ -174,7 +174,7 @@ impl Constant {
if let Ok(bytes) = arg.extract::<&[u8]>() {
return Ok(Self(constant::Constant::from(bytes.to_owned())));
}
if let Ok(tuple) = arg.downcast_exact::<PyTuple>() {
if let Ok(tuple) = arg.cast_exact::<PyTuple>() {
return from_tuple(tuple);
}
if let Ok(arr) = arg.extract::<Vec<Constant>>() {
Expand Down
2 changes: 1 addition & 1 deletion bindings/ergo-lib-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub(crate) fn to_value_error<E: std::error::Error>(e: E) -> PyErr {
}

pub(crate) fn from_json<T: DeserializeOwned>(json: Bound<'_, PyAny>) -> PyResult<T> {
let res = match json.downcast_into::<PyDict>() {
let res = match json.cast_into::<PyDict>() {
Ok(dict) => from_pyobject::<T, PyDict>(dict).map_err(to_value_error)?,
Err(json) => {
serde_json::from_str(json.into_inner().extract::<&str>()?).map_err(JsonError::from)?
Expand Down
2 changes: 1 addition & 1 deletion bindings/ergo-lib-wasm/src/ast/js_conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub(crate) fn constant_from_js(val: &JsValue) -> Result<Constant, ConvError> {
} else if let Ok(coll_longs) = coll_long_from_js(&arr) {
Ok(coll_longs)
} else {
return Err(ConvError::NotSupported(val.clone()));
Err(ConvError::NotSupported(val.clone()))
}
} else {
// regular array
Expand Down
3 changes: 2 additions & 1 deletion ergo-chain-types/src/digest32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use alloc::boxed::Box;
use alloc::string::String;
use alloc::vec::Vec;
use base64::Engine;
use core::array::TryFromSliceError;
use core::convert::TryFrom;
use core::convert::TryInto;
Expand Down Expand Up @@ -46,7 +47,7 @@ impl<const N: usize> Digest<N> {

/// Parse `Digest<N>` from base64 encoded string
pub fn from_base64(s: &str) -> Result<Digest<N>, DigestNError> {
let bytes = base64::decode(s)?;
let bytes = base64::engine::general_purpose::STANDARD.decode(s)?;
let arr: [u8; N] = bytes.as_slice().try_into()?;
Ok(Digest(arr))
}
Expand Down
2 changes: 1 addition & 1 deletion ergo-lib/src/chain/transaction/ergo_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub trait ErgoTransaction: ContextExtensionProvider {
fn outputs(&self) -> &[ErgoBox];

/// Stateless transaction validation (no blockchain context) for a transaction
/// Returns [`Ok(())`] if validation has succeeded or returns [`TxValidationError`]
/// Returns [Ok(())] if validation has succeeded or returns [`TxValidationError`]
fn validate_stateless(&self) -> Result<(), TxValidationError> {
// Note that we don't need to check if inputs/data inputs/outputs are >= 1 <= 32767 here since BoundedVec takes care of that
let inputs = self.inputs_ids();
Expand Down
2 changes: 1 addition & 1 deletion ergo-p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tracing-error = { version = "0.2.0", features = ["traced-error"] }
tokio = { workspace = true }
tokio-stream = { workspace = true }
tokio-util = { workspace = true }
tower = { version = "0.4.11", features = ["retry", "discover", "load", "load-shed", "timeout", "util", "buffer"] }
tower = { version = "0.5.2", features = ["retry", "discover", "load", "load-shed", "timeout", "util", "buffer"] }
bytes = { workspace = true }
chrono = "0.4.19"
proptest = { workspace = true , optional = true }
Expand Down
1 change: 1 addition & 0 deletions ergo-p2p/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::message::Request;

/// Encoder/Decoder for network messages from/to bytes
#[derive(Default)]
#[allow(dead_code)]
pub struct Codec {}

impl Encoder<Request> for Codec {
Expand Down
1 change: 1 addition & 0 deletions ergo-p2p/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::time::Duration;

/// The timeout for handshakes when connecting to new peers.
#[allow(dead_code)]
pub const HANDSHAKE_TIMEOUT: Duration = Duration::from_secs(4);
2 changes: 2 additions & 0 deletions ergo-p2p/src/peer_connection_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use crate::PeerInfo;

/// A service that handshakes with a remote peer and constructs a client/server pair.
#[derive(Clone)]
#[allow(dead_code)]
pub struct PeerConnectionHandler {}

impl Service<HandshakeRequest> for PeerConnectionHandler {
Expand Down Expand Up @@ -89,6 +90,7 @@ pub struct ConnectionId {
direction: ConnectionDirection,
}
impl ConnectionId {
#[allow(dead_code)]
pub(crate) fn new_outbound_direct(_addr: PeerAddr) -> Self {
todo!()
}
Expand Down
2 changes: 2 additions & 0 deletions ergo-p2p/src/peer_connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ use crate::peer_connection_handler::PeerConnectionHandler;
use crate::Client;

/// Opens a TCP connection before forwarding to the inner peer connection handling service for a handshake.
#[allow(dead_code)]
pub struct PeerConnector {
handshaker: PeerConnectionHandler,
}

/// A connector request.
/// Contains the information needed to make an outbound connection to the peer.
#[allow(dead_code)]
pub struct OutboundConnectorRequest {
/// The listener address of the peer.
pub addr: PeerAddr,
Expand Down
20 changes: 1 addition & 19 deletions ergo-rest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,18 @@ crate-type = ["cdylib", "rlib"]
async-trait = "^0.1"
bounded-integer = { workspace = true }
bounded-vec = { workspace = true, features=["serde"] }
sigma-ser = { workspace = true }
sigma-util = { workspace = true }
ergo-chain-types = { workspace = true }
ergo-nipopow = { workspace = true }
ergotree-ir = { workspace = true, features = ["json"] }
ergo-merkle-tree = { workspace = true }
futures = { workspace = true }
thiserror = { workspace = true }
derive_more = { workspace = true }
proptest-derive = {workspace = true, optional = true }
rand = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true, optional = true }
url = { workspace = true }
proptest = { workspace = true , optional = true }

# Dependencies for `wasm-timer`
parking_lot = "0.12"
pin-utils = "0.1"
# Dependencies for `reqwest`
http = "0.2"
bytes = "1.0"
serde_urlencoded = "0.7.1"
reqwest = { version = "0.12.24", default-features = false, features = ["json"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-futures = "0.4"
Expand Down Expand Up @@ -75,17 +64,10 @@ features = [
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { workspace = true }
tokio-stream = { workspace = true }
reqwest = { version = "0.11.10", default-features = false, features = ["json"] }

[features]
json = ["serde_json"]
arbitrary = ["proptest", "proptest-derive"]
default = ["json"]

[dev-dependencies]
sigma-test-util = { workspace = true }

# Addition from `reqwest`
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen = { version = "0.2.68", features = ["serde-serialize"] }
wasm-bindgen-test = "0.3"
3 changes: 1 addition & 2 deletions ergo-rest/src/api.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! REST API for the services in Ergo ecosystem (node, explorer, etc.)

use crate::reqwest;
use crate::reqwest::{header::CONTENT_TYPE, Client, RequestBuilder};
use reqwest::{header::CONTENT_TYPE, Client, RequestBuilder};

use crate::NodeConf;

Expand Down
18 changes: 7 additions & 11 deletions ergo-rest/src/api/peer_discovery_internals/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async fn peer_discovery_impl_chrome(
let rx_timeout_signal = {
let (tx, rx) = futures::channel::oneshot::channel::<()>();
wasm_bindgen_futures::spawn_local(async move {
crate::wasm_timer::Delay::new(settings.global_timeout)
wasm_timer::Delay::new(settings.global_timeout)
.await
.expect("wasm_timer::Delay: can't spawn global timeout");
tx.send(()).unwrap();
Expand Down Expand Up @@ -364,7 +364,7 @@ async fn peer_discovery_impl_chrome(
// pending_requests_after_timeout.len(),
// );
//console_log!("Waiting 180sec for Chrome to relinquish pending HTTP requests");
crate::wasm_timer::Delay::new(Duration::from_secs(180)).await?;
wasm_timer::Delay::new(Duration::from_secs(180)).await?;
Ok(ChromePeerDiscoveryScan {
active_peers,
visited_peers,
Expand Down Expand Up @@ -418,10 +418,8 @@ fn spawn_http_request_task_chrome(
// This task simulates the waiting of a preflight request
// that will timeout from no response.
spawn_local(async move {
let _ = crate::wasm_timer::Delay::new(
Duration::from_secs(80),
)
.await;
let _ = wasm_timer::Delay::new(Duration::from_secs(80))
.await;
let _ = tx_msg.send(Msg::PreflightRequestFailed).await;
});
} else {
Expand Down Expand Up @@ -457,11 +455,9 @@ fn spawn_http_request_task_chrome(
// This task simulates the waiting of a preflight
// request that will timeout from no response.
spawn_local(async move {
crate::wasm_timer::Delay::new(Duration::from_secs(
80,
))
.await
.unwrap();
wasm_timer::Delay::new(Duration::from_secs(80))
.await
.unwrap();

let _ =
tx_msg.send(Msg::PreflightRequestFailed).await;
Expand Down
2 changes: 1 addition & 1 deletion ergo-rest/src/bulk_req.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::reqwest::{Request, Response};
use ergo_chain_types::BlockId;
use ergo_chain_types::PeerAddr;
use ergo_nipopow::NipopowProof;
use reqwest::{Request, Response};

use crate::NodeError;

Expand Down
1 change: 0 additions & 1 deletion ergo-rest/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::reqwest;
use derive_more::From;
use thiserror::Error;

Expand Down
2 changes: 0 additions & 2 deletions ergo-rest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ mod node_conf;
mod node_info;
mod node_response;
mod peer_info;
mod wasm_timer;

pub mod api;
pub mod reqwest;

pub use error::*;
pub use known_nodes::KnownNodes;
Expand Down
2 changes: 1 addition & 1 deletion ergo-rest/src/node_conf.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Duration;

use crate::reqwest::header::HeaderValue;
use ergo_chain_types::PeerAddr;
use reqwest::header::HeaderValue;

/// Ergo node configuration
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
Expand Down
Loading
Loading