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

feat: hash checksums + download urls for snapshot restore and create #201

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

BrendanCoughlan5
Copy link
Contributor

@BrendanCoughlan5 BrendanCoughlan5 commented Jan 27, 2025

hash checksums + download urls for snapshot restore and create, also cleaned up/ logs/ readme/ docs

@BrendanCoughlan5 BrendanCoughlan5 requested a review from a team as a code owner January 27, 2025 17:38
@BrendanCoughlan5 BrendanCoughlan5 changed the title feat: introduce hash checksums + download urls for snapshot restore a… feat: hash checksums + download urls for snapshot restore and create Jan 27, 2025
@BrendanCoughlan5 BrendanCoughlan5 force-pushed the hashes_and_snapshot_download branch from 1bac8ff to 43ca345 Compare January 27, 2025 17:41
README.md Outdated Show resolved Hide resolved
docs/snapshots_docs.md Outdated Show resolved Hide resolved
docs/snapshots_docs.md Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot_test.go Outdated Show resolved Hide resolved
@BrendanCoughlan5 BrendanCoughlan5 force-pushed the hashes_and_snapshot_download branch from 17209f2 to 443cb30 Compare January 29, 2025 10:37
@BrendanCoughlan5 BrendanCoughlan5 self-assigned this Jan 29, 2025
@BrendanCoughlan5 BrendanCoughlan5 force-pushed the hashes_and_snapshot_download branch 2 times, most recently from d215762 to 28d5544 Compare January 30, 2025 20:02
docs/src/content/docs/running/snapshots.md Outdated Show resolved Hide resolved
internal/config/config.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot_test.go Show resolved Hide resolved
docs/src/content/docs/running/snapshots.md Outdated Show resolved Hide resolved
docs/src/content/docs/running/snapshots.md Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
@seanmcgary seanmcgary self-requested a review February 3, 2025 14:49
Copy link
Member

@seanmcgary seanmcgary left a 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.

@seanmcgary
Copy link
Member

seanmcgary commented Feb 3, 2025

Ran the restore-snapshot function and encountered a strange error. It seems to have downloaded the file completely, but then say's it received a 404 after the fact (which isnt possible):

downloading tmp/sidecar-testnet-holesky_v3.0.0-rc.1_public_20250122.dump 100% [========================================] Error: failed to restore snapshot: Error downloading snapshot from 'https://eigenlayer-sidecar.s3.us-east-1.amazonaws.com/snapshots/testnet-holesky/sidecar-testnet-holesky_v3.0.0-rc.1_public_20250122.dump': downloading error, received status code 404

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.

@BrendanCoughlan5
Copy link
Contributor Author

BrendanCoughlan5 commented Feb 3, 2025

Ran the restore-snapshot function and encountered a strange error. It seems to have downloaded the file completely, but then say's it received a 404 after the fact (which isnt possible):

downloading tmp/sidecar-testnet-holesky_v3.0.0-rc.1_public_20250122.dump 100% [========================================] Error: failed to restore snapshot: Error downloading snapshot from 'https://eigenlayer-sidecar.s3.us-east-1.amazonaws.com/snapshots/testnet-holesky/sidecar-testnet-holesky_v3.0.0-rc.1_public_20250122.dump': downloading error, received status code 404

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"}

cmd/createSnapshot.go Outdated Show resolved Hide resolved
cmd/createSnapshot.go Outdated Show resolved Hide resolved
cmd/restoreSnapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot_test.go Show resolved Hide resolved
@BrendanCoughlan5 BrendanCoughlan5 force-pushed the hashes_and_snapshot_download branch from f149b27 to 3929046 Compare February 6, 2025 07:07
@BrendanCoughlan5
Copy link
Contributor Author

#201 (comment)

downloadFile is intended to be used to download an individual file, like you downloadFile(snapshot), then downloadFile(snapshotHash)

@BrendanCoughlan5 BrendanCoughlan5 force-pushed the hashes_and_snapshot_download branch from 04bf17c to 0ed2257 Compare February 12, 2025 00:14
cmd/createSnapshot.go Outdated Show resolved Hide resolved
cmd/restoreSnapshot.go Outdated Show resolved Hide resolved
cmd/root.go Outdated Show resolved Hide resolved
cmd/root.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/snapshot/snapshot.go Outdated Show resolved Hide resolved
inputUrl := s.cfg.Input

// Check if the input URL exists
snapshotExists, err := urlExists(inputUrl)
Copy link
Member

Choose a reason for hiding this comment

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

Doesnt look like thats the case. Still calling urlExists which executes a HEAD request

if s.cfg.VerifyInput {
hashUrl := getHashName(inputUrl)

hashFileExists, err := urlExists(hashUrl)
Copy link
Member

Choose a reason for hiding this comment

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

Still making a HEAD request

pkg/snapshot/snapshot_test.go Outdated Show resolved Hide resolved
@BrendanCoughlan5 BrendanCoughlan5 force-pushed the hashes_and_snapshot_download branch 2 times, most recently from d1af443 to 9c8c169 Compare February 13, 2025 22:52
@BrendanCoughlan5 BrendanCoughlan5 force-pushed the hashes_and_snapshot_download branch from 9c8c169 to d2f477c Compare February 14, 2025 04:59
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.

2 participants