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: add a transaction mirror binary #7183

Merged
merged 33 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f4533b9
feat: add a transaction mirror binary
marcelo-gonzalez Jul 13, 2022
55b9200
fix indentation
marcelo-gonzalez Jul 14, 2022
7dae99d
add comments
marcelo-gonzalez Jul 14, 2022
624aecd
extract ordinal_to_port() function
marcelo-gonzalez Jul 14, 2022
60ce7c5
use subprocess.check_output()
marcelo-gonzalez Jul 14, 2022
5db97a9
use pathlib mkdir()
marcelo-gonzalez Jul 14, 2022
bd5c603
use json.dump()
marcelo-gonzalez Jul 14, 2022
4c20b36
kill process if cant stop with SIGINT
marcelo-gonzalez Jul 14, 2022
2c0ada6
assert exit code is 0
marcelo-gonzalez Jul 14, 2022
e485416
fix typo
marcelo-gonzalez Jul 14, 2022
e7881b5
simplify stuff
marcelo-gonzalez Jul 15, 2022
6fc1a36
fix bug. Don't overwrite the nonces column with a default value if th…
marcelo-gonzalez Jul 19, 2022
5b9a42b
dont fetch nonces we already know about
marcelo-gonzalez Jul 19, 2022
237e87c
fix bug. the Nonces column should be keyed by (account_id, public_key…
marcelo-gonzalez Jul 19, 2022
4dfb256
take care of the TODO saying not to hardcode the sleep time
marcelo-gonzalez Jul 27, 2022
dc7e081
Merge branch 'master' into mirror
marcelo-gonzalez Oct 19, 2022
eb39d0a
adjust
marcelo-gonzalez Jul 28, 2022
d4644a3
fix DeleteKey bug.
marcelo-gonzalez Aug 17, 2022
37b91df
fix NonceDiff initialization
marcelo-gonzalez Oct 18, 2022
1b41393
handle implicit accounts
marcelo-gonzalez Oct 12, 2022
90b0c13
add --no-secret flag
marcelo-gonzalez Oct 3, 2022
01347ba
fix up error handling and actix logic
marcelo-gonzalez Oct 3, 2022
7686196
fix up logic on setting nonces
marcelo-gonzalez Oct 14, 2022
7c91a8a
remove txs from sent_txs if we know theyre skipped
marcelo-gonzalez Oct 8, 2022
3de06ab
remove redundant log. already logged in on_txs_sent()
marcelo-gonzalez Oct 14, 2022
0d95f98
cleanup pytest
marcelo-gonzalez Oct 6, 2022
67a492a
change pytest dir to test-mirror
marcelo-gonzalez Oct 20, 2022
87f1de3
move pytest/tests/mirror to pytest/tools/mirror
marcelo-gonzalez Oct 20, 2022
0a462df
remove parity-secp256k1 dep
marcelo-gonzalez Oct 20, 2022
aa2070c
Merge remote-tracking branch 'origin/master' into mirror
marcelo-gonzalez Oct 21, 2022
1589e07
fix up Cargo.toml
marcelo-gonzalez Oct 21, 2022
bff7e6c
move it to a neard subcommand
marcelo-gonzalez Oct 21, 2022
a9b067e
dont start tokio for the prepare command
marcelo-gonzalez Oct 21, 2022
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
58 changes: 58 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ members = [
"tools/chainsync-loadtest",
"tools/delay-detector",
"tools/indexer/example",
"tools/mirror",
"tools/mock-node",
"tools/restaked",
"tools/rpctypegen/core",
Expand Down Expand Up @@ -111,6 +112,7 @@ fs2 = "0.4"
futures = "0.3.5"
futures-util = "0.3"
hex = { version = "0.4.2", features = ["serde"] }
hkdf = "0.12.3"
hyper = { version = "0.14", features = ["full"] }
hyper-tls = "0.5.0"
im = "15"
Expand Down Expand Up @@ -148,6 +150,7 @@ protobuf-codegen = "3.0.1"
quote = "1.0"
rand = "0.8.5"
rand_chacha = "0.3.1"
rand_core = "0.5"
rand_hc = "0.3.1"
rand_xorshift = "0.3"
rayon = "1.5"
Expand Down
2 changes: 1 addition & 1 deletion core/chain-configs/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ impl<'de, F: FnMut(StateRecord)> DeserializeSeed<'de> for RecordsProcessor<&'_ m
}
}

fn stream_records_from_file(
pub fn stream_records_from_file(
reader: impl Read,
mut callback: impl FnMut(StateRecord),
) -> serde_json::Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions core/chain-configs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ pub use client_config::{
MIN_GC_NUM_EPOCHS_TO_KEEP, TEST_STATE_SYNC_TIMEOUT,
};
pub use genesis_config::{
get_initial_supply, Genesis, GenesisChangeConfig, GenesisConfig, GenesisRecords,
GenesisValidationMode, ProtocolConfig, ProtocolConfigView,
get_initial_supply, stream_records_from_file, Genesis, GenesisChangeConfig, GenesisConfig,
GenesisRecords, GenesisValidationMode, ProtocolConfig, ProtocolConfigView,
};
1 change: 1 addition & 0 deletions neard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ tracing.workspace = true
nearcore = { path = "../nearcore" }
near-chain-configs = { path = "../core/chain-configs" }
near-jsonrpc-primitives = { path = "../chain/jsonrpc-primitives" }
near-mirror = { path = "../tools/mirror" }
near-primitives = { path = "../core/primitives" }
near-performance-metrics = { path = "../utils/near-performance-metrics" }
near-state-viewer = { path = "../tools/state-viewer", package = "state-viewer" }
Expand Down
10 changes: 10 additions & 0 deletions neard/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use anyhow::Context;
use clap::{Args, Parser};
use near_chain_configs::GenesisValidationMode;
use near_jsonrpc_primitives::types::light_client::RpcLightClientExecutionProofResponse;
use near_mirror::MirrorCommand;
use near_o11y::tracing_subscriber::EnvFilter;
use near_o11y::{
default_subscriber, default_subscriber_with_opentelemetry, BuildEnvFilterError,
Expand Down Expand Up @@ -93,6 +94,9 @@ impl NeardCmd {
NeardSubCommand::VerifyProof(cmd) => {
cmd.run();
}
NeardSubCommand::Mirror(cmd) => {
cmd.run()?;
}
};
Ok(())
}
Expand All @@ -104,6 +108,8 @@ pub(crate) enum RunError {
EnvFilter(#[source] BuildEnvFilterError),
#[error("could not install a rayon thread pool")]
RayonInstall(#[source] rayon::ThreadPoolBuildError),
#[error(transparent)]
Other(#[from] anyhow::Error),
}

#[derive(Parser)]
Expand Down Expand Up @@ -189,6 +195,10 @@ pub(super) enum NeardSubCommand {
/// Verify proofs
#[clap(alias = "verify_proof")]
VerifyProof(VerifyProofSubCommand),

/// Mirror transactions from a source chain to a test chain with state forked
/// from it, reproducing traffic and state as closely as possible.
Mirror(MirrorCommand),
}

#[derive(Parser)]
Expand Down
7 changes: 7 additions & 0 deletions pytest/lib/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ def __init__(self, account_id: str, pk: str, sk: str) -> None:
self.pk = pk
self.sk = sk

@classmethod
def from_random(cls, account_id: str) -> 'Key':
keys = ed25519.create_keypair(entropy=os.urandom)
sk = 'ed25519:' + base58.b58encode(keys[0].to_bytes()).decode('ascii')
pk = 'ed25519:' + base58.b58encode(keys[1].to_bytes()).decode('ascii')
return cls(account_id, pk, sk)

@classmethod
def implicit_account(cls) -> 'Key':
keys = ed25519.create_keypair(entropy=os.urandom)
Expand Down
Loading