Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: overwrite ArbitrageMinGasPrice config from .005 to 0.1 #7368

Merged
merged 6 commits into from
Jan 29, 2024

Conversation

p0mvn
Copy link
Member

@p0mvn p0mvn commented Jan 25, 2024

Closes: #XXX

What is the purpose of the change

To address the failing arbitrage spam taking up block space, we will increase arbitrage-min-gas-fee to be near the order of magnitude of 0.1 OSMO.

CL Swap is around 600K gas wanted and 340K gas used. Let's assume a middle ground of 450K and aim to have the arb pay approximately 0.05 OSMO.

0.045 = 450_000 * 0.1 / 10**6

As a result, 0.1 is an appropriate choice.

Testing and Verifying

Tested the following vectors:

  • new config
  • does no overwrite other values
  • old value is "0.005" -> overwritten
  • old value is ".005" -> overwritten
  • old value is something else -> does not change

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes?
  • Changelog entry added to Unreleased section of CHANGELOG.md?

Where is the change documented?

  • Specification (x/{module}/README.md)
  • Osmosis documentation site
  • Code comments?
  • N/A

@p0mvn p0mvn added V:state/compatible/backport State machine compatible PR, should be backported A:backport/v22.x backport patches to v22.x branch labels Jan 25, 2024
Comment on lines +526 to +543
// 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 opening and closing quotes
openQuoteIndex := strings.Index(fileContent[index:], "\"")
openQuoteIndex += index

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

// Replace the old value with the new value
newFileContent := fileContent[:openQuoteIndex+1] + newArbitrageMinGasFeeValue + fileContent[closingQuoteIndex:]
Copy link
Member Author

@p0mvn p0mvn Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:

The following are the reasons why this is done by string matching manually:

  • https://github.com/pelletier/go-toml does not handle comments when writing. So all config comments would be removed if I were to load the file, update the value, and overwrite.
  • SDK helpers either unexpectedly overwrite other config values or run into the same comment issue as above. I found it easier to simply string-match

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also ran into this when I attempted this a while ago, thanks for making an issue

@p0mvn p0mvn marked this pull request as ready for review January 26, 2024 00:08
@p0mvn p0mvn changed the title refactor: overwrite ArbitrageMinGasPriceconfig from .005 to 0.1 refactor: overwrite ArbitrageMinGasPrice config from .005 to 0.1 Jan 26, 2024
Copy link
Member

@czarcas7ic czarcas7ic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work

Comment on lines +518 to +519
// Check if the file is writable
if fileInfo.Mode()&os.FileMode(0200) != 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this implies if the file is not writeable, then the defer func wont trigger so there will be no feedback for the operator right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They would just not have their config updated which IMO is fine. The intention is to silently ignore the update if their file isn't writeable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I just think they would want to still get a log print saying it wasn't overwritten due to permission issues

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mergify mergify bot merged commit af1ed8c into main Jan 29, 2024
3 checks passed
@mergify mergify bot deleted the roman/overwrite-arb-config branch January 29, 2024 23:25
mergify bot pushed a commit that referenced this pull request Jan 29, 2024
Closes: #XXX

## What is the purpose of the change

To address the failing arbitrage spam taking up block space, we will increase [arbitrage-min-gas-fee](https://github.com/osmosis-labs/osmosis/blob/3aaf5d117f96df0092b0375d0c8de0a12850d092/cmd/osmosisd/cmd/root.go#L540) to be near the order of magnitude of 0.1 OSMO.

CL Swap is around 600K gas wanted and 340K gas used. Let's assume a middle ground of 450K and aim to have the arb pay approximately 0.05 OSMO.
```
0.045 = 450_000 * 0.1 / 10**6
```
 As a result, 0.1 is an appropriate choice.

## Testing and Verifying

Tested the following vectors:
- new config
- does no overwrite other values
- old value is "0.005" -> overwritten
- old value is ".005" -> overwritten
- old value is something else -> does not change

## Documentation and Release Note

  - [ ] Does this pull request introduce a new feature or user-facing behavior changes?
  - [ ] Changelog entry added to `Unreleased` section of `CHANGELOG.md`?

Where is the change documented?
  - [ ] Specification (`x/{module}/README.md`)
  - [ ] Osmosis documentation site
  - [ ] Code comments?
  - [ ] N/A

(cherry picked from commit af1ed8c)
p0mvn added a commit that referenced this pull request Feb 1, 2024
…kport #7368) (#7383)

* refactor: overwrite ArbitrageMinGasPrice config from .005 to 0.1 (#7368)

Closes: #XXX

## What is the purpose of the change

To address the failing arbitrage spam taking up block space, we will increase [arbitrage-min-gas-fee](https://github.com/osmosis-labs/osmosis/blob/3aaf5d117f96df0092b0375d0c8de0a12850d092/cmd/osmosisd/cmd/root.go#L540) to be near the order of magnitude of 0.1 OSMO.

CL Swap is around 600K gas wanted and 340K gas used. Let's assume a middle ground of 450K and aim to have the arb pay approximately 0.05 OSMO.
```
0.045 = 450_000 * 0.1 / 10**6
```
 As a result, 0.1 is an appropriate choice.

## Testing and Verifying

Tested the following vectors:
- new config
- does no overwrite other values
- old value is "0.005" -> overwritten
- old value is ".005" -> overwritten
- old value is something else -> does not change

## Documentation and Release Note

  - [ ] Does this pull request introduce a new feature or user-facing behavior changes?
  - [ ] Changelog entry added to `Unreleased` section of `CHANGELOG.md`?

Where is the change documented?
  - [ ] Specification (`x/{module}/README.md`)
  - [ ] Osmosis documentation site
  - [ ] Code comments?
  - [ ] N/A

(cherry picked from commit af1ed8c)

* changelog

---------

Co-authored-by: Roman <roman@osmosis.team>
@hleb-albau
Copy link
Contributor

why not make it just 1 osmo and leave this spam ahead?

@p0mvn
Copy link
Member Author

p0mvn commented Feb 2, 2024

why not make it just 1 osmo and leave this spam ahead?

Generally, I agree with increasing it even higher. I was worried about making too much of a rapid change for all nodes at once. This is already a 20x increase

@github-actions github-actions bot mentioned this pull request May 1, 2024
@github-actions github-actions bot mentioned this pull request May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge A:backport/v22.x backport patches to v22.x branch V:state/compatible/backport State machine compatible PR, should be backported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants