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

set roundId to 1 & write to vstorage at start #10291

Merged
merged 4 commits into from
Oct 18, 2024
Merged

Conversation

Chris-Hibbert
Copy link
Contributor

refs: #9886

Description

Some tests in DevNet indicate that the Oracles need the roundID in vstorage to be reset so they can sync.

Security Considerations

Not a security issue.

Scaling Considerations

Not directly a scaling concern. (see #8400).

Documentation Considerations

not user visible. It would be nice if the protocol between oracles and fluxAggregators were documented somewhere

Testing Considerations

updated the a3p tests to increment the roundId before the upgrade and show that this upgrade resets it.

Upgrade Considerations

This change is to the fluxAggregator which is already being started afresh in this proposal.

@Chris-Hibbert Chris-Hibbert added contract-upgrade oracle Related to on-chain oracles. force:integration Force integration tests to run on PR next-release about next agoric-sdk or endo release labels Oct 17, 2024
@Chris-Hibbert Chris-Hibbert self-assigned this Oct 17, 2024
@Chris-Hibbert Chris-Hibbert requested a review from a team as a code owner October 17, 2024 00:31
Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

I'm pretty sure parts of this are not right; not certain enough to request changes, though.

} = t.context;

await setupVaults(collateralBrandKey, managerIndex, setup);

const instancePre = agoricNamesRemotes.instance['ATOM-USD price feed'];

await priceFeedDrivers[collateralBrandKey].setPrice(15.99);

t.like(readLatest('published.priceFeed.ATOM-USD_price_feed.latestRound'), {
Copy link
Member

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?

Copy link
Contributor Author

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')?

Copy link
Member

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.

@@ -180,6 +180,9 @@ export const prepareFluxAggregatorKit = async (
}),
),
});
const now = await E(timerPresence).getCurrentTimestamp();
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we can put a remote call like that in the critical path to defining this kind. If this doesn't cause a null-upgrade test to fail, I think we're missing some coverage.

Define all exo classes/kits before any incoming method calls from other vats -- in the first "crank".
-- https://docs.agoric.com/guides/zoe/contract-upgrade.html#crank

How about a helper.startInitializingVstorage(timerPresence) thing that returns synchronously but asynchronously gets a timestamp and initializes vstorage?

const trace = makeTracer('RoundsM', false);
const trace = makeTracer('RoundsM', true);
Copy link
Member

Choose a reason for hiding this comment

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

Do you mean to turn that on in production?
(I don't object. I'm just checking that you didn't mean to turn it back off.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Comment on lines 278 to 283
const rounds = makeScalarBigMapStore('rounds', { durable: true });
const details = makeScalarBigMapStore('details', { durable: true });
// @ts-expect-error append-only except for reset
this.state.rounds = rounds;
// @ts-expect-error append-only except for reset
this.state.details = details;
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this already done in the init function? Are we clobbering these 2 map stores?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you're right. I will drop the externally invoked function, and "improve" the initializer.

// @ts-expect-error append-only except for reset
this.state.details = details;

details.init(
Copy link
Member

Choose a reason for hiding this comment

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

I'm not confident that I know the invariants of the state.details map stores. @michaelfig or @turadg are you able to tell from a quick look that this is OK?

answeredInRound: 0n,
});

rounds.init(roundId, round);
Copy link
Member

Choose a reason for hiding this comment

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

again, I'm not confident about this.

Copy link

cloudflare-workers-and-pages bot commented Oct 17, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1bc091a
Status: ✅  Deploy successful!
Preview URL: https://f37ffd68.agoric-sdk.pages.dev
Branch Preview URL: https://9886-resetroundid.agoric-sdk.pages.dev

View logs

Use a minimum start time and roundId of 1 because zero is treated as
an outlier in the code

There are places in the code and tests that compare roundId and round
start time to 0 and 1, so make it easier by starting from 1.

Refactored some tests, mostly by adding a round before the previous tests
to let state get past zero and one.

refactor: set roundId to 1 & write to vstorage at start

use a minimum start time and roundId of 1 because zero is treated as
an outlier in the code

There are places in the code and tests that compare roundId and round
start time to 0 and 1, so make it easier by starting from 1.

Refactored some tests, mostly by adding a round before the previous tests
to let state get past zero and one.
@Chris-Hibbert Chris-Hibbert requested a review from dckc October 17, 2024 22:22
@Chris-Hibbert
Copy link
Contributor Author

I dropped the changes in fluxAggregator, and did everything in roundsManager's finish().

The one issue is that the round record wants to include the time the round started, and we can't get the time in the first crank while creating the exo. I finished initializing in an E.when(). So the first price update can't happen until the time is received. But that's okay in practice since the oracles won't provide prices for the first round until they see the write to vstorage.

The invariants on round progression are enforced in supersedable, acceptingSubmissions, isNextRound, timedOut and validateOracleRound, among other places. Bleah.

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

presuming we test roundid between the core-eval and setPrice, as discussed

@Chris-Hibbert Chris-Hibbert added the automerge:squash Automatically squash merge label Oct 17, 2024
@mergify mergify bot merged commit 36d0670 into master Oct 18, 2024
80 checks passed
@mergify mergify bot deleted the 9886-resetRoundID branch October 18, 2024 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:squash Automatically squash merge contract-upgrade force:integration Force integration tests to run on PR next-release about next agoric-sdk or endo release oracle Related to on-chain oracles.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants