Skip to content

Commit

Permalink
Merge branch 'main' into jds-mempool-enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
GitGab19 authored Mar 4, 2024
2 parents 4be66e0 + 85f8697 commit 5d1390f
Show file tree
Hide file tree
Showing 40 changed files with 1,443 additions and 2,573 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/run-and-track-benchmarks-on-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- uses: actions/checkout@v3
- uses: bencherdev/bencher@v0.3.10
- uses: actions/checkout@v4
- uses: bencherdev/bencher@main
- name: Benchmark with Bencher
run: |
cd benches
Expand All @@ -51,8 +51,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- uses: actions/checkout@v3
- uses: bencherdev/bencher@v0.3.10
- uses: actions/checkout@v4
- uses: bencherdev/bencher@main
- name: Benchmark with Bencher
run: |
cd benches
Expand Down Expand Up @@ -82,8 +82,8 @@ jobs:
sudo apt-get update
sudo apt-get install -y valgrind=1:3.18.1-1ubuntu2
- uses: actions/checkout@v3
- uses: bencherdev/bencher@v0.3.10
- uses: actions/checkout@v4
- uses: bencherdev/bencher@main
- name: Benchmark with Bencher
run: |
cd benches
Expand Down Expand Up @@ -114,8 +114,8 @@ jobs:
sudo apt-get update
sudo apt-get install -y valgrind=1:3.18.1-1ubuntu2
- uses: actions/checkout@v3
- uses: bencherdev/bencher@v0.3.10
- uses: actions/checkout@v4
- uses: bencherdev/bencher@main
- name: Benchmark with Bencher
run: |
cd benches
Expand Down
2 changes: 1 addition & 1 deletion examples/template-provider-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ async fn test_1() {
let frame: StdFrame =
Sv2Frame::from_message(submit_solution, message_type, extension_type, channel_bit).unwrap();
let frame: EitherFrame = frame.into();
dbg!(sender.send(frame).await.unwrap());
sender.send(frame).await.unwrap();
async_std::task::sleep(std::time::Duration::from_secs(10)).await;
}
4 changes: 2 additions & 2 deletions protocols/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion protocols/v2/noise-sv2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "noise_sv2"
version = "1.0.0"
version = "1.1.0"
authors = ["fi3 <[email protected]>"]
edition = "2018"
description = "Sv2 noise"
Expand Down
2 changes: 1 addition & 1 deletion protocols/v2/roles-logic-sv2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "roles_logic_sv2"
version = "0.1.1"
version = "0.1.2"
edition = "2018"
description = "Common handlers for use within SV2 roles"
license = "MIT OR Apache-2.0"
Expand Down
43 changes: 39 additions & 4 deletions protocols/v2/roles-logic-sv2/src/handlers/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{
use common_messages_sv2::{
ChannelEndpointChanged, SetupConnection, SetupConnectionError, SetupConnectionSuccess,
};
use const_sv2::*;
use core::convert::TryInto;
use std::sync::Arc;
use tracing::{debug, error, info, trace};
Expand All @@ -33,9 +34,26 @@ where
self_: Arc<Mutex<Self>>,
message_type: u8,
payload: &mut [u8],
routing_logic: CommonRoutingLogic<Router>,
) -> Result<SendTo, Error> {
Self::handle_message_common_deserilized(
self_,
(message_type, payload).try_into(),
routing_logic,
)
}
/// Takes a message and it calls the appropriate handler function
///
/// Arguments:
///
/// * `message_type`: See [`const_sv2`].
///
fn handle_message_common_deserilized(
self_: Arc<Mutex<Self>>,
message: Result<CommonMessages<'_>, Error>,
_routing_logic: CommonRoutingLogic<Router>,
) -> Result<SendTo, Error> {
match (message_type, payload).try_into() {
match message {
Ok(CommonMessages::SetupConnectionSuccess(m)) => {
info!(
"Received SetupConnectionSuccess: version={}, flags={:b}",
Expand Down Expand Up @@ -63,7 +81,9 @@ where
.safe_lock(|x| x.handle_channel_endpoint_changed(m))
.map_err(|e| crate::Error::PoisonLock(e.to_string()))?
}
Ok(CommonMessages::SetupConnection(_)) => Err(Error::UnexpectedMessage(message_type)),
Ok(CommonMessages::SetupConnection(_)) => {
Err(Error::UnexpectedMessage(MESSAGE_TYPE_SETUP_CONNECTION))
}
Err(e) => Err(e),
}
}
Expand Down Expand Up @@ -106,7 +126,6 @@ where
Err(e) => Err(e),
}
}

/// It takes a message type and a payload, and if the message is a serialized setup connection
/// message, it calls the `on_setup_connection` function on the routing logic, and then calls the
/// `handle_setup_connection` function on the router
Expand All @@ -121,7 +140,23 @@ where
payload: &mut [u8],
routing_logic: CommonRoutingLogic<Router>,
) -> Result<SendTo, Error> {
match (message_type, payload).try_into() {
Self::handle_message_common_deserilized(
self_,
(message_type, payload).try_into(),
routing_logic,
)
}

/// It takes a message do setup connection message, it calls
/// the `on_setup_connection` function on the routing logic, and then calls the
/// `handle_setup_connection` function on the router
///
fn handle_message_common_deserilized(
self_: Arc<Mutex<Self>>,
message: Result<CommonMessages<'_>, Error>,
routing_logic: CommonRoutingLogic<Router>,
) -> Result<SendTo, Error> {
match message {
Ok(CommonMessages::SetupConnection(m)) => {
info!(
"Received SetupConnection: version={}, flags={:b}",
Expand Down
18 changes: 16 additions & 2 deletions protocols/v2/roles-logic-sv2/src/handlers/job_declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ where
message_type: u8,
payload: &mut [u8],
) -> Result<SendTo, Error> {
match (message_type, payload).try_into() {
Self::handle_message_job_declaration_deserialized(self_, (message_type, payload).try_into())
}

fn handle_message_job_declaration_deserialized(
self_: Arc<Mutex<Self>>,
message: Result<JobDeclaration<'_>, Error>,
) -> Result<SendTo, Error> {
match message {
Ok(JobDeclaration::AllocateMiningJobTokenSuccess(message)) => {
debug!(
"Received AllocateMiningJobTokenSuccess with id: {}",
Expand Down Expand Up @@ -117,7 +124,14 @@ where
message_type: u8,
payload: &mut [u8],
) -> Result<SendTo, Error> {
match (message_type, payload).try_into() {
Self::handle_message_job_declaration_deserialized(self_, (message_type, payload).try_into())
}

fn handle_message_job_declaration_deserialized(
self_: Arc<Mutex<Self>>,
message: Result<JobDeclaration<'_>, Error>,
) -> Result<SendTo, Error> {
match message {
Ok(JobDeclaration::AllocateMiningJobToken(message)) => {
debug!(
"Received AllocateMiningJobToken with id: {}",
Expand Down
Loading

0 comments on commit 5d1390f

Please sign in to comment.