Skip to content

Commit 65a1c62

Browse files
committed
fix: accommodate initial_height == "1" as well as > "1"
1 parent 65c6d74 commit 65a1c62

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

packages/cosmic-swingset/Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
REPOSITORY = agoric/cosmic-swingset
22
CHAIN_ID = agoric
33
INITIAL_TOKENS = 1000000000000uag
4+
INITIAL_HEIGHT = 17
5+
GENESIS_TIME = $(shell TZ=UTC date +%Y-%m-%dT%H:%M:%SZ)
46

57
GOSRC = ../../golang/cosmos
68

@@ -65,7 +67,7 @@ scenario2-setup-nobuild:
6567
$(AGCH) --home=t1/n0 validate-genesis
6668
../agoric-cli/bin/agoric set-defaults --export-metrics ag-chain-cosmos t1/n0/config
6769
# Set the chain address in all the ag-solos.
68-
jq '. + { initial_height: "17" }' t1/n0/config/genesis.json > t1/n0/config/genesis2.json
70+
jq '. + { genesis_time: "$(GENESIS_TIME)", initial_height: "$(INITIAL_HEIGHT)" }' t1/n0/config/genesis.json > t1/n0/config/genesis2.json
6971
mv t1/n0/config/genesis2.json t1/n0/config/genesis.json
7072
$(MAKE) set-local-gci-ingress
7173

packages/cosmic-swingset/lib/block-manager.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ export default function makeBlockManager({
2121
saveOutsideState,
2222
savedActions,
2323
savedHeight,
24+
bootstrapBlock,
2425
verboseBlocks = false,
2526
}) {
26-
let computedHeight = savedHeight === 0 ? undefined : savedHeight;
27+
let computedHeight = bootstrapBlock ? undefined : savedHeight;
2728
let runTime = 0;
2829

2930
async function kernelPerformAction(action) {
@@ -172,7 +173,7 @@ export default function makeBlockManager({
172173

173174
// Advance our saved state variables.
174175
savedActions = currentActions;
175-
if (computedHeight === undefined) {
176+
if (computedHeight === undefined && action.blockHeight > 1) {
176177
// Genesis height is the same as the first block, so we
177178
// need to adjust.
178179
computedHeight = action.blockHeight - 1;

packages/cosmic-swingset/lib/launch-chain.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ export async function launch(
152152
schedulerBlockTimeHistogram.record((now - blockStart) / 1000);
153153
}
154154

155-
let firstBlock;
155+
let bootstrapBlock;
156156
async function endBlock(_blockHeight, _blockTime) {
157157
let numCranks = FIXME_MAX_CRANKS_PER_BLOCK;
158-
if (firstBlock) {
158+
if (bootstrapBlock) {
159159
// This is the initial block, we need to finish processing the entire
160160
// bootstrap before opening for business.
161161
numCranks = Infinity;
162-
firstBlock = false;
162+
bootstrapBlock = false;
163163
}
164164
await crankScheduler(numCranks);
165165
}
@@ -201,9 +201,9 @@ export async function launch(
201201
}
202202

203203
const [savedHeight, savedActions, savedChainSends] = JSON.parse(
204-
storage.get(SWING_STORE_META_KEY) || '[0, [], []]',
204+
storage.get(SWING_STORE_META_KEY) || '[-1, [], []]',
205205
);
206-
firstBlock = savedHeight === 0;
206+
bootstrapBlock = savedHeight < 0;
207207

208208
return {
209209
deliverInbound,
@@ -214,6 +214,7 @@ export async function launch(
214214
saveChainState,
215215
saveOutsideState,
216216
savedHeight,
217+
bootstrapBlock,
217218
savedActions,
218219
savedChainSends,
219220
};

0 commit comments

Comments
 (0)