-
Notifications
You must be signed in to change notification settings - Fork 992
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
Whitelist gas accounting #1242
Whitelist gas accounting #1242
Conversation
458c28b
to
7ae6159
Compare
7ae6159
to
66ab4d6
Compare
@@ -1892,23 +1882,26 @@ pub async fn query_conversions(ctx: Context, args: args::QueryConversions) { | |||
} | |||
|
|||
/// Query a conversion. | |||
pub async fn query_conversion( | |||
client: HttpClient, | |||
pub async fn query_conversion<CLIENT>( |
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.
I needed these changes for benchmarks since I wanted to reuse some client functions of masp (specifically to construct shielded txs) but without a real client nor a running ledger. I suspect the SDK guys are doing something similar to this but I haven't has the time to check
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.
yeah, it's exactly like that
7103311
to
c9ca5ad
Compare
pls update wasm |
2466237
to
a0b5d93
Compare
pls update wasm |
dff51dd
to
d1843d2
Compare
pls update wasm |
37b8279
to
823e5a7
Compare
pls update wasm |
09322e8
to
f5ee56d
Compare
const FEE_AMOUNT: ArgDefault<token::Amount> = | ||
arg_default("fee-amount", DefaultFn(|| token::Amount::from(0))); | ||
const GAS_LIMIT: ArgDefault<GasLimit> = | ||
arg_default("gas-limit", DefaultFn(|| GasLimit::from(10))); |
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.
This default for the GasLimit
doesn't really have much sense given how different the costs for different txs will be and the lack of a refunding mechanism (at the moment). It's there to ease the tx submission process in testnets but it will probably be better to remove it in future PRs or even in this one
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.
Agreed. Does the client do gas estimation? A reasonable approach for now can be to estimate gas and add a little bit of a buffer on top, then set that as the gas limit.
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.
At the moment I've added the possibility to dry-run the entire tx (wrapper + inner) to estimate the gas cost manually. Were you thinking about something that doesn't require an action from the user? Like the client automatically doing the estimation right before submitting a tx?
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.
Yes, the latter - at least this should be possible as a default, which can be turned off by a flag manually specifying gas.
8cf8135
to
9768a85
Compare
9768a85
to
fce81b4
Compare
Date: Wed Feb 8 18:55:43 2023 +0100
Date: Mon Mar 20 15:16:06 2023 +0100
Date: Thu Mar 23 17:05:59 2023 +0100
Date: Fri Mar 24 18:50:17 2023 +0100
Date: Wed Mar 29 18:31:41 2023 +0200
Date: Wed Mar 29 18:49:23 2023 +0200
Date: Fri Apr 14 23:57:16 2023 +0200
Date: Sat May 13 17:59:50 2023 +0200
fce81b4
to
6349f96
Compare
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.
Mostly looks fine, a few comments.
const FEE_AMOUNT: ArgDefault<token::Amount> = | ||
arg_default("fee-amount", DefaultFn(|| token::Amount::from(0))); | ||
const GAS_LIMIT: ArgDefault<GasLimit> = | ||
arg_default("gas-limit", DefaultFn(|| GasLimit::from(10))); |
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.
Yes, the latter - at least this should be possible as a default, which can be turned off by a flag manually specifying gas.
@@ -0,0 +1,20 @@ | |||
{ |
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.
How are we generating this file, exactly?
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.
At the moment manually. We first run the benchmarks, then we go through the html report produced and compute the gas cost based on the average execution time. The conversion should be something like 1ms~10 gas units. I didn't feel like automating this because we only need to run the benchmarks from time to time
let wrapper_fees = self.get_wrapper_tx_fees(); | ||
match balance.checked_sub(wrapper_fees) { | ||
Some(amount) => { | ||
self.wl_storage |
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.
Do we have a more... abstract version of this function, perhaps?
I feel like we often do logic with raw keys that should be abstracted.
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.
Yes, I've improved this in #1327
/// Add gas cost. It will return error when the | ||
/// consumed gas exceeds the provided transaction gas limit, but the state | ||
/// will still be updated | ||
fn add(&mut self, gas: u64) -> Result<()>; |
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.
Might be clearer to call this "consume" ?
Closed in favor of #1327 |
Addresses #1010.
This PR implements a first version of gas metering based on the runtime cost of the whitelisted txs and vps:
checksums.json
file)GasLimit
checks inmempool_validate
,prepare_proposal
andprocess_proposal
GasLimit
infinalize_block
checksums.py
, andfn load_genesis_config