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: switch to raw multihashes for blocks #6816

Merged
merged 11 commits into from
Dec 13, 2021
Merged

Conversation

Stebalien
Copy link
Member

Part of: #6815

@hsanjuan
Copy link
Contributor

hsanjuan commented Feb 7, 2020

@Stebalien other than the right import versions here, this should be good.

gc/gc.go Outdated Show resolved Hide resolved
@hsanjuan
Copy link
Contributor

hsanjuan commented Feb 28, 2020

@Stebalien some sharness tests are failing because some outputs changed from CidV0 to CidV1 (i.e. repo gc) and text output is defaulting to base32 then.

Shall I patch at the core/commands level (i.e. we can convert to CidV0 in the places we do .Emit), or update sharness tests? This seems to affect tests relying on refs local and repo gc outputs mostly.

I think things get messy with sharness. If I'm getting it right, blockstore.AllKeysChan is now going to return a list of CidV1.Raw (this affects refs local) regardless of what was the original CID type. But ipfs add will return a CidV1-DagPB.

So a sharness test adding a hash with CidV1 and then checking that refs local shows that hash will fail. Same for some things checking GC output. May also start triggering false positives. Might fix a bunch of those by adding an argument to refs local that allows to check for a single CID (rather than listing and grepping).

@hsanjuan
Copy link
Contributor

hsanjuan commented Mar 9, 2020

I'm going to work on fixing sharness tests directly

@hsanjuan
Copy link
Contributor

hsanjuan commented Mar 9, 2020

Yai all green :) @Stebalien can you check my last commits?

(btw it seems it fast-forwarded a merge from master or something and did not create a merge commit, making the history a bit dirty).

@hsanjuan
Copy link
Contributor

This one seems ok in terms of tests and everything, it just needed some rebase.

@hsanjuan
Copy link
Contributor

I will look at it more closely though, particularly the GC part.

Stebalien and others added 7 commits December 2, 2021 09:41
Not that they will ever happen in the current implementation, but it makes the
linter happy and covers our back for future.
This fixes some tests which expect "refs local" and "repo gc" outputs to match
the CIDs produced when adding data. These operations are now outputting CIDv1-raw
hashes, regardless of the original CIDs used to address those blocks, so some tests
fail.

The fix is usually:

* To use "block stat" to check if a block was correctly gc'ed
* To convert the CIDs to multihash (using cid-fmt) and compare those instead
This sharness test provides 2 datastore blocks directly.

One of them (corresponding to an "insecure block") is not a CIDv0 therefore it
needs to be migrated and stored with its raw-multihash ID.

The (raw) CID of the block used in the test remains the same.

The other block needs no changes.
@aschmahmann
Copy link
Contributor

@hsanjuan the only thing I clobbered/ignored in the rebase was 163794e (t0081-repo-pinning.sh re-enable the offline daemon), since I figured it might've been intentional that we were running some of the tests with the daemon off and some with it on, but in offline mode.

If so we can just remove the extraneous comments. This issue seems unrelated to the main thrust of the PR, but ended up here as you were cleaning things up (thanks for that 🙏).

gc/gc.go Show resolved Hide resolved
Comment on lines +122 to +126
HASH_MH=`cid-fmt -b base32 "%M" "$HASH"` &&
HARDCODED_HASH_MH=`cid-fmt -b base32 "%M" "QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y"` &&
EMPTY_DIR_MH=`cid-fmt -b base32 "%M" "$EMPTY_DIR"` &&
HASH_WELCOME_DOCS_MH=`cid-fmt -b base32 "%M" "$HASH_WELCOME_DOCS"` &&
ipfs refs local | cid-fmt -b base32 --filter "%M" >actual8 &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need cid-fmt here, or can we use ipfs cid format? Generally, asking here and through the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know, this was done before ipfs cid format was there. Worth fixing in a different PR accross all tests?

test/sharness/t0087-repo-robust-gc.sh Outdated Show resolved Hide resolved
Comment on lines +81 to +82
grep -q "removed $(to_raw_cid $LEAF3)" repo_gc_out &&
grep -q "removed $(to_raw_cid $LEAF4)" repo_gc_out &&
Copy link
Contributor

Choose a reason for hiding this comment

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

These don't seem necessary since we're already doing raw leaves, but it can't hurt

@@ -85,7 +89,7 @@ test_gc_robust_part1() {

test_expect_success "'ipfs repo gc' should be ok now" '
ipfs repo gc | tee repo_gc_out
grep -q "removed $LEAF2" repo_gc_out
grep -q "removed $(to_raw_cid $LEAF2)" repo_gc_out
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem necessary since we're already doing raw leaves, but it can't hurt

github.com/ipfs/go-fs-lock v0.0.7
github.com/ipfs/go-graphsync v0.11.0
github.com/ipfs/go-ipfs-blockstore v0.2.1
github.com/ipfs/go-ipfs-blockstore v1.1.2
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO: Update dist CID to point at latest migration

@@ -36,7 +36,7 @@ const LockFile = "repo.lock"
var log = logging.Logger("fsrepo")

// version number that we are currently expecting to see
var RepoVersion = 11
var RepoVersion = 12
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: bumped repo version

@@ -10,7 +10,7 @@ import (

const (
// Current distribution to fetch migrations from
CurrentIpfsDist = "/ipfs/QmP7tLxzhLU1KauTRX3jkVkF93pCv4skcceyUYMhf4AKJR" // fs-repo-migrations v2.0.2
CurrentIpfsDist = "/ipfs/QmPweMoUxWFt1MSpYwLWsHB1GBcyYYDKPnANdERMY4U6hK" // fs-repo-11-to-12 v1.0.1
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: Bumped to latest version of dist.ipfs.io

@aschmahmann aschmahmann merged commit 1a040b0 into master Dec 13, 2021
@aschmahmann aschmahmann deleted the feat/mh-backed-datastore branch December 13, 2021 20:37
@aschmahmann aschmahmann mentioned this pull request Dec 13, 2021
59 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants