-
Notifications
You must be signed in to change notification settings - Fork 104
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(runtime): Track block gas allowance in builtins #4345
base: master
Are you sure you want to change the base?
Conversation
dd3bbaf
to
0085e4d
Compare
0085e4d
to
f1257de
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.
Generally looks good. Regarding "potential todo" mentioned in the description: nobody should under no circumstances be charged for anything in case of gas allowance exceeded case.
@@ -93,6 +95,9 @@ pub enum BuiltinActorError { | |||
/// Actor's inner error encoded as a String. | |||
#[display(fmt = "Builtin execution resulted in error: {_0}")] | |||
Custom(LimitedStr<'static>), | |||
/// Occurs if a builtin actor execution does not fit in the current block. | |||
#[display(fmt = "Block gas allowance exceeded")] |
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.
Im wondering If we could abstract it since it more about how system implemented rather than each particular builtin
} | ||
|
||
gas_spent += to_spend; | ||
gas_left -= to_spend; |
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.
saturating?
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.
Safe due to a check above - if gas_left
is less than to_spend
we abort earlier
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.
But for the sake of universality we can use saturated arithmetics - no problem
} | ||
|
||
gas_spent += to_spend; | ||
gas_left -= to_spend; |
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.
here and in other places
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.
Good job! 🥇
discussed |
The initial implementation of builtin actors overlooked the need of keeping track of the block gas allowance. So far only individual message gas limit has been taken in consideration.
Therefore cases of time-consuming computations in builtin actors's
handle
might affect the block time if not checked against available gas allowance.Potential
todo
: