Skip to content

Commit

Permalink
downgrade many logs to debug level (#115)
Browse files Browse the repository at this point in the history
* downgrade many logs to debug

* v0.15.2-alpha.0

* downgrade some more logs

* v0.15.2-alpha.1
  • Loading branch information
clangenb authored Oct 21, 2024
1 parent 7f696de commit 30ca711
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 56 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"publishConfig": {
"directory": "build"
},
"version": "0.15.1"
"version": "0.15.2-alpha.1"
}
4 changes: 2 additions & 2 deletions packages/node-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
},
"sideEffects": false,
"type": "module",
"version": "0.15.1",
"version": "0.15.2-alpha.1",
"main": "index.js",
"dependencies": {
"@encointer/types": "^0.15.1",
"@encointer/types": "^0.15.2-alpha.1",
"@polkadot/api": "^11.2.1",
"tslib": "^2.6.2"
},
Expand Down
13 changes: 6 additions & 7 deletions packages/node-api/src/encointer-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export async function getMeetupCount(api: ApiPromise, cid: CommunityIdentifier,
}

export async function getMeetupTimeOffset(api: ApiPromise): Promise<MeetupTimeOffsetType> {
console.log('HUHU1337')
return api.query["encointerCeremonies"]["meetupTimeOffset"]<MeetupTimeOffsetType>();
}

Expand Down Expand Up @@ -62,10 +61,10 @@ export async function getMeetupIndex(api: ApiPromise, cid: CommunityIdentifier,
getParticipantRegistration(api, cid, cIndex,address),
]);

console.log(`[getMeetupIndex] mCount: ${mCount}`)
console.log(`[getMeetupIndex] assignment: ${JSON.stringify(assignments)}`)
console.log(`[getMeetupIndex] assignmentCount: ${JSON.stringify(assignmentCount)}`)
console.log(`[getMeetupIndex] registration: ${JSON.stringify(registration)}`)
console.debug(`[getMeetupIndex] mCount: ${mCount}`)
console.debug(`[getMeetupIndex] assignment: ${JSON.stringify(assignments)}`)
console.debug(`[getMeetupIndex] assignmentCount: ${JSON.stringify(assignmentCount)}`)
console.debug(`[getMeetupIndex] registration: ${JSON.stringify(registration)}`)


