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

Updates for oracle bootstrap #4891

Merged
merged 12 commits into from
Mar 28, 2022
Merged

Updates for oracle bootstrap #4891

merged 12 commits into from
Mar 28, 2022

Conversation

michaelfig
Copy link
Member

@michaelfig michaelfig commented Mar 22, 2022

refs: #3595

Description

Several changes needed for bootstrapping the oracle price feeds. Aside from the price aggregator mechanics, here are some of the additional tweaks:

  • more AmountKind type propagation
  • scale the maximum mempool transaction size based on our changes to the maximum rpc message size
  • move startPriceAuthority into pre-economy bootstrap
  • make preapproved wallet bridge more useful (allow it to specify all the offer arguments)

Security Considerations

Documentation Considerations

Testing Considerations

Being tested with third parties as part of the oracle bootstrap process.

@michaelfig michaelfig self-assigned this Mar 22, 2022
@michaelfig michaelfig added the oracle Related to on-chain oracles. label Mar 22, 2022
@michaelfig michaelfig changed the base branch from master to mfig-cl-aggregator March 22, 2022 05:01
@michaelfig michaelfig force-pushed the mfig-oracle-bootstrap branch 2 times, most recently from 3d15399 to 55eeddc Compare March 25, 2022 23:11
@michaelfig michaelfig changed the base branch from mfig-cl-aggregator to master March 25, 2022 23:12
@michaelfig michaelfig marked this pull request as ready for review March 25, 2022 23:18
@michaelfig michaelfig requested a review from dckc March 25, 2022 23:18
@michaelfig
Copy link
Member Author

@dckc, can you please review? You were closer to many of these changes than the code owners.

@turadg, please review the AmountKind change and the contract updates.

Copy link
Member

@turadg turadg left a comment

Choose a reason for hiding this comment

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

@turadg, please review the AmountKind change and the contract updates.

Done. Thanks for the instructions and clean commits.

packages/ERTP/src/types.js Show resolved Hide resolved
@@ -238,8 +238,8 @@ export function buildRootObject(vatPowers) {
* @type {WalletBridge}
*/
const preapprovedBridge = Far('preapprovedBridge', {
addOffer(offer) {
return walletAdmin.addOffer(offer);
addOffer(offer, meta = undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

jsdoc better for optional.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I added a jsdoc to it. How do I indicate to the reader of this code (who isn't using Typescript) that the meta argument is optional without overriding the underlying default?

Copy link
Member

Choose a reason for hiding this comment

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

https://jsdoc.app/tags-param.html#optional-parameters-and-default-values

I don't know the types of those params so improvising:

/**
 * @param {Offer} offer
 * @param {Meta} [meta]
 */
addOffer(offer, meta) {

(default values can be specified with = but [meta=undefined] I think is redundant because undefined is what any param without an argument resolves to)

Comment on lines 267 to 268
// See if we have associated parameters or just a raw value.
const data = value.data || value;
Copy link
Member

Choose a reason for hiding this comment

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

why would it be one or the other?

}

// Adapt the notifier to push results.
const recurse = ({ value, updateCount }) => {
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 clear on what value can be. A type annotation would help. Is value readonly?

const scaledData = Math.floor(parseInt(data, 10) * scaleValueOut);
const newData = BigInt(scaledData);

if (value.data) {
Copy link
Member

Choose a reason for hiding this comment

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

line 268 sort of also has this condition. consider making one conditional:

const scaleData = (data) => BigInt(Math.floor(parseInt(data, 10) * scaleValueOut));

let result;
if (value.data) {
  // We have some associated parameters to push.
  result = { ...value, data: scaleData(value.data) };
} else {
  result = scaleData(value);
}
admin.pushResult(result).catch(console.error);


return zcf.makeInvitation(offerHandler, 'oracle invitation');
},
async initOracle(oracleInstance = undefined, query = undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

ditto on jsdoc as way to expression optional param

assert(quoteKit, X`Must initializeQuoteMint before adding an oracle`);

const oracleKey = oracleInstance || Far('fresh key');
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 understand this "fresh key". Will be be fresh each time it's constructed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Every call to Far creates a new object identity. I was leaning on default arguments to the Far function, but have made it more explicit now.

/** @type {LegacyMap<Instance, Set<OracleRecord>>} */
const instanceToRecords = makeLegacyMap('oracleInstance');
/**
* @typedef {{}} OracleKey
Copy link
Member

Choose a reason for hiding this comment

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

because TS is structurally typed, this make the type just documentation. Reading above it looks like

Suggested change
* @typedef {{}} OracleKey
* @typedef {Instance | Remotable<'fresh key'> } OracleKey

Copy link
Member Author

Choose a reason for hiding this comment

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

It is the type of an object without properties, which is what I want to indicate. Maybe this is where JSDoc types diverge from TS interfaces?

Copy link
Member

Choose a reason for hiding this comment

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

It is the type of an object without properties, which is what I want to indicate.

In that case, 👍 . I assumed an OracleKey was something more specific than an object without properties.

Maybe this is where JSDoc types diverge from TS interfaces?

I'm not aware of any divergences.

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 looked at each commit. I'm not quite confident enough to approve. I'd like to see responses to some of my questions or maybe talk about it with you.

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.

This looks like forward progress, to me.

I trust you'll consider @turadg 's comments as well.

@michaelfig michaelfig force-pushed the mfig-oracle-bootstrap branch from 3824d92 to d1c10bc Compare March 28, 2022 18:28
@michaelfig michaelfig added the automerge:no-update (expert!) Automatically merge without updates label Mar 28, 2022
@mergify mergify bot merged commit 1ee1739 into master Mar 28, 2022
@mergify mergify bot deleted the mfig-oracle-bootstrap branch March 28, 2022 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:no-update (expert!) Automatically merge without updates oracle Related to on-chain oracles.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants