Skip to content

Commit

Permalink
refactor!: don't send public key with signature
Browse files Browse the repository at this point in the history
Signed-off-by: Marin Veršić <marin.versic101@gmail.com>
  • Loading branch information
mversic committed May 1, 2024
1 parent 14b5480 commit dc4d7d7
Show file tree
Hide file tree
Showing 30 changed files with 708 additions and 950 deletions.
1 change: 0 additions & 1 deletion 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 client/benches/tps/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use eyre::{Result, WrapErr};
use iroha_client::{
client::Client,
data_model::{
events::pipeline::{BlockEventFilter, BlockStatus},
parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder},
prelude::*,
},
};
use iroha_data_model::events::pipeline::{BlockEventFilter, BlockStatus};
use nonzero_ext::nonzero;
use serde::Deserialize;
use test_network::*;
Expand Down
7 changes: 4 additions & 3 deletions client/examples/million_accounts_genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
use std::{thread, time::Duration};

use iroha::samples::{construct_executor, get_config};
use iroha_client::data_model::prelude::*;
use iroha_crypto::KeyPair;
use iroha_data_model::isi::InstructionBox;
use iroha_client::{
crypto::KeyPair,
data_model::{isi::InstructionBox, prelude::*},
};
use iroha_genesis::{GenesisNetwork, RawGenesisBlock, RawGenesisBlockBuilder};
use iroha_primitives::unique_vec;
use test_network::{
Expand Down
6 changes: 4 additions & 2 deletions client/examples/register_1000_triggers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
use std::str::FromStr;

use iroha::samples::{construct_executor, get_config};
use iroha_client::{client::Client, data_model::prelude::*};
use iroha_data_model::trigger::TriggerId;
use iroha_client::{
client::Client,
data_model::{prelude::*, trigger::TriggerId},
};
use iroha_genesis::{GenesisNetwork, RawGenesisBlock, RawGenesisBlockBuilder};
use iroha_primitives::unique_vec;
use test_network::{
Expand Down
19 changes: 8 additions & 11 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ use eyre::{eyre, Result, WrapErr};
use futures_util::StreamExt;
use http_default::{AsyncWebSocketStream, WebSocketStream};
pub use iroha_config::client_api::ConfigDTO;
use iroha_data_model::{
events::pipeline::{
BlockEventFilter, BlockStatus, PipelineEventBox, PipelineEventFilterBox,
TransactionEventFilter, TransactionStatus,
},
query::QueryOutputBox,
};
use iroha_logger::prelude::*;
use iroha_telemetry::metrics::Status;
use iroha_torii_const::uri as torii_uri;
Expand All @@ -35,9 +28,13 @@ use crate::{
crypto::{HashOf, KeyPair},
data_model::{
block::SignedBlock,
events::pipeline::{
BlockEventFilter, BlockStatus, PipelineEventBox, PipelineEventFilterBox,
TransactionEventFilter, TransactionStatus,
},
isi::Instruction,
prelude::*,
query::{predicate::PredicateBox, Pagination, Query, Sorting},
query::{predicate::PredicateBox, Pagination, Query, QueryOutputBox, Sorting},
BatchedResponse, ChainId, ValidationFail,
},
http::{Method as HttpMethod, RequestBuilder, Response, StatusCode},
Expand Down Expand Up @@ -70,17 +67,17 @@ pub type QueryResult<T> = core::result::Result<T, ClientQueryError>;
/// Trait for signing transactions
pub trait Sign {
/// Sign transaction with provided key pair.
fn sign(self, key_pair: &crate::crypto::KeyPair) -> SignedTransaction;
fn sign(self, key_pair: &KeyPair) -> SignedTransaction;
}

impl Sign for TransactionBuilder {
fn sign(self, key_pair: &crate::crypto::KeyPair) -> SignedTransaction {
fn sign(self, key_pair: &KeyPair) -> SignedTransaction {
self.sign(key_pair)
}
}

impl Sign for SignedTransaction {
fn sign(self, key_pair: &crate::crypto::KeyPair) -> SignedTransaction {
fn sign(self, key_pair: &KeyPair) -> SignedTransaction {
self.sign(key_pair)
}
}
Expand Down
8 changes: 5 additions & 3 deletions client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ use iroha_config::{
base,
base::{FromEnv, StdEnv, UnwrapPartial},
};
use iroha_crypto::KeyPair;
use iroha_data_model::{prelude::*, ChainId};
use iroha_primitives::small::SmallStr;
use serde::{Deserialize, Serialize};
use serde_with::{DeserializeFromStr, SerializeDisplay};
use url::Url;

use crate::config::user::RootPartial;
use crate::{
config::user::RootPartial,
crypto::KeyPair,
data_model::{prelude::*, ChainId},
};

mod user;

Expand Down
8 changes: 5 additions & 3 deletions client/src/config/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ use std::{fs::File, io::Read, path::Path, str::FromStr, time::Duration};
pub use boilerplate::*;
use eyre::{eyre, Context, Report};
use iroha_config::base::{Emitter, ErrorsCollection};
use iroha_crypto::{KeyPair, PrivateKey, PublicKey};
use iroha_data_model::{account::AccountId, ChainId};
use merge::Merge;
use serde_with::DeserializeFromStr;
use url::Url;

use crate::config::BasicAuth;
use crate::{
config::BasicAuth,
crypto::{KeyPair, PrivateKey, PublicKey},
data_model::{account::AccountId, ChainId},
};

impl RootPartial {
/// Reads the partial layer from TOML
Expand Down
16 changes: 9 additions & 7 deletions client/src/config/user/boilerplate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ use iroha_config::base::{
Emitter, FromEnv, HumanDuration, Merge, ParseEnvResult, UnwrapPartial, UnwrapPartialResult,
UserField,
};
use iroha_crypto::{PrivateKey, PublicKey};
use iroha_data_model::{account::AccountId, ChainId};
use serde::Deserialize;

use crate::config::{
base::{FromEnvResult, ReadEnv},
user::{Account, OnlyHttpUrl, Root, Transaction},
BasicAuth, DEFAULT_TRANSACTION_NONCE, DEFAULT_TRANSACTION_STATUS_TIMEOUT,
DEFAULT_TRANSACTION_TIME_TO_LIVE,
use crate::{
config::{
base::{FromEnvResult, ReadEnv},
user::{Account, OnlyHttpUrl, Root, Transaction},
BasicAuth, DEFAULT_TRANSACTION_NONCE, DEFAULT_TRANSACTION_STATUS_TIMEOUT,
DEFAULT_TRANSACTION_TIME_TO_LIVE,
},
crypto::{PrivateKey, PublicKey},
data_model::{account::AccountId, ChainId},
};

#[derive(Debug, Clone, Deserialize, Eq, PartialEq, Default, Merge)]
Expand Down
6 changes: 3 additions & 3 deletions client/src/query_builder.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::fmt::Debug;

use iroha_data_model::query::QueryOutputBox;

use crate::{
client::{Client, QueryOutput, QueryResult},
data_model::query::{predicate::PredicateBox, sorting::Sorting, FetchSize, Pagination, Query},
data_model::query::{
predicate::PredicateBox, sorting::Sorting, FetchSize, Pagination, Query, QueryOutputBox,
},
};

pub struct QueryRequestBuilder<'a, R> {
Expand Down
Binary file modified configs/swarm/executor.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion core/benches/blocks/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn create_block(
Vec::new(),
)
.chain(0, state)
.sign(key_pair)
.sign(key_pair.private_key())
.unpack(|_| {})
.commit(&topology)
.unpack(|_| {})
Expand Down
6 changes: 3 additions & 3 deletions core/benches/kura.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ async fn measure_block_size_for_n_executors(n_executors: u32) {
let topology = Topology::new(UniqueVec::new());
let mut block = {
let mut state_block = state.block();
BlockBuilder::new(vec![tx], topology, Vec::new())
BlockBuilder::new(vec![tx], topology.clone(), Vec::new())
.chain(0, &mut state_block)
.sign(&KeyPair::random())
.sign(KeyPair::random().private_key())
.unpack(|_| {})
};

for _ in 1..n_executors {
block = block.sign(&KeyPair::random());
block = block.sign(&KeyPair::random(), &topology);
}
let mut block_store = BlockStore::new(dir.path(), LockStatus::Unlocked);
block_store.create_files_if_they_do_not_exist().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion core/benches/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fn sign_blocks(criterion: &mut Criterion) {
b.iter_batched(
|| block.clone(),
|block| {
let _: ValidBlock = block.sign(&key_pair).unpack(|_| {});
let _: ValidBlock = block.sign(key_pair.private_key()).unpack(|_| {});
count += 1;
},
BatchSize::SmallInput,
Expand Down
Loading

0 comments on commit dc4d7d7

Please sign in to comment.