Skip to content

Commit

Permalink
feat(liquidationVisibility): Store liquidationsStorageNode in ephem…
Browse files Browse the repository at this point in the history
…ara instead of state.

Refs: #15
  • Loading branch information
anilhelvaci committed Jun 21, 2024
1 parent 2279a0b commit f309ec4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
15 changes: 10 additions & 5 deletions packages/inter-protocol/src/vaultFactory/vaultManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ export const prepareVaultManagerKit = (
/**
* @param {HeldParams & {
* metricsStorageNode: StorageNode;
* liquidationsStorageNode: StorageNode;
* }} params
* @returns {HeldParams & ImmutableState & MutableState}
*/
Expand Down Expand Up @@ -431,6 +430,10 @@ export const prepareVaultManagerKit = (

const ephemera = collateralEphemera(collateralBrand);
ephemera.prioritizedVaults = makePrioritizedVaults(unsettledVaults);
// We have to store this in ephemera since we can't add new properties
// to the `state`. See https://github.com/Agoric/agoric-sdk/blob/master/packages/SwingSet/docs/virtual-objects.md
ephemera.liquidationsStorageNode =
E(storageNode).makeChildNode('liquidations');

trace('helper.start() making periodNotifier');
const periodNotifier = E(timerService).makeNotifier(
Expand Down Expand Up @@ -796,12 +799,14 @@ export const prepareVaultManagerKit = (
*/
async makeLiquidationRecorderKits(timestamp) {
const {
state: { liquidationsStorageNode },
state: { collateralBrand },
} = this;

const timestampStorageNode = E(liquidationsStorageNode).makeChildNode(
`${timestamp.absValue}`,
);
const ephemera = collateralEphemera(collateralBrand);

const timestampStorageNode = E(
ephemera.liquidationsStorageNode,
).makeChildNode(`${timestamp.absValue}`);

const [
preAuctionStorageNode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
*/
import * as processAmbient from 'child_process';
import * as fsAmbient from 'fs';
import { Fail } from '@agoric/assert';
import { NonNullish } from '@agoric/assert/src/assert.js';
import { Fail, NonNullish } from '@agoric/assert';
import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
import { TimeMath } from '@agoric/time';
import { scale6 } from '../liquidation.js';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import {
SECONDS_PER_HOUR,
SECONDS_PER_MINUTE,
} from '@agoric/inter-protocol/src/proposals/econ-behaviors.js';
import { scale6 } from '../liquidation.js';
import { makeAgoricNamesRemotesFromFakeStorage } from '../../../tools/board-utils.js';
import { makeSwingsetTestKit } from '../supports.js';
import {
Expand Down Expand Up @@ -346,6 +345,7 @@ const makeProposalExtractor = ({ childProcess, fs }) => {
packageScriptName,
env = {},
}) => {
// eslint-disable-next-line no-undef
const scriptEnv = Object.assign(Object.create(process.env), env);
// XXX use '@agoric/inter-protocol'?
const out = await runPackageScript(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-check
/* global process */
/**
* @file Bootstrap test of restarting (almost) all vats
*/
Expand Down Expand Up @@ -95,11 +94,15 @@ test.serial('restart contractGovernor', async t => {
});

test.serial('visibility-after-upgrade', async t => {
const { storage } = t.context;
await checkVMChildNodes({
t,
managerIndex: 0,
collateralBrandKey: 'ATOM',
liquidation: true,
base: 3,
});

t.log('Data', storage.data.keys());
t.pass();
});

0 comments on commit f309ec4

Please sign in to comment.