-
Notifications
You must be signed in to change notification settings - Fork 12
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: improve gas estimation #231
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- This file should undo anything in `up.sql` | ||
DROP TABLE IF EXISTS gas_estimations; | ||
|
||
DROP INDEX IF EXISTS wrapper_transactions_gas; | ||
DROP INDEX IF EXISTS inner_transactions_kind; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- Your SQL goes here | ||
CREATE TABLE gas_estimations ( | ||
id SERIAL PRIMARY KEY, | ||
wrapper_id VARCHAR(64) NOT NULL, | ||
transparent_transfer INT NOT NULL, | ||
shielded_transfer INT NOT NULL, | ||
shielding_transfer INT NOT NULL, | ||
unshielding_transfer INT NOT NULL, | ||
ibc_msg_transfer INT NOT NULL, | ||
bond INT NOT NULL, | ||
redelegation INT NOT NULL, | ||
unbond INT NOT NULL, | ||
withdraw INT NOT NULL, | ||
claim_rewards INT NOT NULL, | ||
vote_proposal INT NOT NULL, | ||
reveal_pk INT NOT NULL, | ||
tx_size INT NOT NULL, | ||
signatures INT NOT NULL, | ||
CONSTRAINT fk_wrapper_id FOREIGN KEY(wrapper_id) REFERENCES wrapper_transactions(id) ON DELETE CASCADE | ||
); | ||
|
||
ALTER TABLE wrapper_transactions ALTER COLUMN gas_used TYPE INTEGER USING (gas_used::integer) ; | ||
|
||
CREATE INDEX wrapper_transactions_gas ON wrapper_transactions (gas_used); | ||
|
||
CREATE INDEX inner_transactions_kind ON inner_transactions (kind); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,97 @@ | ||
use crate::balance::Amount; | ||
use crate::id::Id; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct GasPrice { | ||
pub token: String, | ||
pub amount: Amount, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct GasEstimation { | ||
pub wrapper_id: Id, | ||
pub transparent_transfer: u64, | ||
pub shielded_transfer: u64, | ||
pub shielding_transfer: u64, | ||
pub unshielding_transfer: u64, | ||
pub ibc_msg_transfer: u64, | ||
pub bond: u64, | ||
pub redelegation: u64, | ||
pub unbond: u64, | ||
pub withdraw: u64, | ||
pub claim_rewards: u64, | ||
pub vote_proposal: u64, | ||
pub reveal_pk: u64, | ||
pub size: u64, | ||
pub signatures: u64, | ||
} | ||
|
||
impl GasEstimation { | ||
pub fn new(tx_id: Id) -> Self { | ||
Self { | ||
wrapper_id: tx_id, | ||
transparent_transfer: 0, | ||
shielded_transfer: 0, | ||
shielding_transfer: 0, | ||
unshielding_transfer: 0, | ||
ibc_msg_transfer: 0, | ||
bond: 0, | ||
redelegation: 0, | ||
unbond: 0, | ||
withdraw: 0, | ||
claim_rewards: 0, | ||
vote_proposal: 0, | ||
reveal_pk: 0, | ||
size: 0, | ||
signatures: 0, | ||
} | ||
} | ||
|
||
pub fn increase_transparent_transfer(&mut self) { | ||
self.transparent_transfer += 1 | ||
} | ||
|
||
pub fn increase_shielded_transfer(&mut self) { | ||
self.shielded_transfer += 1 | ||
} | ||
|
||
pub fn increase_shielding_transfer(&mut self) { | ||
self.shielding_transfer += 1 | ||
} | ||
|
||
pub fn increase_unshielding_transfer(&mut self) { | ||
self.unshielding_transfer += 1 | ||
} | ||
|
||
pub fn increase_ibc_msg_transfer(&mut self) { | ||
self.ibc_msg_transfer += 1 | ||
} | ||
|
||
pub fn increase_bond(&mut self) { | ||
self.bond += 1 | ||
} | ||
|
||
pub fn increase_redelegation(&mut self) { | ||
self.redelegation += 1 | ||
} | ||
|
||
pub fn increase_unbond(&mut self) { | ||
self.unbond += 1 | ||
} | ||
|
||
pub fn increase_withdraw(&mut self) { | ||
self.withdraw += 1 | ||
} | ||
|
||
pub fn increase_claim_rewards(&mut self) { | ||
self.claim_rewards += 1 | ||
} | ||
|
||
pub fn increase_vote(&mut self) { | ||
self.vote_proposal += 1 | ||
} | ||
|
||
pub fn increase_reveal_pk(&mut self) { | ||
self.reveal_pk += 1 | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda weird but I messed up in a previous PR