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"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
cmath "github.com/ethereum/go-ethereum/common/math"
|
cmath "github.com/ethereum/go-ethereum/common/math"
|
||||||
|
|
@ -29,10 +30,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
treasury = common.HexToAddress("0xdf09A0afD09a63fb04ab3573922437e1e637dE8b")
|
|
||||||
)
|
|
||||||
|
|
||||||
// ExecutionResult includes all output after executing given evm
|
// ExecutionResult includes all output after executing given evm
|
||||||
// message no matter the execution itself is successful or not.
|
// message no matter the execution itself is successful or not.
|
||||||
type ExecutionResult struct {
|
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.
|
// 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 {
|
if st.evm.ChainConfig().Taiko && st.evm.Context.BaseFee != nil && !st.msg.IsAnchor {
|
||||||
st.state.AddBalance(
|
st.state.AddBalance(
|
||||||
treasury,
|
st.getTreasuryAddress(),
|
||||||
new(big.Int).Mul(st.evm.Context.BaseFee, new(big.Int).SetUint64(st.gasUsed())),
|
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 {
|
func (st *StateTransition) blobGasUsed() uint64 {
|
||||||
return uint64(len(st.msg.BlobHashes) * params.BlobTxBlobGasPerBlob)
|
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
|
var allocJSON []byte
|
||||||
switch networkID {
|
switch networkID {
|
||||||
case params.TaikoInternalNetworkID.Uint64():
|
case params.TaikoInternalL2ANetworkID.Uint64():
|
||||||
chainConfig.ChainID = params.TaikoInternalNetworkID
|
chainConfig.ChainID = params.TaikoInternalL2ANetworkID
|
||||||
allocJSON = taikoGenesis.InternalGenesisAllocJSON
|
allocJSON = taikoGenesis.InternalL2AGenesisAllocJSON
|
||||||
case params.TaikoInternalL3NetworkID.Uint64():
|
case params.TaikoInternalL2BNetworkID.Uint64():
|
||||||
chainConfig.ChainID = params.TaikoInternalL3NetworkID
|
chainConfig.ChainID = params.TaikoInternalL2BNetworkID
|
||||||
allocJSON = taikoGenesis.InternalL3GenesisAllocJSON
|
allocJSON = taikoGenesis.InternalL2BGenesisAllocJSON
|
||||||
case params.SnaefellsjokullNetworkID.Uint64():
|
case params.SnaefellsjokullNetworkID.Uint64():
|
||||||
chainConfig.ChainID = params.SnaefellsjokullNetworkID
|
chainConfig.ChainID = params.SnaefellsjokullNetworkID
|
||||||
allocJSON = taikoGenesis.SnaefellsjokullGenesisAllocJSON
|
allocJSON = taikoGenesis.SnaefellsjokullGenesisAllocJSON
|
||||||
|
|
@ -37,8 +37,8 @@ func TaikoGenesisBlock(networkID uint64) *Genesis {
|
||||||
chainConfig.ChainID = params.JolnirNetworkID
|
chainConfig.ChainID = params.JolnirNetworkID
|
||||||
allocJSON = taikoGenesis.JolnirGenesisAllocJSON
|
allocJSON = taikoGenesis.JolnirGenesisAllocJSON
|
||||||
default:
|
default:
|
||||||
chainConfig.ChainID = params.TaikoInternalNetworkID
|
chainConfig.ChainID = params.TaikoInternalL2ANetworkID
|
||||||
allocJSON = taikoGenesis.InternalGenesisAllocJSON
|
allocJSON = taikoGenesis.InternalL2AGenesisAllocJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
var alloc GenesisAlloc
|
var alloc GenesisAlloc
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed internal.json
|
//go:embed internal_l2a.json
|
||||||
var InternalGenesisAllocJSON []byte
|
var InternalL2AGenesisAllocJSON []byte
|
||||||
|
|
||||||
//go:embed internal_l3.json
|
//go:embed internal_l2b.json
|
||||||
var InternalL3GenesisAllocJSON []byte
|
var InternalL2BGenesisAllocJSON []byte
|
||||||
|
|
||||||
//go:embed snaefellsjokull.json
|
//go:embed snaefellsjokull.json
|
||||||
var SnaefellsjokullGenesisAllocJSON []byte
|
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,12 +282,13 @@ var NetworkNames = map[string]string{
|
||||||
SepoliaChainConfig.ChainID.String(): "sepolia",
|
SepoliaChainConfig.ChainID.String(): "sepolia",
|
||||||
HoleskyChainConfig.ChainID.String(): "holesky",
|
HoleskyChainConfig.ChainID.String(): "holesky",
|
||||||
// CHANGE(taiko): add Taiko network name.
|
// CHANGE(taiko): add Taiko network name.
|
||||||
TaikoInternalNetworkID.String(): "Taiko Internal Devnet",
|
TaikoInternalL2ANetworkID.String(): "Taiko Internal L2A Devnet",
|
||||||
SnaefellsjokullNetworkID.String(): "Taiko Alpha-1 (Snæfellsjökull)",
|
TaikoInternalL2BNetworkID.String(): "Taiko Internal L2B Devnet",
|
||||||
AskjaNetworkID.String(): "Taiko Alpha-2 (Askja)",
|
SnaefellsjokullNetworkID.String(): "Taiko Alpha-1 (Snæfellsjökull)",
|
||||||
GrimsvotnNetworkID.String(): "Taiko Alpha-3 L2 (Grimsvotn)",
|
AskjaNetworkID.String(): "Taiko Alpha-2 (Askja)",
|
||||||
EldfellNetworkID.String(): "Taiko Alpha-4 L3 (Eldfell)",
|
GrimsvotnNetworkID.String(): "Taiko Alpha-3 L2 (Grimsvotn)",
|
||||||
JolnirNetworkID.String(): "Taiko Alpha-5 L2 (Jolnir)",
|
EldfellNetworkID.String(): "Taiko Alpha-4 L3 (Eldfell)",
|
||||||
|
JolnirNetworkID.String(): "Taiko Alpha-5 L2 (Jolnir)",
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChainConfig is the core config which determines the blockchain settings.
|
// ChainConfig is the core config which determines the blockchain settings.
|
||||||
|
|
|
||||||
|
|
@ -10,18 +10,18 @@ func u64(val uint64) *uint64 { return &val }
|
||||||
|
|
||||||
// Network IDs
|
// Network IDs
|
||||||
var (
|
var (
|
||||||
TaikoInternalNetworkID = big.NewInt(167001)
|
TaikoInternalL2ANetworkID = big.NewInt(167001)
|
||||||
TaikoInternalL3NetworkID = big.NewInt(167002)
|
TaikoInternalL2BNetworkID = big.NewInt(167002)
|
||||||
SnaefellsjokullNetworkID = big.NewInt(167003)
|
SnaefellsjokullNetworkID = big.NewInt(167003)
|
||||||
AskjaNetworkID = big.NewInt(167004)
|
AskjaNetworkID = big.NewInt(167004)
|
||||||
GrimsvotnNetworkID = big.NewInt(167005)
|
GrimsvotnNetworkID = big.NewInt(167005)
|
||||||
EldfellNetworkID = big.NewInt(167006)
|
EldfellNetworkID = big.NewInt(167006)
|
||||||
JolnirNetworkID = big.NewInt(167007)
|
JolnirNetworkID = big.NewInt(167007)
|
||||||
)
|
)
|
||||||
|
|
||||||
var networkIDToChainConfig = map[*big.Int]*ChainConfig{
|
var networkIDToChainConfig = map[*big.Int]*ChainConfig{
|
||||||
TaikoInternalNetworkID: TaikoChainConfig,
|
TaikoInternalL2ANetworkID: TaikoChainConfig,
|
||||||
TaikoInternalL3NetworkID: TaikoChainConfig,
|
TaikoInternalL2BNetworkID: TaikoChainConfig,
|
||||||
SnaefellsjokullNetworkID: TaikoChainConfig,
|
SnaefellsjokullNetworkID: TaikoChainConfig,
|
||||||
AskjaNetworkID: TaikoChainConfig,
|
AskjaNetworkID: TaikoChainConfig,
|
||||||
GrimsvotnNetworkID: TaikoChainConfig,
|
GrimsvotnNetworkID: TaikoChainConfig,
|
||||||
|
|
@ -43,7 +43,7 @@ func NetworkIDToChainConfigOrDefault(networkID *big.Int) *ChainConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
var TaikoChainConfig = &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,
|
HomesteadBlock: common.Big0,
|
||||||
EIP150Block: common.Big0,
|
EIP150Block: common.Big0,
|
||||||
EIP155Block: common.Big0,
|
EIP155Block: common.Big0,
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,13 @@ func TestNetworkIDToChainConfigOrDefault(t *testing.T) {
|
||||||
wantChainConfig *ChainConfig
|
wantChainConfig *ChainConfig
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"taikoInternal",
|
"taikoInternalL2ANetworkId",
|
||||||
TaikoInternalNetworkID,
|
TaikoInternalL2ANetworkID,
|
||||||
TaikoChainConfig,
|
TaikoChainConfig,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"taikoInternalL3NetworkId",
|
"taikoInternalL2BNetworkId",
|
||||||
TaikoInternalL3NetworkID,
|
TaikoInternalL2BNetworkID,
|
||||||
TaikoChainConfig,
|
TaikoChainConfig,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue