Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dominant-strategies/go-quai
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b2547c2f6d8812b7dd7041733f7e29466ecb8330
Choose a base ref
..
head repository: dominant-strategies/go-quai
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ab1eb417c349188f69f19a325523b9ded4e25b8e
Choose a head ref
Showing with 21 additions and 6 deletions.
  1. +13 −6 core/state/statedb.go
  2. +6 −0 core/state_transition.go
  3. +2 −0 core/vm/interface.go
19 changes: 13 additions & 6 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
@@ -139,8 +139,8 @@ type StateDB struct {
preimages map[common.Hash][]byte

// Per-transaction access list
accessList *accessList
accessListDebug bool // used for simulating the EVM to create an access list
accessList *accessList
bypassAccessListCheck bool // used for simulating the EVM to create an access list, and allowing ETXs which do not contain an access list
// Journal of state modifications. This is the backbone of
// Snapshot and RevertToSnapshot.
journal *journal
@@ -446,6 +446,13 @@ func (s *StateDB) HasSuicided(addr common.InternalAddress) bool {
* SETTERS
*/

// ConfigureAccessListChecks enables or disables accessList checking
func (s *StateDB) ConfigureAccessListChecks(enable bool) bool {
orig := s.bypassAccessListCheck
s.bypassAccessListCheck = !enable
return orig
}

// AddBalance adds amount to the account associated with addr.
func (s *StateDB) AddBalance(addr common.InternalAddress, amount *big.Int) {
stateObject := s.GetOrNewStateObject(addr)
@@ -936,7 +943,7 @@ func (s *StateDB) Copy() *StateDB {
// However, it doesn't cost us much to copy an empty list, so we do it anyway
// to not blow up if we ever decide copy it in the middle of a transaction
state.accessList = s.accessList.Copy()
state.accessListDebug = s.accessListDebug
state.bypassAccessListCheck = s.bypassAccessListCheck
// If there's a prefetcher running, make an inactive copy of it that can
// only access data but does not actively preload (since the user will not
// know that they need to explicitly terminate an active copy).
@@ -1234,7 +1241,7 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) {
// - Add precompiles to access list
// - Add the contents of the optional tx access list
func (s *StateDB) PrepareAccessList(sender common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList, debug bool) {
s.accessListDebug = debug
s.bypassAccessListCheck = debug
s.AddAddressToAccessList(sender.Bytes20())
if dst != nil {
s.AddAddressToAccessList(dst.Bytes20())
@@ -1278,15 +1285,15 @@ func (s *StateDB) AddSlotToAccessList(addr common.AddressBytes, slot common.Hash

// AddressInAccessList returns true if the given address is in the access list.
func (s *StateDB) AddressInAccessList(addr common.AddressBytes) bool {
if s.accessListDebug {
if s.bypassAccessListCheck {
return true
}
return s.accessList.ContainsAddress(addr)
}

// SlotInAccessList returns true if the given (address, slot)-tuple is in the access list.
func (s *StateDB) SlotInAccessList(addr common.AddressBytes, slot common.Hash) (addressPresent bool, slotPresent bool) {
if s.accessListDebug {
if s.bypassAccessListCheck {
return true, true
}
return s.accessList.Contains(addr, slot)
6 changes: 6 additions & 0 deletions core/state_transition.go
Original file line number Diff line number Diff line change
@@ -304,6 +304,12 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
// 5. there is no overflow when calculating intrinsic gas
// 6. caller has enough balance to cover asset transfer for **topmost** call

// If ETX, bypass accessList enforcement
if st.msg.IsETX() {
orig := st.state.ConfigureAccessListChecks(false)
defer st.state.ConfigureAccessListChecks(orig)
}

// Check clauses 1-3, buy gas if everything is correct
if !st.msg.IsETX() {
if err := st.preCheck(); err != nil {
2 changes: 2 additions & 0 deletions core/vm/interface.go
Original file line number Diff line number Diff line change
@@ -27,6 +27,8 @@ import (
type StateDB interface {
CreateAccount(common.InternalAddress)

ConfigureAccessListChecks(bool) bool

SubBalance(common.InternalAddress, *big.Int)
AddBalance(common.InternalAddress, *big.Int)
GetBalance(common.InternalAddress) *big.Int