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: register init contracts on second block of strategy #1808

Merged
merged 7 commits into from
Apr 13, 2024
Merged
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
91 changes: 49 additions & 42 deletions 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 packages/rs-dpp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ed25519-dalek = { version = "2.0.0-rc.2", features = ["rand_core"], optional = t
nohash-hasher = "0.2.0"
rust_decimal = "1.29.1"
rust_decimal_macros = "1.29.1"
indexmap = { version = "2.0.2"}
indexmap = { version = "2.0.2", features = ["serde"] }
strum = { version = "0.25.0", features = ["derive"] }
json-schema-compatibility-validator = { path = '../rs-json-schema-compatibility-validator' }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ use platform_value::Value;
use rand::distributions::{Alphanumeric, Standard};
use rand::rngs::StdRng;
use rand::Rng;
use serde::Serialize;

pub mod array;

// This struct will be changed in future to support more validation logic and serialization
// It will become versioned and it will be introduced by a new document type version
// @append_only
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Clone, Serialize)]
pub struct DocumentProperty {
pub property_type: DocumentPropertyType,
pub required: bool,
}

// @append_only
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Clone, Serialize)]
pub enum DocumentPropertyType {
///Todo decompose integer
Integer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,24 @@ impl DataContractCreateTransitionMethodsV0 for DataContractCreateTransitionV0 {
let mut state_transition: StateTransition = transition.into();
let value = state_transition.signable_bytes()?;

let public_key =
identity
.loaded_public_keys
.get(&key_id)
.ok_or(ProtocolError::NonConsensusError(
NonConsensusError::StateTransitionCreationError(
"public key did not exist".to_string(),
),
))?;
// The public key ids don't always match the keys in the map, so we need to do this.
let matching_key = identity
.loaded_public_keys
.iter()
.find_map(|(&key, public_key)| {
if public_key.id() == key_id {
Some(key)
} else {
None
}
})
.expect("No matching public key id found in the map");

let public_key = identity.loaded_public_keys.get(&matching_key).ok_or(
ProtocolError::NonConsensusError(NonConsensusError::StateTransitionCreationError(
"public key did not exist".to_string(),
)),
)?;

let security_level_requirements = state_transition.security_level_requirement().ok_or(
ProtocolError::CorruptedCodeExecution(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ mod tests {
// simple case where quorums do not change
let strategy = NetworkStrategy {
strategy: Strategy {
contracts_with_updates: vec![],
start_contracts: vec![],
operations: vec![],
start_identities: StartIdentities::default(),
identities_inserts: IdentityInsertInfo::default(),
identity_inserts: IdentityInsertInfo::default(),

identity_contract_nonce_gaps: None,
signer: None,
Expand Down
12 changes: 6 additions & 6 deletions packages/rs-drive-abci/tests/strategy_tests/core_update_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ mod tests {
fn run_chain_random_bans() {
let strategy = NetworkStrategy {
strategy: Strategy {
contracts_with_updates: vec![],
start_contracts: vec![],
operations: vec![],
start_identities: StartIdentities::default(),
identities_inserts: IdentityInsertInfo::default(),
identity_inserts: IdentityInsertInfo::default(),

identity_contract_nonce_gaps: None,
signer: None,
Expand Down Expand Up @@ -113,10 +113,10 @@ mod tests {
fn run_chain_random_removals() {
let strategy = NetworkStrategy {
strategy: Strategy {
contracts_with_updates: vec![],
start_contracts: vec![],
operations: vec![],
start_identities: StartIdentities::default(),
identities_inserts: IdentityInsertInfo::default(),
identity_inserts: IdentityInsertInfo::default(),

identity_contract_nonce_gaps: None,
signer: None,
Expand Down Expand Up @@ -197,10 +197,10 @@ mod tests {
fn run_chain_random_bans_and_unbans() {
let strategy = NetworkStrategy {
strategy: Strategy {
contracts_with_updates: vec![],
start_contracts: vec![],
operations: vec![],
start_identities: StartIdentities::default(),
identities_inserts: IdentityInsertInfo::default(),
identity_inserts: IdentityInsertInfo::default(),

identity_contract_nonce_gaps: None,
signer: None,
Expand Down
Loading
Loading