Skip to content

Commit

Permalink
Add --gas flag to specify gas limit for a transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
cwgoes authored and ebuchman committed Jun 9, 2018
1 parent d84296e commit c6796b8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ IMPROVEMENTS

FIXES
* [lcd] Switch to bech32 for addresses on all human readable inputs and outputs
* [cli] Added `--gas` flag to specify transaction gas limit

## 0.18.0

Expand Down
2 changes: 1 addition & 1 deletion client/context/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (ctx CoreContext) SignAndBuild(name, passphrase string, msg sdk.Msg, cdc *w
ChainID: chainID,
Sequences: []int64{sequence},
Msg: msg,
Fee: auth.NewStdFee(10000, sdk.Coin{}), // TODO run simulate to estimate gas?
Fee: auth.NewStdFee(ctx.Gas, sdk.Coin{}), // TODO run simulate to estimate gas?
}

keybase, err := keys.GetKeyBase()
Expand Down
7 changes: 7 additions & 0 deletions client/context/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
type CoreContext struct {
ChainID string
Height int64
Gas int64
TrustNode bool
NodeURI string
FromAddressName string
Expand All @@ -31,6 +32,12 @@ func (c CoreContext) WithHeight(height int64) CoreContext {
return c
}

// WithGas - return a copy of the context with an updated gas
func (c CoreContext) WithGas(gas int64) CoreContext {
c.Gas = gas
return c
}

// WithTrustNode - return a copy of the context with an updated TrustNode flag
func (c CoreContext) WithTrustNode(trustNode bool) CoreContext {
c.TrustNode = trustNode
Expand Down
1 change: 1 addition & 0 deletions client/context/viper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func NewCoreContextFromViper() CoreContext {
return CoreContext{
ChainID: chainID,
Height: viper.GetInt64(client.FlagHeight),
Gas: viper.GetInt64(client.FlagGas),
TrustNode: viper.GetBool(client.FlagTrustNode),
FromAddressName: viper.GetString(client.FlagName),
NodeURI: nodeURI,
Expand Down
2 changes: 2 additions & 0 deletions client/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const (
FlagChainID = "chain-id"
FlagNode = "node"
FlagHeight = "height"
FlagGas = "gas"
FlagTrustNode = "trust-node"
FlagName = "name"
FlagSequence = "sequence"
Expand All @@ -25,6 +26,7 @@ func GetCommands(cmds ...*cobra.Command) []*cobra.Command {
c.Flags().String(FlagChainID, "", "Chain ID of tendermint node")
c.Flags().String(FlagNode, "tcp://localhost:46657", "<host>:<port> to tendermint rpc interface for this chain")
c.Flags().Int64(FlagHeight, 0, "block height to query, omit to get most recent provable block")
c.Flags().Int64(FlagGas, 200000, "gas limit to set per-transaction")
}
return cmds
}
Expand Down
3 changes: 2 additions & 1 deletion client/lcd/lcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
tmcfg "github.com/tendermint/tendermint/config"
nm "github.com/tendermint/tendermint/node"
p2p "github.com/tendermint/tendermint/p2p"
pvm "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
tmrpc "github.com/tendermint/tendermint/rpc/lib/server"
tmtypes "github.com/tendermint/tendermint/types"
pvm "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tmlibs/cli"
dbm "github.com/tendermint/tmlibs/db"
"github.com/tendermint/tmlibs/log"
Expand Down Expand Up @@ -385,6 +385,7 @@ func startTMAndLCD() (*nm.Node, net.Listener, error) {
return nil, nil, err
}
viper.Set(cli.HomeFlag, dir)
viper.Set(client.FlagGas, 200000)
kb, err := keys.GetKeyBase() // dbm.NewMemDB()) // :(
if err != nil {
return nil, nil, err
Expand Down

0 comments on commit c6796b8

Please sign in to comment.