-
Notifications
You must be signed in to change notification settings - Fork 666
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
refactor: 1:1 mapping for ActionCosts
to fees
#8044
refactor: 1:1 mapping for ActionCosts
to fees
#8044
Conversation
So far several actions fees were conflated right when they are added to the profile. This is a first step to make profiles universal by tracking in more fine-grained manner at the profile interface. Inside, it's still conflated but it's easier to refactor in steps. (see near#8033)
Context for next steps as outline in #8033 is quite important here. Notably, the The reason for this intermediate step is some circular requirements. I can't easily change the profile's inside before changing runtime config to use parameters everywhere. But I cannot use parameters for actions as long as there is no 1:1 mapping. |
Cost::ActionCost { action_cost_kind: ActionCosts::function_call_base } => 3, | ||
Cost::ActionCost { action_cost_kind: ActionCosts::function_call_byte } => 3, |
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, I think it's fine to map them to a single entry for the time being. Long term, we should just make the array bigger. The serialization/deserialization code doesn't really care about length, is just zeros unknown cost.
It's better not to change the meaning of indicies, to simplify historical analysis, but even that, strinctly speaking, is not required. If we want, wee can reassign the meaning without protocol change.
deploy_contract_base, | ||
deploy_contract_byte, | ||
function_call_base, | ||
function_call_byte, |
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.
😍
used gas must include burned gas on this interface
This cost never made sense to me. It's cost is defined by `new_data_receipt_byte` but for some reason it was tracked as `value_return`. In near#8044 I introduced `new_data_receipt_byte` as an action cost but it is actually never used. This change replaces the old `value_return` cost with `new_data_receipt_byte`. This is an observable change on the RPC, as the profile now returns a different key for this cost. But is is not a breaking change because the profile keys are untyped.
This cost never made sense to me. It's cost is defined by `new_data_receipt_byte` but for some reason it was tracked as `value_return`. In #8044 I introduced `new_data_receipt_byte` as an action cost but it is actually never used. This change replaces the old `value_return` cost with `new_data_receipt_byte`. This is an observable change on the RPC, as the profile now returns a different key for this cost. But is is not a breaking change because the profile keys are untyped.
This cost never made sense to me. It's cost is defined by `new_data_receipt_byte` but for some reason it was tracked as `value_return`. In #8044 I introduced `new_data_receipt_byte` as an action cost but it is actually never used. This change replaces the old `value_return` cost with `new_data_receipt_byte`. This is an observable change on the RPC, as the profile now returns a different key for this cost. But is is not a breaking change because the profile keys are untyped.
We have to charge the gas in one block to preserve the old behavior in case of an "out of gas" failure in between. I will maybe submit the change that makes it "right" with a protocol feature flag, for now just revert it.
Any action can fail due to gas limit exceeded or gas attached exceeded. We must preserve the exact result, including how much gas is burnt. In near#8044, we missed such a case and accidentally changed the burnt gas value if it fails in the wrong place and only exceeds the attached gas, not the gas burnt limit. Tests added here cover this case for all existing action gas costs and would catch this specific error in the future. Not covered yet are ext costs and the case where we add new action costs. We can bandage aid by adding similar tests for ext costs but we also have to come up with a more general prevention.
Any action can fail due to gas limit exceeded or gas attached exceeded. We must preserve the exact result, including how much gas is burnt. In #8044, we missed such a case and accidentally changed the burnt gas value if it fails in the wrong place and only exceeds the attached gas, not the gas burnt limit. Tests added here cover this case for all existing action gas costs and would catch this specific error in the future. Not covered yet are ext costs and the case where we add new action costs. We can bandage aid by adding similar tests for ext costs but we also have to come up with a more general prevention.
So far, several actions fees were conflated right when they are added to
the profile. Here is a first step to make profiles universal by tracking
in more fine-grained manner at the profile interface. Inside, it's
still conflated but it's easier to refactor in steps. (see #8033)