Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Abliazimov committed Sep 23, 2024
1 parent 1ff1d26 commit 3eab82c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmd/wardenkms/wardenkms.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Config struct {
BatchInterval time.Duration `env:"BATCH_INTERVAL, default=8s"`
BatchSize int `env:"BATCH_SIZE, default=7"`
GasLimit uint64 `env:"GAS_LIMIT, default=400000"`
AutoEstimateGas bool `env:"AUTO_ESTIMATE_GAS, default=false"`
AutoEstimateGas bool `env:"AUTO_ESTIMATE_GAS, default=true"`
GasAdjustmentFactor float64 `env:"GAS_ADJUSTMENT_FACTOR, default=1.1"`
TxTimeout time.Duration `env:"TX_TIMEOUT, default=120s"`
TxFee int64 `env:"TX_FEE, default=400000"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func main() {
// setup throughput for batching responses
GasLimit: 400000,
AutoEstimateGas: false,
AutoEstimateGas: true,
GasAdjustmentFactor: 1.2,
BatchTimeout: 8 * time.Second,
BatchSize: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Config struct {
BatchInterval time.Duration `env:"BATCH_INTERVAL, default=8s"`
BatchSize int `env:"BATCH_SIZE, default=7"`
GasLimit uint64 `env:"GAS_LIMIT, default=400000"`
AutoEstimateGas bool `env:"AUTO_ESTIMATE_GAS, default=false"`
AutoEstimateGas bool `env:"AUTO_ESTIMATE_GAS, default=true"`
GasAdjustmentFactor float64 `env:"GAS_ADJUSTMENT_FACTOR, default=1.1"`
TxTimeout time.Duration `env:"TX_TIMEOUT, default=120s"`
TxFee int64 `env:"TX_FEE, default=400000"`
Expand Down
12 changes: 5 additions & 7 deletions go-client/tx_raw_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ func (c *RawTxClient) BuildTx(
signMode := app.TxConfig().SignModeHandler().DefaultMode()

// build unsigned tx
if !autoEstimateGas {
txBuilder.SetGasLimit(gasLimit)
}
txBuilder.SetFeeAmount(fees)

msgs := make([]sdk.Msg, len(msgers))
Expand Down Expand Up @@ -151,11 +148,12 @@ func (c *RawTxClient) BuildTx(

gasLimit, err = c.EstimateGas(ctx, txBytes, gasAdjustmentFactor, gasLimit)
if err != nil {
return nil, fmt.Errorf("estimage gas: %w", err)
return nil, fmt.Errorf("estimate gas: %w", err)
}
txBuilder.SetGasLimit(gasLimit)
}

txBuilder.SetGasLimit(gasLimit)

// Second round: all signer infos are set, so each signer can sign.
signerData := xauthsigning.SignerData{
ChainID: c.chainID,
Expand Down Expand Up @@ -235,8 +233,8 @@ func (c *RawTxClient) WaitForTx(ctx context.Context, hash string) error {
}
}

// EstimateGas estimates gas by simulating the transaction when autoEstimateGas is set to true.
// Otherwise, GasLimit is used.
// EstimateGas estimates gas by simulating the transaction.
// If the simulation exceeds gasLimit, gasLimit is returned.
func (c *RawTxClient) EstimateGas(
ctx context.Context,
txBytes []byte,
Expand Down
2 changes: 1 addition & 1 deletion keychain-sdk/example_keychain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func Main() {

// setup throughput for batching responses
GasLimit: 400000,
AutoEstimateGas: false,
AutoEstimateGas: true,
GasAdjustmentFactor: 1.2,
BatchInterval: 8 * time.Second,
BatchSize: 10,
Expand Down

0 comments on commit 3eab82c

Please sign in to comment.