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

398 client runner #400

Merged
merged 21 commits into from
Oct 13, 2023
Merged

398 client runner #400

merged 21 commits into from
Oct 13, 2023

Conversation

gianfra-t
Copy link
Contributor

Addition of an implementation of the runner client taken from interlay clients.

In summary, the runner fetches periodically for the on-chain information about the vault client, both download URI and checksum. It will then proceed to download and execute it, also checking for new releases and handling them.

The only difference on this implementation is:

  • The runner client will now verify checksum of the vault client once it is downloaded for the first time, rejecting the download if it does not match.
  • The runner will retry the download if it fails (for instance, if the checksum is incorrect)

@gianfra-t gianfra-t linked an issue Sep 14, 2023 that may be closed by this pull request
@gianfra-t gianfra-t requested a review from ebma September 14, 2023 17:14
runner/Cargo.toml Outdated Show resolved Hide resolved
clients/README.md Show resolved Hide resolved
runner/Cargo.toml Outdated Show resolved Hide resolved
runner/src/runner.rs Outdated Show resolved Hide resolved
runner/src/runner.rs Outdated Show resolved Hide resolved
runner/src/runner.rs Outdated Show resolved Hide resolved
runner/src/runner.rs Outdated Show resolved Hide resolved
runner/src/runner.rs Outdated Show resolved Hide resolved
runner/src/runner.rs Outdated Show resolved Hide resolved
runner/src/runner.rs Outdated Show resolved Hide resolved
Copy link
Member

@ebma ebma left a comment

Choose a reason for hiding this comment

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

Looks good overall, I just left some comments about minor issues.

@gianfra-t
Copy link
Contributor Author

gianfra-t commented Sep 14, 2023

Thanks for finding this @ebma! I have updated all the remarked changes. On that note, let me know if we should open a separate task to build an integration test for the runner.

@ebma
Copy link
Member

ebma commented Sep 28, 2023

On that note, let me know if we should open a separate task to build an integration test for the runner.

How would you suggest we approach this kind of test?

Copy link
Member

@ebma ebma left a comment

Choose a reason for hiding this comment

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

The code looks good overall.

How sure are we that this works as expected though @gianfra-t? You said you tested it locally once and it worked with downloading the binary from a target location and replacing the current vault executable, correct?

@gianfra-t
Copy link
Contributor Author

The code looks good overall.

How sure are we that this works as expected though @gianfra-t? You said you tested it locally once and it worked with downloading the binary from a target location and replacing the current vault executable, correct?

Yes. I tested locally with a release of the client and also tested updating it on a local chain. It detected the changes and downloaded/started the new one.

@ebma
Copy link
Member

ebma commented Sep 28, 2023

I also tested it and can confirm that the runner manages to read the URL stored in the clients-info pallet and downloads the release from there. However, the checksum did not match.
@gianfra-t During testing, how did you calculate the checksum for the clientsInfo::setCurrentClientReleases() extrinsic? Using the 'hash a file' option provided by polkadot.js does not seem to work, or at least the result of that hashing process is not the same as the result of the runner hashing the downloaded binary.

To make it work regardless, I just used the hash that the runner calculates and put that on chain. Afterward, downloading etc. worked. But this is not an ideal solution of course.

@gianfra-t
Copy link
Contributor Author

I actually had the same problem, the polkadot.js hash did not work. I thought it was a problem with it so I used this tool. Do you think it is a different hashing algorithm/implementation?
I it presents a problem I guess I could try a different hashing library on the runner that matches the one created by polkadot.js

@ebma
Copy link
Member

ebma commented Sep 29, 2023

Yes, let's try to use the same hashing algorithm for convenience. I tried to find what polkadot.js uses and I think it is blake2. The UI calls this function and according to this test it uses blake2 by default but can be overridden with a custom definition here. I think we don't specify a custom hasher so let's try hashing with blake2 in the vault client and see if the checksum then matches the one generated by polkadot.js upon file upload.

Update:
I just saw that interlay calculate the checksums as part of their release management and put them into an extra file contained in every release, see eg. sha256sums.txt. We could do the same. Do you have any opinions on this @gianfra-t? Would you prefer if we also keep using sha256 or should we switch to blake2?

@gianfra-t
Copy link
Contributor Author

gianfra-t commented Sep 29, 2023

I would say It really boils down to the deployment workflow we want.
If we plan to have a release of the client that is automated then I would say stick with this hashing algorithm and do something similar to interlay.

@ebma
Copy link
Member

ebma commented Sep 29, 2023

Alright. Let's stick to sha256 and not rely on the hash shown in polkadot.js. It's just a UI and we can use other means, like e.g. the tool you linked to.
So in theory this PR is ready for merge now but I'm hesitant to merge it just yet because the CI is failing.

@gianfra-t
Copy link
Contributor Author

It's the issue related to stellar update, so let's wait for that to be solved and we can merge those changes.

@ebma
Copy link
Member

ebma commented Oct 13, 2023

I'll merge this since the ubuntu CI job passed.

@ebma ebma merged commit 468ec56 into main Oct 13, 2023
1 of 2 checks passed
@ebma ebma deleted the 398-client-runner branch October 13, 2023 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create client/runner that supports auto-updating the vault client
2 participants