Skip to content

Commit

Permalink
feat(core): use TaikoL2 address as the treasury address
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Dec 7, 2023
1 parent 19d3316 commit 002815d
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"math"
"math/big"
"strings"

"github.com/ethereum/go-ethereum/common"
cmath "github.com/ethereum/go-ethereum/common/math"
Expand All @@ -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 {
Expand Down Expand Up @@ -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())),
)
}
Expand Down Expand Up @@ -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,
)
}

0 comments on commit 002815d

Please sign in to comment.