From 371871d685d54b916aef28de689d6f0af7822083 Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Fri, 27 Nov 2015 15:40:29 +0100 Subject: parmas, crypto, core, core/vm: homestead consensus protocol changes * change gas cost for contract creating txs * invalidate signature with s value greater than secp256k1 N / 2 * OOG contract creation if not enough gas to store code * new difficulty adjustment algorithm * new DELEGATECALL op code --- core/state/state_object.go | 12 ++++++++++++ core/state/statedb.go | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) (limited to 'core/state') diff --git a/core/state/state_object.go b/core/state/state_object.go index 47546112f..ebc9f8358 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -211,6 +211,11 @@ func (c *StateObject) Address() common.Address { return c.address } +// Sets the address of the contract/account +func (c *StateObject) SetAddress(addr common.Address) { + c.address = addr +} + func (self *StateObject) Trie() *trie.SecureTrie { return self.trie } @@ -238,6 +243,13 @@ func (self *StateObject) Nonce() uint64 { return self.nonce } +// Never called, but must be present to allow StateObject to be used +// as a vm.Account interface that also satisfies the vm.ContractRef +// interface. Interfaces are awesome. +func (self *StateObject) Value() *big.Int { + return nil +} + func (self *StateObject) EachStorage(cb func(key, value []byte)) { // When iterating over the storage check the cache first for h, v := range self.storage { diff --git a/core/state/statedb.go b/core/state/statedb.go index 22ffa36a0..e1dde84d1 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -87,6 +87,18 @@ func (self *StateDB) GetLogs(hash common.Hash) vm.Logs { return self.logs[hash] } +func (self *StateDB) GetAllLogs() *map[common.Hash]vm.Logs { + copy := make(map[common.Hash]vm.Logs, len(self.logs)) + for k, v := range self.logs { + copy[k] = v + } + return © +} + +func (self *StateDB) SetAllLogs(logs *map[common.Hash]vm.Logs) { + self.logs = *logs +} + func (self *StateDB) Logs() vm.Logs { var logs vm.Logs for _, lgs := range self.logs { @@ -95,6 +107,11 @@ func (self *StateDB) Logs() vm.Logs { return logs } +// TODO: this may not be the most proper thing +func (self *StateDB) GetDB() ethdb.Database { + return self.db +} + func (self *StateDB) AddRefund(gas *big.Int) { self.refund.Add(self.refund, gas) } -- cgit v1.2.3 From b6d88a0e9f9aaeb47d585d79c768d457b545af90 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 19 Jan 2016 23:50:00 +0100 Subject: core, core/vm, crypto: fixes for homestead * Removed some strange code that didn't apply state reverting properly * Refactored code setting from vm & state transition to the executioner * Updated tests --- core/state/dump.go | 3 ++- core/state/state_object.go | 7 +------ core/state/statedb.go | 17 ----------------- 3 files changed, 3 insertions(+), 24 deletions(-) (limited to 'core/state') diff --git a/core/state/dump.go b/core/state/dump.go index cff9c50aa..8eb03e8e4 100644 --- a/core/state/dump.go +++ b/core/state/dump.go @@ -28,6 +28,7 @@ type Account struct { Nonce uint64 `json:"nonce"` Root string `json:"root"` CodeHash string `json:"codeHash"` + Code string `json:"code"` Storage map[string]string `json:"storage"` } @@ -47,7 +48,7 @@ func (self *StateDB) RawDump() World { addr := self.trie.GetKey(it.Key) stateObject, _ := DecodeObject(common.BytesToAddress(addr), self.db, it.Value) - account := Account{Balance: stateObject.balance.String(), Nonce: stateObject.nonce, Root: common.Bytes2Hex(stateObject.Root()), CodeHash: common.Bytes2Hex(stateObject.codeHash)} + account := Account{Balance: stateObject.balance.String(), Nonce: stateObject.nonce, Root: common.Bytes2Hex(stateObject.Root()), CodeHash: common.Bytes2Hex(stateObject.codeHash), Code: common.Bytes2Hex(stateObject.Code())} account.Storage = make(map[string]string) storageIt := stateObject.trie.Iterator() diff --git a/core/state/state_object.go b/core/state/state_object.go index ebc9f8358..6095fc96a 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -211,11 +211,6 @@ func (c *StateObject) Address() common.Address { return c.address } -// Sets the address of the contract/account -func (c *StateObject) SetAddress(addr common.Address) { - c.address = addr -} - func (self *StateObject) Trie() *trie.SecureTrie { return self.trie } @@ -247,7 +242,7 @@ func (self *StateObject) Nonce() uint64 { // as a vm.Account interface that also satisfies the vm.ContractRef // interface. Interfaces are awesome. func (self *StateObject) Value() *big.Int { - return nil + panic("Value on StateObject should never be called") } func (self *StateObject) EachStorage(cb func(key, value []byte)) { diff --git a/core/state/statedb.go b/core/state/statedb.go index e1dde84d1..22ffa36a0 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -87,18 +87,6 @@ func (self *StateDB) GetLogs(hash common.Hash) vm.Logs { return self.logs[hash] } -func (self *StateDB) GetAllLogs() *map[common.Hash]vm.Logs { - copy := make(map[common.Hash]vm.Logs, len(self.logs)) - for k, v := range self.logs { - copy[k] = v - } - return © -} - -func (self *StateDB) SetAllLogs(logs *map[common.Hash]vm.Logs) { - self.logs = *logs -} - func (self *StateDB) Logs() vm.Logs { var logs vm.Logs for _, lgs := range self.logs { @@ -107,11 +95,6 @@ func (self *StateDB) Logs() vm.Logs { return logs } -// TODO: this may not be the most proper thing -func (self *StateDB) GetDB() ethdb.Database { - return self.db -} - func (self *StateDB) AddRefund(gas *big.Int) { self.refund.Add(self.refund, gas) } -- cgit v1.2.3