Skip to content

Commit

Permalink
Bump max gas wanted per tx to 60 mil (#7833) (#7861)
Browse files Browse the repository at this point in the history
* Bump max gas wanted per tx

* Add changelog

* Add app default values

* drive by correct overwriteAppTomlValues logic

* remove extra line in changelog

* clean up

---------

Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
(cherry picked from commit 7b0c14a)

Co-authored-by: Matt, Park <[email protected]>
  • Loading branch information
mergify[bot] and mattverse authored Mar 27, 2024
1 parent 4c8dffb commit d97d3ac
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 45 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#7768](https://github.com/osmosis-labs/osmosis/pull/7768) Allow governance module account to transfer any CL position
* [#7746](https://github.com/osmosis-labs/osmosis/pull/7746) Make forfeited incentives redeposit into the pool instead of sending to community pool
* [#7785](https://github.com/osmosis-labs/osmosis/pull/7785) Remove reward claiming during position transfers
* [#7833](https://github.com/osmosis-labs/osmosis/pull/7883) Bump max gas wanted per tx to 6 mil
* [#7839](https://github.com/osmosis-labs/osmosis/pull/7839) Add ICA controller
* [#7527](https://github.com/osmosis-labs/osmosis/pull/7527) Add 30M gas limit to CW pool contract calls

Expand Down
88 changes: 43 additions & 45 deletions cmd/osmosisd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ type DenomUnitMap struct {
}

const (
mempoolConfigName = "osmosis-mempool"
arbitrageMinGasFeeConfigName = "arbitrage-min-gas-fee"
oldArbitrageMinGasFeeValue = ".005"
newArbitrageMinGasFeeValue = "0.1"
mempoolConfigName = "osmosis-mempool"

arbitrageMinGasFeeConfigName = "arbitrage-min-gas-fee"
recommendedNewArbitrageMinGasFeeValue = "0.1"

maxGasWantedPerTxName = "max-gas-wanted-per-tx"
recommendedNewMaxGasWantedPerTxValue = "60000000"

consensusConfigName = "consensus"
timeoutCommitConfigName = "timeout_commit"
Expand Down Expand Up @@ -504,55 +507,50 @@ func overwriteAppTomlValues(serverCtx *server.Context) error {
} else {
// app.toml exists

// Get setting
currentArbitrageMinGasFeeValue := serverCtx.Viper.Get(mempoolConfigName + "." + arbitrageMinGasFeeConfigName)
// Set new values in viper
serverCtx.Viper.Set(mempoolConfigName+"."+maxGasWantedPerTxName, recommendedNewMaxGasWantedPerTxValue)
serverCtx.Viper.Set(mempoolConfigName+"."+arbitrageMinGasFeeConfigName, recommendedNewArbitrageMinGasFeeValue)

// .x format at 0.x format are both valid.
if currentArbitrageMinGasFeeValue == oldArbitrageMinGasFeeValue || currentArbitrageMinGasFeeValue == "0"+oldArbitrageMinGasFeeValue {
// Set new value in viper
serverCtx.Viper.Set(mempoolConfigName+"."+arbitrageMinGasFeeConfigName, newArbitrageMinGasFeeValue)
defer func() {
if err := recover(); err != nil {
fmt.Printf("failed to write to %s: %s\n", configFilePath, err)
}
}()

defer func() {
if err := recover(); err != nil {
fmt.Printf("failed to write to %s: %s\n", configFilePath, err)
}
}()

// Check if the file is writable
if fileInfo.Mode()&os.FileMode(0200) != 0 {
// Read the entire content of the file
content, err := os.ReadFile(configFilePath)
if err != nil {
return err
}
// Check if the file is writable
if fileInfo.Mode()&os.FileMode(0200) != 0 {
// Read the entire content of the file
content, err := os.ReadFile(configFilePath)
if err != nil {
return err
}

// Convert the content to a string
fileContent := string(content)
// Convert the content to a string
fileContent := string(content)

// Find the index of the search line
index := strings.Index(fileContent, arbitrageMinGasFeeConfigName)
if index == -1 {
return fmt.Errorf("search line not found in the file")
}
// Find the index of the search line
index := strings.Index(fileContent, arbitrageMinGasFeeConfigName)
if index == -1 {
return fmt.Errorf("search line not found in the file")
}

// Find the opening and closing quotes
openQuoteIndex := strings.Index(fileContent[index:], "\"")
openQuoteIndex += index
// Find the opening and closing quotes
openQuoteIndex := strings.Index(fileContent[index:], "\"")
openQuoteIndex += index

closingQuoteIndex := strings.Index(fileContent[openQuoteIndex+1:], "\"")
closingQuoteIndex += openQuoteIndex + 1
closingQuoteIndex := strings.Index(fileContent[openQuoteIndex+1:], "\"")
closingQuoteIndex += openQuoteIndex + 1

// Replace the old value with the new value
newFileContent := fileContent[:openQuoteIndex+1] + newArbitrageMinGasFeeValue + fileContent[closingQuoteIndex:]
// Replace the old value with the new value
newFileContent := fileContent[:openQuoteIndex+1] + recommendedNewArbitrageMinGasFeeValue + fileContent[closingQuoteIndex:]

// Write the modified content back to the file
err = os.WriteFile(configFilePath, []byte(newFileContent), 0644)
if err != nil {
return err
}
} else {
fmt.Println("app.toml is not writable. Cannot apply update. Please consder manually changing arbitrage-min-gas-fee to " + newArbitrageMinGasFeeValue)
// Write the modified content back to the file
err = os.WriteFile(configFilePath, []byte(newFileContent), 0644)
if err != nil {
return err
}
} else {
fmt.Println("app.toml is not writable. Cannot apply update. Please consder manually changing arbitrage-min-gas-fee to " + recommendedNewArbitrageMinGasFeeValue + "and max-gas-wanted-per-tx to " + recommendedNewMaxGasWantedPerTxValue)
}
}
return nil
Expand Down Expand Up @@ -614,7 +612,7 @@ func initAppConfig() (string, interface{}) {
[osmosis-mempool]
# This is the max allowed gas any tx.
# This is only for local mempool purposes, and thus is only ran on check tx.
max-gas-wanted-per-tx = "25000000"
max-gas-wanted-per-tx = "60000000"
# This is the minimum gas fee any arbitrage tx should have, denominated in uosmo per gas
# Default value of ".1" then means that a tx with 1 million gas costs (.1 uosmo/gas) * 1_000_000 gas = .1 osmo
Expand Down

0 comments on commit d97d3ac

Please sign in to comment.