Skip to content

Commit

Permalink
refactor(SATP-Hermes): fix cspell and lint
Browse files Browse the repository at this point in the history
Signed-off-by: André Augusto <andre.augusto@tecnico.ulisboa.pt>
  • Loading branch information
AndreAugusto11 committed Mar 11, 2024
1 parent e05cb11 commit 106a80d
Show file tree
Hide file tree
Showing 21 changed files with 207 additions and 238 deletions.
2 changes: 2 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"celo",
"cids",
"clsx",
"connectrpc",
"commenceack",
"configtx",
"Corda",
Expand Down Expand Up @@ -120,6 +121,7 @@
"myroot",
"mysecretpassword",
"myvolume",
"nanos",
"Nerc",
"NETWORKSCOPEALLFORTX",
"NETWORKSCOPEANYFORTX",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,33 +81,33 @@ export class PluginBUNGEEBenchmark {
private level: LogLevelDesc;
private logger: Logger;
public pluginRegistry: PluginRegistry;
private tIgetAllAssetsKey: number;
private tFgetAllAssetsKey: number;
private tIgetAllTxByKey: number;
private tFgetAllTxByKey: number;
private tIfabricGetTxReceiptByTxIDV1: number;
private tFfabricGetTxReceiptByTxIDV1: number;
private tIgenerateLedgerStates: number;
private tFgenerateLedgerStates: number;
private tIgenerateSnapshot: number;
private tFgenerateSnapshot: number;
private tIgenerateView: number;
private tFgenerateView: number;
private tsStartGetAllAssetsKey: number;
private tsEndGetAllAssetsKey: number;
private tsStartGetAllTxByKey: number;
private tsEndGetAllTxByKey: number;
private tsStartfabricGetTxReceiptByTxIDV1: number;
private tsEndfabricGetTxReceiptByTxIDV1: number;
private tsStartgenerateLedgerStates: number;
private tsEndgenerateLedgerStates: number;
private tsStartgenerateSnapshot: number;
private tsEndgenerateSnapshot: number;
private tsStartGenerateView: number;
private tsEndGenerateView: number;
private fileNameDate = Date.now();

constructor(public readonly options: IPluginBUNGEEOptions) {
this.tIgetAllAssetsKey = 0;
this.tFgetAllAssetsKey = 0;
this.tIgetAllTxByKey = 0;
this.tFgetAllTxByKey = 0;
this.tIfabricGetTxReceiptByTxIDV1 = 0;
this.tFfabricGetTxReceiptByTxIDV1 = 0;
this.tIgenerateLedgerStates = 0;
this.tFgenerateLedgerStates = 0;
this.tIgenerateSnapshot = 0;
this.tFgenerateSnapshot = 0;
this.tIgenerateView = 0;
this.tFgenerateView = 0;
this.tsStartGetAllAssetsKey = 0;
this.tsEndGetAllAssetsKey = 0;
this.tsStartGetAllTxByKey = 0;
this.tsEndGetAllTxByKey = 0;
this.tsStartfabricGetTxReceiptByTxIDV1 = 0;
this.tsEndfabricGetTxReceiptByTxIDV1 = 0;
this.tsStartgenerateLedgerStates = 0;
this.tsEndgenerateLedgerStates = 0;
this.tsStartgenerateSnapshot = 0;
this.tsEndgenerateSnapshot = 0;
this.tsStartGenerateView = 0;
this.tsEndGenerateView = 0;

this.className = "pluginBUNGEE";
this.level = options.logLevel || "INFO";
Expand Down Expand Up @@ -187,7 +187,7 @@ export class PluginBUNGEEBenchmark {
* @abstract Create ledger state. Get all keys, iterate every key and get the respective transactions. For each transaction get the receipt
* */
public async generateLedgerStates(): Promise<string> {
this.tIgenerateLedgerStates = performance.now();
this.tsStartgenerateLedgerStates = performance.now();
this.logger.info(`Generating ledger snapshot`);

const assetsKey = await this.getAllAssetsKey();
Expand Down Expand Up @@ -254,7 +254,7 @@ export class PluginBUNGEEBenchmark {
this.tF = asset9.getFinalTime();
}

this.tFgenerateLedgerStates = performance.now();
this.tsEndgenerateLedgerStates = performance.now();

return "";
}
Expand All @@ -264,10 +264,10 @@ export class PluginBUNGEEBenchmark {
* @abstract Returns Snapshot
* */
public generateSnapshot(): Snapshot {
this.tIgenerateSnapshot = performance.now();
this.tsStartgenerateSnapshot = performance.now();
const snapShotId = uuidv4();
const snapshot = new Snapshot(snapShotId, this.participant, this.states);
this.tFgenerateSnapshot = performance.now();
this.tsEndgenerateSnapshot = performance.now();
return snapshot;
}

Expand All @@ -278,7 +278,7 @@ export class PluginBUNGEEBenchmark {
* @param snapshot - Ledger Snapshot
* */
public generateView(snapshot: Snapshot): string {
this.tIgenerateView = performance.now();
this.tsStartGenerateView = performance.now();
const crypto = require("crypto");

this.logger.warn(this.pubKeyBungee);
Expand All @@ -302,7 +302,7 @@ export class PluginBUNGEEBenchmark {
JSON.stringify(signedView, null, 2),
);

this.tFgenerateView = performance.now();
this.tsEndGenerateView = performance.now();
return JSON.stringify(signedView);
}

Expand All @@ -313,7 +313,7 @@ export class PluginBUNGEEBenchmark {
* @param transactionId - Transaction id to return the receipt
* */
async fabricGetTxReceiptByTxIDV1(transactionId: string): Promise<string> {
this.tIfabricGetTxReceiptByTxIDV1 = performance.now();
this.tsStartfabricGetTxReceiptByTxIDV1 = performance.now();

const receiptLockRes = await this.fabricApi?.getTransactionReceiptByTxIDV1({
signingCredential: this.fabricSigningCredential,
Expand All @@ -324,7 +324,7 @@ export class PluginBUNGEEBenchmark {
params: [this.fabricChannelName, transactionId],
} as FabricRunTransactionRequest);

this.tFfabricGetTxReceiptByTxIDV1 = performance.now();
this.tsEndfabricGetTxReceiptByTxIDV1 = performance.now();
return JSON.stringify(receiptLockRes?.data);
}

Expand All @@ -333,7 +333,7 @@ export class PluginBUNGEEBenchmark {
* @abstract Returns all assets key found in the world state.
* */
async getAllAssetsKey(): Promise<string> {
this.tIgetAllAssetsKey = performance.now();
this.tsStartGetAllAssetsKey = performance.now();
const response = await this.fabricApi?.runTransactionV1({
signingCredential: this.fabricSigningCredential,
channelName: this.fabricChannelName,
Expand All @@ -344,7 +344,7 @@ export class PluginBUNGEEBenchmark {
} as FabricRunTransactionRequest);

if (response != undefined) {
this.tFgetAllAssetsKey = performance.now();
this.tsEndGetAllAssetsKey = performance.now();
return response.data.functionOutput;
}

Expand All @@ -358,7 +358,7 @@ export class PluginBUNGEEBenchmark {
* @param key - Key used to get correspondent transactions
* */
async getAllTxByKey(key: string): Promise<Transaction[]> {
this.tIgetAllTxByKey = performance.now();
this.tsStartGetAllTxByKey = performance.now();
const response = await this.fabricApi?.runTransactionV1({
signingCredential: this.fabricSigningCredential,
channelName: this.fabricChannelName,
Expand All @@ -369,7 +369,7 @@ export class PluginBUNGEEBenchmark {
} as FabricRunTransactionRequest);

if (response != undefined) {
this.tFgetAllTxByKey = performance.now();
this.tsEndGetAllTxByKey = performance.now();
return Utils.txsStringToTxs(response.data.functionOutput);
}

Expand Down Expand Up @@ -401,29 +401,29 @@ export class PluginBUNGEEBenchmark {

public generateBenchmarkReport(
numberOfTransactions: number,
tItotalTime: number,
tFtotalTime: number,
tItransactionsTime: number,
tFtransactionsTime: number,
tsStartTotalTime: number,
tsEndTotalTime: number,
tsStartTransactionsTime: number,
tsEndTransactionsTime: number,
): void {
const report = {
tIgetAllAssetsKey: this.tIgetAllAssetsKey,
tFgetAllAssetsKey: this.tFgetAllAssetsKey,
tIgetAllTxByKey: this.tIgetAllTxByKey,
tFgetAllTxByKey: this.tFgetAllTxByKey,
tIfabricGetTxReceiptByTxIDV1: this.tIfabricGetTxReceiptByTxIDV1,
tsStartGetAllAssetsKey: this.tsStartGetAllAssetsKey,
tsEndGetAllAssetsKey: this.tsEndGetAllAssetsKey,
tsStartGetAllTxByKey: this.tsStartGetAllTxByKey,
tsEndGetAllTxByKey: this.tsEndGetAllTxByKey,
tsStartfabricGetTxReceiptByTxIDV1: this.tsStartfabricGetTxReceiptByTxIDV1,
numberOfTransactions: numberOfTransactions,
tFfabricGetTxReceiptByTxIDV1: this.tFfabricGetTxReceiptByTxIDV1,
tIgenerateLedgerStates: this.tIgenerateLedgerStates,
tFgenerateLedgerStates: this.tFgenerateLedgerStates,
tIgenerateSnapshot: this.tIgenerateSnapshot,
tFgenerateSnapshot: this.tFgenerateSnapshot,
tIgenerateView: this.tIgenerateView,
tFgenerateView: this.tFgenerateView,
tItotalTime: tItotalTime,
tFtotalTime: tFtotalTime,
tItransactionsTime: tItransactionsTime,
tFtransactionsTime: tFtransactionsTime,
tsEndfabricGetTxReceiptByTxIDV1: this.tsEndfabricGetTxReceiptByTxIDV1,
tsStartgenerateLedgerStates: this.tsStartgenerateLedgerStates,
tsEndgenerateLedgerStates: this.tsEndgenerateLedgerStates,
tsStartgenerateSnapshot: this.tsStartgenerateSnapshot,
tsEndgenerateSnapshot: this.tsEndgenerateSnapshot,
tsStartGenerateView: this.tsStartGenerateView,
tsEndGenerateView: this.tsEndGenerateView,
tsStartTotalTime: tsStartTotalTime,
tsEndTotalTime: tsEndTotalTime,
tsStartTransactionsTime: tsStartTransactionsTime,
tsEndTransactionsTime: tsEndTransactionsTime,
};
const reportString = JSON.stringify(report, null, 2);
this.saveToFile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ export class PluginBUNGEE implements ICactusPlugin, IPluginWebService {
}

async onCreateView(request: CreateViewRequest): Promise<CreateViewResponse> {
//const fnTag = `${this.className}#onCreateView()`;
const fnTag = `${this.className}#onCreateView()`;
this.log.info(`${fnTag}, request received, ${request}`);
const response = this.generateView(this.generateSnapshot());
return {
y: response,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ export class State {
return this.version.toString();
}

public pruneState(tI: string, tF: string): void {
const tInum = parseInt(tI);
const tFnum = parseInt(tF);
public pruneState(tsStart: string, tsEnd: string): void {
const tsStartNum = parseInt(tsStart);
const tsEndNum = parseInt(tsEnd);
// eslint-disable-next-line prefer-const
this.transactions.forEach((element, index) => {
if (
parseInt(element.getTimeStamp()) < tInum ||
parseInt(element.getTimeStamp()) > tFnum
parseInt(element.getTimeStamp()) < tsStartNum ||
parseInt(element.getTimeStamp()) > tsEndNum
) {
this.version = this.version - 1;
this.transactions.splice(index, 1); //Remove tx
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"{\n \"tIgetAllAssetsKey\": 673460.4071750008,\n \"tFgetAllAssetsKey\": 675503.2377489991,\n \"tIgetAllTxByKey\": 876114.2376549989,\n \"tFgetAllTxByKey\": 878149.4369120002,\n \"tIfabricGetTxReceiptByTxIDV1\": 896200.017411001,\n \"numberOfTransactions\": 100,\n \"tFfabricGetTxReceiptByTxIDV1\": 898290.5824039988,\n \"tIgenerateLedgerStates\": 673458.7849370018,\n \"tFgenerateLedgerStates\": 898497.6535710022,\n \"tIgenerateSnapshot\": 898498.7192119993,\n \"tFgenerateSnapshot\": 898498.8481430002,\n \"tIgenerateView\": 898499.7117410004,\n \"tFgenerateView\": 898650.575286001,\n \"tItotalTime\": 12610.278124999255,\n \"tFtotalTime\": 898903.4868579991,\n \"tItransactionsTime\": 210704.5659589991,\n \"tFtransactionsTime\": 673449.9331209995\n}"
"{\n \"tsStartGetAllAssetsKey\": 673460.4071750008,\n \"tsEndGetAllAssetsKey\": 675503.2377489991,\n \"tsStartGetAllTxByKey\": 876114.2376549989,\n \"tsEndGetAllTxByKey\": 878149.4369120002,\n \"tsStartfabricGetTxReceiptByTxIDV1\": 896200.017411001,\n \"numberOfTransactions\": 100,\n \"tsEndfabricGetTxReceiptByTxIDV1\": 898290.5824039988,\n \"tsStartgenerateLedgerStates\": 673458.7849370018,\n \"tsEndgenerateLedgerStates\": 898497.6535710022,\n \"tsStartgenerateSnapshot\": 898498.7192119993,\n \"tsEndgenerateSnapshot\": 898498.8481430002,\n \"tsStartGenerateView\": 898499.7117410004,\n \"tsEndGenerateView\": 898650.575286001,\n \"tsStartTotalTime\": 12610.278124999255,\n \"tsEndTotalTime\": 898903.4868579991,\n \"tsStartTransactionsTime\": 210704.5659589991,\n \"tsEndTransactionsTime\": 673449.9331209995\n}"
32 changes: 16 additions & 16 deletions packages/cactus-plugin-bungee/src/report/report_1662558750023.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"tIgetAllAssetsKey": 676916.3033309989,
"tFgetAllAssetsKey": 678638.7855750024,
"tIgetAllTxByKey": 842997.5304520018,
"tFgetAllTxByKey": 844710.8069510013,
"tIfabricGetTxReceiptByTxIDV1": 859515.8936589994,
"tsStartGetAllAssetsKey": 676916.3033309989,
"tsEndGetAllAssetsKey": 678638.7855750024,
"tsStartGetAllTxByKey": 842997.5304520018,
"tsEndGetAllTxByKey": 844710.8069510013,
"tsStartfabricGetTxReceiptByTxIDV1": 859515.8936589994,
"numberOfTransactions": 100,
"tFfabricGetTxReceiptByTxIDV1": 861157.3159720004,
"tIgenerateLedgerStates": 676915.3176660016,
"tFgenerateLedgerStates": 861338.2410399988,
"tIgenerateSnapshot": 861339.1607629992,
"tFgenerateSnapshot": 861339.2764950022,
"tIgenerateView": 861340.0791519992,
"tFgenerateView": 861459.1003339998,
"tItotalTime": 12340.61959400028,
"tFtotalTime": 861555.6978779994,
"tItransactionsTime": 200109.30410899967,
"tFtransactionsTime": 676907.3711050004
"tsEndfabricGetTxReceiptByTxIDV1": 861157.3159720004,
"tsStartgenerateLedgerStates": 676915.3176660016,
"tsEndgenerateLedgerStates": 861338.2410399988,
"tsStartgenerateSnapshot": 861339.1607629992,
"tsEndgenerateSnapshot": 861339.2764950022,
"tsStartGenerateView": 861340.0791519992,
"tsEndGenerateView": 861459.1003339998,
"tsStartTotalTime": 12340.61959400028,
"tsEndTotalTime": 861555.6978779994,
"tsStartTransactionsTime": 200109.30410899967,
"tsEndTransactionsTime": 676907.3711050004
}
32 changes: 16 additions & 16 deletions packages/cactus-plugin-bungee/src/report/report_1662561672357.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"tIgetAllAssetsKey": 591096.3023070022,
"tFgetAllAssetsKey": 592822.4099819995,
"tIgetAllTxByKey": 758419.5141910017,
"tFgetAllTxByKey": 760104.0508930013,
"tIfabricGetTxReceiptByTxIDV1": 775115.5524360016,
"tsStartGetAllAssetsKey": 591096.3023070022,
"tsEndGetAllAssetsKey": 592822.4099819995,
"tsStartGetAllTxByKey": 758419.5141910017,
"tsEndGetAllTxByKey": 760104.0508930013,
"tsStartfabricGetTxReceiptByTxIDV1": 775115.5524360016,
"numberOfTransactions": 100,
"tFfabricGetTxReceiptByTxIDV1": 776803.2530790009,
"tIgenerateLedgerStates": 591095.2867860012,
"tFgenerateLedgerStates": 776980.2256029993,
"tIgenerateSnapshot": 776981.1981969997,
"tFgenerateSnapshot": 776981.5412559994,
"tIgenerateView": 776982.4675379992,
"tFgenerateView": 777062.5760970004,
"tItotalTime": 591088.4815299995,
"tFtotalTime": 777189.1618189998,
"tItransactionsTime": 183869.75471699983,
"tFtransactionsTime": 591087.1108880006
"tsEndfabricGetTxReceiptByTxIDV1": 776803.2530790009,
"tsStartgenerateLedgerStates": 591095.2867860012,
"tsEndgenerateLedgerStates": 776980.2256029993,
"tsStartgenerateSnapshot": 776981.1981969997,
"tsEndgenerateSnapshot": 776981.5412559994,
"tsStartGenerateView": 776982.4675379992,
"tsEndGenerateView": 777062.5760970004,
"tsStartTotalTime": 591088.4815299995,
"tsEndTotalTime": 777189.1618189998,
"tsStartTransactionsTime": 183869.75471699983,
"tsEndTransactionsTime": 591087.1108880006
}
32 changes: 16 additions & 16 deletions packages/cactus-plugin-bungee/src/report/report_1662584410609.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"tIgetAllAssetsKey": 219384.86245900393,
"tFgetAllAssetsKey": 221173.2095810026,
"tIgetAllTxByKey": 253188.82620900124,
"tFgetAllTxByKey": 254959.93393400311,
"tIfabricGetTxReceiptByTxIDV1": 254959.99529299885,
"tsStartGetAllAssetsKey": 219384.86245900393,
"tsEndGetAllAssetsKey": 221173.2095810026,
"tsStartGetAllTxByKey": 253188.82620900124,
"tsEndGetAllTxByKey": 254959.93393400311,
"tsStartfabricGetTxReceiptByTxIDV1": 254959.99529299885,
"numberOfTransactions": 10,
"tFfabricGetTxReceiptByTxIDV1": 256772.17797800153,
"tIgenerateLedgerStates": 219383.88455799967,
"tFgenerateLedgerStates": 256805.00567100197,
"tIgenerateSnapshot": 256806.16740500182,
"tFgenerateSnapshot": 256806.35255900025,
"tIgenerateView": 256807.19633500278,
"tFgenerateView": 256842.26325000077,
"tItotalTime": 219374.04392400384,
"tFtotalTime": 256846.67715299875,
"tItransactionsTime": 190752.17684999853,
"tFtransactionsTime": 219372.40088500082
"tsEndfabricGetTxReceiptByTxIDV1": 256772.17797800153,
"tsStartgenerateLedgerStates": 219383.88455799967,
"tsEndgenerateLedgerStates": 256805.00567100197,
"tsStartgenerateSnapshot": 256806.16740500182,
"tsEndgenerateSnapshot": 256806.35255900025,
"tsStartGenerateView": 256807.19633500278,
"tsEndGenerateView": 256842.26325000077,
"tsStartTotalTime": 219374.04392400384,
"tsEndTotalTime": 256846.67715299875,
"tsStartTransactionsTime": 190752.17684999853,
"tsEndTransactionsTime": 219372.40088500082
}
Loading

0 comments on commit 106a80d

Please sign in to comment.