-
Notifications
You must be signed in to change notification settings - Fork 286
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
base: main
Are you sure you want to change the base?
feat(ccmodel-hepheastus): add Hepheastus plugin #3641
Conversation
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]>
This PR/issue depends on:
|
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.
@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 |
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.
@RafaelAPB I recommend storing Python source code under ./src/main/python
instead of ./src/main/typescript/
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.
@brunoffmateus please move the python code to this other folder please
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.
@RafaelAPB I forgot to mention that this was done as well.
private crossChainLog: CrossChainEventLog; | ||
private unmodeledEventLog: CrossChainEventLog; | ||
private nonConformedCrossChainLog: CrossChainEventLog; | ||
private nonConformedCCTxs: string[]; |
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.
@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.
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.
okay, then the 3 Observables and sourceLedger
and targetLedger
should also be readonly
, right?
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...`); | ||
} | ||
} | ||
|
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.
@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.
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.
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( |
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.
@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.
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.
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( |
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.
@RafaelAPB Same question+conditional suggestion as above
const logName = name | ||
? `${name}.csv` | ||
: `hephaestus_log_${startTime.getTime()}.csv`; | ||
const csvFolder = path.join(__dirname, "../", "../", "test", "csv"); |
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.
@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
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.
@brunoffmateus can you please address the path issue
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.
@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"); |
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.
@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"); |
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.
@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
@petermetz @RafaelAPB I also added a quick message about the python dependency in the prerequisites of |
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
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.-s
flag when usinggit commit
command. You may refer to this link for more information.Character Limit
A Must Read for Beginners
For rebasing and squashing, here's a must read guide for beginners.