Skip to content

Commit

Permalink
core/state: drop Journal-prefix on journal methods
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Aug 21, 2024
1 parent 2a2c432 commit d6ee4d9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
24 changes: 12 additions & 12 deletions core/state/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,30 +148,30 @@ func (j *journal) copy() *journal {
}
}

func (j *journal) JournalAccessListAddAccount(addr common.Address) {
func (j *journal) AccessListAddAccount(addr common.Address) {
j.append(accessListAddAccountChange{&addr})
}

func (j *journal) JournalAccessListAddSlot(addr common.Address, slot common.Hash) {
func (j *journal) AccessListAddSlot(addr common.Address, slot common.Hash) {
j.append(accessListAddSlotChange{
address: &addr,
slot: &slot,
})
}

func (j *journal) JournalLog(txHash common.Hash) {
func (j *journal) Log(txHash common.Hash) {
j.append(addLogChange{txhash: txHash})
}

func (j *journal) JournalCreate(addr common.Address) {
func (j *journal) Create(addr common.Address) {
j.append(createObjectChange{account: &addr})
}

func (j *journal) JournalDestruct(addr common.Address) {
func (j *journal) Destruct(addr common.Address) {
j.append(selfDestructChange{account: &addr})
}

func (j *journal) JournalSetState(addr common.Address, key, prev, origin common.Hash) {
func (j *journal) SetStorage(addr common.Address, key, prev, origin common.Hash) {
j.append(storageChange{
account: &addr,
key: key,
Expand All @@ -180,37 +180,37 @@ func (j *journal) JournalSetState(addr common.Address, key, prev, origin common.
})
}

func (j *journal) JournalSetTransientState(addr common.Address, key, prev common.Hash) {
func (j *journal) SetTransientState(addr common.Address, key, prev common.Hash) {
j.append(transientStorageChange{
account: &addr,
key: key,
prevalue: prev,
})
}

func (j *journal) JournalRefundChange(previous uint64) {
func (j *journal) RefundChange(previous uint64) {
j.append(refundChange{prev: previous})
}

func (j *journal) JournalBalanceChange(addr common.Address, previous *uint256.Int) {
func (j *journal) BalanceChange(addr common.Address, previous *uint256.Int) {
j.append(balanceChange{
account: &addr,
prev: previous.Clone(),
})
}

func (j *journal) JournalSetCode(address common.Address) {
func (j *journal) SetCode(address common.Address) {
j.append(codeChange{account: &address})
}

func (j *journal) JournalNonceChange(address common.Address, prev uint64) {
func (j *journal) NonceChange(address common.Address, prev uint64) {
j.append(nonceChange{
account: &address,
prev: prev,
})
}

func (j *journal) JournalTouch(address common.Address) {
func (j *journal) Touch(address common.Address) {
j.append(touchChange{
account: &address,
})
Expand Down
10 changes: 5 additions & 5 deletions core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (s *stateObject) markSelfdestructed() {
}

func (s *stateObject) touch() {
s.db.journal.JournalTouch(s.address)
s.db.journal.Touch(s.address)
}

// getTrie returns the associated storage trie. The trie will be opened if it's
Expand Down Expand Up @@ -244,7 +244,7 @@ func (s *stateObject) SetState(key, value common.Hash) {
return
}
// New value is different, update and journal the change
s.db.journal.JournalSetState(s.address, key, prev, origin)
s.db.journal.SetStorage(s.address, key, prev, origin)
s.setState(key, value, origin)
if s.db.logger != nil && s.db.logger.OnStorageChange != nil {
s.db.logger.OnStorageChange(s.address, key, prev, value)
Expand Down Expand Up @@ -498,7 +498,7 @@ func (s *stateObject) SubBalance(amount *uint256.Int, reason tracing.BalanceChan
}

func (s *stateObject) SetBalance(amount *uint256.Int, reason tracing.BalanceChangeReason) {
s.db.journal.JournalBalanceChange(s.address, s.data.Balance)
s.db.journal.BalanceChange(s.address, s.data.Balance)
if s.db.logger != nil && s.db.logger.OnBalanceChange != nil {
s.db.logger.OnBalanceChange(s.address, s.Balance().ToBig(), amount.ToBig(), reason)
}
Expand Down Expand Up @@ -574,7 +574,7 @@ func (s *stateObject) CodeSize() int {
}

func (s *stateObject) SetCode(codeHash common.Hash, code []byte) {
s.db.journal.JournalSetCode(s.address)
s.db.journal.SetCode(s.address)
if s.db.logger != nil && s.db.logger.OnCodeChange != nil {
// TODO remove prevcode from this callback
s.db.logger.OnCodeChange(s.address, common.BytesToHash(s.CodeHash()), nil, codeHash, code)
Expand All @@ -589,7 +589,7 @@ func (s *stateObject) setCode(codeHash common.Hash, code []byte) {
}

func (s *stateObject) SetNonce(nonce uint64) {
s.db.journal.JournalNonceChange(s.address, s.data.Nonce)
s.db.journal.NonceChange(s.address, s.data.Nonce)
if s.db.logger != nil && s.db.logger.OnNonceChange != nil {
s.db.logger.OnNonceChange(s.address, s.data.Nonce, nonce)
}
Expand Down
18 changes: 9 additions & 9 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (s *StateDB) Error() error {
}

func (s *StateDB) AddLog(log *types.Log) {
s.journal.JournalLog(s.thash)
s.journal.Log(s.thash)

log.TxHash = s.thash
log.TxIndex = uint(s.txIndex)
Expand Down Expand Up @@ -293,14 +293,14 @@ func (s *StateDB) Preimages() map[common.Hash][]byte {

// AddRefund adds gas to the refund counter
func (s *StateDB) AddRefund(gas uint64) {
s.journal.JournalRefundChange(s.refund)
s.journal.RefundChange(s.refund)
s.refund += gas
}

// SubRefund removes gas from the refund counter.
// This method will panic if the refund counter goes below zero
func (s *StateDB) SubRefund(gas uint64) {
s.journal.JournalRefundChange(s.refund)
s.journal.RefundChange(s.refund)
if gas > s.refund {
panic(fmt.Sprintf("Refund counter below zero (gas: %d > refund: %d)", gas, s.refund))
}
Expand Down Expand Up @@ -508,7 +508,7 @@ func (s *StateDB) SelfDestruct(addr common.Address) {
// If it is already marked as self-destructed, we do not need to add it
// for journalling a second time.
if !stateObject.selfDestructed {
s.journal.JournalDestruct(addr)
s.journal.Destruct(addr)
stateObject.markSelfdestructed()
}
}
Expand All @@ -531,7 +531,7 @@ func (s *StateDB) SetTransientState(addr common.Address, key, value common.Hash)
if prev == value {
return
}
s.journal.JournalSetTransientState(addr, key, prev)
s.journal.SetTransientState(addr, key, prev)
s.setTransientState(addr, key, value)
}

Expand Down Expand Up @@ -650,7 +650,7 @@ func (s *StateDB) getOrNewStateObject(addr common.Address) *stateObject {
// existing account with the given address, otherwise it will be silently overwritten.
func (s *StateDB) createObject(addr common.Address) *stateObject {
obj := newObject(s, addr, nil)
s.journal.JournalCreate(addr)
s.journal.Create(addr)
s.setStateObject(obj)
return obj
}
Expand Down Expand Up @@ -1387,7 +1387,7 @@ func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, d
// AddAddressToAccessList adds the given address to the access list
func (s *StateDB) AddAddressToAccessList(addr common.Address) {
if s.accessList.AddAddress(addr) {
s.journal.JournalAccessListAddAccount(addr)
s.journal.AccessListAddAccount(addr)
}
}

Expand All @@ -1399,10 +1399,10 @@ func (s *StateDB) AddSlotToAccessList(addr common.Address, slot common.Hash) {
// scope of 'address' without having the 'address' become already added
// to the access list (via call-variant, create, etc).
// Better safe than sorry, though
s.journal.JournalAccessListAddAccount(addr)
s.journal.AccessListAddAccount(addr)
}
if slotMod {
s.journal.JournalAccessListAddSlot(addr, slot)
s.journal.AccessListAddSlot(addr, slot)
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/state/statedb_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func newStateTestAction(addr common.Address, r *rand.Rand, index int) testAction
args: make([]int64, 1),
},
{
name: "SetState",
name: "SetStorage",
fn: func(a testAction, s *StateDB) {
var key, val common.Hash
binary.BigEndian.PutUint16(key[:], uint16(a.args[0]))
Expand Down
2 changes: 1 addition & 1 deletion core/state/statedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func newTestAction(addr common.Address, r *rand.Rand) testAction {
args: make([]int64, 1),
},
{
name: "SetState",
name: "SetStorage",
fn: func(a testAction, s *StateDB) {
var key, val common.Hash
binary.BigEndian.PutUint16(key[:], uint16(a.args[0]))
Expand Down

0 comments on commit d6ee4d9

Please sign in to comment.