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

Update to build against geth merge-v1.11.4 branch #1652

Merged
merged 5 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 12 additions & 12 deletions arbos/l1pricing/l1pricing.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,41 +529,41 @@ var randS = crypto.Keccak256Hash([]byte("S")).Big()

// The returned tx will be invalid, likely for a number of reasons such as an invalid signature.
// It's only used to check how large it is after brotli level 0 compression.
func makeFakeTxForMessage(message core.Message) *types.Transaction {
nonce := message.Nonce()
func makeFakeTxForMessage(message *core.Message) *types.Transaction {
nonce := message.Nonce
if nonce == 0 {
nonce = randomNonce
}
gasTipCap := message.GasTipCap()
gasTipCap := message.GasTipCap
if gasTipCap.Sign() == 0 {
gasTipCap = randomGasTipCap
}
gasFeeCap := message.GasFeeCap()
gasFeeCap := message.GasFeeCap
if gasFeeCap.Sign() == 0 {
gasFeeCap = randomGasFeeCap
}
// During gas estimation, we don't want the gas limit variability to change the L1 cost.
gas := message.Gas()
if gas == 0 || message.RunMode() == types.MessageGasEstimationMode {
gas := message.GasLimit
if gas == 0 || message.TxRunMode == core.MessageGasEstimationMode {
gas = RandomGas
}
return types.NewTx(&types.DynamicFeeTx{
Nonce: nonce,
GasTipCap: gasTipCap,
GasFeeCap: gasFeeCap,
Gas: gas,
To: message.To(),
Value: message.Value(),
Data: message.Data(),
AccessList: message.AccessList(),
To: message.To,
Value: message.Value,
Data: message.Data,
AccessList: message.AccessList,
V: randV,
R: randR,
S: randS,
})
}

func (ps *L1PricingState) PosterDataCost(message core.Message, poster common.Address) (*big.Int, uint64) {
tx := message.UnderlyingTransaction()
func (ps *L1PricingState) PosterDataCost(message *core.Message, poster common.Address) (*big.Int, uint64) {
tx := message.Tx
if tx != nil {
return ps.GetPosterInfo(tx, poster)
}
Expand Down
58 changes: 29 additions & 29 deletions arbos/tx_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const GasEstimationL1PricePadding arbmath.Bips = 11000 // pad estimates by 10%
// It tracks state for ArbOS, allowing it infuence in Geth's tx processing.
// Public fields are accessible in precompiles.
type TxProcessor struct {
msg core.Message
msg *core.Message
state *arbosState.ArbosState
PosterFee *big.Int // set once in GasChargingHook to track L1 calldata costs
posterGas uint64
Expand All @@ -53,8 +53,8 @@ type TxProcessor struct {
cachedL1BlockHashes map[uint64]common.Hash
}

func NewTxProcessor(evm *vm.EVM, msg core.Message) *TxProcessor {
tracingInfo := util.NewTracingInfo(evm, msg.From(), arbosAddress, util.TracingBeforeEVM)
func NewTxProcessor(evm *vm.EVM, msg *core.Message) *TxProcessor {
tracingInfo := util.NewTracingInfo(evm, msg.From, arbosAddress, util.TracingBeforeEVM)
arbosState := arbosState.OpenSystemArbosStateOrPanic(evm.StateDB, tracingInfo, false)
return &TxProcessor{
msg: msg,
Expand Down Expand Up @@ -99,7 +99,7 @@ func (p *TxProcessor) StartTxHook() (endTxNow bool, gasUsed uint64, err error, r
// This hook is called before gas charging and will end the state transition if endTxNow is set to true
// Hence, we must charge for any l2 resources if endTxNow is returned true

underlyingTx := p.msg.UnderlyingTransaction()
underlyingTx := p.msg.Tx
if underlyingTx == nil {
return false, 0, nil, nil
}
Expand All @@ -115,26 +115,26 @@ func (p *TxProcessor) StartTxHook() (endTxNow bool, gasUsed uint64, err error, r
}
evm.IncrementDepth() // fake a call
tracer := evm.Config.Tracer
from := p.msg.From()
tracer.CaptureStart(evm, from, *p.msg.To(), false, p.msg.Data(), p.msg.Gas(), p.msg.Value())
from := p.msg.From
tracer.CaptureStart(evm, from, *p.msg.To, false, p.msg.Data, p.msg.GasLimit, p.msg.Value)

tracingInfo = util.NewTracingInfo(evm, from, *p.msg.To(), util.TracingDuringEVM)
tracingInfo = util.NewTracingInfo(evm, from, *p.msg.To, util.TracingDuringEVM)
p.state = arbosState.OpenSystemArbosStateOrPanic(evm.StateDB, tracingInfo, false)

return func() {
tracer.CaptureEnd(nil, p.state.Burner.Burned(), nil)
evm.DecrementDepth() // fake the return to the first faked call

tracingInfo = util.NewTracingInfo(evm, from, *p.msg.To(), util.TracingAfterEVM)
tracingInfo = util.NewTracingInfo(evm, from, *p.msg.To, util.TracingAfterEVM)
p.state = arbosState.OpenSystemArbosStateOrPanic(evm.StateDB, tracingInfo, false)
}
}

switch tx := underlyingTx.GetInner().(type) {
case *types.ArbitrumDepositTx:
from := p.msg.From()
to := p.msg.To()
value := p.msg.Value()
from := p.msg.From
to := p.msg.To
value := p.msg.Value
if to == nil {
return true, 0, errors.New("eth deposit has no To address"), nil
}
Expand All @@ -147,7 +147,7 @@ func (p *TxProcessor) StartTxHook() (endTxNow bool, gasUsed uint64, err error, r
return true, 0, nil, nil
case *types.ArbitrumInternalTx:
defer (startTracer())()
if p.msg.From() != arbosAddress {
if p.msg.From != arbosAddress {
return false, 0, errors.New("internal tx not from arbAddress"), nil
}
err = ApplyInternalTxUpdate(tx, p.state, evm)
Expand Down Expand Up @@ -246,11 +246,11 @@ func (p *TxProcessor) StartTxHook() (endTxNow bool, gasUsed uint64, err error, r

balance := statedb.GetBalance(tx.From)
basefee := evm.Context.BaseFee
usergas := p.msg.Gas()
usergas := p.msg.GasLimit

maxGasCost := arbmath.BigMulByUint(tx.GasFeeCap, usergas)
maxFeePerGasTooLow := arbmath.BigLessThan(tx.GasFeeCap, basefee)
if p.msg.RunMode() == types.MessageGasEstimationMode && tx.GasFeeCap.BitLen() == 0 {
if p.msg.TxRunMode == core.MessageGasEstimationMode && tx.GasFeeCap.BitLen() == 0 {
// In gas estimation mode, we permit a zero gas fee cap.
// This matches behavior with normal tx gas estimation.
maxFeePerGasTooLow = false
Expand Down Expand Up @@ -348,8 +348,8 @@ func (p *TxProcessor) StartTxHook() (endTxNow bool, gasUsed uint64, err error, r
return false, 0, nil, nil
}

func GetPosterGas(state *arbosState.ArbosState, baseFee *big.Int, runMode types.MessageRunMode, posterCost *big.Int) uint64 {
if runMode == types.MessageGasEstimationMode {
func GetPosterGas(state *arbosState.ArbosState, baseFee *big.Int, runMode core.MessageRunMode, posterCost *big.Int) uint64 {
if runMode == core.MessageGasEstimationMode {
// Suggest the amount of gas needed for a given amount of ETH is higher in case of congestion.
// This will help the user pad the total they'll pay in case the price rises a bit.
// Note, reducing the poster cost will increase share the network fee gets, not reduce the total.
Expand Down Expand Up @@ -379,7 +379,7 @@ func (p *TxProcessor) GasChargingHook(gasRemaining *uint64) (common.Address, err
basefee := p.evm.Context.BaseFee

var poster common.Address
if p.msg.RunMode() != types.MessageCommitMode {
if p.msg.TxRunMode != core.MessageCommitMode {
poster = l1pricing.BatchPosterAddress
} else {
poster = p.evm.Context.Coinbase
Expand All @@ -393,7 +393,7 @@ func (p *TxProcessor) GasChargingHook(gasRemaining *uint64) (common.Address, err
if calldataUnits > 0 {
p.state.Restrict(p.state.L1PricingState().AddToUnitsSinceUpdate(calldataUnits))
}
p.posterGas = GetPosterGas(p.state, basefee, p.msg.RunMode(), posterCost)
p.posterGas = GetPosterGas(p.state, basefee, p.msg.TxRunMode, posterCost)
p.PosterFee = arbmath.BigMulByUint(basefee, p.posterGas) // round down
gasNeededToStartEVM = p.posterGas
}
Expand All @@ -404,7 +404,7 @@ func (p *TxProcessor) GasChargingHook(gasRemaining *uint64) (common.Address, err
}
*gasRemaining -= gasNeededToStartEVM

if p.msg.RunMode() != types.MessageEthcallMode {
if p.msg.TxRunMode != core.MessageEthcallMode {
// If this is a real tx, limit the amount of computed based on the gas pool.
// We do this by charging extra gas, and then refunding it later.
gasAvailable, _ := p.state.L2PricingState().PerBlockGasLimit()
Expand All @@ -429,15 +429,15 @@ func (p *TxProcessor) ForceRefundGas() uint64 {

func (p *TxProcessor) EndTxHook(gasLeft uint64, success bool) {

underlyingTx := p.msg.UnderlyingTransaction()
underlyingTx := p.msg.Tx
networkFeeAccount, _ := p.state.NetworkFeeAccount()
basefee := p.evm.Context.BaseFee
scenario := util.TracingAfterEVM

if gasLeft > p.msg.Gas() {
if gasLeft > p.msg.GasLimit {
panic("Tx somehow refunds gas after computation")
}
gasUsed := p.msg.Gas() - gasLeft
gasUsed := p.msg.GasLimit - gasLeft

if underlyingTx != nil && underlyingTx.Type() == types.ArbitrumRetryTxType {
inner, _ := underlyingTx.GetInner().(*types.ArbitrumRetryTx)
Expand Down Expand Up @@ -484,7 +484,7 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, success bool) {

if success {
// we don't want to charge for this
tracingInfo := util.NewTracingInfo(p.evm, arbosAddress, p.msg.From(), scenario)
tracingInfo := util.NewTracingInfo(p.evm, arbosAddress, p.msg.From, scenario)
state := arbosState.OpenSystemArbosStateOrPanic(p.evm.StateDB, tracingInfo, false)
_, _ = state.RetryableState().DeleteRetryable(inner.TicketId, p.evm, scenario)
} else {
Expand Down Expand Up @@ -543,7 +543,7 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, success bool) {
}
}

if p.msg.GasPrice().Sign() > 0 { // in tests, gas price could be 0
if p.msg.GasPrice.Sign() > 0 { // in tests, gas price could be 0
// ArbOS's gas pool is meant to enforce the computational speed-limit.
// We don't want to remove from the pool the poster's L1 costs (as expressed in L2 gas in this func)
// Hence, we deduct the previously saved poster L2-gas-equivalent to reveal the compute-only gas
Expand Down Expand Up @@ -602,7 +602,7 @@ func (p *TxProcessor) L1BlockNumber(blockCtx vm.BlockContext) (uint64, error) {
if p.cachedL1BlockNumber != nil {
return *p.cachedL1BlockNumber, nil
}
tracingInfo := util.NewTracingInfo(p.evm, p.msg.From(), arbosAddress, util.TracingDuringEVM)
tracingInfo := util.NewTracingInfo(p.evm, p.msg.From, arbosAddress, util.TracingDuringEVM)
state, err := arbosState.OpenSystemArbosState(p.evm.StateDB, tracingInfo, false)
if err != nil {
return 0, err
Expand All @@ -620,7 +620,7 @@ func (p *TxProcessor) L1BlockHash(blockCtx vm.BlockContext, l1BlockNumber uint64
if cached {
return hash, nil
}
tracingInfo := util.NewTracingInfo(p.evm, p.msg.From(), arbosAddress, util.TracingDuringEVM)
tracingInfo := util.NewTracingInfo(p.evm, p.msg.From, arbosAddress, util.TracingDuringEVM)
state, err := arbosState.OpenSystemArbosState(p.evm.StateDB, tracingInfo, false)
if err != nil {
return common.Hash{}, err
Expand All @@ -643,7 +643,7 @@ func (p *TxProcessor) GetPaidGasPrice() *big.Int {
version := p.state.ArbOSVersion()
if version != 9 {
gasPrice = p.evm.Context.BaseFee
if p.msg.RunMode() != types.MessageCommitMode && p.msg.GasFeeCap().Sign() == 0 {
if p.msg.TxRunMode != core.MessageCommitMode && p.msg.GasFeeCap.Sign() == 0 {
gasPrice.SetInt64(0) // gasprice zero behavior
}
}
Expand All @@ -665,6 +665,6 @@ func (p *TxProcessor) MsgIsNonMutating() bool {
if p.msg == nil {
return false
}
mode := p.msg.RunMode()
return mode == types.MessageGasEstimationMode || mode == types.MessageEthcallMode
mode := p.msg.TxRunMode
return mode == core.MessageGasEstimationMode || mode == core.MessageEthcallMode
}
2 changes: 1 addition & 1 deletion gethhook/geth-hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (p ArbosPrecompileWrapper) RunAdvanced(
}

func init() {
core.ReadyEVMForL2 = func(evm *vm.EVM, msg core.Message) {
core.ReadyEVMForL2 = func(evm *vm.EVM, msg *core.Message) {
if evm.ChainConfig().IsArbitrum() {
evm.ProcessingHook = arbos.NewTxProcessor(evm, msg)
}
Expand Down
2 changes: 1 addition & 1 deletion go-ethereum
Submodule go-ethereum updated 59 files
+24 −24 .travis.yml
+17 −24 accounts/abi/bind/backends/simulated.go
+2 −2 arbitrum/apibackend.go
+1 −0 arbitrum/config.go
+3 −3 cmd/evm/internal/t8ntool/execution.go
+70 −64 cmd/evm/testdata/10/readme.md
+24 −21 cmd/evm/testdata/12/readme.md
+14 −10 cmd/evm/testdata/14/readme.md
+16 −0 cmd/evm/testdata/19/readme.md
+369 −1 cmd/evm/testdata/7/readme.md
+17 −21 cmd/evm/testdata/8/readme.md
+31 −27 cmd/evm/testdata/9/readme.md
+37 −0 cmd/evm/testdata/9/txs_signed.json
+3 −25 cmd/geth/dbcmd.go
+0 −53 common/math/modexp_test.go
+5 −5 core/arbitrum_hooks.go
+5 −0 core/chain_makers.go
+3 −3 core/evm.go
+1 −1 core/forkid/forkid_test.go
+56 −2 core/rawdb/database.go
+2 −2 core/state_prefetcher.go
+3 −3 core/state_processor.go
+167 −139 core/state_transition.go
+36 −9 core/txpool/list.go
+74 −8 core/txpool/txpool.go
+212 −0 core/txpool/txpool2_test.go
+19 −8 core/txpool/txpool_test.go
+0 −84 core/types/transaction.go
+3 −4 core/vm/contracts.go
+1 −1 core/vm/gas_table.go
+2 −2 eth/api_backend.go
+1 −1 eth/backend_arbitrum.go
+2 −2 eth/state_accessor.go
+13 −13 eth/tracers/api.go
+2 −2 eth/tracers/api_test.go
+3 −3 eth/tracers/internal/tracetest/calltrace_test.go
+1 −1 eth/tracers/internal/tracetest/flat_calltrace_test.go
+1 −1 eth/tracers/internal/tracetest/prestate_test.go
+1 −1 eth/tracers/tracers_test.go
+1 −2 go.mod
+0 −2 go.sum
+3 −2 graphql/graphql.go
+9 −9 internal/ethapi/api.go
+1 −1 internal/ethapi/backend.go
+16 −6 internal/ethapi/transaction_args.go
+1 −1 internal/ethapi/transaction_args_test.go
+2 −2 les/api_backend.go
+22 −8 les/odr_test.go
+2 −2 les/state_accessor.go
+11 −7 light/odr_test.go
+0 −2 oss-fuzz.sh
+1 −1 p2p/server.go
+4 −8 params/bootnodes.go
+1 −1 params/version.go
+20 −102 signer/core/apitypes/types.go
+20 −20 signer/core/apitypes/types_test.go
+0 −90 tests/fuzzers/modexp/modexp-fuzzer.go
+4 −4 tests/state_test.go
+13 −3 tests/state_test_util.go
30 changes: 15 additions & 15 deletions nodeInterface/NodeInterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ type NodeInterface struct {
backend core.NodeInterfaceBackendAPI
context context.Context
header *types.Header
sourceMessage types.Message
sourceMessage *core.Message
returnMessage struct {
message *types.Message
message *core.Message
changed *bool
}
}
Expand Down Expand Up @@ -143,8 +143,8 @@ func (n NodeInterface) EstimateRetryableTicket(
From: util.RemapL1Address(sender),
L1BaseFee: l1BaseFee,
DepositValue: deposit,
GasFeeCap: n.sourceMessage.GasPrice(),
Gas: n.sourceMessage.Gas(),
GasFeeCap: n.sourceMessage.GasPrice,
Gas: n.sourceMessage.GasLimit,
RetryTo: pRetryTo,
RetryValue: l2CallValue,
Beneficiary: callValueRefundAddress,
Expand All @@ -154,13 +154,13 @@ func (n NodeInterface) EstimateRetryableTicket(
}

// ArbitrumSubmitRetryableTx is unsigned so the following won't panic
msg, err := types.NewTx(submitTx).AsMessage(types.NewArbitrumSigner(nil), nil)
msg, err := core.TransactionToMessage(types.NewTx(submitTx), types.NewArbitrumSigner(nil), nil)
if err != nil {
return err
}

msg.TxRunMode = types.MessageGasEstimationMode
*n.returnMessage.message = msg
msg.TxRunMode = core.MessageGasEstimationMode
*n.returnMessage.message = *msg
*n.returnMessage.changed = true
return nil
}
Expand Down Expand Up @@ -425,11 +425,11 @@ func (n NodeInterface) messageArgs(
evm mech, value huge, to addr, contractCreation bool, data []byte,
) arbitrum.TransactionArgs {
msg := n.sourceMessage
from := msg.From()
gas := msg.Gas()
nonce := msg.Nonce()
maxFeePerGas := msg.GasFeeCap()
maxPriorityFeePerGas := msg.GasTipCap()
from := msg.From
gas := msg.GasLimit
nonce := msg.Nonce
maxFeePerGas := msg.GasFeeCap
maxPriorityFeePerGas := msg.GasTipCap
chainid := evm.ChainConfig().ChainID

args := arbitrum.TransactionArgs{
Expand Down Expand Up @@ -458,7 +458,7 @@ func (n NodeInterface) GasEstimateL1Component(
args.Gas = (*hexutil.Uint64)(&randomGas)

// We set the run mode to eth_call mode here because we want an exact estimate, not a padded estimate
msg, err := args.ToMessage(randomGas, n.header, evm.StateDB.(*state.StateDB), types.MessageEthcallMode)
msg, err := args.ToMessage(randomGas, n.header, evm.StateDB.(*state.StateDB), core.MessageEthcallMode)
if err != nil {
return 0, nil, nil, err
}
Expand Down Expand Up @@ -510,7 +510,7 @@ func (n NodeInterface) GasEstimateComponents(
// Setting the gas currently doesn't affect the PosterDataCost,
// but we do it anyways for accuracy with potential future changes.
args.Gas = &totalRaw
msg, err := args.ToMessage(gasCap, n.header, evm.StateDB.(*state.StateDB), types.MessageGasEstimationMode)
msg, err := args.ToMessage(gasCap, n.header, evm.StateDB.(*state.StateDB), core.MessageGasEstimationMode)
if err != nil {
return 0, 0, nil, nil, err
}
Expand All @@ -526,7 +526,7 @@ func (n NodeInterface) GasEstimateComponents(
}

// Compute the fee paid for L1 in L2 terms
gasForL1 := arbos.GetPosterGas(c.State, baseFee, types.MessageGasEstimationMode, feeForL1)
gasForL1 := arbos.GetPosterGas(c.State, baseFee, core.MessageGasEstimationMode, feeForL1)

return total, gasForL1, baseFee, l1BaseFeeEstimate, nil
}
Expand Down
4 changes: 2 additions & 2 deletions nodeInterface/NodeInterfaceDebug.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ type NodeInterfaceDebug struct {
backend core.NodeInterfaceBackendAPI
context context.Context
header *types.Header
sourceMessage types.Message
sourceMessage *core.Message
returnMessage struct {
message *types.Message
message *core.Message
changed *bool
}
}
Expand Down
Loading