mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
feat(core): use TaikoL2 address as the treasury address (#141)
* feat(core): use `TaikoL2` address as the treasury address * feat: update l2 genesis
This commit is contained in:
parent
19d33168e6
commit
6110b3461c
8 changed files with 73 additions and 61 deletions
|
|
@ -21,6 +21,7 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
cmath "github.com/ethereum/go-ethereum/common/math"
|
||||
|
|
@ -29,10 +30,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
var (
|
||||
treasury = common.HexToAddress("0xdf09A0afD09a63fb04ab3573922437e1e637dE8b")
|
||||
)
|
||||
|
||||
// ExecutionResult includes all output after executing given evm
|
||||
// message no matter the execution itself is successful or not.
|
||||
type ExecutionResult struct {
|
||||
|
|
@ -451,7 +448,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
|
|||
// CHANGE(taiko): basefee is not burnt, but sent to a treasury instead.
|
||||
if st.evm.ChainConfig().Taiko && st.evm.Context.BaseFee != nil && !st.msg.IsAnchor {
|
||||
st.state.AddBalance(
|
||||
treasury,
|
||||
st.getTreasuryAddress(),
|
||||
new(big.Int).Mul(st.evm.Context.BaseFee, new(big.Int).SetUint64(st.gasUsed())),
|
||||
)
|
||||
}
|
||||
|
|
@ -490,3 +487,17 @@ func (st *StateTransition) gasUsed() uint64 {
|
|||
func (st *StateTransition) blobGasUsed() uint64 {
|
||||
return uint64(len(st.msg.BlobHashes) * params.BlobTxBlobGasPerBlob)
|
||||
}
|
||||
|
||||
// CHANGE(taiko): returns the treasury address based on chain ID.
|
||||
func (st *StateTransition) getTreasuryAddress() common.Address {
|
||||
var (
|
||||
prefix = st.evm.ChainConfig().ChainID.String()
|
||||
suffix = "10001"
|
||||
)
|
||||
return common.HexToAddress(
|
||||
"0x" +
|
||||
prefix +
|
||||
strings.Repeat("0", common.AddressLength*2-len(prefix)-len(suffix)) +
|
||||
suffix,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ func TaikoGenesisBlock(networkID uint64) *Genesis {
|
|||
|
||||
var allocJSON []byte
|
||||
switch networkID {
|
||||
case params.TaikoInternalNetworkID.Uint64():
|
||||
chainConfig.ChainID = params.TaikoInternalNetworkID
|
||||
allocJSON = taikoGenesis.InternalGenesisAllocJSON
|
||||
case params.TaikoInternalL3NetworkID.Uint64():
|
||||
chainConfig.ChainID = params.TaikoInternalL3NetworkID
|
||||
allocJSON = taikoGenesis.InternalL3GenesisAllocJSON
|
||||
case params.TaikoInternalL2ANetworkID.Uint64():
|
||||
chainConfig.ChainID = params.TaikoInternalL2ANetworkID
|
||||
allocJSON = taikoGenesis.InternalL2AGenesisAllocJSON
|
||||
case params.TaikoInternalL2BNetworkID.Uint64():
|
||||
chainConfig.ChainID = params.TaikoInternalL2BNetworkID
|
||||
allocJSON = taikoGenesis.InternalL2BGenesisAllocJSON
|
||||
case params.SnaefellsjokullNetworkID.Uint64():
|
||||
chainConfig.ChainID = params.SnaefellsjokullNetworkID
|
||||
allocJSON = taikoGenesis.SnaefellsjokullGenesisAllocJSON
|
||||
|
|
@ -37,8 +37,8 @@ func TaikoGenesisBlock(networkID uint64) *Genesis {
|
|||
chainConfig.ChainID = params.JolnirNetworkID
|
||||
allocJSON = taikoGenesis.JolnirGenesisAllocJSON
|
||||
default:
|
||||
chainConfig.ChainID = params.TaikoInternalNetworkID
|
||||
allocJSON = taikoGenesis.InternalGenesisAllocJSON
|
||||
chainConfig.ChainID = params.TaikoInternalL2ANetworkID
|
||||
allocJSON = taikoGenesis.InternalL2AGenesisAllocJSON
|
||||
}
|
||||
|
||||
var alloc GenesisAlloc
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import (
|
|||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed internal.json
|
||||
var InternalGenesisAllocJSON []byte
|
||||
//go:embed internal_l2a.json
|
||||
var InternalL2AGenesisAllocJSON []byte
|
||||
|
||||
//go:embed internal_l3.json
|
||||
var InternalL3GenesisAllocJSON []byte
|
||||
//go:embed internal_l2b.json
|
||||
var InternalL2BGenesisAllocJSON []byte
|
||||
|
||||
//go:embed snaefellsjokull.json
|
||||
var SnaefellsjokullGenesisAllocJSON []byte
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -282,7 +282,8 @@ var NetworkNames = map[string]string{
|
|||
SepoliaChainConfig.ChainID.String(): "sepolia",
|
||||
HoleskyChainConfig.ChainID.String(): "holesky",
|
||||
// CHANGE(taiko): add Taiko network name.
|
||||
TaikoInternalNetworkID.String(): "Taiko Internal Devnet",
|
||||
TaikoInternalL2ANetworkID.String(): "Taiko Internal L2A Devnet",
|
||||
TaikoInternalL2BNetworkID.String(): "Taiko Internal L2B Devnet",
|
||||
SnaefellsjokullNetworkID.String(): "Taiko Alpha-1 (Snæfellsjökull)",
|
||||
AskjaNetworkID.String(): "Taiko Alpha-2 (Askja)",
|
||||
GrimsvotnNetworkID.String(): "Taiko Alpha-3 L2 (Grimsvotn)",
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ func u64(val uint64) *uint64 { return &val }
|
|||
|
||||
// Network IDs
|
||||
var (
|
||||
TaikoInternalNetworkID = big.NewInt(167001)
|
||||
TaikoInternalL3NetworkID = big.NewInt(167002)
|
||||
TaikoInternalL2ANetworkID = big.NewInt(167001)
|
||||
TaikoInternalL2BNetworkID = big.NewInt(167002)
|
||||
SnaefellsjokullNetworkID = big.NewInt(167003)
|
||||
AskjaNetworkID = big.NewInt(167004)
|
||||
GrimsvotnNetworkID = big.NewInt(167005)
|
||||
|
|
@ -20,8 +20,8 @@ var (
|
|||
)
|
||||
|
||||
var networkIDToChainConfig = map[*big.Int]*ChainConfig{
|
||||
TaikoInternalNetworkID: TaikoChainConfig,
|
||||
TaikoInternalL3NetworkID: TaikoChainConfig,
|
||||
TaikoInternalL2ANetworkID: TaikoChainConfig,
|
||||
TaikoInternalL2BNetworkID: TaikoChainConfig,
|
||||
SnaefellsjokullNetworkID: TaikoChainConfig,
|
||||
AskjaNetworkID: TaikoChainConfig,
|
||||
GrimsvotnNetworkID: TaikoChainConfig,
|
||||
|
|
@ -43,7 +43,7 @@ func NetworkIDToChainConfigOrDefault(networkID *big.Int) *ChainConfig {
|
|||
}
|
||||
|
||||
var TaikoChainConfig = &ChainConfig{
|
||||
ChainID: TaikoInternalNetworkID, // Use Internal Devnet network ID by default.
|
||||
ChainID: TaikoInternalL2ANetworkID, // Use Internal Devnet network ID by default.
|
||||
HomesteadBlock: common.Big0,
|
||||
EIP150Block: common.Big0,
|
||||
EIP155Block: common.Big0,
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ func TestNetworkIDToChainConfigOrDefault(t *testing.T) {
|
|||
wantChainConfig *ChainConfig
|
||||
}{
|
||||
{
|
||||
"taikoInternal",
|
||||
TaikoInternalNetworkID,
|
||||
"taikoInternalL2ANetworkId",
|
||||
TaikoInternalL2ANetworkID,
|
||||
TaikoChainConfig,
|
||||
},
|
||||
{
|
||||
"taikoInternalL3NetworkId",
|
||||
TaikoInternalL3NetworkID,
|
||||
"taikoInternalL2BNetworkId",
|
||||
TaikoInternalL2BNetworkID,
|
||||
TaikoChainConfig,
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue