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

Keep SwingSet state in the validator state dir #434

Merged
merged 1 commit into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion packages/cosmic-swingset/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ typings/

# next.js build output
.next
ag-cosmos-chain-state.json
lib/git-revision.txt
agoric/
/binding.gyp
4 changes: 1 addition & 3 deletions packages/cosmic-swingset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ all: build-cosmos install

scenario0-setup:
rm -rf ~/.ag-chain-cosmos
rm -f ag-cosmos-chain-state.json
python3 -mvenv ve3
ve3/bin/pip install setup-solo/

Expand All @@ -49,7 +48,6 @@ scenario1-run-client:
AGC = ./lib/ag-chain-cosmos
scenario2-setup: build-cosmos
rm -rf ~/.ag-chain-cosmos
rm -f ag-cosmos-chain-state.json
$(AGC) init scenario2-chain --chain-id=$(CHAIN_ID)
rm -rf t1
mkdir t1
Expand Down Expand Up @@ -148,7 +146,7 @@ start-ag-solo:
cd t1 && ../bin/ag-solo start

show-local-gci:
@./calc-gci.js ~/.ag-cosmos-chain/config/genesis.json
@./calc-gci.js ~/.ag-chain-cosmos/config/genesis.json

set-local-gci-ingress:
set -e; \
Expand Down
31 changes: 27 additions & 4 deletions packages/cosmic-swingset/lib/ag-chain-cosmos
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,33 @@ const BEGIN_BLOCK = 'BEGIN_BLOCK';
const DELIVER_INBOUND = 'DELIVER_INBOUND';
const AG_COSMOS_INIT = 'AG_COSMOS_INIT';

// TODO: use the 'basedir' pattern, or find the cosmos state directory
// (~/.ag-chain-cosmos ?), or something anything better than scribbling
// into the current directory.
const stateFile = 'ag-cosmos-chain-state.json';
// TODO: use the 'basedir' pattern

// Try to determine the cosmos chain home.
function getFlagValue(flagName, deflt) {
let flagValue = deflt;
const envValue = process.env[`AG_CHAIN_COSMOS_${flagName.toUpperCase()}`];
if (envValue !== undefined) {
flagValue = envValue;
}
const flag = `--${flagName}`;
const flagEquals = `--${flagName}=`;
for (let i = 0; i < process.argv.length; i += 1) {
const arg = process.argv[i];
if (arg === flag) {
i += 1;
flagValue = process.argv[i];
} else if (arg.startsWith(flagEquals)) {
flagValue = arg.substr(flagEquals.length);
}
}
return flagValue;
}

// We try to find the actual cosmos state directory (default=~/.ag-chain-cosmos), which
// is better than scribbling into the current directory.
const cosmosHome = getFlagValue('home', `${process.env.HOME}/.ag-chain-cosmos`);
const stateFile = `${cosmosHome}/data/ag-cosmos-chain-state.json`;

const { launch } = require('./launch-chain');
const path = require('path');
Expand Down