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

feat: add support for gas estimation on CQ messages #1238

Merged
merged 5 commits into from
Aug 2, 2024

Conversation

byte-bandit
Copy link
Contributor

@byte-bandit byte-bandit commented Jul 31, 2024

Related Github tickets

Background

Important

This will only merged back to master after Pigeon changes and successful smoke tests on PTN

This change adds the infrastructure for Paloma to support gas estimation. Most notably, it

  • changes the lifecycle of the consensus queue message
  • adds endpoints for Pigeons to query for and report gas estimation
  • uses an endblocker to process any estimated messages

Lifecycle changes

The current message lifecycle is very bare bone. Pigeons ask for messages to be signed, and ultimately relay it. There is little filtering or state processing done. A message will even be handed out for relaying long before it has reached consensus on signatures (Pigeon checks that, not Paloma).

This change adds the concept of gas estimation to all consensus queue messages. It's not super pretty, since really only EVM messages will need the data. However, the CQ module is the main interface for managing the queue and message lifecycles. It's already grossly interwoven with the EVM module, and the whole idea of abstraction has not really paid off. We hope to address this in the future.

Paloma will hand out messages for gas estimation once they have reached consensus on signatures. Pigeons will not relay a message that requires gas estimation and has not yet received one. Even though a message might have been fully signed, it won't be relayed until gas estimation is completed.

For this, Pigeons will query the message, build the payload and estimate the gas using their configured RPC provider. They will send their estimate to Paloma, and Paloma will start tracking every estimate. We expect estimates to be different across RPC providers, and have settled to use the median value of all collected estimates, with a generous 1.2 multiplier for safety margins.

Paloma will continuously monitor messages and check whether they have received enough estimates to calculate the estimate. IF the message happens to be an SLC message, Paloma will then proceed to automatically calculated the fees based on the relayer fee settings for this message.

Once a message has been estimated, all signatures are removed from the message and the signing process starts again, this time using the embedded information (fees & estimates). After this second round of signatures, the messages will finally be sent.

Testing completed

  • test coverage exists or has been added/updated
  • tested in a private testnet

Breaking changes

  • I have checked my code for breaking changes
  • If there are breaking changes, there is a supporting migration.

byte-bandit and others added 2 commits July 31, 2024 16:56
- #1892

Currently skyway send-tx transactions are described as "Send to Eth". It
should be renamed to more generic. e.g. "send to remote chain"

- [ ] test coverage exists or has been added/updated
- [ ] tested in a private testnet

- [ ] I have checked my code for breaking changes
- [ ] If there are breaking changes, there is a supporting migration.
@byte-bandit byte-bandit requested a review from maharifu July 31, 2024 15:09
util/libcons/consensus.go Dismissed Show dismissed Hide dismissed
util/libcons/consensus.go Show resolved Hide resolved
util/liblog/liblog.go Show resolved Hide resolved
x/consensus/keeper/concensus_keeper.go Show resolved Hide resolved
x/consensus/keeper/estimate.go Show resolved Hide resolved
x/consensus/keeper/estimate.go Show resolved Hide resolved
x/consensus/keeper/msg_server.go Outdated Show resolved Hide resolved
@byte-bandit byte-bandit requested a review from maharifu August 2, 2024 09:05
Copy link
Contributor

@maharifu maharifu 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! LGTM

@byte-bandit byte-bandit merged commit 170c74d into palomachain:dev16 Aug 2, 2024
4 checks passed
@byte-bandit byte-bandit deleted the feat/msg-lifecycle branch August 2, 2024 10:54
byte-bandit added a commit that referenced this pull request Aug 2, 2024
# Related Github tickets

- VolumeFi#344
- VolumeFi#1761

# Background

> [!IMPORTANT]  
> This will only merged back to master after Pigeon changes and
successful smoke tests on PTN

This change adds the infrastructure for Paloma to support gas
estimation. Most notably, it

- changes the lifecycle of the consensus queue message
- adds endpoints for Pigeons to query for and report gas estimation
- uses an endblocker to process any estimated messages

