-
Notifications
You must be signed in to change notification settings - Fork 215
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(a3p-integration): Improve log output #10485
Conversation
Deploying agoric-sdk with Cloudflare Pages
|
0ffeeb9
to
4d3822b
Compare
ebec543
to
42945e4
Compare
5192642
to
85dfb59
Compare
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 afraid I don't know enough to approve.
* @param {bigint} numValInPercent | ||
*/ | ||
const toRatio = (brand, numValInPercent) => { | ||
const commonDenominator = AmountMath.make(brand, 10_000n); |
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 wonder why the denominator is not 100n
. But I suppose that pre-dates this PR?
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.
Yep, I just moved it. 🤷
export const logRecord = (label, data, log = console.log) => { | ||
const entries = Array.isArray(data) ? [...data] : Object.entries(data); | ||
/** @type {[labelKey: PropertyKey, valueKey: PropertyKey] | undefined} */ | ||
let shape; | ||
for (let i = 0; i < entries.length; i += 1) { | ||
let entry = entries[i]; | ||
if (!Array.isArray(entry)) { |
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 not confident that I can follow this logic. And I'm not quite sure what it's supposed to do.
I'm looking for examples in ci logs, but I see:
Integration tests / test-docker-build (pull_request) Skipped
... even though the force:integration label is present.
Some examples in the docstring might be nice. Or unit tests.
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.
Updated the docstring. Actual output is visible in a prior CI run: https://github.com/Agoric/agoric-sdk/actions/runs/11881729913/job/33106407896#step:10:4506
✔ swap into IST using agd with default gas (9s)
ℹ METRICS {
anchorPoolBalance: {
brand: Object @Alleged: BoardRemoteUSDC_axl brand {},
value: 30010011n,
},
feePoolBalance: {
brand: Object @Alleged: BoardRemoteIST brand {},
value: 0n,
},
mintedPoolBalance: {
brand: Object @Alleged: BoardRemoteIST brand {},
value: 30010011n,
},
totalAnchorProvided: {
brand: Object @Alleged: BoardRemoteUSDC_axl brand {},
value: 0n,
},
totalMintedProvided: {
brand: Object @Alleged: BoardRemoteIST brand {},
value: 30010011n,
},
}
ℹ BALANCES { [denom]: amount, ... } {
'ibc/295548A78785A1007F232DE286149A6FF512F180AF5657780FC89C009E2C348F': '300000000',
ubld: '20000000',
uist: '250000',
}
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.
This is a lot of new code in psm-lib that isn't specific to PSM. I'm not opposed to landing it but please don't spend effort improving these deprecated utils. It would be better spent on @agoric/client-utils
and getting psm-lib to use that.
incidentally, consider marking @deprecated
all the functions in psm-lib that aren't about PSM per se.
"require": [ | ||
"@endo/init/legacy.js" |
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 should know more about why we were using endo legacy before approving this.
I'm also not sure about why use imports in every file rather than ava require. I sort of prefer it that way, but it hasn't been the norm here.
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.
The general reason seems to generally be JS assignment override mistake mitigation, albeit in a noisy way:
$ for import in @endo/init @endo/init/legacy.js; do
echo
node --input-type=module -e "
import '$import';
import { inspect } from 'node:util';
console.log('$import');
let MyObject = () => 'not implemented';
try {
MyObject = function MyObject(props = {}) {
return new.target ? Object.assign(this, props) : new MyObject(props);
};
(MyObject.prototype = Object.create(Object.prototype)).constructor = MyObject;
} catch (err) { console.log('ERROR', err.message); }
const instance = MyObject({ foo: 'bar' });
console.log(util.inspect({
data: {
object: {instance},
map: new Map([['instance', instance]]),
}
}, { depth: 10 }));
"
done
@endo/init
ERROR Cannot assign to read only property 'constructor' of object '[object Object]'
{
data: {
object: { instance: { foo: 'bar' } },
map: Map(1) { 'instance' => { foo: 'bar' } }
}
}
@endo/init/legacy.js
Object <[Object: null prototype] {}> {
data: Object <[Object: null prototype] {}> {
object: Object <[Object: null prototype] {}> {
instance: MyObject { foo: 'bar' }
},
map: Map <Object <[Object: null prototype] {}>>(1) [Map] {
'instance' => MyObject { foo: 'bar' }
}
}
}
But AFAICT, it is not helpful here.
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.
IIRC some import of axios or protobufjs prompted it. I didn't realize it had any DX downsides. Given that it impairs the console messages I agree we should avoid it.
Howeverplease keep the endo/init config in the Ava require so it's consistent across tests. Also, shouldn't it be @endo/init/debug.js
for better output?
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.
shouldn't it be
@endo/init/debug.js
for better output?
Good point; done.
a2f79ba
to
b6e49c9
Compare
), | ||
]); | ||
console.log('charterAcceptOfferId', charterAcceptOfferId); | ||
const { brands, instances } = await snapshotAgoricNames(); |
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.
Let's not put any more effort into improving these functions that can be replaced by @agoric/client-utils
.
export const logRecord = (label, data, log = console.log) => { | ||
const entries = Array.isArray(data) ? [...data] : Object.entries(data); | ||
/** @type {[labelKey: PropertyKey, valueKey: PropertyKey] | undefined} */ | ||
let shape; | ||
for (let i = 0; i < entries.length; i += 1) { | ||
let entry = entries[i]; | ||
if (!Array.isArray(entry)) { |
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.
This is a lot of new code in psm-lib that isn't specific to PSM. I'm not opposed to landing it but please don't spend effort improving these deprecated utils. It would be better spent on @agoric/client-utils
and getting psm-lib to use that.
incidentally, consider marking @deprecated
all the functions in psm-lib that aren't about PSM per se.
a3p-integration/proposals/p:upgrade-19/replaceFeeDistributor.test.js
Outdated
Show resolved
Hide resolved
48f8df2
to
7eb1564
Compare
// TODO @import {Ratio} from '@agoric/zoe' | ||
/** @typedef {any} Ratio */ |
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.
It's in ERTP now. Why wait?
// TODO @import {Ratio} from '@agoric/zoe' | |
/** @typedef {any} Ratio */ | |
/** @import {Ratio} from '@agoric/ertp`; |
(it might need src/types.js)
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.
error TS2305: Module '"@agoric/ertp"' has no exported member 'Ratio'.
error TS2305: Module '"@agoric/ertp/src/types.js"' has no exported member 'Ratio'.
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.
Ah, the proposal must have an old version of ERTP. We'd have the one in agoric-sdk if this used the new 'yarn link' trick but it's not worth further churn on the PR.
...in anticipation of improving log output
…nit/debug.js This should eliminate noisy `Object <[Object: null prototype] {}>` output.
…ome generic helper functions
…rmalizing entries and records
Ref fd9394b Unlike maxRetries and retryIntervalMs and message, it is independent of expected timing and result output, and therefore just noise in CI logs.
916d2ca
to
5b2e20c
Compare
Description
Extracted from #10165 and best reviewed by commit.
Object <[Object: null prototype] {}>
output.logRecord
helper to concisely log possibly-remotable-bearing records and/or record entries.Security Considerations
n/a
Scaling Considerations
n/a
Documentation Considerations
n/a
Testing Considerations
n/a
Upgrade Considerations
n/a