if (mCount.eq(0)) {
Expand All @@ -74,7 +73,7 @@ export async function getMeetupIndex(api: ApiPromise, cid: CommunityIdentifier,
}

if (registration.isNone) {
console.log("[getMeetupIndex] participantIndex was 0");
console.debug("[getMeetupIndex] participantIndex was 0");
return mCount.registry.createTypeUnsafe("MeetupIndexType", [0]) as MeetupIndexType; // don't know why the cast is necessary
}

Expand Down Expand Up @@ -264,5 +263,5 @@ function bootstrapperOrReputableQuery(
}

function _log(msg: String) {
console.log(`[encointer-js:api] ${msg}`)
console.debug(`[encointer-js:api] ${msg}`)
}
8 changes: 4 additions & 4 deletions packages/node-api/src/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ export function submitAndWatchTx(api: ApiPromise, signer: KeyringPair, tx: Submi
}
unsub();
} else {
console.log('txStatusChange', result.status.type)
console.debug('txStatusChange', result.status.type)
}
}
tx.signAndSend(signer, {}, onStatusChange)
.then((res) => {
unsub = res;
})
.catch((err) => {
console.log(`{error: ${err.message}}`);
console.error(`{error: ${err.message}}`);
});
}))
}
Expand Down Expand Up @@ -83,15 +83,15 @@ export function extractEvents(api: ApiPromise, result: ISubmittableResult): IExt
message = `could not extract dispatch error: ${JSON.stringify(error)}`;
}
}
console.log('txUpdateEvent', `${JSON.stringify({
console.debug('txUpdateEvent', `${JSON.stringify({
title: `${section}.${method}`,
message
})}`);
error = message;
}

} else {
console.log('txUpdateEvent', `${JSON.stringify({
console.debug('txUpdateEvent', `${JSON.stringify({
title: `${section}.${method}`,
message: data
})}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"sideEffects": false,
"type": "module",
"version": "0.15.1",
"version": "0.15.2-alpha.1",
"main": "index.js",
"scripts": {
"generate:defs": "node --experimental-specifier-resolution=node --loader ts-node/esm ../../node_modules/.bin/polkadot-types-from-defs --package @encointer/types/interfaces --input ./src/interfaces",
Expand Down
2 changes: 1 addition & 1 deletion packages/util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"sideEffects": false,
"type": "module",
"types": "./index.d.ts",
"version": "0.15.1",
"version": "0.15.2-alpha.1",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.18.9",
Expand Down
22 changes: 11 additions & 11 deletions packages/util/src/assignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import type {Moment} from "@polkadot/types/interfaces/runtime";
export function assignmentFn(participantIndex: ParticipantIndexType, assignmentParams: AssignmentParams, assignmentCount: u64): MeetupIndexType {

if (assignmentParams.m.eq(0) || assignmentCount.eq(0)) {
console.log(`[assignmentFn] invalid params or assignmentCount. Returning 0`);
console.error(`[assignmentFn] invalid params or assignmentCount. Returning 0`);
return participantIndex.registry.createTypeUnsafe('MeetupIndexType', [0]);
}

Expand All @@ -42,7 +42,7 @@ export type ParticipantIndexes = [ParticipantIndexType, ParticipantIndexType, Pa
export function getRegistration(pIndexes: ParticipantIndexes): Option<ParticipantRegistration> {
const registry = pIndexes[0].registry;

console.log(`[getRegistration] pIndexes: ${JSON.stringify(pIndexes)}`);
console.debug(`[getRegistration] pIndexes: ${JSON.stringify(pIndexes)}`);

if (!pIndexes[0].eq(0)) {
return registry.createTypeUnsafe('Option<ParticipantRegistration>', [[pIndexes[0], 'Bootstrapper']]);
Expand Down Expand Up @@ -77,7 +77,7 @@ export function computeMeetupIndex(
}

if (registration.index.eq(0)) {
console.log("[computeMeetupIndex] supplied registration with participantIndex = 0. returning...")
console.warn("[computeMeetupIndex] supplied registration with participantIndex = 0. returning...")
return registration.index;
} else {
pIndex = registration.index.subn(1) as ParticipantIndexType;
Expand All @@ -87,25 +87,25 @@ export function computeMeetupIndex(
(pIndex: ParticipantIndexType, params: AssignmentParams) => meetupIndex(pIndex, params, meetupCount);

if (registration.registrationType.isBootstrapper) {
console.log("[computeMeetupIndex] is bootstrapper.")
console.debug("[computeMeetupIndex] is bootstrapper.")
if (pIndex.lt(assignmentCount.bootstrappers)) {
return meetupIndexFn(pIndex, assignments.bootstrappersReputables)
}
} else if (registration.registrationType.isReputable) {
console.log("[computeMeetupIndex] is reputable")
console.debug("[computeMeetupIndex] is reputable")
if (pIndex.lt(assignmentCount.reputables)) {
return meetupIndexFn(
pIndex.add(assignmentCount.bootstrappers) as ParticipantIndexType,
assignments.bootstrappersReputables
)
}
} else if (registration.registrationType.isEndorsee) {
console.log("[computeMeetupIndex] is endorsee.")
console.debug("[computeMeetupIndex] is endorsee.")
if (pIndex.lt(assignmentCount.endorsees)) {
return meetupIndexFn(pIndex, assignments.endorsees);
}
} else if (registration.registrationType.isNewbie) {
console.log("[computeMeetupIndex] is endorsee.")
console.debug("[computeMeetupIndex] is endorsee.")
if (pIndex.lt(assignmentCount.newbies)){
return meetupIndexFn(pIndex, assignments.newbies);
}
Expand All @@ -123,13 +123,13 @@ export function computeMeetupIndex(
*/
export function meetupIndex(participantIndex: ParticipantIndexType, assignmentParams: AssignmentParams, meetupCount: MeetupIndexType): MeetupIndexType {

console.log(`[meetupIndex] executing assignmentFn`);
console.debug(`[meetupIndex] executing assignmentFn`);

const result = assignmentFn(participantIndex, assignmentParams, meetupCount);

const mIndex = result.addn(1) as MeetupIndexType

console.log(`[meetupIndex] mIndex (=assignmentFn result + 1): ${JSON.stringify(mIndex)}`);
console.debug(`[meetupIndex] mIndex (=assignmentFn result + 1): ${JSON.stringify(mIndex)}`);

return mIndex;
}
Expand All @@ -149,7 +149,7 @@ export function meetupLocation(meetupIndex: MeetupIndexType, locations: Vec<Loca
const len: u64 = registry.createTypeUnsafe('u64', [locations.length]);

if (len.eq(0)) {
console.log(`[meetup_location]: Locations empty: ${len}`)
console.debug(`[meetup_location]: Locations empty: ${len}`)
return registry.createTypeUnsafe('Option<Location>', [])
}

Expand All @@ -158,7 +158,7 @@ export function meetupLocation(meetupIndex: MeetupIndexType, locations: Vec<Loca
if (location_index < len) {
return registry.createTypeUnsafe('Option<Location>', [locations[location_index.toNumber()]])
} else {
console.log(`[meetup_location]: Location index is out of bounds ${location_index}. Locations length: ${len}`)
console.debug(`[meetup_location]: Location index is out of bounds ${location_index}. Locations length: ${len}`)
return registry.createTypeUnsafe('Option<Location>', [])
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/worker-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"sideEffects": false,
"type": "module",
"types": "./index.d.ts",
"version": "0.15.1",
"version": "0.15.2-alpha.1",
"main": "index.js",
"dependencies": {
"@encointer/node-api": "^0.15.1",
"@encointer/types": "^0.15.1",
"@encointer/util": "^0.15.1",
"@encointer/node-api": "^0.15.2-alpha.1",
"@encointer/types": "^0.15.2-alpha.1",
"@encointer/util": "^0.15.2-alpha.1",
"@peculiar/webcrypto": "^1.4.6",
"@polkadot/api": "^11.2.1",
"@polkadot/keyring": "^12.6.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/worker-api/src/encointerWorker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('worker', () => {
describe('getTotalIssuance', () => {
it('should return value', async () => {
const result = await worker.getTotalIssuance(network.chosenCid);
// console.log('getTotalIssuance', result);
// console.debug('getTotalIssuance', result);
expect(result).toBeDefined();
});
});
Expand Down Expand Up @@ -87,7 +87,7 @@ describe('worker', () => {
describe('getSchedulerState', () => {
it('should return value', async () => {
const result = await worker.getSchedulerState(network.chosenCid);
// console.log('schedulerStateResult', result);
// console.debug('schedulerStateResult', result);
expect(result).toBeDefined();
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/worker-api/src/integriteeWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ export class IntegriteeWorker extends Worker {
const call = createTrustedCall(this, ['guess_the_number', 'GuessTheNumberTrustedCall'], guessThNumberCall);
const signed = await signTrustedCall(this, call, account, shardT, mrenclave, nonce, signerOptions);

console.log(`GuessTheNumber ${JSON.stringify(signed)}`);
console.debug(`GuessTheNumber ${JSON.stringify(signed)}`);
return this.sendTrustedCall(signed, shardT, requestOptions);
}

async sendTrustedCall(call: IntegriteeTrustedCallSigned, shard: ShardIdentifier, requestOptions?: RequestOptions): Promise<Hash> {
if (this.shieldingKey() == undefined) {
console.log(`[sentTrustedCall] Setting the shielding pubKey of the worker.`)
console.debug(`[sentTrustedCall] Setting the shielding pubKey of the worker.`)
await this.getShieldingKey(requestOptions);
}

Expand Down
3 changes: 1 addition & 2 deletions packages/worker-api/src/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ export async function signTrustedGetter(self: IWorker, account: AddressOrPair, g
}
});

// console.log(`TrustedGetter: ${JSON.stringify(g)}`);
// console.log(`TrustedGetter Encoded: ${g.toU8a()}`);
console.debug(`Signed TrustedGetter: ${JSON.stringify(g)}`);
return g;
}

Expand Down
6 changes: 2 additions & 4 deletions packages/worker-api/src/sendRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ export const sendTrustedCall = async <T>(self: IWorker, call: IntegriteeTrustedC
let result: Promise<any>;
let parserType: string = options.debug ? 'raw': parser;

// console.log(`TrustedCall: ${JSON.stringify(call)}`);

let top;
if (direct) {
top = self.createType('IntegriteeTrustedOperation', {
Expand All @@ -54,7 +52,7 @@ export const sendTrustedCall = async <T>(self: IWorker, call: IntegriteeTrustedC
})
}

console.log(`TrustedOperation: ${JSON.stringify(top)}`);
console.debug(`Sending TrustedOperation: ${JSON.stringify(top)}`);

const cyphertext = await self.encrypt(top.toU8a());

Expand All @@ -65,7 +63,7 @@ export const sendTrustedCall = async <T>(self: IWorker, call: IntegriteeTrustedC
const rpc = createJsonRpcRequest('author_submitExtrinsic', [r.toHex()], 1);
result = sendWorkerRequest(self, rpc, parserType, options)

console.log(`[sendTrustedCall] sent request: ${JSON.stringify(rpc)}`);
console.debug(`[sendTrustedCall] sent request: ${JSON.stringify(rpc)}`);

return result as Promise<T>
}
Expand Down
2 changes: 0 additions & 2 deletions packages/worker-api/src/webCryptoRSA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ export async function parseWebCryptoRSA(data: any): Promise<CryptoKey> {
["encrypt"]
);

console.log(`PublicKey: ${JSON.stringify(publicKey)}`);

return publicKey;
}

Expand Down
12 changes: 6 additions & 6 deletions packages/worker-api/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ const parseGetterResponse = (self: IWorker, responseType: string, data: string)
throw new Error(`Worker error: ${data}`);
}

// console.log(`Getter response: ${data}`);
// console.debug(`Getter response: ${data}`);
const json = JSON.parse(data);

const value = hexToU8a(json["result"]);
const returnValue = self.createType('RpcReturnValue', value);
console.log(`RpcReturnValue ${JSON.stringify(returnValue)}`);
console.debug(`RpcReturnValue ${JSON.stringify(returnValue)}`);

if (returnValue.status.isError) {
const errorMsg = self.createType('String', returnValue.value);
Expand All @@ -60,7 +60,7 @@ const parseGetterResponse = (self: IWorker, responseType: string, data: string)
const jsonStr = self.createType('String', returnValue.value);
// Todo: For some reason there are 2 non-utf characters, where I don't know where
// they come from currently.
console.log(`Got shielding key: ${jsonStr.toJSON().substring(2)}`);
console.debug(`Got shielding key: ${jsonStr.toJSON().substring(2)}`);
parsedData = parseWebCryptoRSA(jsonStr.toJSON().substring(2));
break
case 'Vault':
Expand All @@ -70,12 +70,12 @@ const parseGetterResponse = (self: IWorker, responseType: string, data: string)
parsedData = self.createType(responseType, returnValue.value);
break
case 'TrustedOperationResult':
console.log(`Got TrustedOperationResult`)
console.debug(`Got TrustedOperationResult`)
parsedData = self.createType('Hash', returnValue.value);
break
default:
parsedData = unwrapWorkerResponse(self, returnValue.value);
console.log(`unwrapped data ${parsedData}`);
console.debug(`unwrapped data ${parsedData}`);
parsedData = self.createType(responseType, parsedData);
break;
}
Expand Down Expand Up @@ -127,7 +127,7 @@ export class Worker extends WebSocketAsPromised implements IWorker {
const be = new BN(outputData)
const beArray = new Uint8Array(be.toArray());

// console.log(`${JSON.stringify({encrypted_array: beArray})}`)
// console.debug(`${JSON.stringify({encrypted_array: beArray})}`)

return this.createType('Vec<u8>', compactAddLength(beArray))
}
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -755,18 +755,18 @@ __metadata:
languageName: node
linkType: hard

"@encointer/node-api@npm:^0.15.1, @encointer/node-api@workspace:packages/node-api":
"@encointer/node-api@npm:^0.15.2-alpha.1, @encointer/node-api@workspace:packages/node-api":
version: 0.0.0-use.local
resolution: "@encointer/node-api@workspace:packages/node-api"
dependencies:
"@encointer/types": "npm:^0.15.1"
"@encointer/types": "npm:^0.15.2-alpha.1"
"@polkadot/api": "npm:^11.2.1"
"@polkadot/util-crypto": "npm:^12.6.2"
tslib: "npm:^2.6.2"
languageName: unknown
linkType: soft

"@encointer/types@npm:^0.15.1, @encointer/types@workspace:packages/types":
"@encointer/types@npm:^0.15.2-alpha.1, @encointer/types@workspace:packages/types":
version: 0.0.0-use.local
resolution: "@encointer/types@workspace:packages/types"
dependencies:
Expand All @@ -781,7 +781,7 @@ __metadata:
languageName: unknown
linkType: soft

"@encointer/util@npm:^0.15.1, @encointer/util@workspace:packages/util":
"@encointer/util@npm:^0.15.2-alpha.1, @encointer/util@workspace:packages/util":
version: 0.0.0-use.local
resolution: "@encointer/util@workspace:packages/util"
dependencies:
Expand All @@ -798,9 +798,9 @@ __metadata:
version: 0.0.0-use.local
resolution: "@encointer/worker-api@workspace:packages/worker-api"
dependencies:
"@encointer/node-api": "npm:^0.15.1"
"@encointer/types": "npm:^0.15.1"
"@encointer/util": "npm:^0.15.1"
"@encointer/node-api": "npm:^0.15.2-alpha.1"
"@encointer/types": "npm:^0.15.2-alpha.1"
"@encointer/util": "npm:^0.15.2-alpha.1"
"@peculiar/webcrypto": "npm:^1.4.6"
"@polkadot/api": "npm:^11.2.1"
"@polkadot/keyring": "npm:^12.6.2"
Expand Down

0 comments on commit 30ca711

Please sign in to comment.