-
Notifications
You must be signed in to change notification settings - Fork 214
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
set roundId to 1 & write to vstorage at start #10291
Changes from 2 commits
84d09c7
c302226
018cf59
1bc091a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ const V3_NO_DATA_ERROR = 'No data present'; | |
/** @type {bigint} */ | ||
export const ROUND_MAX = BigInt(2 ** 32 - 1); | ||
|
||
const trace = makeTracer('RoundsM', false); | ||
const trace = makeTracer('RoundsM', true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean to turn that on in production? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I went back and forth. I settled on yes, because we're diagnosing issues here, and it would give some added visibility. |
||
|
||
/** @param {bigint} roundId */ | ||
const validRoundId = roundId => { | ||
|
@@ -172,10 +172,13 @@ export const prepareRoundsManagerKit = baggage => | |
rounds, | ||
unitIn, | ||
}; | ||
|
||
const roundId = 0n; | ||
|
||
return { | ||
...immutable, | ||
lastValueOutForUnitIn: null, | ||
reportingRoundId: 0n, | ||
reportingRoundId: roundId, | ||
}; | ||
}, | ||
{ | ||
|
@@ -600,8 +603,8 @@ export const prepareRoundsManagerKit = baggage => | |
|
||
/** | ||
* a method to provide all current info oracleStatuses need. Intended | ||
* only only to be callable by oracleStatuses. Not for use by contracts | ||
* to read state. | ||
* only to be callable by oracleStatuses. Not for use by contracts to | ||
* read state. | ||
* | ||
* @param {OracleStatus} status | ||
* @param {Timestamp} blockTimestamp | ||
|
@@ -728,4 +731,50 @@ export const prepareRoundsManagerKit = baggage => | |
}, | ||
}, | ||
}, | ||
{ | ||
finish: ({ state }) => { | ||
const { details, rounds, timerPresence } = state; | ||
// Zero is treated as special as roundId and in times. It's hard to | ||
// avoid on restart and in tests, so make 1 the minimum | ||
|
||
const firstRound = 1n; | ||
state.reportingRoundId = firstRound; | ||
details.init( | ||
firstRound, | ||
harden({ | ||
submissions: [], | ||
maxSubmissions: state.maxSubmissionCount, | ||
minSubmissions: state.minSubmissionCount, | ||
roundTimeout: state.timeout, | ||
}), | ||
); | ||
|
||
// Cannot await in first crank. Fail if no timestamp available | ||
void E.when( | ||
E(timerPresence).getCurrentTimestamp(), | ||
nowMaybe => { | ||
const now = | ||
TimeMath.compareAbs(nowMaybe, 1n) < 0 | ||
? TimeMath.coerceTimestampRecord(1n, nowMaybe.timerBrand) | ||
: nowMaybe; | ||
|
||
const round = harden({ | ||
answer: 0n, | ||
startedAt: now, | ||
updatedAt: 0n, | ||
answeredInRound: 0n, | ||
}); | ||
rounds.init(firstRound, round); | ||
|
||
// In case this is a replacement priceFeed, set roundId in vstorage. | ||
void state.latestRoundPublisher.write({ | ||
roundId: firstRound, | ||
startedAt: round.startedAt, | ||
startedBy: 'uninitialized', | ||
}); | ||
}, | ||
reason => Fail`need a timestamp to start roundsManager ${reason}`, | ||
); | ||
}, | ||
}, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should test before
setPrice
(and after the core-eval) to match the problem we saw in practice, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a test before that shows that roundID is 1.
The test on line 148 (it'll move, so early in '2. trigger liquidation by changing price') checks after the coreEval and before setting prices again. Do you want another check in this test ('setupVaults')?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm. I think I wasn't reading this quite right. no, I don't see any more tests that I want.