-
Notifications
You must be signed in to change notification settings - Fork 208
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
chore: update moddable to get snapshot fixes #3358
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, as far as I can tell. Agreed that we should wait (at least a little bit) for upstream to get the fixes, so we can remain as close the official sources as we can.
Moddable released their stuff as well as some metering stuff. PTAL. |
packages/xsnap/src/xsnap.c
Outdated
@@ -84,7 +86,8 @@ static char* fxWriteNetStringError(int code); | |||
#define mxSnapshotCallbackCount 6 | |||
txCallback gxSnapshotCallbacks[mxSnapshotCallbackCount] = { | |||
fx_issueCommand, // 0 | |||
fx_Array_prototype_meter, // 1 | |||
// fx_Array_prototype_meter, // 1 | |||
NULL, // 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that we cannot load any snapshots that happened to include a reference to this function? Or, we can load them, but if they subsequently actually try to call it, we'll get a crash?
I'm wondering if it would be better to remove the callback slot entirely, rather than replacing it with a NULL, if we aren't really preserving snapshot compatibility across this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right; the NULL isn't worth the risk.
fixed in f337f8a
Huh, in |
Other than |
That does look goofy. I don't think it affects us: It's in the But I guess we owe a heads-up to moddable. (p.s. done.) |
That test failure suggests that our default CPU meter allowance might be too low. |
fx_print, // 1 | ||
fx_setImmediate, // 2 | ||
fx_gc, // 3 | ||
fx_performance_now, // 4 | ||
// fx_evalScript, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any snapshots in databases that we care about continuing to be able to restore? We will eventually need to put tombstones in this table rather than renumbering syscalls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NULL
was my hand-wave at a tombstone. Both you and @warner called my bluff, in different directions (which is good!).
The moddable folks added fx_Function_prototype_bound
to the middle rather than the end of the array in xsSnapshot.c
; so unless we want to push back on that, we're already not in a good position to preserve snapshot compatibility across this change.
Are there any snapshots in databases that we care about continuing to be able to restore?
I think not, and @warner 's comment suggests likewise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, not yet
We'll need some sort of versioning marker sooner or later. I suspect we're going to need @agoric/xsnap
to keep multiple binaries around, since all of (snapshot binary format, the callbacks
table, metering behavior) will be highly dependent upon the binary. So once a vat starts executing with a given version of the xsnap
binary, both its snapshots and it's future execution are forever bound to that one version (modulo whole-transcript replay to switch to a different version, which might work with consensus but we can figure out the details later).
// https://en.wikipedia.org/wiki/ReDoS | ||
// http://www.owasp.org/index.php/OWASP_Validation_Regex_Repository | ||
const result = await vat.evaluate(` | ||
'aaaaaaaaa!'.match(/^(([a-z])+.)+/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
packages/xsnap/test/test-xs-perf.js
Outdated
@@ -56,7 +63,23 @@ test('meter details', async t => { | |||
}, | |||
'auxiliary (non-consensus) meters are available', | |||
); | |||
t.is(meterType, 'xs-meter-7'); | |||
// @ts-ignore extra meters not declared on RunResult (yet?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth tracking this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm mentally tracking it as #3139 . I guess since I have to re-spin ci anyway, I'll note it in the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 5fd6c6f
packages/xsnap/src/xsnap.c
Outdated
@@ -859,11 +860,13 @@ void fxFreezeBuiltIns(txMachine* the) | |||
mxPop(); | |||
} | |||
|
|||
#if 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this permanently dead code? How do we decide whether to remove the pragma fence or remove the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, it's good that you call my bluff here.
This is the how to organize xsnap? issue, to my mind. I lean toward a separate xsnap-native submodule.
I guess I might as well delete this code rather than #if 0
it, but I wanted to prompt some discussion first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in e432531
moddable/xs$ git log --graph --pretty=format:'%ad %h %s' --abbrev-commit --date=short a97e1.. . * 2021-06-20 2602c98c quick change to preflight keys needed by mod * 2021-06-19 71b46945 XS: too many mod keys will abort later * 2021-06-19 2572a7bc XS snapshot missing bound functions callback * 2021-06-18 fd6dcf52 XS: safer capture error stack * 2021-06-17 028fcd45 XS snapshot: cleanup chunks after wrtiting * 2021-06-15 969ba224 XS metering string from/to number conversions * 2021-06-14 274c545f XS: metering bigint * 2021-06-14 a14a5c03 XS: metering regexp * 2021-06-14 b594c62a XS: metering changes * 2021-06-09 b99a8268 add ArrayBuffer.fromBigInt moddable/xs$ git diff -w --stat a97e1fb60dde.. . xs/includes/xs.d.ts | 1 + xs/platforms/esp/xsHost.c | 8 ++++++++ xs/sources/xsAPI.c | 35 +++++++++++++++++++++++++++++++++-- xs/sources/xsAll.h | 3 +-- xs/sources/xsBigInt.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++------------------- xs/sources/xsError.c | 8 ++++++-- xs/sources/xsFunction.c | 35 ----------------------------------- xs/sources/xsMapSet.c | 15 --------------- xs/sources/xsMemory.c | 2 +- xs/sources/xsRun.c | 20 +++++++++++++++----- xs/sources/xsSnapshot.c | 21 ++++++++++++++++++++- xs/sources/xsre.c | 19 +++++++++++++++++-- 12 files changed, 148 insertions(+), 84 deletions(-)
`fx_Array_prototype_meter` was obsolete but it still caused a link error.
We aren't really preserving snapshot compatibility across this change, since the bound callback got added to the middle of the list in xsSnapshot.c. So never mind holding a slot for `fx_Array_prototype_meter`.
... as shown in solo tests
This experimental metering design was removed from the XS sources Jun 14 in b594c62acaee .
4d04180
to
e0a6634
Compare
fixes #3350
fixes #2322
ref https://github.com/agoric-labs/moddable/tree/ag-testnet-4
We were previously at a97e1fb60dde. Moddable released the fixes re #3350 as well as metering for bigint, regex for #2322. Here we add test and bump the metering version. In the moddable repo, the top two commits (20ec3085, 29b71e09) are our metering tweaks, rebased. 2602c98c is the latest change from moddable that affects XS.