Skip to content

Commit

Permalink
feat(cosmic-swingset): add swingset 'activityhash' to state vector
Browse files Browse the repository at this point in the history
This 'activityhash' covers all kernel state changes, so if any two validators
diverge, their activityhashes should diverge too. By storing them into the
cosmos-sdk state vector, the AppHashes will diverage as well, causing at
least one of them to fall out of consensus. This should let us catch
divergence as soon as possible.

closes #3442
  • Loading branch information
warner committed Aug 13, 2021
1 parent 99d8f6e commit 5247326
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/cosmic-swingset/src/chain-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ export default async function main(progname, args, { env, homedir, agcc }) {
},
exportMailbox,
);
function setActivityhash(activityhash) {
const msg = stringify({
method: 'set',
key: 'activityhash',
value: activityhash,
});
chainSend(portNums.storage, msg);
}
function doOutboundBridge(dstID, obj) {
const portNum = portNums[dstID];
if (portNum === undefined) {
Expand Down Expand Up @@ -245,6 +253,7 @@ export default async function main(progname, args, { env, homedir, agcc }) {
const s = await launch(
stateDBDir,
mailboxStorage,
setActivityhash,
doOutboundBridge,
vatconfig,
argv,
Expand Down
4 changes: 4 additions & 0 deletions packages/cosmic-swingset/src/launch-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function neverStop() {
export async function launch(
kernelStateDBDir,
mailboxStorage,
setActivityhash,
bridgeOutbound,
vatconfig,
argv,
Expand Down Expand Up @@ -232,6 +233,9 @@ export async function launch(
blockHeight,
blockTime,
});
if (setActivityhash) {
setActivityhash(controller.getActivityhash());
}
}

async function saveChainState() {
Expand Down
1 change: 1 addition & 0 deletions packages/cosmic-swingset/src/sim-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export async function connectToFakeChain(basedir, GCI, delay, inbound) {
stateDBdir,
mailboxStorage,
undefined,
undefined,
vatconfig,
argv,
GCI, // debugName
Expand Down

0 comments on commit 5247326

Please sign in to comment.