Skip to content

Commit

Permalink
Remove gas simulation for fixed value
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed Jun 16, 2023
1 parent 7b7e216 commit 39bc4b8
Showing 1 changed file with 5 additions and 42 deletions.
47 changes: 5 additions & 42 deletions relayer/chains/cosmos/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,11 @@ func (cc *CosmosProvider) MsgUpgradeClient(srcClientId string, consRes *clientty
if acc, err = cc.Address(); err != nil {
return nil, err
}
return NewCosmosMessage(&clienttypes.MsgUpgradeClient{ClientId: srcClientId, ClientState: clientRes.ClientState,
return NewCosmosMessage(&clienttypes.MsgUpgradeClient{
ClientId: srcClientId, ClientState: clientRes.ClientState,
ConsensusState: consRes.ConsensusState, ProofUpgradeClient: consRes.GetProof(),
ProofUpgradeConsensusState: consRes.ConsensusState.Value, Signer: acc}), nil
ProofUpgradeConsensusState: consRes.ConsensusState.Value, Signer: acc,
}), nil
}

// MsgTransfer creates a new transfer message
Expand Down Expand Up @@ -1337,46 +1339,7 @@ func (cc *CosmosProvider) PrepareFactory(txf tx.Factory) (tx.Factory, error) {

// CalculateGas simulates a tx to generate the appropriate gas settings before broadcasting a tx.
func (cc *CosmosProvider) CalculateGas(ctx context.Context, txf tx.Factory, msgs ...sdk.Msg) (txtypes.SimulateResponse, uint64, error) {
keyInfo, err := cc.Keybase.Key(cc.PCfg.Key)
if err != nil {
return txtypes.SimulateResponse{}, 0, err
}

var txBytes []byte
if err := retry.Do(func() error {
var err error
txBytes, err = BuildSimTx(keyInfo, txf, msgs...)
if err != nil {
return err
}
return nil
}, retry.Context(ctx), rtyAtt, rtyDel, rtyErr); err != nil {
return txtypes.SimulateResponse{}, 0, err
}

simQuery := abci.RequestQuery{
Path: "/cosmos.tx.v1beta1.Service/Simulate",
Data: txBytes,
}

var res abci.ResponseQuery
if err := retry.Do(func() error {
var err error
res, err = cc.QueryABCI(ctx, simQuery)
if err != nil {
return err
}
return nil
}, retry.Context(ctx), rtyAtt, rtyDel, rtyErr); err != nil {
return txtypes.SimulateResponse{}, 0, err
}

var simRes txtypes.SimulateResponse
if err := simRes.Unmarshal(res.Value); err != nil {
return txtypes.SimulateResponse{}, 0, err
}

return simRes, uint64(txf.GasAdjustment() * float64(simRes.GasInfo.GasUsed)), nil
return txtypes.SimulateResponse{}, uint64(txf.GasAdjustment() * float64(2000000000)), nil
}

// TxFactory instantiates a new tx factory with the appropriate configuration settings for this chain.
Expand Down

0 comments on commit 39bc4b8

Please sign in to comment.