wasmd: During migration from legacy 20 byte address a 'no history for address' error occurs

In testing 0.23 on a testnet with existing contract instance an error is thrown due to the way kvstore addresses are generated. Addresses are based on the current 32 byte length form, unfortunately some contracts were established with the prior 20 byte address form which is incompatible with this approach.

https://github.com/CosmWasm/wasmd/blob/de38ea008b07f6537e077039469e64648e6e9747/x/wasm/types/keys.go#L90

The above line always presumes the length will be 32 and it fails because it can’t delete the history here:

https://github.com/CosmWasm/wasmd/blob/de38ea008b07f6537e077039469e64648e6e9747/x/wasm/keeper/keeper.go#L578

This occurred during testing on Provenance (using wasmd 0.23) with the following:

provenanced tx wasm migrate \
    tp15qkf84uddc0zjpkjrn64rln75w40plrtcq4kp3 \
    111 \
    '{}' \
    --chain-id pio-testnet-1 \
    --node tcp://rpc-0.test.provenance.io:26657 \
    [ ... ]

Error: rpc error: code = InvalidArgument desc = recovered: no history for tp15qkf84uddc0zjpkjrn64rln75w40plrtcq4kp3
stack:
goroutine 764913 [running]:
runtime/debug.Stack()
    runtime/debug/stack.go:24 +0x65

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 19 (19 by maintainers)

Commits related to this issue

Most upvoted comments

@channa-figure / @iramiller would you put in a PR to wasmd with your solution? On the current Juno testnet we’ve moved off our fork and onto mainline wasmd, so we can test a point release/pre-release as well if it’s in this repo. Otherwise a bit of faff to change to your fork, test, then change back to mainline 🙂

I agree with @iramiller that we should support both and new addresses are 32 bytes

We have a fork with this change which we are running now on our testnet for evaluation… it would be straight forward to contribute this solution… in addition if this solution needs to develop further we are interested in helping out cosmwasm with testing these changes and we would want to see those included in our network before we cut our next release.

To summarize, I can see these 3 options:

A) “upgrade” all contracts to 32 byte addresses and go with vanilla wasmd

Addresses are stored in many places and we cannot change them. Wasmd upgrades must work with immutable contracts.

B) we make ContractAddrLen a var so that every team can decide and set their contract address length (32byte would be default)

They don’t want 20 bytes. They want 32, but want backwards support for 20 bytes. Note that various components in the sdk (notably ibc) choked on 32 bytes addresses when Provenance and Juno made these choices.

C) have a mixed setup with 20 and 32 byte addresses as @iramiller has in their testnet currently which require changes to vanilla wasmd

As mentioned before, C) is not my preferred option as it adds complexity.

It is more complex for wasmd, but it is needed complexity and part of the follow up from our decision to move to 32 byte contract addresses (which I think everyone on this thread commented on and supported). I agree with @iramiller that we need to support this on the sdk side.

I also know that Alex is very busy with Tgrade work right now, but I would ask if there is interest in an external PR to add this as this is a critical fix needed for both your chains.

The contract address is well known and used in several frontend applications… so while we could programmatically shift the state to a new 32 byte address that would break the application dependencies above the blockchain if we modify it. In this case there is a consortium of banks that all agreed on it. Certainly do able but the ask is to avoid that because these kinds of changes take more time than they should.

My fears about not supporting the 32 byte form are not well defined but are based on suspicions that future applications over IBC/interchain may see difficulties. By removing the constraint that the address will be 32 in length then existing ones continue to work and all future ones can be the proper 32 byte form.