@neutron-org/cosmopark
v1.7.14
Published
Start and interact with your cosmos park
Downloads
265
Maintainers
Keywords
Readme
Cosmopark
This one is a tool to run your own Cosmos (Cosmos-SDK based blockchains). It supports standard cosmos-sdk chains and ICS (as for now tested with Neutron).
Usage
CLI
- prepare docker images (or just use some from the dockerhub)
- create config (see Configuration)
- run
npx @neutron-org/cosmopark start your_config.toml
Using as a library from integration tests
You can use cosmopark as a library in your integration tests. It allows you to have several environments running in parallel.
Start basic environment
const config: CosmoparkConfig = {
context,
networks: {
...networksConfigs,
},
relayers: {
...relayersConfigs,
},
master_mnemonic: wallets.master,
loglevel: 'info',
wallets: {
demo1: { mnemonic: `mnemonic1`, balance: '1000000000' },
demo2: { mnemonic: `mnemonic2`, balance: '1000000000' },
demo3: { mnemonic: `mnemonic3`, balance: '1000000000' },
},
};
const instance = await cosmopark.create(config);
and instance will have the following structure and methods:
class Cosmopark {
private context;
private filename;
logLevel: pino.Level;
ports: Record<string, CosmoparkNetworkPortOutput>;
config: CosmoparkConfig;
networks: Record<string, CosmoparkChain>;
relayers: CosmoparkHermesRelayer[];
custom_containers: CosmoparkCustomContainer[];
constructor(config: CosmoparkConfig);
static create(config: CosmoparkConfig): Promise<Cosmopark>;
awaitFirstBlock: () => Promise<void>;
pauseRelayer(type: 'hermes' | 'neutron', index: number): Promise<void>;
resumeRelayer(type: 'hermes' | 'neutron', index: number): Promise<void>;
restartRelayer(type: 'hermes' | 'neutron', index: number): Promise<void>;
pauseNetwork(network: string): Promise<void>;
executeInNetwork: (network: string, command: string) => Promise<IDockerComposeResult>;
stop: () => Promise<void>;
generateDockerCompose: () => void;
validateConfig: (config: CosmoparkConfig) => void;
}
Having this instance you can control your environment as well as get some info using ports populated after the start of the environment.
Networks configuration
There are two types of networks supported: ics
and standard
. ICS network doesn't have validators and is run in standalone mode. Standard network has validators and you can configure validators count and stake per validator.
const icsChain = {
loglevel: 'debug',
trace: true,
public: true,
type: 'ics',
upload: [
'./artifacts/contracts',
'./artifacts/contracts_thirdparty',
'./artifacts/scripts/init-neutrond.sh',
],
post_init: ['CHAINID=ntrntest CHAIN_DIR=/opt /opt/init-neutrond.sh'],
genesis_opts: {
'app_state.crisis.constant_fee.denom': 'untrn',
},
config_opts: {
'consensus.timeout_commit': '500ms',
'consensus.timeout_propose': '500ms',
},
app_opts: {
'api.enable': 'true',
'api.address': 'tcp://0.0.0.0:1317',
'api.swagger': 'true',
'grpc.enable': 'true',
'grpc.address': '0.0.0.0:9090',
'minimum-gas-prices': '0.0025untrn',
'rosetta.enable': 'true',
'telemetry.prometheus-retention-time': 1000,
},
},
It is an example of the ICS network configuration. Here you can see the artifacts and init scripts that will be uploaded to the container, genesis options, and some additional options for the chain.
cosnt gaiaChain = {
binary: 'gaiad',
chain_id: 'testgaia',
denom: 'stake',
image: 'gaia-test',
prefix: 'cosmos',
trace: true,
validators: 2,
validators_balance: ['1900000000', '100000000'],
genesis_opts: {
'app_state.slashing.params.downtime_jail_duration': '10s',
'app_state.slashing.params.signed_blocks_window': '10',
'app_state.slashing.params.min_signed_per_window': '0.9',
'app_state.slashing.params.slash_fraction_downtime': '0.1',
'app_state.staking.params.validator_bond_factor': '10',
'app_state.staking.params.unbonding_time': '1814400s',
'app_state.mint.minter.inflation': '0.9',
'app_state.mint.params.inflation_max': '0.95',
'app_state.mint.params.inflation_min': '0.5',
'app_state.interchainaccounts.host_genesis_state.params.allow_messages': [
'*',
],
},
config_opts: {
'rpc.laddr': 'tcp://0.0.0.0:26657',
},
app_opts: {
'api.enable': true,
'api.address': 'tcp://0.0.0.0:1317',
'api.swagger': true,
'grpc.enable': true,
'grpc.address': '0.0.0.0:9090',
'minimum-gas-prices': '0stake',
'rosetta.enable': true,
},
commands: {
addGenesisAccount: 'genesis add-genesis-account',
gentx: 'genesis gentx',
collectGenTx: 'genesis collect-gentxs'
},
upload: redefinedParams.upload || ['./artifacts/scripts/init-gaia.sh'],
post_start: redefinedParams.postUpload || [
`/opt/init-gaia.sh > /opt/init-gaia.log 2>&1`,
],
}
This is an example of the standard network configuration. Here you can see the validators count, their balance, and genesis/app options. Also, you can see how to redefine commands to add genesis accounts and generate gentx files.
const networksConfigs = {
icsChain,
gaiaChain,
}
Custom containers
You can run custom containers in your environment. You can have an idea (it's pretty simmilar to docker-compose) of how to configure them from the following type:
export type CosmoparkCustomContainer = {
name: string;
image: string;
entrypoint: string;
ports: string[];
depends_on: string[];
volumes: string[];
};
Relayers
Cosmopark can run hermes and neutron-query-relayer. You can configure them in the following way:
const relayersConfig = {
hermes: {
balance: '1000000000',
binary: 'hermes',
config: {
'chains.0.gas_multiplier': 1.2,
'chains.0.trusting_period': '112h0m0s',
'chains.0.unbonding_period': '336h0m0s',
'chains.1.gas_multiplier': 1.2,
'chains.1.trusting_period': '168h0m0s',
},
image: `hermes-test`,
log_level: 'trace',
type: 'hermes',
},
neutron: {
balance: '1000000000',
binary: 'neutron-query-relayer',
image: `neutron-query-relayer-test`,
log_level: 'debug',
type: 'neutron',
},
};
Configuration
Please find TOML sample or JSON sample