-
Notifications
You must be signed in to change notification settings - Fork 0
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
WIP: blockfrost module and test #81
Conversation
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 prepared a branch with minimal changes to make CI happy. Feel free to re-implement them here.
Also in the branch I'm also starting an ssh server so that you can connect with ssh root@localhost -p 2000
after having started the test interactively with nix run .#vmTests-blockfrost -- --interactive
.
I don't if you already knew this "trick" but I believe it can help a lot.
Moreover if possible let's test something more significative besides /health
, perhaps we can check /blocks/latest
to see if the slot number is greater than a certain amount? Something similar to what we did for cardano-db-sync
I mean.
blockfrost = { | ||
url = "github:blockfrost/blockfrost-backend-ryo?ref=v2.0.2"; | ||
}; |
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.
We support multiple versions for the same packages now. Even if we'll have only one blockfrost for now I would already start preparing multiple blockfrost versions support for instance by renaming this input to something like blockrost-2.0.2
. Feel free to address this in another PR so that we can merge this ASAP.
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.
Take a look at what has been done for cardano-node
, ogmios
and kupo
. Also you should export the blockfrost derivation between this flake's packages.
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.
At the moment this done only for node, -- kupo, dbsync, ogmios remain unversioned (and I feel this versioning follow to bloating code, and should be used only when neccesary). So should I rename it?
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.
Ok let's ignore this until we support multiple versions.
tests/blockfrost.nix
Outdated
machine.wait_until_succeeds("""[[ $(echo "$(cardano-cli query tip --testnet-magic ${magic} | jq '.syncProgress' --raw-output) > 0.001" | bc) == "1" ]]""") | ||
machine.wait_for_unit("blockfrost-backend-ryo") | ||
time.sleep(10) | ||
machine.succeed("curl http://localhost:3000/health") |
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 believe it's /api/v0/health
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.
Nope, /api/v0
is only on public instances, local ones have straight /health
tests/blockfrost.nix
Outdated
machine.wait_for_unit("cardano-node-socket") | ||
machine.wait_until_succeeds("""[[ $(echo "$(cardano-cli query tip --testnet-magic ${magic} | jq '.syncProgress' --raw-output) > 0.001" | bc) == "1" ]]""") | ||
machine.wait_for_unit("blockfrost-backend-ryo") | ||
time.sleep(10) |
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.
The reason why the test is failing is because this is not enough in CI. Anyway I would avoid using timeouts like this and suggest machine.wait_until_succeeds()
.
tests/blockfrost.nix
Outdated
time.sleep(10) | ||
machine.succeed("curl http://localhost:3000/health") | ||
machine.succeed("curl --silent --fail http://localhost:3000/health") | ||
print(machine.succeed("systemd-analyze security blockfrost")) |
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.
For some reason this is also returning non-zero, I haven't investigated it.
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.
Different module name, it should be "blockfrost-ryo". Already fixed this
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.
@brainrake could you also please take a look? Especially for what concerns the internal coherence with other modules and if the options interface really makes sense in all cases (what if one runs postgres on a different machine? These kind of scenarios I mean...). I was wondering if it should also have an assertion but I'm not sure what it should assert.
PS: @avnik remember to check how docs look like
blockfrost = { | ||
url = "github:blockfrost/blockfrost-backend-ryo?ref=v2.0.2"; | ||
}; |
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.
Ok let's ignore this until we support multiple versions.
modules/blockfrost.nix
Outdated
mkEnableOption '' | ||
''; |
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.
Shouldn't we put something 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.
Check here. I t would be nice also having an example.
modules/blockfrost.nix
Outdated
enable = true; | ||
settings = { | ||
inherit (config.cardano) network; | ||
server.debug = true; |
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.
This is related to logs, right? Do we want it by default? Don't have a strong opinion honestly...
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.
Yes, debug probably could be removed. Was need to figure out that we had db connection issues
tests/blockfrost.nix
Outdated
perSystem.vmTests.tests.blockfrost = { | ||
impure = true; | ||
module = { | ||
nodes .machine = {pkgs, ...}: { |
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.
nodes .machine = {pkgs, ...}: { | |
nodes.machine = {pkgs, ...}: { |
modules/blockfrost.nix
Outdated
ProtectKernelModules = true; | ||
SystemCallArchitectures = "native"; | ||
# FIXME: Turn MemoryDenyWriteExecute prevent service from work | ||
# MemoryDenyWriteExecute = true; |
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.
# MemoryDenyWriteExecute = true; | |
# MemoryDenyWriteExecute = true; |
modules/blockfrost.nix
Outdated
ProtectKernelTunables = true; | ||
RestrictRealtime = true; | ||
# FIXME: Turn SystemCallFilter prevent service from work | ||
# SystemCallFilter = ["@system-service" "~@privileged"]; |
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.
# SystemCallFilter = ["@system-service" "~@privileged"]; | |
# SystemCallFilter = ["@system-service" "~@privileged"]; |
Signed-off-by: Alexander V. Nikolaev <avn@avnik.info>
Co-authored-by: Andrea Ciceri <andrea.ciceri@autistici.org> Co-authored-by: Alexander V. Nikolaev <avn@avnik.info> Signed-off-by: Alexander V. Nikolaev <avn@avnik.info>
Signed-off-by: Alexander V. Nikolaev <avn@avnik.info>
Improved behaviour in case when db-sync and/or postgress not enabled locally Signed-off-by: Alexander V. Nikolaev <avn@avnik.info>
It was causing issues with package options having as default values packages not in `pkgs`
No description provided.