Skip to main content

cosmos-sdk fork

Dchain replaces upstream github.com/cosmos/cosmos-sdk with the d-foundation fork via the go.mod replace directive:

github.com/cosmos/cosmos-sdk => github.com/d-foundation/cosmos-sdk v0.54.3-dchain-v1

Source: github.com/d-foundation/cosmos-sdk. The branch is pinned to the tag v0.54.3-dchain-v1, a rebase of the dchain customisations onto upstream v0.54.3 (which ships cometbft v0.39.3 — the earlier fork-side cometbft pin to v0.38.21 is gone with it).

The canonical, file-level list of customisations is the fork's own CHANGELOG_DCHAIN.md. This page summarises what is carried and why; the changelog is authoritative on exactly which files changed.

Customisations carried on v0.54.3​

1. Verifiable Presentation (VP) flag on the tx factory​

Every CLI-built transaction can carry a base64-encoded Verifiable Presentation as a transaction extension option:

  • client/flags/flags.go adds the --verifiable-presentation flag (registered as BytesBase64 in AddTxFlagsToCmd).
  • client/tx/factory.go's NewFactoryCLI reads the flag; when non-empty it wraps the bytes into a *codectypes.Any with the vcv extension-option TypeUrl and stores it in Factory.extOptions.

The factory does not enforce the VP's presence — when the flag is absent the transaction is built without the extension option, and enforcement happens on-chain via Protocol's vcv ante handler. This feature introduces a runtime dependency on github.com/d-foundation/protocol (for the vcv package and VerifiablePresentation proto type).

2. Bank hooks (BlockBeforeSend / TrackBeforeSend)​

Lets other modules veto or observe coin movements before they happen — the compliance-gating primitive dchain modules build on:

  • New BankHooks interface and MultiBankHooks aggregator (x/bank/types/hooks.go), with keeper-side dispatch (x/bank/keeper/hooks.go): BlockBeforeSend returns the first non-nil error; TrackBeforeSend is fire-and-forget.
  • BaseSendKeeper gains a SetHooks setter (panics on double-set). SendCoins calls BlockBeforeSend before the move and TrackBeforeSend after; SendCoinsWithoutBlockHook exposes a bypass path; InputOutputCoins invokes both hooks per output.
  • Pointer BaseKeeper narrowing. bankkeeper.NewMsgServerImpl, the bank migrator, and the depinject output all take/emit *BaseKeeper instead of the Keeper interface or a value keeper. SetHooks mutates the keeper; with a value copy the mutation would only affect that copy, so the pointer guarantees every consumer (msg server, migrator, depinject consumers) sees the same hook set.
  • Depinject wiring in x/bank/module.go so external modules can supply hooks.

Dropped in the v0.54.3 rebase​

Two customisations carried through earlier rebases (up to v0.53.4-dchain-v5) were deliberately dropped:

  • AbstractContinuousVesting + NilPubKey (x/auth/vesting, proto/cosmos/vesting/dchainv1/). It existed solely to let ContinuousVestingAccount act as a wasm-controlled abstract account for the cosmwasm abstractaccount ante handler. CosmWasm has been fully removed from dchain and Protocol has zero references to these types. x/auth/vesting is now identical to upstream.
  • Epochs pointer-keeper plumbing (x/epochs depinject/keeper changes). Upstream v0.54 ships the equivalent wiring (InvokeSetHooks, pointer keeper handling, EpochHooksWrapper), making the fork patch redundant. x/epochs is now identical to upstream.

Downstream consequence: cosmos/evm precompile​

github.com/cosmos/evm's ERC-20 precompile is written against the upstream signature (NewMsgServerImpl(keeper Keeper)) and type-switches over both a value bankkeeper.BaseKeeper arm and a pointer *bankkeeper.BaseKeeper arm. Go type-checks every arm of a type switch, so against the narrowed fork signature the value arm fails to compile. This is patched downstream in the d-foundation evm fork — see the cosmos/evm fork page.

Rebase strategy​

When rebasing onto a new upstream cosmos-sdk release:

  1. Pull the new upstream tag and rebase the dchain commits onto it.
  2. Use the fork's CHANGELOG_DCHAIN.md file-level diff summary as the checklist of what must survive the rebase (VP flag/factory, bank hooks + pointer keeper); check whether upstream has absorbed anything (as happened with the epochs plumbing in v0.54), and drop what is no longer needed.
  3. Update CHANGELOG_DCHAIN.md to reflect the new base and any dropped/added patches.
  4. Re-tag as vX.Y.Z-dchain-vN.
  5. Bump the replace directive in protocol/go.mod and re-verify the d-foundation/evm ERC-20 precompile patch still compiles against the fork; if upstream cosmos/evm has reshaped the type switch, that patch needs re-deriving.