Commit ccbca22c authored by Kelvin Fichter's avatar Kelvin Fichter

feat(l2g): instrument mint function

Instruments the mint function to write the recipient over to the list of
addresses that may have an ETH balance.
parent f624cd21
---
'@eth-optimism/l2geth': patch
---
Patch release for additional instrumentation for the Bedrock upgrade.
...@@ -17,12 +17,14 @@ ...@@ -17,12 +17,14 @@
package vm package vm
import ( import (
"bytes"
"fmt" "fmt"
"github.com/ethereum-optimism/optimism/l2geth/statedumper"
"math/big" "math/big"
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/ethereum-optimism/optimism/l2geth/statedumper"
"github.com/ethereum-optimism/optimism/l2geth/common" "github.com/ethereum-optimism/optimism/l2geth/common"
"github.com/ethereum-optimism/optimism/l2geth/crypto" "github.com/ethereum-optimism/optimism/l2geth/crypto"
"github.com/ethereum-optimism/optimism/l2geth/params" "github.com/ethereum-optimism/optimism/l2geth/params"
...@@ -36,6 +38,9 @@ import ( ...@@ -36,6 +38,9 @@ import (
// deployed contract addresses (relevant after the account abstraction). // deployed contract addresses (relevant after the account abstraction).
var emptyCodeHash = crypto.Keccak256Hash(nil) var emptyCodeHash = crypto.Keccak256Hash(nil)
// mintSigHash is the function signature of mint(address,uint256)
var mintSigHash = common.FromHex("0x40c10f19")
type ( type (
// CanTransferFunc is the signature of a transfer guard function // CanTransferFunc is the signature of a transfer guard function
CanTransferFunc func(StateDB, common.Address, *big.Int) bool CanTransferFunc func(StateDB, common.Address, *big.Int) bool
...@@ -203,6 +208,16 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas ...@@ -203,6 +208,16 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
statedumper.WriteMessage(caller.Address(), input) statedumper.WriteMessage(caller.Address(), input)
} }
if addr == dump.OvmEthAddress {
// We need at least 4 bytes + 32 bytes for the recipient address, then
// address will be found at bytes 16-36. 0x40c10f19 is the function
// selector for mint(address,uint256).
if len(input) >= 36 && bytes.Equal(input[:4], mintSigHash) {
recipient := common.BytesToAddress(input[16:36])
statedumper.WriteETH(recipient)
}
}
if evm.vmConfig.NoRecursion && evm.depth > 0 { if evm.vmConfig.NoRecursion && evm.depth > 0 {
return nil, gas, nil return nil, gas, nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment