cosmos/evm fork
Dchain replaces upstream github.com/cosmos/evm with the d-foundation fork via the go.mod replace directive:
github.com/cosmos/evm => github.com/d-foundation/evm v0.7.3-dchain-v1
Source: github.com/d-foundation/evm. The branch is pinned to the tag
v0.7.3-dchain-v1, upstream v0.7.3 plus a single patch.
The canonical list of customisations is the fork's own
CHANGELOG_DCHAIN.md. This page summarises
the patch, the deliberate non-patches, and the rebase procedure.
Customisations
ERC-20 precompile: remove value-case for bankkeeper.BaseKeeper
Commit: bde11e5e BankKeeper is used with pointer on dchain
File touched: precompiles/erc20/msgsrv.go — the only code change in the fork.
Surface change
The upstream type switch in MsgServer.Send covers both a value bankkeeper.BaseKeeper arm and a pointer
*bankkeeper.BaseKeeper arm, because upstream bankkeeper.NewMsgServerImpl takes the Keeper interface, which both
forms satisfy. The dchain patch deletes the value arm and leaves a comment in its place:
// dchain patch: removed `case bankkeeper.BaseKeeper:` (value).
// The d-foundation/cosmos-sdk fork narrowed
// `bankkeeper.NewMsgServerImpl` to `*BaseKeeper` (pointer) only,
// making the value case fail to compile. dchain stores BankKeeper
// as `*BaseKeeper` exclusively, so the value case is unreachable.
case *bankkeeper.BaseKeeper:
msgSrv := bankkeeper.NewMsgServerImpl(keeper)
...
Rationale
This is a forced downstream consequence of the cosmos-sdk fork's bank keeper narrowing. The
d-foundation cosmos-sdk fork changes bankkeeper.NewMsgServerImpl from func(keeper Keeper) types.MsgServer to
func(keeper *BaseKeeper) types.MsgServer.
Go type-checks every arm of a type switch, not only the arm selected at runtime. Against the narrowed signature the value arm fails to compile with:
cannot use keeper (variable of type bankkeeper.BaseKeeper) as
*bankkeeper.BaseKeeper value in argument to bankkeeper.NewMsgServerImpl
The dchain application instantiates the bank keeper as *BaseKeeper exclusively (driven by the same cosmos-sdk fork's
depinject change), so the value arm is also unreachable at runtime. Deleting it both restores compilation and removes
dead code.
The pointer arm remains untouched and is the one that runs in production.
Deliberately NOT patched
ante IBCKeeper nil-check
Upstream ante/ante.go ships HandlerOptions.Validate(), which rejects a nil IBCKeeper. Dchain has no IBC, so it
wires no IBCKeeper into the evm ante handler — but the fork does not patch the check out. Protocol never calls
upstream Validate(): it validates its own HandlerOptions fields at app initialisation (see app/ante.go in
Protocol), mirroring the upstream checks for the fields dchain wires, minus IBCKeeper. The fork's ante/ante.go
therefore tracks upstream byte-for-byte, keeping the diff minimal.
x/precisebank: no longer carried
Earlier dchain pins (v0.5.0-dchain-v1) implicitly retained x/precisebank because upstream removed it (in
#1019 chore!: Remove x/precisebank) only after v0.5.0. That situation is
resolved on v0.7.3: upstream no longer wires x/precisebank into the core module set — the code survives only as an
opt-in module under contrib/x/precisebank, nothing in the core stack or the reference evmd app references it, and
the ERC-20 precompile type switch no longer has precisebank arms. Dchain does not opt in: Protocol contains no
references to precisebank. The open question from the v0.5.0 pin era is closed — dropped.
Rebase strategy
This customisation is one commit on top of a vanilla v0.7.3 base. When rebasing onto a new upstream cosmos/evm
release:
- Pull the new upstream tag.
- Cherry-pick
bde11e5eand resolve conflicts inprecompiles/erc20/msgsrv.go. The patch is a single arm deletion; if upstream has reshaped the type switch (for example, replaced it with an interface-driven dispatch), the patch needs re-deriving rather than re-applying. - Re-verify the resulting file compiles against the current
d-foundation/cosmos-sdkfork. - Re-check the deliberate non-patches: if Protocol ever starts calling upstream
HandlerOptions.Validate(), theIBCKeepernil-check becomes a problem again. - Update
CHANGELOG_DCHAIN.md, re-tag asvX.Y.Z-dchain-vN, and bump the replace directive inprotocol/go.mod.