Skip to content

Commit

Permalink
[feature] #2085: Authenticate personal accounts by ID
Browse files Browse the repository at this point in the history
Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
  • Loading branch information
s8sato committed Apr 4, 2024
1 parent bc6be98 commit 77ad236
Show file tree
Hide file tree
Showing 127 changed files with 1,514 additions and 2,509 deletions.
18 changes: 18 additions & 0 deletions Cargo.lock

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

147 changes: 144 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ iroha_data_model_derive = { version = "=2.0.0-pre-rc.20", path = "data_model/der
iroha_client = { version = "=2.0.0-pre-rc.20", path = "client" }
iroha_config = { version = "=2.0.0-pre-rc.20", path = "config" }
iroha_config_base = { version = "=2.0.0-pre-rc.20", path = "config/base" }
iroha_sample_params = { version = "=2.0.0-pre-rc.20", path = "configs/sample_params" }
iroha_schema_gen = { version = "=2.0.0-pre-rc.20", path = "schema/gen" }
iroha_schema = { version = "=2.0.0-pre-rc.20", path = "schema", default-features = false }
iroha_schema_derive = { version = "=2.0.0-pre-rc.20", path = "schema/derive" }
Expand Down Expand Up @@ -131,65 +132,204 @@ storage = { git = "https://github.com/Erigara/storage.git", rev = "e0afe4b42810e
rustdoc.private_doc_tests = "deny"

rust.anonymous_parameters = "deny"

rust.future_incompatible = "deny"

rust.missing_copy_implementations = "deny"

rust.missing_docs = "deny"

rust.nonstandard_style = "deny"

rust.rust_2018_idioms = "deny"

rust.trivial_casts = "deny"

rust.trivial_numeric_casts = "deny"

rust.unsafe_code = "deny"

rust.unused = "deny"

rust.unused_import_braces = "deny"

rust.variant_size_differences = "deny"

rust.explicit_outlives_requirements = "deny"

rust.non_ascii_idents = "deny"

rust.elided_lifetimes_in_paths = "allow"

rust.unknown_lints = "warn"

rust.single_use_lifetimes = "warn"

rust.unused_lifetimes = "warn"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.pedantic = { level = "warn", priority = -1 }
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.match_wildcard_for_single_variants = "allow"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.semicolon_if_nothing_returned = "allow"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.wildcard_imports = "allow"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.manual_let_else = "allow"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.enum_glob_use = "allow"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.module_name_repetitions = "allow"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.must_use_candidate = "allow"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.missing_panics_doc = "allow"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# restriction
# pedantic
clippy.dbg_macro = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# nursery
# pedantic
clippy.debug_assert_with_mut_call = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.derive_partial_eq_without_eq = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.empty_line_after_outer_attr = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.fallible_impl_from = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.future_not_send = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.iter_with_drain = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.mutex_integer = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.needless_collect = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.path_buf_push_overwrite = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.suboptimal_flops = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.trailing_empty_array = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.transmute_undefined_repr = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.trivial_regex = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.unused_peekable = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.unused_rounding = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.option_if_let_else = "warn"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.or_fun_call = "warn"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.redundant_pub_crate = "warn"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.string_lit_as_bytes = "warn"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.suspicious_operation_groupings = "warn"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.useless_let_if_seq = "warn"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

#cargo
# pedantic
clippy.redundant_feature_names = "deny"
# TODO: reenable
# rust.unsafe_op_in_unsafe_fn = "deny"

# pedantic
clippy.wildcard_dependencies = "deny"

[workspace]
Expand Down Expand Up @@ -242,6 +382,7 @@ members = [
"wasm_codec",
"wasm_codec/derive",
"wasm_builder",
"configs/sample_params",
]

[profile.deploy]
Expand Down
18 changes: 7 additions & 11 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,7 @@ impl Iroha {
.wrap_err("Unable to start P2P-network")?;

let (events_sender, _) = broadcast::channel(10000);
let world = World::with(
[genesis_domain(config.genesis.public_key().clone())],
config.sumeragi.trusted_peers.clone(),
);
let world = World::with([genesis_domain()], config.sumeragi.trusted_peers.clone());

let kura = Kura::new(&config.kura)?;
let live_query_store_handle = LiveQueryStore::from_config(config.live_query_store).start();
Expand Down Expand Up @@ -472,19 +469,18 @@ impl Iroha {
}
}

fn genesis_account(public_key: PublicKey) -> Account {
Account::new(iroha_genesis::GENESIS_ACCOUNT_ID.clone(), public_key)
fn genesis_account() -> Account {
Account::new(iroha_genesis::GENESIS_ACCOUNT_ID.clone())
.build(&iroha_genesis::GENESIS_ACCOUNT_ID)
}

fn genesis_domain(public_key: PublicKey) -> Domain {
fn genesis_domain() -> Domain {
let mut domain = Domain::new(iroha_genesis::GENESIS_DOMAIN_ID.clone())
.build(&iroha_genesis::GENESIS_ACCOUNT_ID);

domain.accounts.insert(
iroha_genesis::GENESIS_ACCOUNT_ID.clone(),
genesis_account(public_key),
);
domain
.accounts
.insert(iroha_genesis::GENESIS_ACCOUNT_ID.clone(), genesis_account());

domain
}
Expand Down
26 changes: 17 additions & 9 deletions cli/src/samples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,25 @@ pub fn get_trusted_peers(public_key: Option<&PublicKey>) -> HashSet<PeerId> {
pub fn get_user_config(
peers: &UniqueVec<PeerId>,
chain_id: Option<ChainId>,
key_pair: Option<KeyPair>,
peer_key_pair: Option<KeyPair>,
genesis_key_pair: Option<KeyPair>,
) -> UserConfig {
let chain_id = chain_id.unwrap_or_else(|| ChainId::from("0"));

let (public_key, private_key) = key_pair.unwrap_or_else(KeyPair::random).into_parts();
iroha_logger::info!(%public_key);
let (peer_public_key, peer_private_key) =
peer_key_pair.unwrap_or_else(KeyPair::random).into_parts();
iroha_logger::info!(%peer_public_key);
// TODO remove "genesis account" #4409
let (genesis_public_key, genesis_private_key) = genesis_key_pair
.unwrap_or_else(KeyPair::random)
.into_parts();
iroha_logger::info!(%genesis_public_key);

let mut config = UserConfig::new();

config.chain_id.set(chain_id);
config.public_key.set(public_key.clone());
config.private_key.set(private_key.clone());
config.public_key.set(peer_public_key);
config.private_key.set(peer_private_key);
config.network.address.set(DEFAULT_P2P_ADDR);
config
.chain_wide
Expand All @@ -89,8 +96,8 @@ pub fn get_user_config(
.network
.block_gossip_period
.set(HumanDuration(Duration::from_millis(500)));
config.genesis.private_key.set(private_key);
config.genesis.public_key.set(public_key);
config.genesis.private_key.set(genesis_private_key);
config.genesis.public_key.set(genesis_public_key);
config.genesis.file.set("./genesis.json".into());
// There is no need in persistency in tests
// If required to should be set explicitly not to overlap with other existing tests
Expand All @@ -109,9 +116,10 @@ pub fn get_user_config(
pub fn get_config(
trusted_peers: &UniqueVec<PeerId>,
chain_id: Option<ChainId>,
key_pair: Option<KeyPair>,
peer_key_pair: Option<KeyPair>,
genesis_key_pair: Option<KeyPair>,
) -> Config {
get_user_config(trusted_peers, chain_id, key_pair)
get_user_config(trusted_peers, chain_id, peer_key_pair, genesis_key_pair)
.unwrap_partial()
.expect("config should build as all required fields were provided")
.parse(CliContext {
Expand Down
Loading

0 comments on commit 77ad236

Please sign in to comment.