Agoric / ui-kit

Components and tools for building graphical UIs
https://ui-kit-dwm.pages.dev/
Apache License 2.0
3 stars 3 forks source link

calls to makeClientMarshaller share static mutable state #73

Open dckc opened 9 months ago

dckc commented 9 months ago

Describe the bug

Calls to makeClientMarshaller share static mutable state: the results of 1 call to makeTranslationTable(...).

To Reproduce

This test fails:

test('calls to makeClientMarshaller do not share static mutable state', () => {
  const m1 = makeClientMarshaller();
  const m2 = makeClientMarshaller();
  const capData = { body: '#"$0.Brand"', slots: ['board0123'] };
  // b1 is a fresh synthetic remotable object
  const b1 = m1.fromCapData(capData);
  // unless m2 somehow has access to state from m1, m2 can't access b1.
  const b2 = m2.fromCapData(capData);
  expect(b1).not.toBe(b2);
});

Expected behavior

The call to makeTranslationTable(...) should be inside makeClientMarshaller.

Exported function such as makeClientMarshaller should not close over static mutable state. This follows from anything globally accessible is immutable data in OCap Discipline.

Platform Environment