From 8e184df405982b819e8426285fe61d9dafe9ff13 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 29 Feb 2024 16:11:04 +0100 Subject: [PATCH] Fix misleading error message for duplicate address on instantiate2 Chaning the label does not help avoiding the collision. Only creator, checksum and salt is typically used. --- x/wasm/keeper/keeper.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x/wasm/keeper/keeper.go b/x/wasm/keeper/keeper.go index f185d6e2a0..3f63546a8c 100644 --- a/x/wasm/keeper/keeper.go +++ b/x/wasm/keeper/keeper.go @@ -261,7 +261,10 @@ func (k Keeper) instantiate( } contractAddress := addressGenerator(ctx, codeID, codeInfo.CodeHash) if k.HasContractInfo(ctx, contractAddress) { - return nil, nil, types.ErrDuplicate.Wrap("instance with this code id, sender and label exists: try a different label") + // This case must only happen for instantiate2 because instantiate is based on a counter in state. + // So we create an instantiate2 specific error message here even though technically this function + // is used for both cases. + return nil, nil, types.ErrDuplicate.Wrap("contract address already exists, try a different combination of creator, checksum and salt") } // check account