Skip to content
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
4 changes: 1 addition & 3 deletions overlay/execution/vm/intrinsic_gas_override.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@ func CalcCustomIntrinsicGas(
data []byte,
accessListLen, storageKeysLen uint64,
isContractCreation bool,
isEIP2, isEIP2028, isEIP3860, isEIP7623, isAATxn bool,
isEIP2, isEIP2028, isEIP3860, isEIP7623 bool,
authorizationsLen uint64,
) (gas uint64, floorGas7623 uint64) {
// Set the starting gas for the raw transaction
if isContractCreation && isEIP2 {
gas = schedule.GetOr(GasKeyTxCreateBase, params.TxGasContractCreation)
} else if isAATxn {
gas = params.TxAAGas // AA base cost not overridable (niche, can add later)
} else {
gas = schedule.GetOr(GasKeyTxBase, params.TxGas)
}
Expand Down
14 changes: 13 additions & 1 deletion overlay/node/xatu/datasource_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func (s *Service) DebugTraceTransaction(
}

// Compute tx context
msg, txCtx, err := transactions.ComputeTxContext(statedb, s.engine, chainRules, signer, block, execChainConfig, txIndex)
msg, txCtx, err := computeTxContext(statedb, chainRules, signer, block, txIndex)
if err != nil {
return nil, fmt.Errorf("failed to compute tx context: %w", err)
}
Expand Down Expand Up @@ -433,6 +433,18 @@ func (s *Service) IsSynced() bool {
return s.synced.Load()
}

// computeTxContext does what transactions.ComputeTxContext does. Its signature
// differs between erigon main and the v3.7 and v3.8 releases, which share this file.
func computeTxContext(statedb *erigonstate.IntraBlockState, chainRules *chain.Rules, signer *erigontypes.Signer, block *erigontypes.Block, txIndex int) (protocol.Message, evmtypes.TxContext, error) {
txn := block.Transactions()[txIndex]
statedb.SetTxContext(block.NumberU64(), txIndex)
msg, err := txn.AsMessage(*signer, block.BaseFee(), chainRules)
if err != nil {
return nil, evmtypes.TxContext{}, fmt.Errorf("convert transaction at index %d (%s) to message: %w", txIndex, txn.Hash(), err)
}
return msg, protocol.NewEVMTxContext(msg), nil
}

// executeWithTracer executes a transaction with the given tracer.
func (s *Service) executeWithTracer(
statedb *erigonstate.IntraBlockState,
Expand Down
2 changes: 1 addition & 1 deletion overlay/node/xatu/intrinsic_gas_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func calcIntrinsicGasForTx(txn erigontypes.Transaction, chainRules *chain.Rules,
intrinsicGas, _ = vm.CalcCustomIntrinsicGas(
vmSchedule, txn.GetData(), accessListLen, storageKeysLen,
txn.GetTo() == nil, chainRules.IsHomestead, chainRules.IsIstanbul,
chainRules.IsShanghai, chainRules.IsPrague, false, 0,
chainRules.IsShanghai, chainRules.IsPrague, 0,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion overlay/node/xatu/intrinsic_gas_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func calcIntrinsicGasForTx(txn erigontypes.Transaction, chainRules *chain.Rules,
intrinsicGas, _ = vm.CalcCustomIntrinsicGas(
vmSchedule, txn.GetData(), accessListLen, storageKeysLen,
txn.GetTo() == nil, chainRules.IsHomestead, chainRules.IsIstanbul,
chainRules.IsShanghai, chainRules.IsPrague, false, 0,
chainRules.IsShanghai, chainRules.IsPrague, 0,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion overlay/node/xatu/simulation_rpc_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ func (s *Service) executeSingleTransaction(
}

// Compute tx context
msg, txCtx, err := transactions.ComputeTxContext(statedb, s.engine, chainRules, signer, block, execChainConfig, txIndex)
msg, txCtx, err := computeTxContext(statedb, chainRules, signer, block, txIndex)
if err != nil {
return nil, fmt.Errorf("failed to compute tx context: %w", err)
}
Expand Down
5 changes: 4 additions & 1 deletion overlay/node/xatu/tracer_main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ func (m *mockIntraBlockState) GetState(accounts.Address, accounts.StorageKey) (u
return uint256.Int{}, nil
}
func (m *mockIntraBlockState) Exist(accounts.Address) (bool, error) { return false, nil }
func (m *mockIntraBlockState) GetRefund() uint64 { return m.refund }
func (m *mockIntraBlockState) HasSelfdestructed(accounts.Address) (bool, error) {
return false, nil
}
func (m *mockIntraBlockState) GetRefund() uint64 { return m.refund }

// TestRefundCapture verifies that refund values are captured when OnTxStart
// is called to initialize the tracer with a VMContext.
Expand Down
513 changes: 260 additions & 253 deletions patches/erigontech/erigon/main/base.patch

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions patches/erigontech/erigon/v3.3.10/base.patch
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ index 6ad846b..f7c908c 100644
+ return x - y
+}
diff --git a/execution/protocol/state_transition.go b/execution/protocol/state_transition.go
index ffbfe15..5ecbbba 100644
index ffbfe15..c4e5b09 100644
--- a/execution/protocol/state_transition.go
+++ b/execution/protocol/state_transition.go
@@ -504,6 +504,12 @@ func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (result *
Expand All @@ -255,7 +255,7 @@ index ffbfe15..5ecbbba 100644
+
+ // Xatu: Allow custom intrinsic gas schedule overrides for gas simulation
+ if st.evm.GasSchedule != nil && st.evm.GasSchedule.HasIntrinsicOverrides() {
+ gas, floorGas7623 = vm.CalcCustomIntrinsicGas(st.evm.GasSchedule, st.data, uint64(len(accessTuples)), uint64(accessTuples.StorageKeys()), contractCreation, rules.IsHomestead, rules.IsIstanbul, isEIP3860, rules.IsPrague, false, uint64(len(auths)))
+ gas, floorGas7623 = vm.CalcCustomIntrinsicGas(st.evm.GasSchedule, st.data, uint64(len(accessTuples)), uint64(accessTuples.StorageKeys()), contractCreation, rules.IsHomestead, rules.IsIstanbul, isEIP3860, rules.IsPrague, uint64(len(auths)))
+ overflow = false
+ }
if overflow {
Expand Down
4 changes: 2 additions & 2 deletions patches/erigontech/erigon/v3.7.0/base.patch
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ index 95ca56f..7344d2a 100644
+ return x - y
+}
diff --git a/execution/protocol/txn_executor.go b/execution/protocol/txn_executor.go
index cee4e5d..af82190 100644
index cee4e5d..32b77b9 100644
--- a/execution/protocol/txn_executor.go
+++ b/execution/protocol/txn_executor.go
@@ -612,6 +612,16 @@ func (st *TxnExecutor) Execute(refunds bool, gasBailout bool) (result *evmtypes.
Expand All @@ -258,7 +258,7 @@ index cee4e5d..af82190 100644
+ rules := st.evm.ChainRules()
+ vmConfig := st.evm.Config()
+ isEIP3860 := vmConfig.HasEip3860(rules)
+ gas, floorGas := vm.CalcCustomIntrinsicGas(st.evm.GasSchedule, st.data, uint64(len(accessTuples)), uint64(accessTuples.StorageKeys()), contractCreation, rules.IsHomestead, rules.IsIstanbul, isEIP3860, rules.IsPrague, false, uint64(len(auths)))
+ gas, floorGas := vm.CalcCustomIntrinsicGas(st.evm.GasSchedule, st.data, uint64(len(accessTuples)), uint64(accessTuples.StorageKeys()), contractCreation, rules.IsHomestead, rules.IsIstanbul, isEIP3860, rules.IsPrague, uint64(len(auths)))
+ intrinsicGasResult = mdgas.IntrinsicGasCalcResult{ExecutionGas: gas, FloorGasCost: floorGas}
+ overflow = false
+ }
Expand Down
4 changes: 2 additions & 2 deletions patches/erigontech/erigon/v3.7.1/base.patch
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ index 95ca56f..7344d2a 100644
+ return x - y
+}
diff --git a/execution/protocol/txn_executor.go b/execution/protocol/txn_executor.go
index cee4e5d..af82190 100644
index cee4e5d..32b77b9 100644
--- a/execution/protocol/txn_executor.go
+++ b/execution/protocol/txn_executor.go
@@ -612,6 +612,16 @@ func (st *TxnExecutor) Execute(refunds bool, gasBailout bool) (result *evmtypes.
Expand All @@ -258,7 +258,7 @@ index cee4e5d..af82190 100644
+ rules := st.evm.ChainRules()
+ vmConfig := st.evm.Config()
+ isEIP3860 := vmConfig.HasEip3860(rules)
+ gas, floorGas := vm.CalcCustomIntrinsicGas(st.evm.GasSchedule, st.data, uint64(len(accessTuples)), uint64(accessTuples.StorageKeys()), contractCreation, rules.IsHomestead, rules.IsIstanbul, isEIP3860, rules.IsPrague, false, uint64(len(auths)))
+ gas, floorGas := vm.CalcCustomIntrinsicGas(st.evm.GasSchedule, st.data, uint64(len(accessTuples)), uint64(accessTuples.StorageKeys()), contractCreation, rules.IsHomestead, rules.IsIstanbul, isEIP3860, rules.IsPrague, uint64(len(auths)))
+ intrinsicGasResult = mdgas.IntrinsicGasCalcResult{ExecutionGas: gas, FloorGasCost: floorGas}
+ overflow = false
+ }
Expand Down
4 changes: 2 additions & 2 deletions patches/erigontech/erigon/v3.8.0/base.patch
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ index 95ca56f..7344d2a 100644
+ return x - y
+}
diff --git a/execution/protocol/txn_executor.go b/execution/protocol/txn_executor.go
index e78a83c..6f8929e 100644
index e78a83c..3b99580 100644
--- a/execution/protocol/txn_executor.go
+++ b/execution/protocol/txn_executor.go
@@ -595,6 +595,16 @@ func (st *TxnExecutor) Execute(refunds bool, gasBailout bool) (result *evmtypes.
Expand All @@ -56,7 +56,7 @@ index e78a83c..6f8929e 100644
+ rules := st.evm.ChainRules()
+ vmConfig := st.evm.Config()
+ isEIP3860 := vmConfig.HasEip3860(rules)
+ gas, floorGas := vm.CalcCustomIntrinsicGas(st.evm.GasSchedule, st.data, uint64(len(accessTuples)), uint64(accessTuples.StorageKeys()), contractCreation, rules.IsHomestead, rules.IsIstanbul, isEIP3860, rules.IsPrague, false, uint64(len(auths)))
+ gas, floorGas := vm.CalcCustomIntrinsicGas(st.evm.GasSchedule, st.data, uint64(len(accessTuples)), uint64(accessTuples.StorageKeys()), contractCreation, rules.IsHomestead, rules.IsIstanbul, isEIP3860, rules.IsPrague, uint64(len(auths)))
+ intrinsicGasResult = mdgas.IntrinsicGasCalcResult{ExecutionGas: gas, FloorGasCost: floorGas}
+ overflow = false
+ }
Expand Down
4 changes: 2 additions & 2 deletions patches/erigontech/erigon/v3.8.1/base.patch
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ index 95ca56f..7344d2a 100644
+ return x - y
+}
diff --git a/execution/protocol/txn_executor.go b/execution/protocol/txn_executor.go
index e78a83c..6f8929e 100644
index e78a83c..3b99580 100644
--- a/execution/protocol/txn_executor.go
+++ b/execution/protocol/txn_executor.go
@@ -595,6 +595,16 @@ func (st *TxnExecutor) Execute(refunds bool, gasBailout bool) (result *evmtypes.
Expand All @@ -56,7 +56,7 @@ index e78a83c..6f8929e 100644
+ rules := st.evm.ChainRules()
+ vmConfig := st.evm.Config()
+ isEIP3860 := vmConfig.HasEip3860(rules)
+ gas, floorGas := vm.CalcCustomIntrinsicGas(st.evm.GasSchedule, st.data, uint64(len(accessTuples)), uint64(accessTuples.StorageKeys()), contractCreation, rules.IsHomestead, rules.IsIstanbul, isEIP3860, rules.IsPrague, false, uint64(len(auths)))
+ gas, floorGas := vm.CalcCustomIntrinsicGas(st.evm.GasSchedule, st.data, uint64(len(accessTuples)), uint64(accessTuples.StorageKeys()), contractCreation, rules.IsHomestead, rules.IsIstanbul, isEIP3860, rules.IsPrague, uint64(len(auths)))
+ intrinsicGasResult = mdgas.IntrinsicGasCalcResult{ExecutionGas: gas, FloorGasCost: floorGas}
+ overflow = false
+ }
Expand Down