Skip to content

Commit

Permalink
remove bech32 hack
Browse files Browse the repository at this point in the history
  • Loading branch information
agouin committed May 15, 2024
1 parent fa00ec3 commit 8a99828
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 64 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,5 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/cosmos/cosmos-sdk => github.com/agouin/cosmos-sdk v0.50.6-0.20240402230622-aeacbc20f38d
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I=
github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
github.com/agouin/cosmos-sdk v0.50.6-0.20240402230622-aeacbc20f38d h1:prR6P+t5DCInnnGIcIUd0+s6bdWWYtIxUDg33nL+EyM=
github.com/agouin/cosmos-sdk v0.50.6-0.20240402230622-aeacbc20f38d/go.mod h1:oV/k6GJgXV9QPoM2fsYDPPsyPBgQbdotv532O6Mz1OQ=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
Expand Down Expand Up @@ -382,8 +384,6 @@ github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAK
github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA=
github.com/cosmos/cosmos-proto v1.0.0-beta.4 h1:aEL7tU/rLOmxZQ9z4i7mzxcLbSCY48OdY7lIWTLG7oU=
github.com/cosmos/cosmos-proto v1.0.0-beta.4/go.mod h1:oeB+FyVzG3XrQJbJng0EnV8Vljfk9XvTIpGILNU/9Co=
github.com/cosmos/cosmos-sdk v0.50.5 h1:MOEi+DKYgW67YaPgB+Pf+nHbD3V9S/ayitRKJYLfGIA=
github.com/cosmos/cosmos-sdk v0.50.5/go.mod h1:oV/k6GJgXV9QPoM2fsYDPPsyPBgQbdotv532O6Mz1OQ=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE=
Expand Down
11 changes: 0 additions & 11 deletions interchaintest/feegrant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,6 @@ func TestRelayerFeeGrant(t *testing.T) {
continue
}

done := cProv.SetSDKContext()

hash, err := hex.DecodeString(curr.Response.TxHash)
require.Nil(t, err)
txResp, err := TxWithRetry(ctx, cProv.RPCClient, hash)
Expand Down Expand Up @@ -465,7 +463,6 @@ func TestRelayerFeeGrant(t *testing.T) {
}
fmt.Printf("Chain: %s, msg type: %s, height: %d, signer: %s, granter: %s\n", chain, msgType, curr.Response.Height, actualGrantee, string(granter))
}
done()
}
}
default:
Expand Down Expand Up @@ -664,18 +661,13 @@ func TestRelayerFeeGrantExternal(t *testing.T) {
gaiaGranterWallet, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, granterKeyPrefix, mnemonicAny, fundAmount, gaia)
require.NoError(t, err)

// Set SDK context to the right bech32 prefix
prefix := gaia.Config().Bech32Prefix
done := cosmos.SetSDKConfigContext(prefix)

// Feegrant each of the grantees
err = Feegrant(t, gaia.(*cosmosv8.CosmosChain), gaiaGranterWallet, gaiaGranterWallet.Address(), gaiaGranteeWallet.Address(), gaiaGranterWallet.FormattedAddress(), gaiaGranteeWallet.FormattedAddress())
require.NoError(t, err)
err = Feegrant(t, gaia.(*cosmosv8.CosmosChain), gaiaGranterWallet, gaiaGranterWallet.Address(), gaiaGrantee2Wallet.Address(), gaiaGranterWallet.FormattedAddress(), gaiaGrantee2Wallet.FormattedAddress())
require.NoError(t, err)
err = Feegrant(t, gaia.(*cosmosv8.CosmosChain), gaiaGranterWallet, gaiaGranterWallet.Address(), gaiaGrantee3Wallet.Address(), gaiaGranterWallet.FormattedAddress(), gaiaGrantee3Wallet.FormattedAddress())
require.NoError(t, err)
done()

mnemonic := gaiaGranterWallet.Mnemonic()
fmt.Printf("Wallet mnemonic: %s\n", mnemonic)
Expand Down Expand Up @@ -866,8 +858,6 @@ func TestRelayerFeeGrantExternal(t *testing.T) {
continue
}

done := cProv.SetSDKContext()

hash, err := hex.DecodeString(curr.Response.TxHash)
require.Nil(t, err)
txResp, err := TxWithRetry(ctx, cProv.RPCClient, hash)
Expand Down Expand Up @@ -939,7 +929,6 @@ func TestRelayerFeeGrantExternal(t *testing.T) {
}
fmt.Printf("Chain: %s, msg type: %s, height: %d, signer: %s, granter: %s\n", chain, msgType, curr.Response.Height, actualGrantee, string(granter))
}
done()
}
}
default:
Expand Down
2 changes: 2 additions & 0 deletions interchaintest/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,10 @@ require (
)

