Skip to content

Commit

Permalink
Remove legacy balance query (ethereum#244)
Browse files Browse the repository at this point in the history
* Add legacy balance query

* remove legacy bals

* remove legacy check

* update balance check
  • Loading branch information
ben-chain authored Mar 3, 2021
1 parent 515ea43 commit ad5f893
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/diffdb"
Expand Down Expand Up @@ -268,21 +267,14 @@ func (s *StateDB) GetBalance(addr common.Address) *big.Int {

func (s *StateDB) GetOVMBalance(addr common.Address) *big.Int {
eth := common.HexToAddress("0x4200000000000000000000000000000000000006")
position1 := big.NewInt(3)
hasher1 := sha3.NewLegacyKeccak256()
hasher1.Write(common.LeftPadBytes(addr.Bytes(), 32))
hasher1.Write(common.LeftPadBytes(position1.Bytes(), 32))
digest1 := hasher1.Sum(nil)
key1 := common.BytesToHash(digest1)
slot1 := s.GetState(eth, key1)
position2 := big.NewInt(5)
hasher2 := sha3.NewLegacyKeccak256()
hasher2.Write(common.LeftPadBytes(addr.Bytes(), 32))
hasher2.Write(common.LeftPadBytes(position2.Bytes(), 32))
digest := hasher2.Sum(nil)
key2 := common.BytesToHash(digest)
slot2 := s.GetState(eth, key2)
return math.BigMax(slot1.Big(), slot2.Big())
position := big.NewInt(5)
hasher := sha3.NewLegacyKeccak256()
hasher.Write(common.LeftPadBytes(addr.Bytes(), 32))
hasher.Write(common.LeftPadBytes(position.Bytes(), 32))
digest := hasher.Sum(nil)
key := common.BytesToHash(digest)
slot := s.GetState(eth, key)
return slot.Big()
}

func (s *StateDB) GetNonce(addr common.Address) uint64 {
Expand Down

0 comments on commit ad5f893

Please sign in to comment.