Skip to content

Commit

Permalink
Cleanup comments
Browse files Browse the repository at this point in the history
  • Loading branch information
palango committed Nov 8, 2023
1 parent 7d206ab commit 4253602
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
27 changes: 2 additions & 25 deletions contracts/fee_currencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const (
// Default intrinsic gas cost of transactions paying for gas in alternative currencies.
// Calculated to estimate 1 balance read, 1 debit, and 4 credit transactions.
IntrinsicGasForAlternativeFeeCurrency uint64 = 50 * Thousand
// TODO(pl): where top put this best
)

var (
Expand Down Expand Up @@ -52,29 +51,16 @@ func DebitFees(evm *vm.EVM, address common.Address, amount *big.Int, feeCurrency
if amount.Cmp(big.NewInt(0)) == 0 {
return nil
}

// Run only primary evm.Call() with tracer
// if evm.GetDebug() {
// evm.SetDebug(false)
// defer func() { evm.SetDebug(true) }()
// }

// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb.
//
// Solidity: function transfer(address to, uint256 amount) returns(bool)
// transferSelector := hexutil.MustDecode("0xa9059cbb")
// transferData := common.GetEncodedAbi(transferSelector, [][]byte{common.AddressToAbi(tmpAddress), common.AmountToAbi(amount)})

abi, err := abigen.FeeCurrencyMetaData.GetAbi()
if err != nil {
return err
}
// Solidity: function transfer(address to, uint256 amount) returns(bool)
input, err := abi.Pack("transfer", tmpAddress, amount)
if err != nil {
return err
}

// create account ref
caller := vm.AccountRef(address)

_, leftoverGas, err := evm.Call(caller, *feeCurrency, input, maxGasForDebitGasFeesTransactions, big.NewInt(0))
Expand All @@ -92,23 +78,14 @@ func CreditFees(
tipTxFee *big.Int,
baseTxFee *big.Int,
feeCurrency *common.Address) error {
// Run only primary evm.Call() with tracer
// if evm.GetDebug() {
// evm.SetDebug(false)
// defer func() { evm.SetDebug(true) }()
// }

caller := vm.AccountRef(tmpAddress)

// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb.
//
// Solidity: function transfer(address to, uint256 amount) returns(bool)
// transferSelector := hexutil.MustDecode("0xa9059cbb")
abi, err := abigen.FeeCurrencyMetaData.GetAbi()
if err != nil {
return err
}

// Solidity: function transfer(address to, uint256 amount) returns(bool)
transfer1Data, err := abi.Pack("transfer", from, refund)
if err != nil {
return err
Expand Down
9 changes: 1 addition & 8 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,8 @@ func (st *StateTransition) innerTransitionDb() (*ExecutionResult, error) {
contractCreation = msg.To == nil
)

// TODO(pl) Decide if we want to read this from the chain?
gasForAlternativeCurrency := uint64(0)
// If the fee currency is nil, do not retrieve the intrinsic gas adjustment from the chain state, as it will not be used.
gasForAlternativeCurrency := uint64(0)
if msg.FeeCurrency != nil {
gasForAlternativeCurrency = fee_currencies.IntrinsicGasForAlternativeFeeCurrency
}
Expand Down Expand Up @@ -661,12 +660,6 @@ func (st *StateTransition) blobGasUsed() uint64 {

// distributeTxFees calculates the amounts and recipients of transaction fees and credits the accounts.
func (st *StateTransition) distributeTxFees() error {
// TODO(pl): check tracing
// Run only primary evm.Call() with tracer
// if st.evm.GetDebug() {
// st.evm.SetDebug(false)
// defer func() { st.evm.SetDebug(true) }()
// }
if st.evm.Config.NoBaseFee && st.msg.GasFeeCap.Sign() == 0 && st.msg.GasTipCap.Sign() == 0 {
// Skip fee payment when NoBaseFee is set and the fee fields
// are 0. This avoids a negative effectiveTip being applied to
Expand Down

0 comments on commit 4253602

Please sign in to comment.