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

[R4R]-feat: merge from release to main; fix some audits #72

Merged
merged 44 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
77b7f84
R4R: compatible with 4844 (#34)
abelliumnt Jan 29, 2024
97be26d
Merge pull request #36 from mantlenetworkio/release/v0.5.0
Tri-stone Jan 30, 2024
d120ff2
R4R: mint eth to msg.from and transfer revertable (#31)
abelliumnt Feb 5, 2024
3645f7b
MetaTxSignData add fromAddr, signHash includes this field
Jan 31, 2024
244fc78
metaTxSignData fork with metaTxUpdateHeight
Jan 31, 2024
21cfd30
change var name
Jan 31, 2024
25af21f
metatx upgrade with config
Feb 4, 2024
23a74e2
set metatx upgrade blkNum 2744121
Feb 4, 2024
020aff6
update func name IsMetaTxUpgraded to IsMetaTxV2
Feb 4, 2024
eb6b730
metatxV2 upgrade by timestamp
Feb 4, 2024
1536797
add rules into TransactionToMessage params, set metaTxUpgradeTime nil
Feb 5, 2024
86ac3fd
del metatx upgradeTime from mainnet config
Feb 5, 2024
74937cb
del useless config
Feb 5, 2024
19660a8
IsMetaTxV2 func use isTimestampForked instead of isMetaTxForked
Feb 5, 2024
8824dc5
validateTx reject BlobTxType txs, Receipt.MarshalJSON check Effective…
Feb 6, 2024
4d05b2c
Merge pull request #37 from mantlenetworkio/wwq/metatx-signFromAddr
wwqicode-blkchain Feb 6, 2024
d12aec3
[R4R]feat: add error message when failing to forward tx to sequencer …
Tri-stone Feb 22, 2024
52122bd
[R4R]-[tx]feat: fix tx cost (#41)
Tri-stone Feb 22, 2024
0cf00ba
add balance check for transferring bvm ethTxValue
abelliumnt Feb 25, 2024
72e4779
fix incorrect balance check
abelliumnt Feb 27, 2024
f636735
fix incorrectly calculation of the user balance
abelliumnt Feb 27, 2024
b5ea92b
sponsor percent should be more than zero
abelliumnt Feb 29, 2024
b2cb932
Merge pull request #47 from mantlenetworkio/release/v0.5.0
Tri-stone Mar 1, 2024
7ea77b8
Merge pull request #42 from mantlenetworkio/bugfix/add-check-for-tran…
Tri-stone Mar 3, 2024
5cce695
Merge pull request #45 from mantlenetworkio/bugfix/incorrectly-calcul…
Tri-stone Mar 3, 2024
a1734e5
Merge pull request #44 from mantlenetworkio/bufix/incorrect-balance-c…
Tri-stone Mar 3, 2024
64996df
Merge pull request #46 from mantlenetworkio/bugfix/sponsor-percent-mo…
Tri-stone Mar 3, 2024
bb4117b
[R4R]-{estimateGas}feature: EstimateGas performance optimization (#38)
DevDynamo2024 Mar 6, 2024
a209406
Migrate GetBlockRange to op-geth (#48)
asdv23 Mar 6, 2024
556ba3f
Set SuggestTipCap to zero (#49)
asdv23 Mar 6, 2024
5fb5758
check accumulated sponsor amount (#43)
abelliumnt Mar 6, 2024
a442ea7
[R4R]-[L04]-fix: fix balanceCheck for shared pointer (#52)
Tri-stone Mar 6, 2024
b8cdd4b
[R4R]-fix: N-09 Unnecessary Double Check of SponsorPercent (#57)
asdv23 Mar 6, 2024
3857979
R4R: fix/ivan/L-01 Incorrect Error Message (#50)
asdv23 Mar 6, 2024
e3e9399
[R4R]-fix: N-06 Inexplicit Struct Declaration (#55)
asdv23 Mar 6, 2024
0bd29f8
R4R: fix_N-05 Unused Variables (#54)
asdv23 Mar 6, 2024
2eaa043
[R4R]-feature: ethclient: use 'input', not 'data' as field for transa…
asdv23 Mar 6, 2024
8ae3d1f
Merge pull request #60 from mantlenetworkio/audits
Tri-stone Mar 7, 2024
468d164
increase accumulated sponsor fee (#62)
abelliumnt Mar 11, 2024
b17e053
fix balance check in tx replacement for metatx
abelliumnt Mar 11, 2024
f458046
Merge pull request #63 from mantlenetworkio/bugfix/replacement-sum-check
idyllsss Mar 11, 2024
db24062
Revert "[R4R]-{estimateGas}feature: EstimateGas performance optimizat…
Tri-stone Mar 12, 2024
4d49b52
[R4R]-[fee]fix: fix estimateGas; discard invalid tx (#67)
Tri-stone Mar 13, 2024
74e3b45
fix workflow go version (#70)
shidaxi Mar 13, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/check-make-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
submodules: recursive
token: ${{ secrets.PAT }}
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
golang-version: 1.19
go-version: '1.20'
- name: Checking Make Build
run: |
sudo apt update
Expand Down
3 changes: 2 additions & 1 deletion cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
misc.ApplyDAOHardFork(statedb)
}

rules := chainConfig.Rules(new(big.Int).SetUint64(pre.Env.Number), false, pre.Env.Timestamp)
for i, tx := range txs {
msg, err := core.TransactionToMessage(tx, signer, pre.Env.BaseFee)
msg, err := core.TransactionToMessage(tx, signer, pre.Env.BaseFee, &rules)
if err != nil {
log.Warn("rejected tx", "index", i, "hash", tx.Hash(), "error", err)
rejectedTxs = append(rejectedTxs, &rejectedTx{i, err.Error()})
Expand Down
11 changes: 11 additions & 0 deletions core/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ var (
// than required to start the invocation.
ErrIntrinsicGas = errors.New("intrinsic gas too low")

// ErrInsufficientGasForL1Cost is returned if the transaction is specified to use less gas
// than required for l1Cost.
ErrInsufficientGasForL1Cost = errors.New("insufficient gas for l1Cost. Please use estimateGas to get gasLimit")

// ErrTxTypeNotSupported is returned if a transaction is not supported in the
// current network configuration.
ErrTxTypeNotSupported = types.ErrTxTypeNotSupported
Expand All @@ -98,9 +102,16 @@ var (
// base fee of the block.
ErrFeeCapTooLow = errors.New("max fee per gas less than block base fee")

// ErrGasPriceTooLow is returned if the transaction gasPrice is less than the
// base fee of the block for legacy tx
ErrGasPriceTooLow = errors.New("legacy tx's gasPrice less than block base fee")

// ErrSenderNoEOA is returned if the sender of a transaction is a contract.
ErrSenderNoEOA = errors.New("sender not an eoa")

// ErrSystemTxNotSupported is returned for any deposit tx with IsSystemTx=true after the Regolith fork
ErrSystemTxNotSupported = errors.New("system tx not supported")

// ErrEthTxValueTooLarge is returned when EthTxValue is larger than the BVM balance of msg.from
ErrEthTxValueTooLarge = errors.New("eth tx value is too large")
)
2 changes: 2 additions & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen
mantleUpgradeChainConfig := GetUpgradeConfigForMantle(config.ChainID)
if mantleUpgradeChainConfig != nil {
config.BaseFeeTime = mantleUpgradeChainConfig.BaseFeeTime
config.BVMETHMintUpgradeTime = mantleUpgradeChainConfig.BVMETHMintUpgradeTime
config.MetaTxUpgradeTime = mantleUpgradeChainConfig.MetaTxUpgradeTime
}

if overrides != nil && overrides.OverrideShanghai != nil {
Expand Down
29 changes: 20 additions & 9 deletions core/mantle_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,37 @@ import (

var (
MantleMainnetUpgradeConfig = MantleUpgradeChainConfig{
ChainID: params.MantleMainnetChainId,
BaseFeeTime: u64Ptr(0),
ChainID: params.MantleMainnetChainId,
BaseFeeTime: u64Ptr(0),
BVMETHMintUpgradeTime: u64Ptr(0),
MetaTxUpgradeTime: u64Ptr(0),
}

MantleSepoliaUpgradeConfig = MantleUpgradeChainConfig{
ChainID: params.MantleSepoliaChainId,
BaseFeeTime: u64Ptr(1_704_891_600),
ChainID: params.MantleSepoliaChainId,
BaseFeeTime: u64Ptr(1_704_891_600),
BVMETHMintUpgradeTime: nil, //TODO set upgrade timestamp
MetaTxUpgradeTime: nil, //TODO set upgrade timestamp
}
MantleLocalUpgradeConfig = MantleUpgradeChainConfig{
ChainID: params.MantleLocalChainId,
BaseFeeTime: u64Ptr(0),
ChainID: params.MantleLocalChainId,
BaseFeeTime: u64Ptr(0),
BVMETHMintUpgradeTime: u64Ptr(0),
MetaTxUpgradeTime: u64Ptr(0),
}
MantleDefaultUpgradeConfig = MantleUpgradeChainConfig{
BaseFeeTime: u64Ptr(0),
BaseFeeTime: u64Ptr(0),
BVMETHMintUpgradeTime: u64Ptr(0),
MetaTxUpgradeTime: u64Ptr(0),
}
)

type MantleUpgradeChainConfig struct {
ChainID *big.Int `json:"chainId"` // chainId identifies the current chain and is used for replay protection
BaseFeeTime *uint64 `json:"BaseFeeTime"` // Mantle BaseFee switch time (nil = no fork, 0 = already on mantle baseFee)
ChainID *big.Int `json:"chainId"` // chainId identifies the current chain and is used for replay protection

BaseFeeTime *uint64 `json:"BaseFeeTime"` // Mantle BaseFee switch time (nil = no fork, 0 = already on mantle baseFee)
BVMETHMintUpgradeTime *uint64 `json:"BVMETHMintUpgradeTime"` // BVM_ETH mint upgrade switch time (nil = no fork, 0 = already on)
MetaTxUpgradeTime *uint64 `json:"metaTxUpgradeTime"` // MetaTxUpgradeBlock identifies the current block height is using metaTx with MetaTxSignDataV2
}

func GetUpgradeConfigForMantle(chainID *big.Int) *MantleUpgradeChainConfig {
Expand Down
4 changes: 3 additions & 1 deletion core/state_prefetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c
)
// Iterate over and process the individual transactions
byzantium := p.config.IsByzantium(block.Number())
rules := evm.ChainConfig().Rules(block.Number(), false, header.Time)

for i, tx := range block.Transactions() {
// If block precaching was interrupted, abort
if interrupt != nil && atomic.LoadUint32(interrupt) == 1 {
return
}
// Convert the transaction into an executable message and pre-cache its sender
msg, err := TransactionToMessage(tx, signer, header.BaseFee)
msg, err := TransactionToMessage(tx, signer, header.BaseFee, &rules)
if err != nil {
return // Also invalid block, bail out
}
Expand Down
7 changes: 5 additions & 2 deletions core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
}
blockContext := NewEVMBlockContext(header, p.bc, nil, p.config, statedb)
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg)
rules := vmenv.ChainConfig().Rules(header.Number, false, header.Time)

// Iterate over and process the individual transactions
for i, tx := range block.Transactions() {
msg, err := TransactionToMessage(tx, types.MakeSigner(p.config, header.Number), header.BaseFee)
msg, err := TransactionToMessage(tx, types.MakeSigner(p.config, header.Number), header.BaseFee, &rules)
if err != nil {
return nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err)
}
Expand Down Expand Up @@ -171,7 +173,8 @@ func applyTransaction(msg *Message, config *params.ChainConfig, gp *GasPool, sta
// for the transaction, gas used and an error if the transaction failed,
// indicating the block was invalid.
func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config) (*types.Receipt, error) {
msg, err := TransactionToMessage(tx, types.MakeSigner(config, header.Number), header.BaseFee)
rules := config.Rules(header.Number, false, header.Time)
msg, err := TransactionToMessage(tx, types.MakeSigner(config, header.Number), header.BaseFee, &rules)
if err != nil {
return nil, err
}
Expand Down
126 changes: 105 additions & 21 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package core

import (
"errors"
"fmt"
"math"
"math/big"
Expand Down Expand Up @@ -161,6 +162,7 @@ type Message struct {
IsDepositTx bool // IsDepositTx indicates the message is force-included and can persist a mint.
Mint *big.Int // Mint is the amount to mint before EVM processing, or nil if there is no minting.
ETHValue *big.Int // ETHValue is the amount to mint BVM_ETH before EVM processing, or nil if there is no minting.
ETHTxValue *big.Int // ETHTxValue is the amount to be transferred to msg.To before EVM processing, and the transfer will be reverted if EVM failed
MetaTxParams *types.MetaTxParams // MetaTxParams contains necessary parameter to sponsor gas fee for msg.From.
RollupDataGas types.RollupGasData // RollupDataGas indicates the rollup cost of the message, 0 if not a rollup or no cost.

Expand All @@ -169,8 +171,11 @@ type Message struct {
}

// TransactionToMessage converts a transaction into a Message.
func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.Int) (*Message, error) {
metaTxParams, err := types.DecodeAndVerifyMetaTxParams(tx)
func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.Int, rules *params.Rules) (*Message, error) {
if rules == nil {
return nil, errors.New("param rules is nil pointer")
}
metaTxParams, err := types.DecodeAndVerifyMetaTxParams(tx, rules.IsMetaTxV2)
if err != nil {
return nil, err
}
Expand All @@ -189,6 +194,7 @@ func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.In
Mint: tx.Mint(),
RollupDataGas: tx.RollupDataGas(),
ETHValue: tx.ETHValue(),
ETHTxValue: tx.ETHTxValue(),
MetaTxParams: metaTxParams,
SkipAccountChecks: false,
RunMode: CommitMode,
Expand Down Expand Up @@ -295,9 +301,9 @@ func (st *StateTransition) buyGas() (*big.Int, error) {
if l1Cost != nil && (st.msg.RunMode == GasEstimationMode || st.msg.RunMode == GasEstimationWithSkipCheckBalanceMode) {
mgval = mgval.Add(mgval, l1Cost)
}
balanceCheck := mgval
balanceCheck := new(big.Int).Set(mgval)
if st.msg.GasFeeCap != nil {
balanceCheck = new(big.Int).SetUint64(st.msg.GasLimit)
balanceCheck.SetUint64(st.msg.GasLimit)
balanceCheck = balanceCheck.Mul(balanceCheck, st.msg.GasFeeCap)
balanceCheck.Add(balanceCheck, st.msg.Value)
if l1Cost != nil && st.msg.RunMode == GasEstimationMode {
Expand Down Expand Up @@ -438,19 +444,15 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
if mint := st.msg.Mint; mint != nil {
st.state.AddBalance(st.msg.From, mint)
}

//Mint BVM_ETH
rules := st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber, st.evm.Context.Random != nil, st.evm.Context.Time)
//add eth value
if ethValue := st.msg.ETHValue; ethValue != nil && ethValue.Cmp(big.NewInt(0)) != 0 {
var ethRecipient common.Address
if st.msg.To != nil {
ethRecipient = *st.msg.To
} else {
ethRecipient = crypto.CreateAddress(st.msg.From, st.evm.StateDB.GetNonce(st.msg.From))
}
st.addBVMETHBalance(ethRecipient, ethValue)
st.addBVMETHTotalSupply(ethValue)
st.generateBVMETHMintEvent(ethRecipient, ethValue)
st.mintBVMETH(ethValue, rules)
}
snap := st.state.Snapshot()
// Will be reverted if failed

result, err := st.innerTransitionDb()
// Failed deposits must still be included. Unless we cannot produce the block at all due to the gas limit.
Expand Down Expand Up @@ -478,6 +480,14 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
}

func (st *StateTransition) innerTransitionDb() (*ExecutionResult, error) {
rules := st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber, st.evm.Context.Random != nil, st.evm.Context.Time)
if ethTxValue := st.msg.ETHTxValue; ethTxValue != nil && ethTxValue.Cmp(big.NewInt(0)) != 0 {
err := st.transferBVMETH(ethTxValue, rules)
if err != nil {
return nil, err
}
}

// First check this message satisfies all consensus rules before
// applying the message. The rules include these clauses
//
Expand Down Expand Up @@ -505,7 +515,6 @@ func (st *StateTransition) innerTransitionDb() (*ExecutionResult, error) {
var (
msg = st.msg
sender = vm.AccountRef(msg.From)
rules = st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber, st.evm.Context.Random != nil, st.evm.Context.Time)
contractCreation = msg.To == nil
)

Expand All @@ -514,6 +523,7 @@ func (st *StateTransition) innerTransitionDb() (*ExecutionResult, error) {
if err != nil {
return nil, err
}

if !st.msg.IsDepositTx && !st.msg.IsSystemTx {
gas = gas * tokenRatio
}
Expand All @@ -526,12 +536,9 @@ func (st *StateTransition) innerTransitionDb() (*ExecutionResult, error) {
if !st.msg.IsDepositTx && !st.msg.IsSystemTx {
if st.msg.GasPrice.Cmp(common.Big0) > 0 && l1Cost != nil {
l1Gas = new(big.Int).Div(l1Cost, st.msg.GasPrice).Uint64()
if st.msg.GasLimit < l1Gas {
return nil, fmt.Errorf("%w: have %d, want %d", ErrIntrinsicGas, st.gasRemaining, l1Gas)
}
}
if st.gasRemaining < l1Gas {
return nil, fmt.Errorf("%w: have %d, want %d", ErrIntrinsicGas, st.gasRemaining, l1Gas)
return nil, fmt.Errorf("%w: have %d, want %d", ErrInsufficientGasForL1Cost, st.gasRemaining, l1Gas)
}
st.gasRemaining -= l1Gas
if tokenRatio > 0 {
Expand Down Expand Up @@ -647,7 +654,7 @@ func (st *StateTransition) refundGas(refundQuotient, tokenRatio uint64) {
}
st.gasRemaining += refund

// Return ETH for remaining gas, exchanged at the original rate.
// Return MNT for remaining gas, exchanged at the original rate.
st.gasRemaining = st.gasRemaining * tokenRatio
remaining := new(big.Int).Mul(new(big.Int).SetUint64(st.gasRemaining), st.msg.GasPrice)
if st.msg.MetaTxParams != nil {
Expand All @@ -671,12 +678,33 @@ func (st *StateTransition) gasUsed() uint64 {
return st.initialGas - st.gasRemaining
}

func (st *StateTransition) addBVMETHBalance(ethRecipient common.Address, ethValue *big.Int) {
key := getBVMETHBalanceKey(ethRecipient)
func (st *StateTransition) mintBVMETH(ethValue *big.Int, rules params.Rules) {
if !rules.IsMantleBVMETHMintUpgrade {
var key common.Hash
var ethRecipient common.Address
if st.msg.To != nil {
ethRecipient = *st.msg.To
} else {
ethRecipient = crypto.CreateAddress(st.msg.From, st.evm.StateDB.GetNonce(st.msg.From))
}
key = getBVMETHBalanceKey(ethRecipient)
value := st.state.GetState(BVM_ETH_ADDR, key)
bal := value.Big()
bal = bal.Add(bal, ethValue)
st.state.SetState(BVM_ETH_ADDR, key, common.BigToHash(bal))

st.addBVMETHTotalSupply(ethValue)
st.generateBVMETHMintEvent(ethRecipient, ethValue)
return
}
key := getBVMETHBalanceKey(st.msg.From)
value := st.state.GetState(BVM_ETH_ADDR, key)
bal := value.Big()
bal = bal.Add(bal, ethValue)
st.state.SetState(BVM_ETH_ADDR, key, common.BigToHash(bal))

st.addBVMETHTotalSupply(ethValue)
st.generateBVMETHMintEvent(st.msg.From, ethValue)
}

func (st *StateTransition) addBVMETHTotalSupply(ethValue *big.Int) {
Expand All @@ -687,6 +715,43 @@ func (st *StateTransition) addBVMETHTotalSupply(ethValue *big.Int) {
st.state.SetState(BVM_ETH_ADDR, key, common.BigToHash(bal))
}

func (st *StateTransition) transferBVMETH(ethValue *big.Int, rules params.Rules) error {
if !rules.IsMantleBVMETHMintUpgrade {
return nil
}
var ethRecipient common.Address
if st.msg.To != nil {
ethRecipient = *st.msg.To
} else {
ethRecipient = crypto.CreateAddress(st.msg.From, st.evm.StateDB.GetNonce(st.msg.From))
}
if ethRecipient == st.msg.From {
return nil
}

fromKey := getBVMETHBalanceKey(st.msg.From)
toKey := getBVMETHBalanceKey(ethRecipient)

fromBalanceValue := st.state.GetState(BVM_ETH_ADDR, fromKey)
toBalanceValue := st.state.GetState(BVM_ETH_ADDR, toKey)

fromBalance := fromBalanceValue.Big()
toBalance := toBalanceValue.Big()

if fromBalance.Cmp(ethValue) < 0 {
return ErrEthTxValueTooLarge
}

fromBalance = new(big.Int).Sub(fromBalance, ethValue)
toBalance = new(big.Int).Add(toBalance, ethValue)

st.state.SetState(BVM_ETH_ADDR, fromKey, common.BigToHash(fromBalance))
st.state.SetState(BVM_ETH_ADDR, toKey, common.BigToHash(toBalance))

st.generateBVMETHTransferEvent(st.msg.From, ethRecipient, ethValue)
return nil
}

func getBVMETHBalanceKey(addr common.Address) common.Hash {
position := common.Big0
hasher := sha3.NewLegacyKeccak256()
Expand Down Expand Up @@ -717,3 +782,22 @@ func (st *StateTransition) generateBVMETHMintEvent(mintAddress common.Address, m
BlockNumber: st.evm.Context.BlockNumber.Uint64(),
})
}

func (st *StateTransition) generateBVMETHTransferEvent(from, to common.Address, amount *big.Int) {
// keccak("Transfer(address,address,uint256)") = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
methodHash := common.HexToHash("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
topics := make([]common.Hash, 3)
topics[0] = methodHash
topics[1] = from.Hash()
topics[2] = to.Hash()
//data means the transfer amount in Transfer EVENT.
data := common.HexToHash(common.Bytes2Hex(amount.Bytes())).Bytes()
st.evm.StateDB.AddLog(&types.Log{
Address: BVM_ETH_ADDR,
Topics: topics,
Data: data,
// This is a non-consensus field, but assigned here because
// core/state doesn't know the current block number.
BlockNumber: st.evm.Context.BlockNumber.Uint64(),
})
}
Loading