Skip to content

Commit 5b4aff6

Browse files
committed
feat(cosmic-swingset): add swingset 'activityhash' to state vector
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
1 parent ef3723e commit 5b4aff6

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

packages/cosmic-swingset/src/chain-main.js

+9
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ export default async function main(progname, args, { env, homedir, agcc }) {
209209
},
210210
exportMailbox,
211211
);
212+
function setActivityhash(activityhash) {
213+
const msg = stringify({
214+
method: 'set',
215+
key: 'activityhash',
216+
value: activityhash,
217+
});
218+
chainSend(portNums.storage, msg);
219+
}
212220
function doOutboundBridge(dstID, obj) {
213221
const portNum = portNums[dstID];
214222
if (portNum === undefined) {
@@ -245,6 +253,7 @@ export default async function main(progname, args, { env, homedir, agcc }) {
245253
const s = await launch(
246254
stateDBDir,
247255
mailboxStorage,
256+
setActivityhash,
248257
doOutboundBridge,
249258
vatconfig,
250259
argv,

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

+4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ async function buildSwingset(
8888
export async function launch(
8989
kernelStateDBDir,
9090
mailboxStorage,
91+
setActivityhash,
9192
bridgeOutbound,
9293
vatconfig,
9394
argv,
@@ -188,6 +189,9 @@ export async function launch(
188189
blockHeight,
189190
blockTime,
190191
});
192+
if (setActivityhash) {
193+
setActivityhash(controller.getActivityhash());
194+
}
191195
}
192196

193197
async function saveChainState() {

packages/cosmic-swingset/src/sim-chain.js

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export async function connectToFakeChain(basedir, GCI, delay, inbound) {
7777
stateDBdir,
7878
mailboxStorage,
7979
undefined,
80+
undefined,
8081
vatconfig,
8182
argv,
8283
GCI, // debugName

0 commit comments

Comments
 (0)