Skip to content
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: Add Support for Zero Fee Addresses #53

Merged
merged 4 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?
ckartik marked this conversation as resolved.
Show resolved Hide resolved
ckartik marked this conversation as resolved.
Show resolved Hide resolved
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"
ckartik marked this conversation as resolved.
Show resolved Hide resolved
]
},
"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
Loading