Skip to content

Commit

Permalink
fix: merge repair
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Sep 16, 2022
1 parent b38f158 commit ab15e4b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
34 changes: 33 additions & 1 deletion packages/cosmic-swingset/src/launch-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,11 @@ export async function launch({
`Cannot run a bootstrap block at height ${action.blockHeight}`,
);
}
// This nested await is safe because "terminal-control-flow".
//
// It occurs at the top level of a case of an unbalanced,
// but top level terminal switch. Nothing happens after the switch.
// eslint-disable-next-line @jessie.js/no-nested-await
await processAction(action);
break;
}
Expand All @@ -533,6 +538,9 @@ export async function launch({

// Save the kernel's computed state just before the chain commits.
const start2 = Date.now();
// This nested await is safe because "terminal-control-flow".
//
// eslint-disable-next-line @jessie.js/no-nested-await
await saveOutsideState(computedHeight, action.blockTime);

const saveTime = Date.now() - start2;
Expand Down Expand Up @@ -588,15 +596,39 @@ export async function launch({
// END_BLOCK, but still reentrancy-protected

// Process our begin, queued actions, and end.
//
// This nested await is safe because "terminal-control-flow".
//
// It occurs at the top level of a branch of an unbalanced
// but terminal if, that is top level and terminal within a case
// of a top level unbalanced but terminal and top level switch.
// Thus, nothing happens after completion of the immeiately
// enclosing if.
// eslint-disable-next-line @jessie.js/no-nested-await
await processAction(beginBlockAction); // BEGIN_BLOCK
for (const a of actionQueue.consumeAll()) {
// eslint-disable-next-line no-await-in-loop
// This nested await is safe because "terminal-combined-control-flow".
//
// Taking the previous statement, this loop, and the subsequent
// statement together,
// these represent a non - empty sequence of calls to
// `processAction`, where each happens in a separate turn. Even
// if this loop per-se executes zero times, the overall activity
// has effectively had at least two iterations, with one turn for
// each beyond the first.
// eslint-disable-next-line no-await-in-loop, @jessie.js/no-nested-await
await processAction(a);
}
// This nested await is safe because "terminal-control-flow".
//
// eslint-disable-next-line @jessie.js/no-nested-await
await processAction(action); // END_BLOCK

// We write out our on-chain state as a number of chainSends.
const start = Date.now();
// This nested await is safe because "terminal-control-flow".
//
// eslint-disable-next-line @jessie.js/no-nested-await
await saveChainState();
chainTime = Date.now() - start;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const start = async zcf => {
}
// This await almost certainly does not do what was intended.
// `oncePerBlock()` returns an async generator, not a promise,
// and does nothing observable affectful to anyone not pulling on
// and does nothing observably effectful to anyone not pulling on
// the generator, which this code drops. AFAICT, this code is
// equivalent to `await null;`. It imposes a non-delayed turn boundary
// and does nothing else.
Expand Down

0 comments on commit ab15e4b

Please sign in to comment.