mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/state, core/vm: rename field
This commit is contained in:
parent
a8711c035d
commit
8c62b0e500
9 changed files with 64 additions and 64 deletions
|
|
@ -34,7 +34,7 @@ type DumpAccount struct {
|
|||
Root string `json:"root"`
|
||||
CodeHash string `json:"codeHash"`
|
||||
Code string `json:"code,omitempty"`
|
||||
CodeVersion uint64 `json:"codeVersion"`
|
||||
Version uint64 `json:"version"`
|
||||
Storage map[common.Hash]string `json:"storage,omitempty"`
|
||||
Address *common.Address `json:"address,omitempty"` // Address only present in iterative (line-by-line) mode
|
||||
SecureKey hexutil.Bytes `json:"key,omitempty"` // If we don't have address, we can output the key
|
||||
|
|
@ -71,7 +71,7 @@ func (self iterativeDump) onAccount(addr common.Address, account DumpAccount) {
|
|||
Root: account.Root,
|
||||
CodeHash: account.CodeHash,
|
||||
Code: account.Code,
|
||||
CodeVersion: account.CodeVersion,
|
||||
Version: account.Version,
|
||||
Storage: account.Storage,
|
||||
SecureKey: account.SecureKey,
|
||||
Address: nil,
|
||||
|
|
@ -104,7 +104,7 @@ func (self *StateDB) dump(c collector, excludeCode, excludeStorage, excludeMissi
|
|||
Nonce: data.Nonce,
|
||||
Root: common.Bytes2Hex(data.Root[:]),
|
||||
CodeHash: common.Bytes2Hex(data.CodeHash),
|
||||
CodeVersion: data.CodeVersion,
|
||||
Version: data.Version,
|
||||
}
|
||||
if emptyAddress == addr {
|
||||
// Preimage missing
|
||||
|
|
|
|||
|
|
@ -113,12 +113,12 @@ type Account struct {
|
|||
Balance *big.Int // The balance of account.
|
||||
Root common.Hash // Merkle root of the storage trie.
|
||||
CodeHash []byte // The code hash of account.
|
||||
CodeVersion uint64 // The version of account code.
|
||||
Version uint64 // The version of account as well as the version of code.
|
||||
}
|
||||
|
||||
// EncodeRLP implements rlp.Encoder.
|
||||
func (a *Account) EncodeRLP(w io.Writer) error {
|
||||
if a.CodeVersion == 0 {
|
||||
if a.Version == 0 {
|
||||
return rlp.Encode(w, legacyStoredAccount{a.Nonce, a.Balance, a.Root, a.CodeHash})
|
||||
}
|
||||
return rlp.Encode(w, storedAccount(*a))
|
||||
|
|
@ -421,7 +421,7 @@ func (s *stateObject) SetCode(codeHash common.Hash, code []byte, version uint64)
|
|||
account: &s.address,
|
||||
prevhash: s.CodeHash(),
|
||||
prevcode: prevcode,
|
||||
version: s.data.CodeVersion,
|
||||
version: s.data.Version,
|
||||
})
|
||||
s.setCode(codeHash, code, version)
|
||||
}
|
||||
|
|
@ -429,7 +429,7 @@ func (s *stateObject) SetCode(codeHash common.Hash, code []byte, version uint64)
|
|||
func (s *stateObject) setCode(codeHash common.Hash, code []byte, version uint64) {
|
||||
s.code = code
|
||||
s.data.CodeHash = codeHash[:]
|
||||
s.data.CodeVersion = version
|
||||
s.data.Version = version
|
||||
s.dirtyCode = true
|
||||
}
|
||||
|
||||
|
|
@ -458,7 +458,7 @@ func (s *stateObject) Nonce() uint64 {
|
|||
}
|
||||
|
||||
func (s *stateObject) CodeVersion() uint64 {
|
||||
return s.data.CodeVersion
|
||||
return s.data.Version
|
||||
}
|
||||
|
||||
// Never called, but must be present to allow stateObject to be used
|
||||
|
|
|
|||
|
|
@ -61,14 +61,14 @@ func (s *StateSuite) TestDump(c *checker.C) {
|
|||
"nonce": 0,
|
||||
"root": "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
|
||||
"codeHash": "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
|
||||
"codeVersion": 0
|
||||
"version": 0
|
||||
},
|
||||
"0x0000000000000000000000000000000000000002": {
|
||||
"balance": "44",
|
||||
"nonce": 0,
|
||||
"root": "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
|
||||
"codeHash": "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
|
||||
"codeVersion": 0
|
||||
"version": 0
|
||||
},
|
||||
"0x0000000000000000000000000000000000000102": {
|
||||
"balance": "0",
|
||||
|
|
@ -76,7 +76,7 @@ func (s *StateSuite) TestDump(c *checker.C) {
|
|||
"root": "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
|
||||
"codeHash": "87874902497a5bb968da31a2998d8f22e949d1ef6214bcdedd8bae24cca4b9e3",
|
||||
"code": "03030303030303",
|
||||
"codeVersion": 0
|
||||
"version": 0
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ func (self *StateDB) GetCodeHash(addr common.Address) common.Hash {
|
|||
return common.BytesToHash(stateObject.CodeHash())
|
||||
}
|
||||
|
||||
func (self *StateDB) GetCodeVersion(addr common.Address) uint64 {
|
||||
func (self *StateDB) GetVersion(addr common.Address) uint64 {
|
||||
stateObject := self.getStateObject(addr)
|
||||
if stateObject == nil {
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -464,21 +464,21 @@ func TestStateObjectDecoding(t *testing.T) {
|
|||
Balance: big.NewInt(100),
|
||||
Root: common.HexToHash("deadbeef"),
|
||||
CodeHash: []byte{0x01, 0x02, 0x03},
|
||||
CodeVersion: 0,
|
||||
Version: 0,
|
||||
},
|
||||
{
|
||||
Nonce: 100,
|
||||
Balance: big.NewInt(100),
|
||||
Root: common.HexToHash("deadbeef"),
|
||||
CodeHash: []byte{0x01, 0x02, 0x03},
|
||||
CodeVersion: 1,
|
||||
Version: 1,
|
||||
},
|
||||
{
|
||||
Nonce: 100,
|
||||
Balance: big.NewInt(100),
|
||||
Root: common.HexToHash("deadbeef"),
|
||||
CodeHash: []byte{0x01, 0x02, 0x03},
|
||||
CodeVersion: math.MaxUint64,
|
||||
Version: math.MaxUint64,
|
||||
},
|
||||
}
|
||||
for _, acct := range accounts {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ type Contract struct {
|
|||
CodeAddr *common.Address
|
||||
Input []byte
|
||||
|
||||
CodeVersion uint64
|
||||
Version uint64
|
||||
Gas uint64
|
||||
value *big.Int
|
||||
}
|
||||
|
|
@ -174,7 +174,7 @@ func (c *Contract) SetCallCode(addr *common.Address, hash common.Hash, code []by
|
|||
c.Code = code
|
||||
c.CodeHash = hash
|
||||
c.CodeAddr = addr
|
||||
c.CodeVersion = version
|
||||
c.Version = version
|
||||
}
|
||||
|
||||
// SetCodeOptionalHash can be used to provide code, but it's optional to provide hash.
|
||||
|
|
@ -183,5 +183,5 @@ func (c *Contract) SetCodeOptionalHash(addr *common.Address, codeAndHash *codeAn
|
|||
c.Code = codeAndHash.code
|
||||
c.CodeHash = codeAndHash.hash
|
||||
c.CodeAddr = addr
|
||||
c.CodeVersion = version
|
||||
c.Version = version
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func run(evm *EVM, contract *Contract, input []byte, readOnly bool) ([]byte, err
|
|||
return RunPrecompiledContract(p, input, contract)
|
||||
}
|
||||
}
|
||||
interpreters := evm.interpreters[contract.CodeVersion]
|
||||
interpreters := evm.interpreters[contract.Version]
|
||||
for _, interpreter := range interpreters {
|
||||
if interpreter.CanRun(contract.Code) {
|
||||
if evm.interpreter != interpreter {
|
||||
|
|
@ -239,7 +239,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
|
|||
// Initialise a new contract and set the code that is to be used by the EVM.
|
||||
// The contract is a scoped environment for this execution context only.
|
||||
contract := NewContract(caller, to, value, gas)
|
||||
contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr), evm.StateDB.GetCodeVersion(addr))
|
||||
contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr), evm.StateDB.GetVersion(addr))
|
||||
|
||||
// Even if the account has no code, we need to continue because it might be a precompile
|
||||
start := time.Now()
|
||||
|
|
@ -294,7 +294,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
|
|||
// Initialise a new contract and set the code that is to be used by the EVM.
|
||||
// The contract is a scoped environment for this execution context only.
|
||||
contract := NewContract(caller, to, value, gas)
|
||||
contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr), evm.StateDB.GetCodeVersion(addr))
|
||||
contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr), evm.StateDB.GetVersion(addr))
|
||||
|
||||
ret, err = run(evm, contract, input, false)
|
||||
if err != nil {
|
||||
|
|
@ -327,7 +327,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
|
|||
|
||||
// Initialise a new contract and make initialise the delegate values
|
||||
contract := NewContract(caller, to, nil, gas).AsDelegate()
|
||||
contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr), evm.StateDB.GetCodeVersion(addr))
|
||||
contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr), evm.StateDB.GetVersion(addr))
|
||||
|
||||
ret, err = run(evm, contract, input, false)
|
||||
if err != nil {
|
||||
|
|
@ -359,7 +359,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
|
|||
// Initialise a new contract and set the code that is to be used by the EVM.
|
||||
// The contract is a scoped environment for this execution context only.
|
||||
contract := NewContract(caller, to, new(big.Int), gas)
|
||||
contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr), evm.StateDB.GetCodeVersion(addr))
|
||||
contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr), evm.StateDB.GetVersion(addr))
|
||||
|
||||
// We do an AddBalance of zero here, just in order to trigger a touch.
|
||||
// This doesn't matter on Mainnet, where all empties are gone at the time of Byzantium,
|
||||
|
|
|
|||
|
|
@ -699,7 +699,7 @@ func opCreate(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memor
|
|||
}
|
||||
|
||||
contract.UseGas(gas)
|
||||
res, addr, returnGas, suberr := interpreter.evm.Create(contract, input, gas, value, contract.CodeVersion)
|
||||
res, addr, returnGas, suberr := interpreter.evm.Create(contract, input, gas, value, contract.Version)
|
||||
// Push item on the stack based on the returned error. If the ruleset is
|
||||
// homestead we must check for CodeStoreOutOfGasError (homestead only
|
||||
// rule) and treat as an error, if the ruleset is frontier we must
|
||||
|
|
@ -732,7 +732,7 @@ func opCreate2(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memo
|
|||
// Apply EIP150
|
||||
gas -= gas / 64
|
||||
contract.UseGas(gas)
|
||||
res, addr, returnGas, suberr := interpreter.evm.Create2(contract, input, gas, endowment, salt, contract.CodeVersion)
|
||||
res, addr, returnGas, suberr := interpreter.evm.Create2(contract, input, gas, endowment, salt, contract.Version)
|
||||
// Push item on the stack based on the returned error.
|
||||
if suberr != nil {
|
||||
stack.push(interpreter.intPool.getZero())
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ type StateDB interface {
|
|||
GetCode(common.Address) []byte
|
||||
SetCode(common.Address, []byte, uint64)
|
||||
GetCodeSize(common.Address) int
|
||||
GetCodeVersion(address common.Address) uint64
|
||||
GetVersion(address common.Address) uint64
|
||||
|
||||
AddRefund(uint64)
|
||||
SubRefund(uint64)
|
||||
|
|
|
|||
Loading…
Reference in a new issue