-
Notifications
You must be signed in to change notification settings - Fork 47
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
chore(rln): update ganache #1347
Conversation
… test + uninstall; gracefully terminate ganache
Jenkins BuildsClick to see older builds (11)
|
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.
LGTM, please add package.json to the .gitignore, thanks!
Thanks! Done in 2db873d |
Merged #1344 into
|
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.
LGTM: Looks Great To Me 😁
Thank you for taking the time to solve this issue. Very much appreciated 🙏🏼
let installGanache = startProcess("npm", args = ["install", "ganache"], options = {poUsePath}) | ||
debug "Ganache installation completed. Printing install log", returnCode=installGanache.waitForExit(), log=installGanache.outputstream.readAll() |
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.
Chronicles at compile time remove all the statements below the -d:chronicles_log_level=<level>
log level. So, in this case, if we set the log level to INFO
, for example, it won't call waitForExit()
nor readAll()
.
let installGanache = startProcess("npm", args = ["install", "ganache"], options = {poUsePath}) | |
debug "Ganache installation completed. Printing install log", returnCode=installGanache.waitForExit(), log=installGanache.outputstream.readAll() | |
let installGanache = startProcess("npm", args = ["install", "ganache"], options = {poUsePath}) | |
let installGanacheRc = installGanache.waitForExit() | |
let installGanacheOutStream = installGanache.outputstream.readAll() | |
debug "Ganache installation completed. Printing install log", returnCode=installGanacheRc, log=installGanacheOutStream |
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.
Done in 20dc2da
# We gracefully terminate Ganache daemon | ||
# We send a SIGINT signal to the runGanache PID to trigger RPC server termination and clean-up | ||
debug "Sending SIGINT to Ganache", returnCode=kill(ganachePID.int32, SIGINT) | ||
debug "Ganache daemon terminated. Printing run log", returnCode=runGanache.waitForExit(), log=runGanache.outputstream.readAll() |
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.
Same here.
# We gracefully terminate Ganache daemon | |
# We send a SIGINT signal to the runGanache PID to trigger RPC server termination and clean-up | |
debug "Sending SIGINT to Ganache", returnCode=kill(ganachePID.int32, SIGINT) | |
debug "Ganache daemon terminated. Printing run log", returnCode=runGanache.waitForExit(), log=runGanache.outputstream.readAll() | |
# We gracefully terminate Ganache daemon | |
# We send a SIGINT signal to the runGanache PID to trigger RPC server termination and clean-up | |
let ganacheKillRc = kill(ganachePID.int32, SIGINT) | |
debug "Sent SIGINT to Ganache", returnCode=ganacheKillRc | |
let ganacheDaemonRc = runGanache.waitForExit() | |
let ganacheDaemonOutStream = runGanache.outputstream.readAll() | |
debug "Ganache daemon terminated. Printing run log", returnCode=ganacheDaemonRc, log=ganacheDaemonOutStream |
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.
Done in 20dc2da
|
||
# We uninstall Ganache | ||
let uninstallGanache = startProcess("npm", args = ["uninstall", "ganache"], options = {poUsePath}) | ||
debug "Ganache uninstall completed. Printing uninstall log", returnCode=uninstallGanache.waitForExit(), log=uninstallGanache.outputstream.readAll() |
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.
And here.
debug "Ganache uninstall completed. Printing uninstall log", returnCode=uninstallGanache.waitForExit(), log=uninstallGanache.outputstream.readAll() | |
let uninstallGanacheRc = uninstallGanache.waitForExit() | |
let uninstallGanacheOutStream = uninstallGanache.outputstream.readAll() | |
debug "Ganache uninstall completed. Printing uninstall log", returnCode=uninstallGanacheRc, log=uninstallGanacheOutStream` |
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.
Done in 20dc2da
######################## | ||
## Ganache installation | ||
######################## |
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.
Can you wrap the ganache install and start logic in a proc
(e.g., proc setupGanache()
) and call it here?
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.
+1
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.
Done in 20dc2da
################################ | ||
## Terminating/removing Ganache | ||
################################ |
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.
Same here. Can you wrap the ganache kill and uninstall logic in a proc
(e.g., proc cleanupGanache()
) and call it here?
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.
Done in 20dc2da
@rymnc Sorry for my ignorance, but why do you need to add |
@LNSD During my testing for this PR with process spawning etc. in nim, I realized that some of osproc APIs might act differently in macOS and linux (and windows) or lack some features. Hence, I strongly believe that tests (and in particular these ones) should happen on both platforms, even though this means longer tests. Of course, we might allow exceptions with well documented reasons. But IMO this is not the case and by running them on both platform we just give users more confidence that everything is working fine. |
Yeah, the npm install adds one by default :) |
Yes, and when I uninstall ganache, it leaves an empty |
My only concern about running the on-chain RLN tests in Linux is that it takes more than 1h to execute each task in the GH Actions CI. The macOS jobs were already failing due to timeout. We need to investigate why it is taking too much time (on-chain tests are doubling the current tests duration) |
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.
looks great! I always had the impression the Makefile wasn't the right place for ganache.
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.
Good one! left a comment, also I agree with @LNSD comment about creating separate procs for ganache setup and termination.
|
||
# We run Ganache daemon | ||
# Note that we run directly "node node_modules/ganache/dist/node/cli.js" rather than using "npx ganache", so that the daemon does not spawn in a new child process. | ||
# In this way, we can directly send a SIGINT signal to the corresponding PID to gracefully terminate Ganache without dealing with multiple processes. |
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.
I'd add the description of the argument as well as a link to the ganache documentation https://github.com/trufflesuite/ganache#documentation:
-p
stands for port, -l
sets the gas limit, and -e
sets the default account balance, specified in ether.
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.
Indeed! This is a very good point, I completely missed it:
@s1fr0 instead of using the short version of the flags, can you use the long version (e.g., --port
instead of -p
)?
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.
Absolutely! Options documented and switched to long version in 20dc2da
@s1fr0 |
Yes, this PR removes previous check on the OS for the CI, hence onchain tests will be executed on both platforms. |
Actually, the tests fail, and I guess the ganache process is not killed appropriately (even though there is a pkill in the Makefile for it). That's why they live for an hour. This PR should resolve that! |
@rymnc The tests went fine today (now jenkins seems to fail for an unrelated one) but I obseverd an absurd amount of time while building macOS (not even in test): did you notice some specific test failing that relates to this? Of course it is likely affecting something, but I'm not completely sure it's the (only) reason. |
Unsure, macOS always took longer than linux to build and test |
FYI in 37fd9c8 I moved installation of nodes modules to the build folder as proposed in #1347 (comment). I believe it makes sense to have there cache of installed/built packages since are the result of a building process, git will automatically ignore files there (with no need to manually change .gitignore) and |
Merging. See #1356 for a possible follow-up improvement to this PR. |
The npm package
ganache-cli
employed by onchain RLN tests is deprecated and is now replaced byganache
.This issue was originally raised in #1344 (comment).
Scope
This PR:
ganache-cli
withganache
.This update introduced some breaking changes which required some parameters previously passed to ganache-cli to be revised.
This allows to run ganache only during execution of onchain tests and not during the whole duration of tests2. Furthermore, onchain RLN tests will be executed by CI on both linux and macOS platform (before only macOS was ran these tests in CI).
ganache
by sending a SIGINT signal.ganache
when tests are terminated.Out of scope
Any other extra feature.