Skip to content
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

feat(ccmodel-hepheastus): add Hepheastus plugin #3641

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RafaelAPB
Copy link
Contributor

@RafaelAPB RafaelAPB commented Nov 15, 2024

Implementation of the paper Hepheastus https://ieeexplore.ieee.org/document/10363680

Depends on #3638 and #3639;: #3642, #3643 #3644
Authored-by: Bruno Mateus [email protected]
Co-authored-by: Rafael Belchior [email protected]
Signed-off-by: Rafael Belchior [email protected]

Pull Request Requirements

  • Rebased onto upstream/main branch and squashed into single commit to help maintainers review it more efficient and to avoid spaghetti git commit graphs that obfuscate which commit did exactly what change, when and, why.
  • Have git sign off at the end of commit message to avoid being marked red. You can add -s flag when using git commit command. You may refer to this link for more information.
  • Follow the Commit Linting specification. You may refer to this link for more information.

Character Limit

  • Pull Request Title and Commit Subject must not exceed 72 characters (including spaces and special characters).
  • Commit Message per line must not exceed 80 characters (including spaces and special characters).

A Must Read for Beginners
For rebasing and squashing, here's a must read guide for beginners.

Implementation  of the paper Hepheastus https://ieeexplore.ieee.org/document/10363680

Authored-by: Bruno Mateus <[email protected]>
Co-authored-by: Rafael Belchior <[email protected]>
Signed-off-by: Rafael Belchior <[email protected]>
Copy link

github-actions bot commented Nov 15, 2024

This PR/issue depends on:

Copy link
Contributor

@petermetz petermetz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelAPB I left some suggestions in the code, but it's fine by me if you'd prefer to address those later or never. I want to make sure I'm not slowing down the development.

@@ -0,0 +1,226 @@
import sys
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelAPB I recommend storing Python source code under ./src/main/python instead of ./src/main/typescript/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brunoffmateus please move the python code to this other folder please

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelAPB I forgot to mention that this was done as well.

Comment on lines +80 to +83
private crossChainLog: CrossChainEventLog;
private unmodeledEventLog: CrossChainEventLog;
private nonConformedCrossChainLog: CrossChainEventLog;
private nonConformedCCTxs: string[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelAPB If these are not getting re-assigned anywhere outside of the constructor then you can also mark them readonly which doesn't change anything at runtime but it's a good practice to have as much of the state of your class being readonly as possible which helps lower bugs in this regard.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, then the 3 Observables and sourceLedger and targetLedger should also be readonly, right?

Comment on lines +190 to +202
public async shutdown(): Promise<void> {
this.log.info(`Shutting down...`);
const serverMaybe = this.getHttpServer();
if (serverMaybe.isPresent()) {
this.log.info(`Awaiting server.close() ...`);
const server = serverMaybe.get();
await promisify(server.close.bind(server))();
this.log.info(`server.close() OK`);
} else {
this.log.info(`No HTTP server found, skipping...`);
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelAPB This is no longer a needed method of the plugin interfaces and you can also delete the getHttpServer method and the httpServer field itself. Makes no difference but I figured it helps to tidy up a little.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i remove the shutdown() method i get an error saying Property 'shutdown' is missing in type 'CcModelHephaestus' but required in type 'IPluginWebService', should i keep it with just the log message then?

};
}

private pollTxReceiptsBesu(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelAPB Does this do any actual polling? It looks like it just massages the data. If I'm understanding it correctly then I'd recommend renaming it to something expressing that instead of polling for tx receipts.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, I removed pollTxReceiptsBesu, and now the createReceiptFromRunTransactionV1ExchangeBesu is directly called when receiving data through the Observable. Same with the other 2 "poll" methods.

};
}

private pollTxReceiptsEth(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelAPB Same question+conditional suggestion as above

const logName = name
? `${name}.csv`
: `hephaestus_log_${startTime.getTime()}.csv`;
const csvFolder = path.join(__dirname, "../", "../", "test", "csv");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelAPB Depending on this will break the code in production when it is under a different sub-directory path (./dist/lib/.../) I recommend making it configurable through constructor parameters so that this issue can be avoided

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brunoffmateus can you please address the path issue

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelAPB I forgot to mention, but I added the parameter ccLogsDir: string that is set in the constructor. When not provided in the plugin options a default path is used.

const logName = name
? `${name}.json`
: `hephaestus_log_${startTime.getTime()}.json`;
const jsonFolder = path.join(__dirname, "../", "../", "test", "json");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelAPB Depending on this will break the code in production when it is under a different sub-directory path (./dist/lib/.../) I recommend making it configurable through constructor parameters so that this issue can be avoided

private async persistUnmodeledEventLog(): Promise<string> {
const startTime = new Date();
const logName = `hephaestus_log_${startTime.getTime()}`;
const jsonFolder = path.join(__dirname, "../", "../", "test", "json");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelAPB Depending on this will break the code in production when it is under a different sub-directory path (./dist/lib/.../) I recommend making it configurable through constructor parameters so that this issue can be avoided

@brunoffmateus
Copy link

brunoffmateus commented Nov 22, 2024

@petermetz @RafaelAPB I also added a quick message about the python dependency in the prerequisites of README.md. If you don't find it necessary I can remove it.
Otherwise I think everything is done in this commit: e1626c4. You should be able to cherry-pick and squash it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants