Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Print error message when passing a non-existant socket path in the PAB #323

Merged
merged 1 commit into from
Feb 24, 2022

Conversation

koslambrou
Copy link
Contributor

@koslambrou koslambrou commented Feb 21, 2022

Fixes #287

Pre-submit checklist:

  • Branch
    • Tests are provided (if possible)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
    • Relevant tickets are mentioned in commit messages
    • Formatting, materialized Nix files, PNG optimization, etc. are updated
  • PR
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

@koslambrou koslambrou requested a review from raduom February 21, 2022 20:53
let priorContract :: (SomeBuiltinState a, Wallet.ContractInstanceId, ContractActivationArgs a)
priorContract = (s, cid, args)
pure priorContract
runConfigCommand
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes in this function are only formatting

@koslambrou koslambrou force-pushed the kll-pab-invalid-socket-path branch from f705402 to b1acd56 Compare February 23, 2022 09:55
@koslambrou koslambrou requested a review from bwbush February 23, 2022 09:56
@koslambrou
Copy link
Contributor Author

@bwbush This works for you as well? Since we print the information on the tip of the cardano using the socket, it will depend wheter the socket file doesn't exist.

@koslambrou koslambrou force-pushed the kll-pab-invalid-socket-path branch from b1acd56 to e72e60a Compare February 23, 2022 13:42
Copy link
Collaborator

@bwbush bwbush left a comment

Choose a reason for hiding this comment

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

The changes are okay, but they don't fix the problem.

When I run plutus-pab-executables with a valid socket, I get

[nix-shell:plutus-apps.PR323/plutus-pab-executables]$ git log -n 1 --oneline
e72e60adf (HEAD -> kll-pab-invalid-socket-path, origin/kll-pab-invalid-socket-path) Print error message when passing a non-existant socket path in the PAB

[nix-shell:plutus-apps.PR323/plutus-pab-executables]$ cabal run exe:plutus-pab-examples -- webserver --config marlowe-pab.yaml
Up to date
[pab:Info:19] [2022-02-23 18:01:41.21 UTC] Restoring PAB state ...
[pab:Info:19] [2022-02-23 18:01:41.21 UTC] No contract instance were restored in the PAB state.
[pab:Info:19] [2022-02-23 18:01:41.21 UTC] Starting PAB backend server on port 9080
Current block: 95. Current slot: 127678
Current block: 97. Current slot: 161191
Current block: 252. Current slot: 363718
^C

but when I remove the socket file, I get continuing silence and no error message:

[nix-shell:plutus-apps.PR323/plutus-pab-executables]$ rm node.socket 

[nix-shell:plutus-apps.PR323/plutus-pab-executables]$ cabal run exe:plutus-pab-examples -- webserver --config marlowe-pab.yaml
Up to date
[pab:Info:19] [2022-02-23 18:01:51.92 UTC] Restoring PAB state ...
[pab:Info:19] [2022-02-23 18:01:51.92 UTC] No contract instance were restored in the PAB state.
[pab:Info:19] [2022-02-23 18:01:51.92 UTC] Starting PAB backend server on port 9080
^C

This needs to pass several test cases:

  1. Success: the socket file is connected to a running node.
  2. Failure: the socket file exists but is not connected to a running node.
  3. Failure: the socket file does not exist.

@koslambrou koslambrou force-pushed the kll-pab-invalid-socket-path branch from e72e60a to 917fde8 Compare February 24, 2022 13:34
@koslambrou
Copy link
Contributor Author

@bwbush Oops, I put the code in the wrong place. Should be fixed now.
It now correctly outputs an error when the socket file doesn't exist in AlonzoMode.

Copy link
Collaborator

@bwbush bwbush left a comment

Choose a reason for hiding this comment

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

Works perfectly now!

[nix-shell:plutus-apps.PR323/plutus-pab-executables]$ ln -s ../../networks/private/node.socket 
[nix-shell:plutus-apps.PR323/plutus-pab-executables]$ cabal run exe:plutus-pab-examples -- webserver --config ../../networks/private/marlowe-pab.yaml
[pab:Info:19] [2022-02-24 16:26:20.73 UTC] Connecting to Alonzo node with config:
Socket: node.socket
Network Id: Testnet (NetworkMagic {unNetworkMagic = 1564})
Port: 80
Security Param: 2160
The tip of the local node: SlotNo 790305
[pab:Info:19] [2022-02-24 16:26:20.81 UTC] Restoring PAB state ...
[pab:Info:19] [2022-02-24 16:26:20.81 UTC] No contract instance were restored in the PAB state.
[pab:Info:19] [2022-02-24 16:26:20.81 UTC] Starting PAB backend server on port 9080
Current block: 72. Current slot: 105761
^C

[nix-shell:plutus-apps.PR323/plutus-pab-executables]$ rm node.socket
[nix-shell:plutus-apps.PR323/plutus-pab-executables]$ cabal run exe:plutus-pab-examples -- webserver --config ../../networks/private/marlowe-pab.yaml
plutus-pab-examples: Network.Socket.connect: <socket: 74>: does not exist (No such file or directory)

[nix-shell:plutus-apps.PR323/plutus-pab-executables]$ rm node.socket
[nix-shell:plutus-apps.PR323/plutus-pab-executables]$ mkfifo node.socket
[nix-shell:plutus-apps.PR323/plutus-pab-executables]$ cabal run exe:plutus-pab-examples -- webserver --config ../../networks/private/marlowe-pab.yaml
plutus-pab-examples: Network.Socket.connect: <socket: 74>: does not exist (Connection refused)

@koslambrou koslambrou merged commit 13836ec into main Feb 24, 2022
@koslambrou koslambrou deleted the kll-pab-invalid-socket-path branch February 24, 2022 17:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PAB does not report invalid node socket path
2 participants