Agoric / agoric-sdk

monorepo for the Agoric Javascript smart contract platform
Apache License 2.0
327 stars 207 forks source link

subscribers from makeERecorderKit lose identity between restarts #8277

Open turadg opened 1 year ago

turadg commented 1 year ago

Describe the bug

The subscriber in kit returned by makeERecorderKit is "durable" but made anew. https://github.com/Agoric/agoric-sdk/blob/3ce0599d5173b802598b5bedf57d3c30f016f789/packages/zoe/src/contractSupport/recorder.js#L174-L181

So in auctioneer, after restart this would return a different subscriber: https://github.com/Agoric/agoric-sdk/blob/3ce0599d5173b802598b5bedf57d3c30f016f789/packages/inter-protocol/src/auction/auctioneer.js#L658-L661

And the old one, being durable, would persist but not get any new records.

The other place this is a problem: https://github.com/Agoric/agoric-sdk/blob/3ce0599d5173b802598b5bedf57d3c30f016f789/packages/inter-protocol/src/vaultFactory/vaultDirector.js#L251-L254

Additional context

We could pass the durable publish kit in,

  const makeERecorderKit = (
    { publisher, subscriber },
    storageNodeP,
    valueShape,
  ) => {
    const recorderP = E.when(storageNodeP, storageNode =>
      makeRecorder(publisher, storageNode, valueShape),
    );
    return { subscriber, recorderP };
  };
  const schedulePublishKit = provide(baggage, 'schedulePublishKit', () =>
    makeDurablePublishKit(),
  );
  const scheduleKit = makeERecorderKit(
    schedulePublishKit,
    E(privateArgs.storageNode).makeChildNode('schedule'),
    /**
     * @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<
     *     import('./scheduler.js').ScheduleNotification
     *   >}
     */ (M.any()),
  );
Chris-Hibbert commented 2 months ago

And the old one, being durable, would persist but not get any new records.

Even if it's durable, there are no references left to it, right? Won't it get GC'd eventually?