Skip to content

Commit

Permalink
CLEANUP: remove sov-election module since we don't need it and modify…
Browse files Browse the repository at this point in the history
… tests using it to use sov-bank (#739)

* cleanup sov election

* fix unused import

* fix removed arguments to genesis config

* remove extra argument for create_demo_genesis_config

* add a bad nonce test case as well

* formatting :(

* another place where private key for election module needs to be removed

* linter suggestions

---------

Co-authored-by: dubbelosix <[email protected]>
  • Loading branch information
2 people authored and preston-evans98 committed Sep 14, 2023
1 parent 86cb528 commit 20447be
Show file tree
Hide file tree
Showing 29 changed files with 382 additions and 1,089 deletions.
22 changes: 0 additions & 22 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ members = [
"module-system/module-implementations/module-template",
"module-system/module-implementations/examples/sov-value-setter",
"module-system/module-implementations/examples/sov-vec-setter",
"module-system/module-implementations/examples/sov-election",
"module-system/module-implementations/integration-tests",
]
exclude = [
Expand Down Expand Up @@ -114,4 +113,4 @@ secp256k1 = { version = "0.27.0", default-features = false, features = ["global-
[patch.crates-io]
# See reth: https://github.com/paradigmxyz/reth/blob/main/Cargo.toml#L79
revm = { git = "https://github.com/bluealloy/revm/", branch = "release/v25" }
revm-primitives = { git = "https://github.com/bluealloy/revm/", branch = "release/v25" }
revm-primitives = { git = "https://github.com/bluealloy/revm/", branch = "release/v25" }
1 change: 0 additions & 1 deletion examples/demo-prover/host/benches/prover_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ async fn main() -> Result<(), anyhow::Error> {
sequencer_private_key.default_address(),
sequencer_da_address.as_ref().to_vec(),
&sequencer_private_key,
&sequencer_private_key,
);
println!("Starting from empty storage, initialization chain");
app.stf.init_chain(genesis_config);
Expand Down
1 change: 0 additions & 1 deletion examples/demo-prover/host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ async fn main() -> Result<(), anyhow::Error> {
sequencer_private_key.default_address(),
sequencer_da_address.as_ref().to_vec(),
&sequencer_private_key,
&sequencer_private_key,
);
info!("Starting from empty storage, initialization chain");
app.stf.init_chain(genesis_config);
Expand Down
1 change: 0 additions & 1 deletion examples/demo-rollup/benches/rollup_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ fn rollup_bench(_bench: &mut Criterion) {
sequencer_private_key.default_address(),
sequencer_da_address.as_ref().to_vec(),
&sequencer_private_key,
&sequencer_private_key,
);

demo.init_chain(demo_genesis_config);
Expand Down
1 change: 0 additions & 1 deletion examples/demo-rollup/benches/rollup_coarse_measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ async fn main() -> Result<(), anyhow::Error> {
sequencer_private_key.default_address(),
sequencer_da_address.as_ref().to_vec(),
&sequencer_private_key,
&sequencer_private_key,
);

demo.init_chain(demo_genesis_config);
Expand Down
1 change: 0 additions & 1 deletion examples/demo-rollup/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,5 @@ pub fn get_genesis_config<A: BasicAddress>(
sequencer_private_key.default_address(),
sequencer_da_address.as_ref().to_vec(),
&sequencer_private_key,
&sequencer_private_key,
)
}
2 changes: 0 additions & 2 deletions examples/demo-stf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ tracing = { workspace = true }
const-rollup-config = { path = "../const-rollup-config" }
sov-rollup-interface = { path = "../../rollup-interface" }
sov-cli = { path = "../../module-system/sov-cli", optional = true }
sov-election = { path = "../../module-system/module-implementations/examples/sov-election" }
sov-sequencer-registry = { path = "../../module-system/module-implementations/sov-sequencer-registry" }
sov-blob-storage = { path = "../../module-system/module-implementations/sov-blob-storage" }
sov-bank = { path = "../../module-system/module-implementations/sov-bank" }
Expand All @@ -56,7 +55,6 @@ native = [
"sov-bank/native",
"sov-cli",
"sov-accounts/native",
"sov-election/native",
"sov-sequencer-registry/native",
"sov-blob-storage/native",
"sov-value-setter/native",
Expand Down
9 changes: 0 additions & 9 deletions examples/demo-stf/src/genesis_config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use sov_election::ElectionConfig;
#[cfg(feature = "experimental")]
use sov_evm::{AccountData, EvmConfig, SpecId};
pub use sov_modules_api::default_context::DefaultContext;
Expand All @@ -21,7 +20,6 @@ pub fn create_demo_genesis_config<C: Context>(
sequencer_address: C::Address,
sequencer_da_address: Vec<u8>,
value_setter_admin_private_key: &DefaultPrivateKey,
election_admin_private_key: &DefaultPrivateKey,
) -> GenesisConfig<C> {
let token_config: sov_bank::TokenConfig<C> = sov_bank::TokenConfig {
token_name: DEMO_TOKEN_NAME.to_owned(),
Expand Down Expand Up @@ -53,10 +51,6 @@ pub fn create_demo_genesis_config<C: Context>(
admin: value_setter_admin_private_key.pub_key().to_address(),
};

let election_config = ElectionConfig {
admin: election_admin_private_key.pub_key().to_address(),
};

#[cfg(feature = "experimental")]
let genesis_evm_address = hex::decode("f39Fd6e51aad88F6F4ce6aB8827279cffFb92266")
.unwrap()
Expand All @@ -67,7 +61,6 @@ pub fn create_demo_genesis_config<C: Context>(
bank_config,
sequencer_registry_config,
(),
election_config,
value_setter_config,
sov_accounts::AccountConfig { pub_keys: vec![] },
#[cfg(feature = "experimental")]
Expand All @@ -89,13 +82,11 @@ pub fn create_demo_genesis_config<C: Context>(
pub fn create_demo_config(
initial_sequencer_balance: u64,
value_setter_admin_private_key: &DefaultPrivateKey,
election_admin_private_key: &DefaultPrivateKey,
) -> GenesisConfig<DefaultContext> {
create_demo_genesis_config::<DefaultContext>(
initial_sequencer_balance,
generate_address::<DefaultContext>(DEMO_SEQ_PUB_KEY_STR),
DEMO_SEQUENCER_DA_ADDRESS.to_vec(),
value_setter_admin_private_key,
election_admin_private_key,
)
}
5 changes: 0 additions & 5 deletions examples/demo-stf/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use sov_bank::query::{BankRpcImpl, BankRpcServer};
#[cfg(feature = "native")]
use sov_blob_storage::{BlobStorageRpcImpl, BlobStorageRpcServer};
#[cfg(feature = "native")]
use sov_election::query::{ElectionRpcImpl, ElectionRpcServer};
#[cfg(feature = "native")]
#[cfg(feature = "experimental")]
use sov_evm::query::{EvmRpcImpl, EvmRpcServer};
use sov_modules_api::capabilities::{BlobRefOrOwned, BlobSelector};
Expand All @@ -29,7 +27,6 @@ use sov_value_setter::query::{ValueSetterRpcImpl, ValueSetterRpcServer};
pub mod query {
pub use sov_accounts::query as accounts;
pub use sov_bank::query as bank;
pub use sov_election::query as election;
pub use sov_sequencer_registry::query as sequencer_registry;
pub use sov_value_setter::query as value_setter;
}
Expand Down Expand Up @@ -82,7 +79,6 @@ pub struct Runtime<C: Context> {
pub sequencer_registry: sov_sequencer_registry::SequencerRegistry<C>,
#[cfg_attr(feature = "native", cli_skip)]
pub blob_storage: sov_blob_storage::BlobStorage<C>,
pub election: sov_election::Election<C>,
pub value_setter: sov_value_setter::ValueSetter<C>,
pub accounts: sov_accounts::Accounts<C>,
}
Expand All @@ -100,7 +96,6 @@ pub struct Runtime<C: Context> {
pub sequencer_registry: sov_sequencer_registry::SequencerRegistry<C>,
#[cfg_attr(feature = "native", cli_skip)]
pub blob_storage: sov_blob_storage::BlobStorage<C>,
pub election: sov_election::Election<C>,
pub value_setter: sov_value_setter::ValueSetter<C>,
pub accounts: sov_accounts::Accounts<C>,
#[cfg_attr(feature = "native", cli_skip)]
Expand Down
47 changes: 22 additions & 25 deletions examples/demo-stf/src/tests/da_simulation.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::rc::Rc;

use sov_data_generators::election_data::{
BadNonceElectionCallMessages, BadSerializationElectionCallMessages, BadSigElectionCallMessages,
ElectionCallMessages, InvalidElectionCallMessages,
use sov_data_generators::bank_data::{
BadNonceBankCallMessages, BadSerializationBankCallMessages, BadSignatureBankCallMessages,
BankMessageGenerator,
};
use sov_data_generators::value_setter_data::{ValueSetterMessage, ValueSetterMessages};
use sov_data_generators::MessageGenerator;
Expand All @@ -14,43 +14,40 @@ use crate::runtime::Runtime;

type C = DefaultContext;

pub fn simulate_da(
value_setter_admin: DefaultPrivateKey,
election_admin: DefaultPrivateKey,
) -> Vec<RawTx> {
pub fn simulate_da(value_setter_admin: DefaultPrivateKey) -> Vec<RawTx> {
let mut messages = Vec::default();

let election: ElectionCallMessages<C> = ElectionCallMessages::new(election_admin);
messages.extend(election.create_raw_txs::<Runtime<C>>());
let bank_generator = BankMessageGenerator::<C>::default();
let bank_txns = bank_generator.create_raw_txs::<Runtime<C>>();

let value_setter = ValueSetterMessages::new(vec![ValueSetterMessage {
admin: Rc::new(value_setter_admin),
messages: vec![99, 33],
}]);
messages.extend(value_setter.create_raw_txs::<Runtime<C>>());

messages.extend(bank_txns);
messages
}

pub fn simulate_da_with_revert_msg(election_admin: DefaultPrivateKey) -> Vec<RawTx> {
let election = InvalidElectionCallMessages::new(election_admin);
election.create_raw_txs::<Runtime<C>>()
pub fn simulate_da_with_revert_msg() -> Vec<RawTx> {
let mut messages = Vec::default();
let bank_generator = BankMessageGenerator::<C>::create_invalid_transfer();
let bank_txns = bank_generator.create_raw_txs::<Runtime<C>>();
messages.extend(bank_txns);
messages
}

pub fn simulate_da_with_bad_sig(election_admin: DefaultPrivateKey) -> Vec<RawTx> {
let election = BadSigElectionCallMessages::<DefaultContext>::new(election_admin);
election.create_raw_txs::<Runtime<C>>()
pub fn simulate_da_with_bad_sig() -> Vec<RawTx> {
let b: BadSignatureBankCallMessages = Default::default();
b.create_raw_txs::<Runtime<C>>()
}

// TODO: Remove once we fix test with bad nonce
// https://github.com/Sovereign-Labs/sovereign-sdk/issues/235
#[allow(unused)]
pub fn simulate_da_with_bad_nonce(election_admin: DefaultPrivateKey) -> Vec<RawTx> {
let election = BadNonceElectionCallMessages::new(election_admin);
election.create_raw_txs::<Runtime<C>>()
pub fn simulate_da_with_bad_nonce() -> Vec<RawTx> {
let b: BadNonceBankCallMessages = Default::default();
b.create_raw_txs::<Runtime<C>>()
}

pub fn simulate_da_with_bad_serialization(election_admin: DefaultPrivateKey) -> Vec<RawTx> {
let election = BadSerializationElectionCallMessages::new(election_admin);
election.create_raw_txs::<Runtime<C>>()
pub fn simulate_da_with_bad_serialization() -> Vec<RawTx> {
let b: BadSerializationBankCallMessages = Default::default();
b.create_raw_txs::<Runtime<C>>()
}
Loading

0 comments on commit 20447be

Please sign in to comment.