-
Notifications
You must be signed in to change notification settings - Fork 1
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
Read IntrinsicGas from FeeCurrencyDirectory #178
Conversation
916de30
to
720d2d8
Compare
720d2d8
to
9b1d9fa
Compare
36ce29a
to
71082e6
Compare
71082e6
to
ba82b0d
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.
Looks great, and nice independent commits.
Comments are mostly nits :)
return contracts.TryDebitFees(tx, from, pool.celoBackend) | ||
//NOTE: we only test the `debitFees` call here. | ||
// If the `creditFees` reverts (or runs out of gas), the transaction will | ||
// not be invalidated here and will be included in the block. |
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.
Will it be included in the block? Or just stay in the txpool?
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.
It will be included in the block, since the txpool validation is successful here. (also see the discussion in #177 )
if feeCurrency == nil { | ||
return 0, true | ||
} |
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 had to look up why feeCurrency
cannot be nil
here. I think a comment would be helpful. Or maybe we can even panic.
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.
The reason it is there is to guard the pointer deref just below and because I thought it would make sense that the additional intrinsic gas cost of a nil
currency is 0.
This also translates to an additional fee-currency specific max gas allowance for EVM calls as used by the MaxAllowedIntrinsicGasCost
for the credit/debit EVM calls.
This then will be 0 and will cause the EVM calls to revert with out of gas, if ever called with a nil
currency.
However this is all theoretical and currently there is no code-path where it comes to this, since the CreditFees
and DebitFees
are only called in non-nil fee-currency code-branches.
I will put the above in a comment.
9c84c83
to
bec64ac
Compare
This replaces the `BlockContext.ExchangeRates` with a wrapper object `BlockContext.FeeCurrencyContext`. This enables easier addition of fee-currency related information to the block context and passing around that information. The exchange-rates are now part of the `FeeCurrencyContext`
Co-authored-by: Paul Lange <[email protected]>
bec64ac
to
111be39
Compare
* Add FeeCurrencyContext object to BlockContext This replaces the `BlockContext.ExchangeRates` with a wrapper object `BlockContext.FeeCurrencyContext`. This enables easier addition of fee-currency related information to the block context and passing around that information. The exchange-rates are now part of the `FeeCurrencyContext` * Add intrinsic gas retrieval from FeeCurrencyDirectory * Use intrinsic gas from FeeCurrencyDirectory in STF * Add test for intrinsic gas too high in fee currency * Add empty fee-currency context to tools and tests * Add minor code improvements Co-authored-by: Paul Lange <[email protected]> * Add comment for nil fee-currency code path * Add fee-currency-context to CeloBackend.NewEVM constructor --------- Co-authored-by: Paul Lange <[email protected]>
* Add FeeCurrencyContext object to BlockContext This replaces the `BlockContext.ExchangeRates` with a wrapper object `BlockContext.FeeCurrencyContext`. This enables easier addition of fee-currency related information to the block context and passing around that information. The exchange-rates are now part of the `FeeCurrencyContext` * Add intrinsic gas retrieval from FeeCurrencyDirectory * Use intrinsic gas from FeeCurrencyDirectory in STF * Add test for intrinsic gas too high in fee currency * Add empty fee-currency context to tools and tests * Add minor code improvements Co-authored-by: Paul Lange <[email protected]> * Add comment for nil fee-currency code path * Add fee-currency-context to CeloBackend.NewEVM constructor --------- Co-authored-by: Paul Lange <[email protected]>
* Add FeeCurrencyContext object to BlockContext This replaces the `BlockContext.ExchangeRates` with a wrapper object `BlockContext.FeeCurrencyContext`. This enables easier addition of fee-currency related information to the block context and passing around that information. The exchange-rates are now part of the `FeeCurrencyContext` * Add intrinsic gas retrieval from FeeCurrencyDirectory * Use intrinsic gas from FeeCurrencyDirectory in STF * Add test for intrinsic gas too high in fee currency * Add empty fee-currency context to tools and tests * Add minor code improvements Co-authored-by: Paul Lange <[email protected]> * Add comment for nil fee-currency code path * Add fee-currency-context to CeloBackend.NewEVM constructor --------- Co-authored-by: Paul Lange <[email protected]>
* Add FeeCurrencyContext object to BlockContext This replaces the `BlockContext.ExchangeRates` with a wrapper object `BlockContext.FeeCurrencyContext`. This enables easier addition of fee-currency related information to the block context and passing around that information. The exchange-rates are now part of the `FeeCurrencyContext` * Add intrinsic gas retrieval from FeeCurrencyDirectory * Use intrinsic gas from FeeCurrencyDirectory in STF * Add test for intrinsic gas too high in fee currency * Add empty fee-currency context to tools and tests * Add minor code improvements Co-authored-by: Paul Lange <[email protected]> * Add comment for nil fee-currency code path * Add fee-currency-context to CeloBackend.NewEVM constructor --------- Co-authored-by: Paul Lange <[email protected]>
* Add FeeCurrencyContext object to BlockContext This replaces the `BlockContext.ExchangeRates` with a wrapper object `BlockContext.FeeCurrencyContext`. This enables easier addition of fee-currency related information to the block context and passing around that information. The exchange-rates are now part of the `FeeCurrencyContext` * Add intrinsic gas retrieval from FeeCurrencyDirectory * Use intrinsic gas from FeeCurrencyDirectory in STF * Add test for intrinsic gas too high in fee currency * Add empty fee-currency context to tools and tests * Add minor code improvements Co-authored-by: Paul Lange <[email protected]> * Add comment for nil fee-currency code path * Add fee-currency-context to CeloBackend.NewEVM constructor --------- Co-authored-by: Paul Lange <[email protected]>
* Add FeeCurrencyContext object to BlockContext This replaces the `BlockContext.ExchangeRates` with a wrapper object `BlockContext.FeeCurrencyContext`. This enables easier addition of fee-currency related information to the block context and passing around that information. The exchange-rates are now part of the `FeeCurrencyContext` * Add intrinsic gas retrieval from FeeCurrencyDirectory * Use intrinsic gas from FeeCurrencyDirectory in STF * Add test for intrinsic gas too high in fee currency * Add empty fee-currency context to tools and tests * Add minor code improvements Co-authored-by: Paul Lange <[email protected]> * Add comment for nil fee-currency code path * Add fee-currency-context to CeloBackend.NewEVM constructor --------- Co-authored-by: Paul Lange <[email protected]>
* Add FeeCurrencyContext object to BlockContext This replaces the `BlockContext.ExchangeRates` with a wrapper object `BlockContext.FeeCurrencyContext`. This enables easier addition of fee-currency related information to the block context and passing around that information. The exchange-rates are now part of the `FeeCurrencyContext` * Add intrinsic gas retrieval from FeeCurrencyDirectory * Use intrinsic gas from FeeCurrencyDirectory in STF * Add test for intrinsic gas too high in fee currency * Add empty fee-currency context to tools and tests * Add minor code improvements Co-authored-by: Paul Lange <[email protected]> * Add comment for nil fee-currency code path * Add fee-currency-context to CeloBackend.NewEVM constructor --------- Co-authored-by: Paul Lange <[email protected]>
* Add FeeCurrencyContext object to BlockContext This replaces the `BlockContext.ExchangeRates` with a wrapper object `BlockContext.FeeCurrencyContext`. This enables easier addition of fee-currency related information to the block context and passing around that information. The exchange-rates are now part of the `FeeCurrencyContext` * Add intrinsic gas retrieval from FeeCurrencyDirectory * Use intrinsic gas from FeeCurrencyDirectory in STF * Add test for intrinsic gas too high in fee currency * Add empty fee-currency context to tools and tests * Add minor code improvements Co-authored-by: Paul Lange <[email protected]> * Add comment for nil fee-currency code path * Add fee-currency-context to CeloBackend.NewEVM constructor --------- Co-authored-by: Paul Lange <[email protected]>
Closes #125
Implements:
FeeCurrencyContext
in block context for fee-currency related context info, storing both the exchange rates as well as the intrinsic fee currency gas costsevm.Context.GasUsedForDebit
removed from Context (which should be read only after initialization) and now passed as argument directly. The value is now stored in the state-transition'sfeeCurrencyGasUsed
FeeCurrencyDirectory
on a per block context basis