Skip to content

Commit

Permalink
feat: adds zero-fee addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
ckartik committed Nov 22, 2024
1 parent 5219dc3 commit 89c6964
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
8 changes: 7 additions & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,13 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
// Send both base and prio fee to preconf.eth address
treasuryAccount := common.HexToAddress("0xfA0B0f5d298d28EFE4d35641724141ef19C05684")
bothFees := baseFee.Add(baseFee, priorityFee)
st.state.AddBalance(treasuryAccount, bothFees)

// @shaspitz do we note want to also remove the fee from the sender account, even when we increment the treasury account?
if st.evm.ChainConfig().IsZeroFee(sender.Address()) {
st.state.AddBalance(sender.Address(), bothFees)
} else {
st.state.AddBalance(treasuryAccount, bothFees)
}
}

return &ExecutionResult{
Expand Down
5 changes: 4 additions & 1 deletion geth-poa/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
"clique": {
"period": 200,
"epoch": 30000
}
},
"zeroFeeAddresses": [
"0xfA0B0f5d298d28EFE4d35641724141ef19C05684"
]
},
"nonce": "0x0",
"timestamp": "0x18E0A4E0D22",
Expand Down
7 changes: 7 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package params
import (
"fmt"
"math/big"
"slices"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params/forks"
Expand Down Expand Up @@ -364,6 +365,8 @@ type ChainConfig struct {
// Various consensus engines
Ethash *EthashConfig `json:"ethash,omitempty"`
Clique *CliqueConfig `json:"clique,omitempty"`

ZeroFeeAddresses []common.Address `json:"zeroFeeAddresses,omitempty"`
}

// EthashConfig is the consensus engine configs for proof-of-work based sealing.
Expand Down Expand Up @@ -577,6 +580,10 @@ func (c *ChainConfig) IsVerkle(num *big.Int, time uint64) bool {
return c.IsLondon(num) && isTimestampForked(c.VerkleTime, time)
}

func (c *ChainConfig) IsZeroFee(address common.Address) bool {
return slices.Contains(c.ZeroFeeAddresses, address)
}

// CheckCompatible checks whether scheduled fork transitions have been imported
// with a mismatching chain configuration.
func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64, time uint64) *ConfigCompatError {
Expand Down

0 comments on commit 89c6964

Please sign in to comment.