Skip to content

Commit

Permalink
chore(a3p-integration): Improve log output (#10485)
Browse files Browse the repository at this point in the history
## Description
Extracted from #10165 and best reviewed by commit.
* Include relevant variable details (e.g., block height).
* Omit output that doesn't convey new information "done", "reading", etc.).
* Provide a common logging prefix for subtasks, inlining functions where relevant.
* Remove endo/init/legacy.js from z:acceptance ava config to eliminate noisy `Object <[Object: null prototype] {}>` output.
* Introduce a `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
  • Loading branch information
mergify[bot] authored Nov 20, 2024
2 parents d268023 + 5b2e20c commit 7e54272
Show file tree
Hide file tree
Showing 36 changed files with 5,423 additions and 323 deletions.
1 change: 1 addition & 0 deletions a3p-integration/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
agoric-sdk/
5 changes: 4 additions & 1 deletion a3p-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"build:sdk": "make -C ../packages/deployment docker-build-sdk",
"build:submissions": "scripts/build-all-submissions.sh",
"build:synthetic-chain": "yarn synthetic-chain build",
"lint": "../node_modules/.bin/eslint proposals",
"lint-fix": "yarn lint:eslint --fix",
"lint": "../node_modules/.bin/run-s --continue-on-error 'lint:*'",
"lint:types": "find proposals -maxdepth 2 -name package.json -type f -exec ../node_modules/.bin/tsc -p '{}'/.. ';'",
"lint:eslint": "../node_modules/.bin/eslint .",
"test": "yarn synthetic-chain test",
"doctor": "yarn synthetic-chain doctor"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
diff --git a/dist/node/axios.cjs b/dist/node/axios.cjs
index db4997bee1aa48aca215c6b2e7443292c94c086f..fb39f7e0046c66b1c0275c1a82ed49d3cc7cff83 100644
--- a/dist/node/axios.cjs
+++ b/dist/node/axios.cjs
@@ -371,9 +371,18 @@ function merge(/* obj1, obj2, obj3, ... */) {
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
forEach(b, (val, key) => {
if (thisArg && isFunction(val)) {
- a[key] = bind(val, thisArg);
- } else {
+ val = bind(val, thisArg);
+ }
+ const oldDesc = Object.getOwnPropertyDescriptor(a, key);
+ if (oldDesc) {
a[key] = val;
+ } else {
+ Object.defineProperty(a, key, {
+ value: val,
+ writable: true,
+ enumerable: true,
+ configurable: true
+ });
}
}, {allOwnKeys});
return a;
@@ -404,7 +413,9 @@ const stripBOM = (content) => {
*/
const inherits = (constructor, superConstructor, props, descriptors) => {
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
- constructor.prototype.constructor = constructor;
+ Object.defineProperty(constructor.prototype, 'constructor', {
+ value: constructor
+ });
Object.defineProperty(constructor, 'super', {
value: superConstructor.prototype
});
@@ -566,7 +577,7 @@ const isRegExp = kindOfTest('RegExp');

const reduceDescriptors = (obj, reducer) => {
const descriptors = Object.getOwnPropertyDescriptors(obj);
- const reducedDescriptors = {};
+ const reducedDescriptors = Object.create(null);

forEach(descriptors, (descriptor, name) => {
let ret;
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/src/util/minimal.js b/src/util/minimal.js
index 3c406dee753b5c6fb29dda2e64d4482e754e7873..564e5dadaa50e4ad05fc18b767ee276c99e9f0f9 100644
--- a/src/util/minimal.js
+++ b/src/util/minimal.js
@@ -280,7 +280,30 @@ function newError(name) {
merge(this, properties);
}

- (CustomError.prototype = Object.create(Error.prototype)).constructor = CustomError;
+ CustomError.prototype = Object.create(Error.prototype, {
+ constructor: {
+ value: CustomError,
+ writable: true,
+ enumerable: false,
+ configurable: true,
+ },
+ name: {
+ get() { return name; },
+ set: undefined,
+ enumerable: false,
+ // configurable: false would accurately preserve the behavior of
+ // the original, but I'm guessing that was not intentional.
+ // For an actual error subclass, this property would
+ // be configurable.
+ configurable: true,
+ },
+ toString: {
+ value() { return this.name + ": " + this.message; },
+ writable: true,
+ enumerable: false,
+ configurable: true,
+ },
+ });

Object.defineProperty(CustomError.prototype, "name", { get: function() { return name; } });

2 changes: 1 addition & 1 deletion a3p-integration/proposals/n:upgrade-next/acceptInvites.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
import '@endo/init';
import '@endo/init/debug.js';
import { agops, GOV1ADDR, GOV2ADDR } from '@agoric/synthetic-chain';
import { GOV4ADDR } from './agoric-tools.js';

Expand Down
2 changes: 1 addition & 1 deletion a3p-integration/proposals/n:upgrade-next/addGov4.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '@endo/init';
import '@endo/init/debug.js';
import { execFileSync } from 'node:child_process';
import { makeAgd } from './synthetic-chain-excerpt.js';
import { GOV4ADDR } from './agoric-tools.js';
Expand Down
1 change: 1 addition & 0 deletions a3p-integration/proposals/n:upgrade-next/initial.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import test from 'ava';
import '@endo/init/debug.js';

import { getVatDetails } from '@agoric/synthetic-chain';

Expand Down
7 changes: 7 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@agoric/client-utils": "dev",
"@agoric/synthetic-chain": "^0.3.0",
"@endo/init": "^1.1.6",
"@endo/marshal": "^1.6.1",
Expand All @@ -30,6 +31,12 @@
},
"packageManager": "[email protected]",
"devDependencies": {
"eslint": "^8.57.0",
"npm-run-all": "^4.1.5",
"typescript": "^5.6.3"
},
"resolutions": {
"axios@npm:^1.6.0": "patch:axios@npm%3A1.7.7#~/.yarn/patches/axios-npm-1.7.7-cfbedc233d.patch",
"protobufjs@npm:^6.8.8": "patch:protobufjs@npm%3A6.11.4#~/.yarn/patches/protobufjs-npm-6.11.4-af11968b80.patch"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import test from 'ava';
import '@endo/init/debug.js';
import { getDetailsMatchingVats } from './vatDetails.js';

test('new auction vat', async t => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import test from 'ava';
import '@endo/init/debug.js';

import {
agops,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava';
import '@endo/init';
import '@endo/init/debug.js';
import { GOV1ADDR, GOV2ADDR } from '@agoric/synthetic-chain';
import { passStyleOf } from '@endo/marshal';
import { GOV4ADDR, queryVstorageFormatted } from './agoric-tools.js';
Expand Down
22 changes: 10 additions & 12 deletions a3p-integration/proposals/n:upgrade-next/synthetic-chain-excerpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,20 @@ const waitForBootstrap = async () => {
}
};

export const waitForBlock = async (times = 1) => {
console.log(times);
let time = 0;
while (time < times) {
const block1 = await waitForBootstrap();
export const waitForBlock = async (n = 1) => {
console.log(`waitForBlock waiting for ${n} new block(s)...`);
const h0 = await waitForBootstrap();
let lastHeight = h0;
for (let i = 0; i < n; i += 1) {
while (true) {
const block2 = await waitForBootstrap();

if (block1 !== block2) {
console.log('block produced');
await new Promise(r => setTimeout(r, 1000));
const currentHeight = await waitForBootstrap();
if (currentHeight !== lastHeight) {
console.log(`waitForBlock saw new height ${currentHeight}`);
lastHeight = currentHeight;
break;
}

await new Promise(r => setTimeout(r, 1000));
}
time += 1;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
pushPrices,
getPriceQuote,
} from '@agoric/synthetic-chain';
import { retryUntilCondition } from './sync-tools.js';
import { retryUntilCondition } from '@agoric/client-utils';

export const scale6 = x => BigInt(x * 1_000_000);

Expand Down Expand Up @@ -57,6 +57,6 @@ export const getPriceFeedRoundId = async brand => {
prefix: '',
});

console.log('latestRound: ', latestRound);
console.log(latestRoundPath, latestRound);
return Number(latestRound.roundId);
};
72 changes: 0 additions & 72 deletions a3p-integration/proposals/n:upgrade-next/test-lib/sync-tools.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node

import '@endo/init/debug.js';
import {
registerOraclesForBrand,
generateOracleMap,
Expand Down
Loading

0 comments on commit 7e54272

Please sign in to comment.