-
Notifications
You must be signed in to change notification settings - Fork 1
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: hash checksums + download urls for snapshot restore and create #201
base: master
Are you sure you want to change the base?
Conversation
1bac8ff
to
43ca345
Compare
17209f2
to
443cb30
Compare
acb5f62
to
d215762
Compare
d215762
to
28d5544
Compare
pkg/snapshot/snapshot.go
Outdated
hashFileName := inputFileName + ".sha256sum" | ||
hashFile, err := downloadFile(inputUrl+".sha256sum", hashFileName) | ||
if err != nil { | ||
return fmt.Errorf("failed to download snapshot hash: %w", err) |
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.
Do we want to differentiate between an problem downloading the file and an error like a 404 where the file simply doesnt exist? If it doesnt exist, what do you think is the best thing to do?
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.
When using the repo_metadata/ manifest, if there's a 404 and you can't find the file, then you should go through older versions, i.e. curl -I through newest -> oldest, then download it, i think this would be handled no in the downloadFile but in a function interpreting the manifest to find the file.
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.
also did the errors.Wrap and the downloadFile gives a 404 to be more explicit
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.
potentially you could give an error that the hash file isn't there, no verification happened and then proceed with restoring the snapshot, but i think that might be dangerous/ security wouldn't like that? Maybe for testnet that's fine to allow, i'm a bit hesitant to allow restore snapshot without
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.
Selected the wrong option on accident...see above feedback for changes needed.
Ran the
It also didnt clean up the file that was created, which it probably should. arguments: go run main.go restore-snapshot
--ethereum.rpc-url="https://winter-white-crater.ethereum-holesky.quiknode.pro/1b1d75c4ada73b7ad98e1488880649d4ea637733/" \
--chain="preprod" \
--database.host="localhost" \
--database.port="5432" \
--database.user="seanmcgary" \
--database.password="" \
--database.db_name="sidecar_test_restore" \
--ethereum.use_native_batch_call=false \
--snapshot.input=https://eigenlayer-sidecar.s3.us-east-1.amazonaws.com/snapshots/testnet-holesky/sidecar-testnet-holesky_v3.0.0-rc.1_public_20250122.dump \
--database.schema_name=public As a sidenote, when we encounter an error during execution, can we change it so that the usage message isnt printed? It adds a lot of noise and should really only be printed if the inputs are incorrect. |
Fixed to be clear it's the filesum the hash that doesn't exist. Try with the --snapshot.verify-input=false flag It should now give something like : {"level":"fatal","ts":"2025-02-03T12:53:34.148-0800","caller":"cmd/restoreSnapshot.go:44","msg":"failed to restore snapshot","error":"snapshot hash file not found at 'https://eigenlayer-sidecar.s3.us-east-1.amazonaws.com/snapshots/testnet-holesky/sidecar-testnet-holesky_v3.0.0-rc.1_public_20250122.dump.sha256sum'. Ensure the file exists or set --verify-input=false to skip verification","stacktrace":"github.com/Layr-Labs/sidecar/cmd.init.func4\n\t/Users/brendan/Documents/GitHub/sidecar/cmd/restoreSnapshot.go:44\ngithub.com/spf13/cobra.(*Command).execute\n\t/Users/brendan/go/pkg/mod/github.com/spf13/[email protected]/command.go:985\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\t/Users/brendan/go/pkg/mod/github.com/spf13/[email protected]/command.go:1117\ngithub.com/spf13/cobra.(*Command).Execute\n\t/Users/brendan/go/pkg/mod/github.com/spf13/[email protected]/command.go:1041\ngithub.com/Layr-Labs/sidecar/cmd.Execute\n\t/Users/brendan/Documents/GitHub/sidecar/cmd/root.go:19\nmain.main\n\t/Users/brendan/Documents/GitHub/sidecar/main.go:8\nruntime.main\n\t/opt/homebrew/Cellar/go/1.23.4/libexec/src/runtime/proc.go:272"} |
} | ||
} | ||
|
||
// Download the snapshot file and assign to s.cfg.Input |
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.
except we're using inputUrl
not s.cfg.Input
. Comments should explain why, not what and/or clarify potentially complex code/edgecases
} | ||
|
||
// Download the snapshot file and assign to s.cfg.Input | ||
fileName, err := getFileNameFromURL(inputUrl) |
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.
Comment says we're downloading the file but this function is not downloading the file. Recommend removing the comment
if err != nil { | ||
return errors.Wrap(err, fmt.Sprintf("failed to resolve input file path '%s'", s.cfg.Input)) | ||
} | ||
s.cfg.Input = resolvedFilePath |
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 as above, we should not be overwriting config values
} | ||
|
||
info, err := os.Stat(s.cfg.InputFile) | ||
// s.cfg.input is resolved from a url in resolveAndDownloadRestoreInput() |
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 we're having to leave comments because the meaning of our config values changes during runtime, we need to modify the behavior to prevent that. config values should be immutable in nature
f149b27
to
3929046
Compare
downloadFile is intended to be used to download an individual file, like you downloadFile(snapshot), then downloadFile(snapshotHash) |
hash checksums + download urls for snapshot restore and create, also cleaned up/ logs/ readme/ docs