-
Notifications
You must be signed in to change notification settings - Fork 28
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
fix(levm): change gas type from U256 to u64 #1528
Conversation
We'll see when it finishes running, but in theory all the uses of gas have been changed to u64. The files that relate to parsing the tests and running the benchmarks remain in U256, simply to maintain how the parsing works. Those values are cast to u64 when the tests run. |
Changed here: 7b3bccc |
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.
LGTM
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.
Great job! There was a lot of effort in this
.stack | ||
.pop()? | ||
.try_into() | ||
.map_err(|_| VMError::Internal(InternalError::ConversionError))?; |
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 shouldn't be internal
.stack | ||
.pop()? | ||
.try_into() | ||
.map_err(|_| VMError::Internal(InternalError::ConversionError))?; |
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.
ditto
.stack | ||
.pop()? | ||
.try_into() | ||
.map_err(|_| VMError::Internal(InternalError::ConversionError))?; |
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.
ditto
.stack | ||
.pop()? | ||
.try_into() | ||
.map_err(|_| VMError::Internal(InternalError::ConversionError))?; |
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.
ditto
bab45f2
to
a6592d7
Compare
Suggested-by: Jeremias Salomon <jeremias.salomon@lambdaclass.com>
Hello Jere, thank you very much for your feedback. I incorporated your suggestions and re-reviewed the PR. Let me know if you find anything else that need correction. PS: I also found some other places (ef21d78) where I had created a variable where there wasn't any before. I rolled back those changes so that is more aligned with the previous style. LMKWYT! |
crates/vm/levm/src/vm.rs
Outdated
fn get_max_blob_gas_cost(&self) -> Result<U256, VMError> { | ||
let blob_gas_used = U256::from(self.env.tx_blob_hashes.len()) | ||
fn get_max_blob_gas_price(&self) -> Result<U256, VMError> { | ||
let blob_gas_used: u64 = self |
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 know you rewrite this variable but this is not blob_gas_used
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.
Noted, I changed it to blob_gas_amout
(e0a5eec), what do you think?
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.
Well, it is actually not blob_gas_amount
, in that case it is just the length of the blob hash list! Not related to gas
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.
Sorry Jere, it was reading the variable name wrong in my head. It's been a rough day! Haha,
Changed here: 341ca8d
crates/vm/levm/src/vm.rs
Outdated
fn get_blob_gas_cost(&self) -> Result<U256, VMError> { | ||
let blob_gas_used = U256::from(self.env.tx_blob_hashes.len()) | ||
fn get_blob_gas_price(&self) -> Result<U256, VMError> { | ||
let blob_gas_used: u64 = self |
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.
ditto
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.
ditto ditto: e235e99
crates/vm/levm/src/vm.rs
Outdated
} | ||
|
||
pub fn get_base_fee_per_blob_gas(&self) -> Result<U256, VMError> { | ||
pub fn get_base_fee_per_blob_gas(&self) -> Result<u64, VMError> { |
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 sounds like it should be an U256 because it is a fee. I am not 100% sure but I think it should because in the validations you are comparing it against tx_max_fee_per_blob_gas
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.
Hello Jere, this was changed here: 96b9bf5
I added an additional let binding (let blob_gas_price: U256 = blob_gas_price.into();
, 96b9bf5#diff-e20d30a6efb08393eee586d44f3bc4a8df6cbd53ec8ea5bb4d5def88c9487de1R655) simply out of necessity. It was the cleanest way I could think of to cast the value to U256.
e748b0c
to
a5cec4d
Compare
a5cec4d
to
341ca8d
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.
nice! sorry if I was pretty annoying with the suggestions. good work
Please Jere, no need to apologize! On the contrary, I not only value your diligence, I also admire it! I have never taken any offense from your comments. Thank you very much for all your dedication! 😊 |
Motivation
The execution client uses
u64
for measuring gas, while LEVM usesU256
. This PR makes LEVM also use u64 for gasDescription
Closes #1499