Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Use value copy instead of pointer copy in stateObject.deepCopy #741

Closed
wants to merge 7 commits into from
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (api) [\#687](https://github.com/cosmos/ethermint/issues/687) Returns error for a transaction with an incorrect nonce.
* (evm) [\#674](https://github.com/cosmos/ethermint/issues/674) Reset all cache after account data has been committed in `EndBlock` to make sure every node state consistent.
* (evm) [\#672](https://github.com/cosmos/ethermint/issues/672) Fix panic of `wrong Block.Header.AppHash` when restart a node with snapshot.
* (evm) [\#740](https://github.com/cosmos/ethermint/issues/740) Use value copy instead of pointer copy in stateObject.deepCopy.

## [v0.4.0] - 2020-12-15

Expand Down
11 changes: 10 additions & 1 deletion x/evm/types/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,16 @@ func (so *stateObject) GetCommittedState(_ ethstate.Database, key ethcmn.Hash) e
func (so *stateObject) ReturnGas(gas *big.Int) {}

func (so *stateObject) deepCopy(db *CommitStateDB) *stateObject {
newStateObj := newStateObject(db, so.account)
newAccount := ethermint.ProtoAccount().(*ethermint.EthAccount)
jsonAccount, err := so.account.MarshalJSON()
if err != nil {
panic(err)
}
err = newAccount.UnmarshalJSON(jsonAccount)
if err != nil {
panic(err)
}
newStateObj := newStateObject(db, newAccount)

newStateObj.code = so.code
newStateObj.dirtyStorage = so.dirtyStorage.Copy()
Expand Down