fix(cmds): CIDv1 and correct multicodecs in 'block put' and 'cid codecs’ #8568
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.
Ready for review together with ipfs/interface-go-ipfs-core#80
- CI is green.
- Added TLDR for release notes in the top comment #8568 (comment)
| if mhtval != mh.SHA2_256 || (mhlen != -1 && mhlen != 32) { | ||
| format = "protobuf" | ||
| } else { | ||
| format = "v0" | ||
| } |
There was a problem hiding this comment.
|
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.
@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.
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.
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 blockcommandsipfs block putnow produces CIDv1 withrawcodec by default nowipfs block put --cid-codecmakesblock putreturn CID with alternative codecipfs block put --formatis 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=v0will produce CIDv0 (implicit dag-pb)ipfs block put --format=cborwill produce CIDv1 with dag-cbor (!)ipfs block put --format=protobufwill produce CIDv1 with dag-pb (!)ipfs cid codecsipfs cid codecs --supportedcan be passed to only show codecs supported in various go-ipfs commandsDepends on:
refactor: remove invalid string2code mappings go-cid#137TODO:
--store-codec--cid-codecsharness tests.blockandcidcommand helptextgithub.com/ipfs/interface-go-ipfs-coredependency with version.Updategithub.com/ipfs/go-ciddependency with version that includes fix(cmds): CIDv1 and correct multicodecs in 'block put' and 'cid codecs’ #8568github.com/multiformats/go-multicodecdependency 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-coreis reviewed and the--format=protobufbackward-compatibility is added back.Closes #8471