Skip to content

Commit

Permalink
feat: Update neard localnet command to support archival and rpc nodes…
Browse files Browse the repository at this point in the history
… in post-stateless-validation (#11797)

(This change is to test archival nodes in a localnet for any archival
node improvements.)

The `neard localnet` command does not have flexibility to configure
archival and RPC nodes separately from the other validator and
non-validator nodes. For example today `--archival-nodes` is a boolean
flag and makes all nodes archival nodes. Similarly `--tracked-shards`
specify the shards tracked by all the nodes. Thus, there is no way to
have some validator nodes tracking no shards (single-shard tracking) and
separate archival/RPC nodes tracking all shards. Especially after
stateless validation gets effective, validators will start tracking
single/some shards, while we can archival and RPC nodes to track all
shards.

To support this for localnet setup, we add flags to the `neard localnet`
command to create non-validator nodes configured as archival and RPC
nodes. These nodes track all shards even if the validators run with
single-shard tracking enabled. This allows to run a `neard localnet`
command, for example, to have 4 validator nodes to track single-shard, 1
archival node to track all shards, and 1 RPC node to track all shards as
follows:

```
neard localnet \
  --validators 4 \               # node0..node3 will be validator nodes.
  --non-validators-archival 1 \  # node4 will be archival non-validator node.
  --non-validators-rpc 1 \       # node5 will be RPC non-validator node.
  --non-validators 2 \           # node6..node7 will non-validators that can be custom-configured .
  --shards 4 \
  --tracked-shards "none"
```

Other changes:
- Remove `--archive` flag, since it is not used in rest of the code and
instead the new flag should be used.
- Remove the function param `local_port` since it is always true.
- Rename functions from `create_testnet_config...` to
`create_localnet_config...`.

- NEXT: We will update the appropriate code (eg. nayduck tests) in
follow-up PRs to use the new flags `--non-validators-archival` and
--non-validators-rpc` instead of setting up a regular non-validator node
and updating its config separately.

---------

Co-authored-by: Aleksandr Logunov <[email protected]>
Co-authored-by: Razvan Barbascu <[email protected]>
Co-authored-by: Marcelo Diop-Gonzalez <[email protected]>
Co-authored-by: Viktar Makouski <[email protected]>
Co-authored-by: Viktar Makouski <[email protected]>
Co-authored-by: caseylove <[email protected]>
Co-authored-by: Andrea <[email protected]>
Co-authored-by: Waclaw Banasik <[email protected]>
Co-authored-by: Andrei Kashin <[email protected]>
Co-authored-by: Adam Chudaś <[email protected]>
Co-authored-by: Bowen Wang <[email protected]>
  • Loading branch information
12 people authored Jul 18, 2024
1 parent 8fee337 commit c422664
Show file tree
Hide file tree
Showing 3 changed files with 380 additions and 107 deletions.
14 changes: 11 additions & 3 deletions integration-tests/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use near_primitives::types::{AccountId, Balance, NumSeats};
use near_primitives::validator_signer::ValidatorSigner;
use near_primitives::views::AccountView;
use near_vm_runner::ContractCode;
use nearcore::config::{create_testnet_configs, create_testnet_configs_from_seeds, Config};
use nearcore::config::{create_localnet_configs, create_localnet_configs_from_seeds, Config};
use nearcore::NearConfig;
use testlib::runtime_utils::{alice_account, bob_account};

Expand Down Expand Up @@ -147,14 +147,22 @@ fn near_configs_to_node_configs(

pub fn create_nodes(num_nodes: usize, prefix: &str) -> Vec<NodeConfig> {
let (configs, validator_signers, network_signers, genesis, _) =
create_testnet_configs(1, num_nodes as NumSeats, 0, prefix, true, false, vec![]);
create_localnet_configs(1, num_nodes as NumSeats, 0, 0, 0, prefix, vec![]);
near_configs_to_node_configs(configs, validator_signers, network_signers, genesis)
}

pub fn create_nodes_from_seeds(seeds: Vec<String>) -> Vec<NodeConfig> {
let code = near_test_contracts::rs_contract();
let (configs, validator_signers, network_signers, mut genesis) =
create_testnet_configs_from_seeds(seeds.clone(), 1, 0, true, false, vec![]);
create_localnet_configs_from_seeds(
seeds.clone(),
1,
seeds.len() as NumSeats,
0,
0,
0,
vec![],
);
genesis.config.gas_price_adjustment_rate = Ratio::from_integer(0);
for seed in seeds {
let mut found_account_record = false;
Expand Down
Loading

0 comments on commit c422664

Please sign in to comment.