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

feat(cosmic-swingset): add swingset 'crankhash' to state vector #3626

Merged
merged 2 commits into from
Aug 13, 2021
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
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
7 changes: 7 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 @@ -218,6 +219,9 @@ export async function launch(
type: 'cosmic-swingset-bootstrap-block-finish',
blockTime,
});
if (setActivityhash) {
setActivityhash(controller.getActivityhash());
}
}

async function endBlock(blockHeight, blockTime) {
Expand All @@ -232,6 +236,9 @@ export async function launch(
blockHeight,
blockTime,
});
if (setActivityhash) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why is this not a part of the above bootstrapBlock function as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, good question, I hadn't thought about it. I think that'd be fine, it would capture/signal any divergence during the initial controller.run() that sets up the javascript world. Without it, we'd signal that divergence during the second block instead of during the first. The activityhash is updated for every commitCrank (including the one that initializeKernel() does, making its starting value effectively a hash of the config object), so even if we don't read it at that point, it's still sensitive to the initial state.

I'll add that.

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