Skip to content

Commit

Permalink
fix: prepare for --import-from=node0
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Nov 4, 2020
1 parent 6606a67 commit 7300c3a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
29 changes: 17 additions & 12 deletions packages/agoric-cli/lib/chain-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ export function finishCosmosGenesis({ genesisJson, exportedGenesisJson }) {
const genesis = JSON.parse(genesisJson);
const exported = exportedGenesisJson ? JSON.parse(exportedGenesisJson) : {};

// We upgrade from export data.
const { app_state: exportedAppState } = exported;
if (exportedAppState) {
genesis.app_state = exportedAppState;
}

// Remove IBC and capability state.
// TODO: This needs much more support to preserve contract state
// between exports in order to be able to carry forward IBC conns.
delete genesis.app_state.capability;
delete genesis.app_state.ibc;

genesis.app_state.staking.params.bond_denom = STAKING_DENOM;

// We scale this parameter according to our own block cadence, so
Expand All @@ -62,23 +74,16 @@ export function finishCosmosGenesis({ genesisJson, exportedGenesisJson }) {
// Reduce the cost of a transaction.
genesis.app_state.auth.params.tx_size_cost_per_byte = '1';

// We upgrade from export data.
const { app_state: exportedAppState = {} } = exported;
for (const state of Object.keys(exportedAppState)) {
genesis.app_state[state] = exportedAppState[state];
}

// Remove IBC and capability state.
// TODO: This needs much more support to preserve contract state
// between exports in order to be able to carry forward IBC conns.
delete genesis.app_state.capability;
delete genesis.app_state.ibc;

// Use the same consensus_params.
if ('consensus_params' in exported) {
genesis.consensus_params = exported.consensus_params;
}

// Give some continuity between chains.
if ('initial_height' in exported) {
genesis.initial_height = exported.initial_height;
}

// Should be equal to the block cadence in milliseconds, according to @melekes
// on Discord.
genesis.consensus_params.block.time_iota_ms = `${BLOCK_CADENCE_S * 1000}`;
Expand Down
4 changes: 4 additions & 0 deletions packages/deployment/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ docker-build-solo:
docker-build-deployment:
docker build -t agoric/deployment:latest --file=Dockerfile.deployment ./docker

# Just push $(TAG)
docker-push-only:
$(MAKE) docker-push DONT_PUSH_LATEST=: TAG=$(TAG)

docker-push: docker-push-base docker-push-solo docker-push-setup \
docker-push-ibc-alpha docker-push-deployment

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
- name: "Create exported-genesis.json"
become: yes
become_user: "{{ service }}"
shell: "{{ service }} export --for-zero-height > /home/{{ service }}/exported-genesis.json"
register: exported
shell: "{{ service }} export > /home/{{ service }}/exported-genesis.json 2>&1"
failed_when: False

- name: "Fetch {{ exported | default('exported') }}/*/exported-genesis.json"
fetch:
dest: "{{ exported | default('exported') }}/{{ inventory_hostname }}/"
flat: yes
src: "/home/{{ service }}/exported-genesis.json"
when: exported.rc == 0
20 changes: 10 additions & 10 deletions packages/deployment/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,14 @@ show-config display the client connection parameters
const importFlags = [];
const importFrom = subOpts['import-from'];
if (importFrom) {
console.error(
chalk.redBright('FIXME: --import-from is not yet supported!'),
);
return 1;
if (importFrom.startsWith('node') && !importFrom.endsWith('/')) {
// Export from all nodes.
await needReMain(['play', 'export-genesis']);
}

// Add the exported prefix if not absolute.
/*
const absImportFrom = resolve(`${SETUP_HOME}/exported`, importFrom);
importFlags.push(`--import-from=${absImportFrom}`);
*/
}

if (subOpts.bump) {
Expand Down Expand Up @@ -422,9 +421,11 @@ show-config display the client connection parameters
await needReMain(['wait-for-any']);

// Add the bootstrap validators.
await guardFile(`${COSMOS_DIR}/validators.stamp`, () =>
needReMain(['play', 'cosmos-validators']),
);
if (!importFrom) {
await guardFile(`${COSMOS_DIR}/validators.stamp`, () =>
needReMain(['play', 'cosmos-validators']),
);
}

console.error(
chalk.black.bgGreenBright.bold(
Expand All @@ -437,7 +438,6 @@ show-config display the client connection parameters

case 'dweb': {
await inited();
const networkName = await trimReadFile('network.txt');
const cfg = await needBacktick(`${shellEscape(progname)} show-config`);
process.stdout.write(`${chalk.yellow(cfg)}\n`);

Expand Down

0 comments on commit 7300c3a

Please sign in to comment.