Skip to content

Commit

Permalink
fix: sdk prefix change handle for neutron and archway (#119)
Browse files Browse the repository at this point in the history
* fix: sdk prefix change handle for neutron and archway

* fix: wasm prefix change optimize

* fix: add config during successlogtx as well due to feepayer address
  • Loading branch information
viveksharmapoudel authored and DeepakBomjan committed Aug 15, 2023
1 parent 24aa2af commit d7e3493
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
3 changes: 3 additions & 0 deletions relayer/chains/icon/icon_chain_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ loop:
break
}

icp.log.Debug("Verified block ",
zap.Int64("height", int64(processedheight)))

icp.latestBlock = provider.LatestBlock{
Height: uint64(processedheight),
}
Expand Down
2 changes: 0 additions & 2 deletions relayer/chains/wasm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,6 @@ func (ap *WasmProvider) Init(ctx context.Context) error {
}
ap.LightProvider = lightprovider

ap.SetSDKContext()

clientCtx := client.Context{}.
WithClient(rpcClient).
WithFromName(ap.PCfg.Key).
Expand Down
3 changes: 2 additions & 1 deletion relayer/chains/wasm/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ func (ap *WasmProvider) QueryClientConsensusState(ctx context.Context, chainHeig
}

func (ap *WasmProvider) QueryIBCHandlerContract(ctx context.Context, param wasmtypes.RawContractMessage) (*wasmtypes.QuerySmartContractStateResponse, error) {

done := ap.SetSDKContext()
defer done()
return ap.QueryClient.SmartContractState(ctx, &wasmtypes.QuerySmartContractStateRequest{
Address: ap.PCfg.IbcHandlerAddress,
QueryData: param,
Expand Down
5 changes: 5 additions & 0 deletions relayer/chains/wasm/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,8 @@ func (ap *WasmProvider) LogFailedTx(res *provider.RelayerTxResponse, err error,
func (ap *WasmProvider) LogSuccessTx(res *sdk.TxResponse, msgs []provider.RelayerMessage) {
// Include the chain_id
fields := []zapcore.Field{zap.String("chain_id", ap.ChainId())}
done := ap.SetSDKContext()
defer done()

// Include the gas used
fields = append(fields, zap.Int64("gas_used", res.GasUsed))
Expand Down Expand Up @@ -879,6 +881,9 @@ func (ap *WasmProvider) sdkError(codespace string, code uint32) error {
}

func (ap *WasmProvider) buildMessages(clientCtx client.Context, txf tx.Factory, msgs ...sdk.Msg) ([]byte, uint64, error) {
done := ap.SetSDKContext()
defer done()

for _, msg := range msgs {
if err := msg.ValidateBasic(); err != nil {
return nil, 0, err
Expand Down
15 changes: 8 additions & 7 deletions relayer/chains/wasm/wasm_prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ var sdkConfigMutex sync.Mutex
// SetSDKContext sets the SDK config to the proper bech32 prefixes for wasm.
// Don't use this unless you know what you're doing.
// TODO: :dagger: :knife: :chainsaw: remove this function
func (ap *WasmProvider) SetSDKContext() {
func (ap *WasmProvider) SetSDKContext() func() {

sdkConfigMutex.Lock()
cfg := sdk.GetConfig()
cfg.SetBech32PrefixForAccount(ap.PCfg.AccountPrefix, app.Bech32PrefixAccPub)
cfg.SetBech32PrefixForValidator(ap.PCfg.AccountPrefix, app.Bech32PrefixValPub)
cfg.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub)
cfg.SetAddressVerifier(wasmtypes.VerifyAddressLen())
sdkConfigMutex.Unlock()
cfg_update := sdk.GetConfig()
cfg_update.SetBech32PrefixForAccount(ap.PCfg.AccountPrefix, app.Bech32PrefixAccPub)
cfg_update.SetBech32PrefixForValidator(ap.PCfg.AccountPrefix, app.Bech32PrefixValPub)
cfg_update.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub)
cfg_update.SetAddressVerifier(wasmtypes.VerifyAddressLen())
return sdkConfigMutex.Unlock
}

0 comments on commit d7e3493

Please sign in to comment.