replace (

github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d
github.com/ChainSafe/go-schnorrkel/1 => github.com/ChainSafe/go-schnorrkel v1.0.0
github.com/cosmos/cosmos-sdk => github.com/agouin/cosmos-sdk v0.50.6-0.20240402230622-aeacbc20f38d
// For this nested module, you always want to replace the parent reference with the current worktree.
github.com/cosmos/relayer/v2 => ../

Expand Down
4 changes: 2 additions & 2 deletions interchaintest/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I=
github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
github.com/agouin/cosmos-sdk v0.50.6-0.20240402230622-aeacbc20f38d h1:prR6P+t5DCInnnGIcIUd0+s6bdWWYtIxUDg33nL+EyM=
github.com/agouin/cosmos-sdk v0.50.6-0.20240402230622-aeacbc20f38d/go.mod h1:oV/k6GJgXV9QPoM2fsYDPPsyPBgQbdotv532O6Mz1OQ=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
Expand Down Expand Up @@ -409,8 +411,6 @@ github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAK
github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA=
github.com/cosmos/cosmos-proto v1.0.0-beta.4 h1:aEL7tU/rLOmxZQ9z4i7mzxcLbSCY48OdY7lIWTLG7oU=
github.com/cosmos/cosmos-proto v1.0.0-beta.4/go.mod h1:oeB+FyVzG3XrQJbJng0EnV8Vljfk9XvTIpGILNU/9Co=
github.com/cosmos/cosmos-sdk v0.50.5 h1:MOEi+DKYgW67YaPgB+Pf+nHbD3V9S/ayitRKJYLfGIA=
github.com/cosmos/cosmos-sdk v0.50.5/go.mod h1:oV/k6GJgXV9QPoM2fsYDPPsyPBgQbdotv532O6Mz1OQ=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
Expand Down
28 changes: 0 additions & 28 deletions relayer/chains/cosmos/bech32_hack.go

This file was deleted.

3 changes: 0 additions & 3 deletions relayer/chains/cosmos/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ func MakeCodecConfig(accBech32Prefix, valBech32Prefix string) Codec {
}
marshaler := codec.NewProtoCodec(interfaceRegistry)

done := SetSDKConfigContext(accBech32Prefix)
defer done()

return Codec{
InterfaceRegistry: interfaceRegistry,
Marshaler: marshaler,
Expand Down
7 changes: 0 additions & 7 deletions relayer/chains/cosmos/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,11 @@ func (cc *CosmosProvider) KeyAddOrRestore(keyName string, coinType uint32, signi
}
}

done := SetSDKConfigContext(cc.PCfg.AccountPrefix)

info, err := cc.Keybase.NewAccount(keyName, mnemonicStr, "", hd.CreateHDPath(coinType, 0, 0).String(), algo)
if err != nil {
return nil, err
}

done()

acc, err := info.GetAddress()
if err != nil {
return nil, err
Expand Down Expand Up @@ -256,9 +252,6 @@ func (cc *CosmosProvider) KeyFromKeyOrAddress(keyOrAddress string) (string, erro
return "", err
}

done := SetSDKConfigContext(cc.PCfg.AccountPrefix)
defer done()

kr, err := cc.Keybase.KeyByAddress(acc)
if err != nil {
return "", err
Expand Down
14 changes: 3 additions & 11 deletions relayer/chains/cosmos/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,6 @@ func (cc *CosmosProvider) AwaitTx(txHash bytes.HexBytes, timeout time.Duration)
//
// feegranterKey - key name of the address set as the feegranter, empty string will not feegrant
func (cc *CosmosProvider) SendMsgsWith(ctx context.Context, msgs []sdk.Msg, memo string, gas uint64, signingKey string, feegranterKey string) (*coretypes.ResultBroadcastTx, error) {
sdkConfigMutex.Lock()
sdkConf := sdk.GetConfig()
sdkConf.SetBech32PrefixForAccount(cc.PCfg.AccountPrefix, cc.PCfg.AccountPrefix+"pub")
sdkConf.SetBech32PrefixForValidator(cc.PCfg.AccountPrefix+"valoper", cc.PCfg.AccountPrefix+"valoperpub")
sdkConf.SetBech32PrefixForConsensusNode(cc.PCfg.AccountPrefix+"valcons", cc.PCfg.AccountPrefix+"valconspub")
defer sdkConfigMutex.Unlock()

rand.Seed(time.Now().UnixNano())
feegrantKeyAcc, _ := cc.GetKeyAddressForKey(feegranterKey)

Expand Down Expand Up @@ -676,9 +669,6 @@ func (cc *CosmosProvider) buildMessages(
fees sdk.Coins,
err error,
) {
done := cc.SetSDKContext()
defer done()

cMsgs := CosmosMsgs(msgs...)

txf, err := cc.PrepareFactory(cc.TxFactory(dynamicFee), txSignerKey)
Expand Down Expand Up @@ -1873,7 +1863,9 @@ func (cc *CosmosProvider) TxFactory(dynamicFee string) tx.Factory {
WithGasAdjustment(cc.PCfg.GasAdjustment).
WithGasPrices(gasPrice).
WithKeybase(cc.Keybase).
WithSignMode(cc.PCfg.SignMode())
WithSignMode(cc.PCfg.SignMode()).
WithBech32Prefix(cc.PCfg.AccountPrefix)

}

// SignMode returns the SDK sign mode type reflective of the specified sign mode in the config file.
Expand Down

0 comments on commit 8a99828

Please sign in to comment.