Skip to content

Commit

Permalink
chore: upgrade 18 cherrypicks round 4 (#10645)
Browse files Browse the repository at this point in the history
### Description

Cherry-picks the following commits from master:
- #10551
(9e19321)
- #10635
(ad4e83e)
- #10615
(e596a01 )
- #10634
(a1856f3)

Since we plan to verify this rc on devnet rather than emerynet, there is
no apparent need for a new upgrade name. Not aware of any deployments on
devnet before so can reuse the previous upgrade name. However, skipping
emerynet is dependent on comms with the validators so I have added a new
upgrade name `agoric-ugprade-18-emerynet-rc3` just in case. Only added
to bypass the need for a new rc if for some reason emerynet validation
is needed anyways - best case scenario is that it remains unused.

commits added using git cherry-pick
  • Loading branch information
mujahidkay authored Dec 9, 2024
2 parents bdbf7c9 + 4292ab5 commit 89128d3
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 36 deletions.
4 changes: 3 additions & 1 deletion golang/cosmos/app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var upgradeNamesOfThisVersion = []string{
"agoric-upgrade-18-emerynet",
"agoric-upgrade-18-basic",
"agoric-upgrade-18-basic-2",
"agoric-upgrade-18-emerynet-rc3",
"agoric-upgrade-18-a3p",
}

Expand Down Expand Up @@ -59,7 +60,8 @@ func isPrimaryUpgradeName(name string) bool {
validUpgradeName("agoric-upgrade-18-basic"),
validUpgradeName("agoric-upgrade-18-a3p"):
return true
case validUpgradeName("agoric-upgrade-18-basic-2"):
case validUpgradeName("agoric-upgrade-18-basic-2"),
validUpgradeName("agoric-upgrade-18-emerynet-rc3"):
return false
default:
panic(fmt.Errorf("unexpected upgrade name %s", validUpgradeName(name)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const configurations = {
'agoric1qj07c7vfk3knqdral0sej7fa6eavkdn8vd8etf', // Simply Staking
'agoric10vjkvkmpp9e356xeh6qqlhrny2htyzp8hf88fk', // P2P
],
inBrandNames: ['ATOM', 'stTIA', 'stkATOM'],
inBrandNames: ['ATOM', 'stTIA', 'stkATOM', 'dATOM'],
},
EMERYNET: {
oracleAddresses: [
Expand Down
74 changes: 49 additions & 25 deletions packages/inter-protocol/src/auction/auctionBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ export const makeOfferSpecShape = (bidBrand, collateralBrand) => {
export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
const makeScaledBidBook = prepareScaledBidBook(baggage);
const makePriceBook = preparePriceBook(baggage);
// Brands that have or are making active quoteNotifier Observers
const observedBrands = new Set();

const AuctionBookStateShape = harden({
collateralBrand: M.any(),
Expand Down Expand Up @@ -454,38 +456,59 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
});
return state.bookDataKit.recorder.write(bookData);
},
observeQuoteNotifier() {
// Ensure that there is an observer monitoring the quoteNotifier. We
// assume that all failure modes for quoteNotifier eventually lead to
// fail or finish.
ensureQuoteNotifierObserved() {
const { state, facets } = this;
const { collateralBrand, bidBrand, priceAuthority } = state;

if (observedBrands.has(collateralBrand)) {
return;
}
observedBrands.add(collateralBrand);
trace('observing');

const quoteNotifier = E(priceAuthority).makeQuoteNotifier(
const quoteNotifierP = E(priceAuthority).makeQuoteNotifier(
AmountMath.make(collateralBrand, QUOTE_SCALE),
bidBrand,
);
void observeNotifier(quoteNotifier, {
updateState: quote => {
trace(
`BOOK notifier ${priceFrom(quote).numerator.value}/${
priceFrom(quote).denominator.value
}`,
);
state.updatingOracleQuote = priceFrom(quote);
},
fail: reason => {
trace(`Failure from quoteNotifier (${reason}) setting to null`);
// lack of quote will trigger restart
state.updatingOracleQuote = null;
},
finish: done => {
trace(
`quoteNotifier invoked finish(${done}). setting quote to null`,
);
// lack of quote will trigger restart

void E.when(
quoteNotifierP,
quoteNotifier =>
observeNotifier(quoteNotifier, {
updateState: quote => {
trace(
`BOOK notifier ${priceFrom(quote).numerator.value}/${
priceFrom(quote).denominator.value
}`,
);
state.updatingOracleQuote = priceFrom(quote);
},
fail: reason => {
trace(
`Failure from quoteNotifier (${reason}) setting to null`,
);
// lack of quote will trigger restart
state.updatingOracleQuote = null;
observedBrands.delete(collateralBrand);
},
finish: done => {
trace(
`quoteNotifier invoked finish(${done}). setting quote to null`,
);
// lack of quote will trigger restart
state.updatingOracleQuote = null;
observedBrands.delete(collateralBrand);
},
}),
e => {
trace('makeQuoteNotifier failed, resetting', e);
state.updatingOracleQuote = null;
observedBrands.delete(collateralBrand);
},
});
);

void facets.helper.publishBookData();
},
Expand Down Expand Up @@ -645,8 +668,9 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {

trace(`capturing oracle price `, state.updatingOracleQuote);
if (!state.updatingOracleQuote) {
// if the price has feed has died, try restarting it.
facets.helper.observeQuoteNotifier();
// if the price feed has died (or hasn't been started for this
// incarnation), (re)start it.
facets.helper.ensureQuoteNotifierObserved();
return;
}

Expand Down Expand Up @@ -750,7 +774,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
const { collateralBrand, bidBrand, priceAuthority } = state;
assertAllDefined({ collateralBrand, bidBrand, priceAuthority });

facets.helper.observeQuoteNotifier();
facets.helper.ensureQuoteNotifierObserved();
},
stateShape: AuctionBookStateShape,
},
Expand Down
16 changes: 10 additions & 6 deletions packages/telemetry/src/context-aware-slog.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ export const makeContextualSlogProcessor = (

/**
* @param {Slog} slog
* @returns {{ attributes: T & LogAttributes, body: Partial<Slog>; timestamp: Slog['time'] }}
* @returns {{ attributes: T & LogAttributes, body: Partial<Slog>; time: Slog['time'] }}
*/
const slogProcessor = ({ monotime, time: timestamp, ...body }) => {
const slogProcessor = ({ monotime, time, ...body }) => {
const finalBody = { ...body };

/** @type {{'crank.syscallNum'?: Slog['syscallNum']}} */
Expand Down Expand Up @@ -321,13 +321,13 @@ export const makeContextualSlogProcessor = (

const logAttributes = {
...staticContext,
'process.uptime': monotime,
...initContext, // Optional prelude
...blockContext, // Block is the first level of execution nesting
...triggerContext, // run and trigger info is nested next
...crankContext, // Finally cranks are the last level of nesting
...replayContext, // Replay is a substitute for crank context during vat page in
...eventLogAttributes,
'process.uptime': monotime,
};

/**
Expand Down Expand Up @@ -356,7 +356,11 @@ export const makeContextualSlogProcessor = (
// eslint-disable-next-line no-restricted-syntax
case SLOG_TYPES.COSMIC_SWINGSET.RUN.FINISH: {
assert(!!triggerContext);
persistContext(finalBody.remainingBeans ? {} : triggerContext);
persistContext(
finalBody.remainingBeans && finalBody.remainingBeans > 0
? {}
: triggerContext,
);
triggerContext = null;
break;
}
Expand All @@ -373,9 +377,9 @@ export const makeContextualSlogProcessor = (
}

return {
attributes: /** @type {T & LogAttributes} */ (logAttributes),
body: finalBody,
timestamp,
attributes: /** @type {T & LogAttributes} */ (logAttributes),
time,
};
};

Expand Down
4 changes: 2 additions & 2 deletions packages/telemetry/src/otel-context-aware-slog.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ export const makeSlogSender = async options => {
* @param {import('./context-aware-slog.js').Slog} slog
*/
const slogSender = slog => {
const { timestamp, ...logRecord } = contextualSlogProcessor(slog);
const { time, ...logRecord } = contextualSlogProcessor(slog);

const [secondsStr, fractionStr] = String(timestamp).split('.');
const [secondsStr, fractionStr] = String(time).split('.');
const seconds = parseInt(secondsStr, 10);
const nanoSeconds = parseInt(
(fractionStr || String(0)).padEnd(9, String(0)).slice(0, 9),
Expand Down
2 changes: 1 addition & 1 deletion packages/telemetry/src/slog-to-otel.js
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ export const makeSlogToOtelKit = (tracer, overrideAttrs = {}) => {
spans.pop('timer-poll');
break;
}
case 'cosmic-swinget-inject-kernel-upgrade-events': {
case 'cosmic-swingset-inject-kernel-upgrade-events': {
spans.push('kernel-upgrade-events');
spans.pop('kernel-upgrade-events');
break;
Expand Down

0 comments on commit 89128d3

Please sign in to comment.