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

ledger: improve genesis flow #685

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c6e5deb
refactor bech32m string encoding for address and MASP addresses
tzemanovic Nov 29, 2022
f0e3e94
add bech32m string encoding for `common::PublicKey` and `DkgPublicKey`
tzemanovic Nov 30, 2022
7bac229
changelog: add #849
tzemanovic Dec 7, 2022
20a4296
add `common::Signature` bech32m encoding
tzemanovic Dec 8, 2022
6a3ddd9
core/key: add a helper to gen ed25519 key in bech32m format
tzemanovic Feb 8, 2023
cb4cf8e
test/e2e/ledger_tests: use bech32m PK format for `init-account` cmd
tzemanovic Feb 8, 2023
0f7da43
[ci] wasm checksums update
github-actions[bot] Feb 8, 2023
0245bf8
make cli::Context chain optional and allow to use wallet `--pre-genesis`
tzemanovic Dec 7, 2022
0b3b357
changelog: add #870
tzemanovic Dec 7, 2022
82c2e78
feat: remove dev feature flag
Oct 25, 2022
c1769d4
token: switch serde serialization from via String to via Decimal
tzemanovic Nov 22, 2022
99f6a3c
WIP: add new genesis module
tzemanovic Nov 22, 2022
50ab441
Add genesis template files validation utils cmd
tzemanovic Dec 6, 2022
c7b5b3f
new genesis: add parameters file
tzemanovic Dec 6, 2022
4c2e2e4
add localnet genesis templates and a unit test for these files
tzemanovic Dec 8, 2022
ba78acc
wallet/store: sort entries by keys
tzemanovic Dec 9, 2022
1872137
wallet/alias: add borsh serialization
tzemanovic Dec 14, 2022
565c908
core/types/string_encoding: add `StringEncoded<T>` wrapper type
tzemanovic Dec 14, 2022
541640e
core/types/time: add `MIN_UTC`
tzemanovic Dec 14, 2022
7903e3f
core/types: add a method to get a standalone Tx sig and verify it
tzemanovic Dec 14, 2022
0a51f93
add genesis templates and transactions with a locanet setup
tzemanovic Dec 14, 2022
93b93c5
wallet: print PK on `key gen`
tzemanovic Dec 14, 2022
4dbac1b
genesis: add starter templates
tzemanovic Dec 14, 2022
6dfeee8
core/types/time: add serde serialization and Display/FromStr
tzemanovic Dec 19, 2022
c83f7ba
client/utils: update init-network to use the new genesis
tzemanovic Dec 19, 2022
ed49f08
wallet/alias: normalize deserialized aliases
tzemanovic Dec 20, 2022
5334ebc
core/types/address: add serde support for `EstablishedAddressGen`
tzemanovic Dec 20, 2022
5dd3366
dev-deps: update pretty_assertions and add it to apps crate
tzemanovic Dec 20, 2022
ec5e6bb
core/types: derive more traits for Address and Rfc3339String duration
tzemanovic Dec 20, 2022
baac62c
genesis: derive addresses for established addrs before chain ID
tzemanovic Dec 20, 2022
40414c2
WIP
tzemanovic Jan 18, 2023
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
6 changes: 6 additions & 0 deletions .changelog/unreleased/features/870-pre-genesis-wallet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- Added `--pre-genesis` argument to the wallet commands to allow to generate
keys, implicit addresses and shielded keys without having a chain setup. If
no chain is setup yet (i.e. there's no base-dir `.namada` or it's empty), the
wallet defaults to use the pre-genesis wallet even without the `--pre-genesis`
flag. The pre-genesis wallet is located in `.namada/pre-genesis/wallet.toml`.
([#870](https://github.com/anoma/namada/pull/870))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added bech32m string encoding for `common::PublicKey` and `DkgPublicKey`.
([#849](https://github.com/anoma/namada/pull/849))
23 changes: 11 additions & 12 deletions Cargo.lock

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

12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ build-test:
$(cargo) build --tests

build-release:
NAMADA_DEV=false $(cargo) build --release --package namada_apps --manifest-path Cargo.toml
$(cargo) build --release --package namada_apps --manifest-path Cargo.toml

install-release:
NAMADA_DEV=false $(cargo) install --path ./apps --locked
$(cargo) install --path ./apps --locked

check-release:
NAMADA_DEV=false $(cargo) check --release --package namada_apps
$(cargo) check --release --package namada_apps

package: build-release
scripts/make-package.sh
Expand All @@ -55,13 +55,13 @@ check-mainnet:
clippy-wasm = $(cargo) +$(nightly) clippy --manifest-path $(wasm)/Cargo.toml --all-targets -- -D warnings

clippy:
NAMADA_DEV=false $(cargo) +$(nightly) clippy --all-targets -- -D warnings && \
$(cargo) +$(nightly) clippy --all-targets -- -D warnings && \
make -C $(wasms) clippy && \
make -C $(wasms_for_tests) clippy && \
$(foreach wasm,$(wasm_templates),$(clippy-wasm) && ) true

clippy-abcipp:
NAMADA_DEV=false $(cargo) +$(nightly) clippy --all-targets \
$(cargo) +$(nightly) clippy --all-targets \
--manifest-path ./apps/Cargo.toml \
--no-default-features \
--features "std testing abcipp" && \
Expand All @@ -86,7 +86,7 @@ clippy-fix:
$(cargo) +$(nightly) clippy --fix -Z unstable-options --all-targets --allow-dirty --allow-staged

install: tendermint
NAMADA_DEV=false $(cargo) install --path ./apps --locked
$(cargo) install --path ./apps --locked

tendermint:
./scripts/get_tendermint.sh
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ Guide.
```shell
# Build the provided validity predicate and transaction wasm modules
make build-wasm-scripts-docker

# Development (debug) build Namada, which includes a validator and some default
# accounts, whose keys and addresses are available in the wallet
NAMADA_DEV=true make
```

### Before submitting a PR, pls make sure to run the following
Expand Down
4 changes: 2 additions & 2 deletions apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ default = ["std", "abciplus"]
mainnet = [
"namada/mainnet",
]
dev = ["namada/dev"]
std = ["ed25519-consensus/std", "rand/std", "rand_core/std"]
# for integration tests and test utilies
testing = ["dev"]
testing = []

abcipp = [
"namada/abcipp",
Expand Down Expand Up @@ -155,6 +154,7 @@ rust_decimal_macros = "1.26.1"
[dev-dependencies]
namada = {path = "../shared", default-features = false, features = ["testing", "wasm-runtime"]}
bit-set = "0.5.2"
pretty_assertions = "1.3.0"
# A fork with state machime testing
proptest = {git = "https://github.com/heliaxdev/proptest", branch = "tomas/sm"}
tempfile = "3.2.0"
Expand Down
9 changes: 0 additions & 9 deletions apps/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,4 @@ fn main() {

// Tell Cargo that if the given file changes, to rerun this build script.
println!("cargo:rerun-if-changed={}", PROTO_SRC);

// Tell Cargo to build when the `NAMADA_DEV` env var changes
println!("cargo:rerun-if-env-changed=NAMADA_DEV");
// Enable "dev" feature if `NAMADA_DEV` is trueish
if let Ok(dev) = env::var("NAMADA_DEV") {
if dev.to_ascii_lowercase().trim() == "true" {
println!("cargo:rustc-cfg=feature=\"dev\"");
}
}
}
6 changes: 6 additions & 0 deletions apps/src/bin/namada-client/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ pub async fn main() -> Result<()> {
Utils::InitGenesisValidator(InitGenesisValidator(args)) => {
utils::init_genesis_validator(global_args, args)
}
Utils::ValidateGenesisTemplates(ValidateGenesisTemplates(args)) => {
utils::validate_genesis_templates(global_args, args)
}
Utils::SignGenesisTx(SignGenesisTx(args)) => {
utils::sign_genesis_tx(global_args, args)
}
},
}
Ok(())
Expand Down
27 changes: 16 additions & 11 deletions apps/src/bin/namada-node/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ use namada_apps::node::ledger;
pub fn main() -> Result<()> {
let (cmd, mut ctx) = cli::namada_node_cli()?;
if let Some(mode) = ctx.global_args.mode.clone() {
ctx.config.ledger.tendermint.tendermint_mode = mode;
if let Some(chain) = ctx.chain.as_mut() {
chain.config.ledger.tendermint.tendermint_mode = mode;
}
}
match cmd {
cmds::NamadaNode::Ledger(sub) => match sub {
cmds::Ledger::Run(cmds::LedgerRun(args)) => {
let wasm_dir = ctx.wasm_dir();
let chain_ctx = ctx.take_chain_or_exit();
let wasm_dir = chain_ctx.wasm_dir();

// Sleep until start time if needed
if let Some(time) = args.0 {
Expand All @@ -31,14 +34,16 @@ pub fn main() -> Result<()> {
}
}
}
ledger::run(ctx.config.ledger, wasm_dir);
ledger::run(chain_ctx.config.ledger, wasm_dir);
}
cmds::Ledger::Reset(_) => {
ledger::reset(ctx.config.ledger)
let chain_ctx = ctx.take_chain_or_exit();
ledger::reset(chain_ctx.config.ledger)
.wrap_err("Failed to reset Namada node")?;
}
cmds::Ledger::DumpDb(cmds::LedgerDumpDb(args)) => {
ledger::dump_db(ctx.config.ledger, args);
let chain_ctx = ctx.take_chain_or_exit();
ledger::dump_db(chain_ctx.config.ledger, args);
}
},
cmds::NamadaNode::Config(sub) => match sub {
Expand All @@ -47,18 +52,18 @@ pub fn main() -> Result<()> {
// In here, we just need to overwrite the default chain ID, in
// case it's been already set to a different value
if let Some(chain_id) = ctx.global_args.chain_id.as_ref() {
ctx.global_config.default_chain_id = chain_id.clone();
ctx.global_config.default_chain_id = Some(chain_id.clone());
ctx.global_config
.write(&ctx.global_args.base_dir)
.unwrap_or_else(|err| {
eprintln!("Error writing global config: {}", err);
eprintln!("Error writing global config: {err}");
cli::safe_exit(1)
});
tracing::debug!(
"Generated config and set default chain ID to \
{chain_id}"
);
}
tracing::debug!(
"Generated config and set default chain ID to {}",
&ctx.global_config.default_chain_id
);
}
},
}
Expand Down
Loading