Skip to content

Commit

Permalink
fix: proper error handling for period submission. (#363)
Browse files Browse the repository at this point in the history
We were prematurely marking the period as submitted (in updatePeriod).
The code which was supposed to do that in `submitPeriod` was broken and never really called.

Additionally, logging period submission errors now.
  • Loading branch information
troggy authored Nov 19, 2019
1 parent 88d337d commit d17c86d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/block/updatePeriod.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module.exports = async (state, chainInfo, bridgeState, sender) => {
bridgeState.periodHeights[pendingPeriodRoot],
bridgeState
);
bridgeState.submittedPeriods[pendingPeriodRoot] = true;
} catch (err) {
/* istanbul ignore next */
logPeriod(`submit period: ${err}`);
Expand Down
15 changes: 7 additions & 8 deletions src/txHelpers/submitPeriod.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,17 @@ module.exports = async (period, slots, height, bridgeState) => {
),
bridgeState.operatorContract.options.address,
bridgeState.account
).catch(
/* istanbul ignore next */ () => {
delete inFlight[periodRoot];
logError(height);
}
);
).catch((e) => {
logPeriod('submitPeriod error', e);
delete inFlight[periodRoot];
logError(height);
});

tx.then(receipt => {
logPeriod('submitPeriod tx', receipt);
delete inFlight[periodRoot];
if (receipt && receipt.status === 1) {
bridgeState.submittedPeriod[periodRoot] = true;
if (receipt && receipt.status) {
bridgeState.submittedPeriods[periodRoot] = true;
}
});
}
Expand Down

0 comments on commit d17c86d

Please sign in to comment.