-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix(cmds): CIDv1 and correct multicodecs in 'block put' and 'cid codecs’ #8568
Conversation
@schomatis : @lidel is going to take this over as it is being used to validate his work in ipfs/go-cid#137 . The issue has been reeassigned. |
6c90cda
to
1b7c968
Compare
(wip rebase, need to rebase ipfs/interface-go-ipfs-core#80 too and switch this PR to that) |
- switches to ipfs/interface-go-ipfs-core#80 (comment) - updates helptext of block commands to reflect the fact we now use CIDs everywhere and document the defaults - add tests for new --cid-codec and old --format behavior
1b7c968
to
70c13cf
Compare
we use it in IPNS-related commands
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.
Ready for review together with ipfs/interface-go-ipfs-core#80
- CI is green.
- Added TLDR for release notes in the top comment fix(cmds): CIDv1 and correct multicodecs in 'block put' and 'cid codecs’ #8568 (comment)
core/commands/block.go
Outdated
if mhtval != mh.SHA2_256 || (mhlen != -1 && mhlen != 32) { | ||
format = "protobuf" | ||
} else { | ||
format = "v0" | ||
} |
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.
TODO: see if we can error if no |
cmds.StringOption(mhtypeOptionName, "multihash hash function").WithDefault("sha2-256"), | ||
cmds.IntOption(mhlenOptionName, "multihash hash length").WithDefault(-1), | ||
cmds.BoolOption(pinOptionName, "pin added blocks recursively").WithDefault(false), | ||
cmds.StringOption(blockCidCodecOptionName, "Multicodec to use in returned CID").WithDefault("raw"), |
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.
@aschmahmann I did some tests around this and the good news is that I was wrong, there is a way to have unified handling of default opts that works the same in ipfs block put
CLI and raw HTTP POST to /api/v0/block/put
.
If we keep the .WithDefault("raw")
here, then this implicit default is also applied when people use curl against /api/v0/block/put
and forget to pass cid-codec
. It will also produce good docs at https://docs.ipfs.io/reference/http/api/#api-v0-block-put.
If we want to be extra strict and return error, I'd have to remove WithDefault
and add some glue code that detects cidCodec == ""
and throws error, but that feels hacky and annoying because it would make cid-codec
a mandatory parameter, making it bad UX for the common use case where people are fine with codec being raw.
My vote is to keep WithDefault("raw")
.
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.
Yep, the only breaking change is:
ipfs block put now produces CIDv1 with raw codec by default now
Which only effects the output CID, but ipfs block put <some-dagpb-stuff>; ipfs block get QmDagPBv0Thing
will still work fine. This seems like a not too bad silent breakage, although I'm generally averse to silent breakages. WDYT?
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.
sgtm. Added 0.13 breaking changes section to CHANGELOG.md in 2f5b8a4
As per triage verbal with Adin today, will merge as soon CI is green. |
Applies necessary changes to ensure 'block/put' works and is backward-compatible. Context: ipfs/kubo#8568
* chore: interop with go-ipfs 0.13 Applies necessary changes to ensure 'block/put' works and is backward-compatible. Context: ipfs/kubo#8568 * chore: 0.3.1 bumping as patch because we bumped to 0.3.0 recently, as part of other (unreleased) go-ipfs 0.13 work
This ensures cid-codec introduced in ipfs/kubo#8568 gets correctly passed (+ we maintain backward-compatibility with CIDv0)
This ensures cid-codec introduced in ipfs/kubo#8568 gets correctly passed (+ we maintain backward-compatibility with CIDv0)
This ensures cid-codec introduced in ipfs/kubo#8568 gets correctly passed (+ we maintain backward-compatibility with CIDv0)
This ensures cid-codec introduced in ipfs/kubo#8568 gets correctly passed (+ we maintain backward-compatibility with CIDv0)
* chore: interop with go-ipfs 0.13 Applies necessary changes to ensure 'block/put' works and is backward-compatible. Context: #8568 * chore: 0.3.1 bumping as patch because we bumped to 0.3.0 recently, as part of other (unreleased) go-ipfs 0.13 work This commit was moved from ipfs/go-ipfs-http-client@ecf364c
This ensures cid-codec introduced in #8568 gets correctly passed (+ we maintain backward-compatibility with CIDv0) This commit was moved from ipfs/go-ipfs-http-client@9c9f43f
…cs' (#8568) BREAKING CHANGES: - see ipfs/kubo#8568 (comment) Co-authored-by: Marcin Rataj <[email protected]>
@lidel's blurb for Release Notes
BREAKING CHANGES
ipfs block
commandsipfs block put
now produces CIDv1 withraw
codec by default nowipfs block put --cid-codec
makesblock put
return CID with alternative codecipfs block put --format
is deprecated. It used incorrect codec names and should be avoided for new deployments. Use it only if you need the old, invalid behavior, namely:ipfs block put --format=v0
will produce CIDv0 (implicit dag-pb)ipfs block put --format=cbor
will produce CIDv1 with dag-cbor (!)ipfs block put --format=protobuf
will produce CIDv1 with dag-pb (!)ipfs cid codecs
ipfs cid codecs --supported
can be passed to only show codecs supported in various go-ipfs commandsDepends on:
refactor: remove invalid string2code mappings go-cid#137TODO:
--store-codec
--cid-codec
sharness tests.block
andcid
command helptextgithub.com/ipfs/interface-go-ipfs-core
dependency with version.Updategithub.com/ipfs/go-cid
dependency with version that includes fix(cmds): CIDv1 and correct multicodecs in 'block put' and 'cid codecs’ #8568github.com/multiformats/go-multicodec
dependency with version that includes tidy code generation, add KnownCodes, add Code.Tag method multiformats/go-multicodec#59"can set multihash type and length on block put without format"
onceinterface-go-ipfs-core
is reviewed and the--format=protobuf
backward-compatibility is added back.Closes #8471