## Lifecycle changes

The current message lifecycle is very bare bone. Pigeons ask for
messages to be signed, and ultimately relay it. There is little
filtering or state processing done. A message will even be handed out
for relaying long before it has reached consensus on signatures (Pigeon
checks that, not Paloma).

This change adds the concept of gas estimation to all consensus queue
messages. It's not super pretty, since really only EVM messages will
need the data. However, the CQ module is the main interface for managing
the queue and message lifecycles. It's already grossly interwoven with
the EVM module, and the whole idea of abstraction has not really paid
off. We hope to address this in the future.

Paloma will hand out messages for gas estimation once they have reached
consensus on signatures. Pigeons will not relay a message that requires
gas estimation and has not yet received one. Even though a message might
have been fully signed, it won't be relayed until gas estimation is
completed.

For this, Pigeons will query the message, build the payload and estimate
the gas using their configured RPC provider. They will send their
estimate to Paloma, and Paloma will start tracking every estimate. We
expect estimates to be different across RPC providers, and have settled
to use the median value of all collected estimates, with a generous
`1.2` multiplier for safety margins.

Paloma will continuously monitor messages and check whether they have
received enough estimates to calculate the estimate. IF the message
happens to be an SLC message, Paloma will then proceed to automatically
calculated the fees based on the relayer fee settings for this message.

Once a message has been estimated, all signatures are removed from the
message and the signing process starts again, this time using the
embedded information (fees & estimates). After this second round of
signatures, the messages will finally be sent.

# Testing completed

- [x] test coverage exists or has been added/updated
- [ ] tested in a private testnet

# Breaking changes

- [x] I have checked my code for breaking changes
- [x] If there are breaking changes, there is a supporting migration.

---------

Co-authored-by: Luis Carvalho <[email protected]>
maharifu added a commit that referenced this pull request Aug 16, 2024
# Related Github tickets

- VolumeFi#344
- VolumeFi#1761

# Background

> [!IMPORTANT]  
> This will only merged back to master after Pigeon changes and
successful smoke tests on PTN

This change adds the infrastructure for Paloma to support gas
estimation. Most notably, it

- changes the lifecycle of the consensus queue message
- adds endpoints for Pigeons to query for and report gas estimation
- uses an endblocker to process any estimated messages

## Lifecycle changes

The current message lifecycle is very bare bone. Pigeons ask for
messages to be signed, and ultimately relay it. There is little
filtering or state processing done. A message will even be handed out
for relaying long before it has reached consensus on signatures (Pigeon
checks that, not Paloma).

This change adds the concept of gas estimation to all consensus queue
messages. It's not super pretty, since really only EVM messages will
need the data. However, the CQ module is the main interface for managing
the queue and message lifecycles. It's already grossly interwoven with
the EVM module, and the whole idea of abstraction has not really paid
off. We hope to address this in the future.

Paloma will hand out messages for gas estimation once they have reached
consensus on signatures. Pigeons will not relay a message that requires
gas estimation and has not yet received one. Even though a message might
have been fully signed, it won't be relayed until gas estimation is
completed.

For this, Pigeons will query the message, build the payload and estimate
the gas using their configured RPC provider. They will send their
estimate to Paloma, and Paloma will start tracking every estimate. We
expect estimates to be different across RPC providers, and have settled
to use the median value of all collected estimates, with a generous
`1.2` multiplier for safety margins.

Paloma will continuously monitor messages and check whether they have
received enough estimates to calculate the estimate. IF the message
happens to be an SLC message, Paloma will then proceed to automatically
calculated the fees based on the relayer fee settings for this message.

Once a message has been estimated, all signatures are removed from the
message and the signing process starts again, this time using the
embedded information (fees & estimates). After this second round of
signatures, the messages will finally be sent.

# Testing completed

- [x] test coverage exists or has been added/updated
- [ ] tested in a private testnet

# Breaking changes

- [x] I have checked my code for breaking changes
- [x] If there are breaking changes, there is a supporting migration.

---------

Co-authored-by: Luis Carvalho <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants