Commit 8a645640 authored by George Hotz's avatar George Hotz

block is processing now

parent e95b08cf
D6 uWÿo{>,?XW'&HG,9)s8
:PhZK
\ No newline at end of file
D5Ziwc'<)\ -
 4^ ZgeM"5eʁ
\ No newline at end of file
Dm,'@pKqZJ~%sq_O㠒Ez4Ol 5Cdg>GFt
\ No newline at end of file
D.rmG3ERx5EAi!;jVU!Ba:(M:t
\ No newline at end of file
Dᗡ:fH IߴTö.
2zW>֩l^8=Ν zS͔
\ No newline at end of file
D 2{F;蕁SJu0s^PFaԜ) DH+41V%y#k]„Cz
\ No newline at end of file
DNs=lU˻I w #G %T;VrEEk]E{nd
\ No newline at end of file
Dz`QU;$]69 ؙ e/Cנii,uFsm}:7dy̍
\ No newline at end of file
D<SO Q3r"QA+Q%A`oȜe^xp `r
\ No newline at end of file
M 3{dr *[i
rVJDH;yEMUm
ܭݩu?3 >V ?@Q"
\ No newline at end of file
D\VDد ٶY:7ET] ucu&fgOs~B5dw
\ No newline at end of file
D_ p+
X4)`A,96=fu&EtGqS65kB7eS
\ No newline at end of file
DRFeʢYF_ WrE; g޺oۥf]W^%@<Ƙo|nh
\ No newline at end of file
K#ez̳]*̸ךC=jv=RQ#]ҠT'Q_/߰tR:*<5J`gи/3
\ No newline at end of file
DLy; ,*%3Jؖ7*r:$^VUCp.]Em+.'
\ No newline at end of file
D-uF!JiFxV0YQˠzMO:MÜ'|’Ŧf{
\ No newline at end of file
D-&j{J0Q^ b'{ʏ+RȰM`:)#܀U߄Ysv8'/P\
\ No newline at end of file
DS=z&'w~PrQ]@^+,]_Ć; HShNQw
\ No newline at end of file
MzdLjsp<X>C ɹMMiY|8Sb7O03,3h5.
\ No newline at end of file
D@nҽR2ɶ3;@^W5vleN-!XܒڒF[u9
\ No newline at end of file
Lt i03B.tdžxlC>u:23-WGxop'k D5c
\ No newline at end of file
D<&|VJlqzfP9B2'~?b?<pr3ZZ09 )U;^
\ No newline at end of file
D@Ofz-kD<ET[KFKut,6RV_9QND<$m_8g
\ No newline at end of file
DW]zs^x](9Ozr„-,q|෣hxCQ'
dVNy$3nMU
\ No newline at end of file
D7}nn_m5Suj:`)ˆI>gB_J/1@6jZ
\ No newline at end of file
DZIGfl7f~u+ ) -Z7Ylί?Ntsl
\ No newline at end of file
D!fy4jdDcI~3y,z.1dG*7;Oil2
\ No newline at end of file
D4C6T+^z+u;E/PRנhWb#odμpiJ=.$z
\ No newline at end of file
MY?AWbpMvaJݳy)j3ÂM8 C؀XPJs{
\ No newline at end of file
DC ]6,-WκlsKC4ݏ iHƠĄBTJY KS:DEg}y/
\ No newline at end of file
D0labY!>9,~w_ RF@SNE} ()~cNY8 ٣*
\ No newline at end of file
D0an")˭VtӓiZ78eg!?Qphj1Lib
NrϠ.
\ No newline at end of file
D;ڟZt;$vULa)EDv/{~|ךR5s:kF
\ No newline at end of file
D<\>@ onDkSqb#
Quʼn)blSwFsi2:
\ No newline at end of file
DVUEn[Hlb/c!$}Б&䊜p9;<_}DZǡTL
\ No newline at end of file
Dzʤޘ<yII,c4ZtoB,+aVy|1:q9 Decgd
\ No newline at end of file
DTb mE9(3WSMP|&rg{m!xETV
\ No newline at end of file
D;VFӝ1B\VؚqzX
=U'Lh/e u;IJw
\ No newline at end of file
DJj0"Iomh4ZDjS]DWʠtLR93Nmh=p)au
\ No newline at end of file
D"8*l
?NM NrnuYil?
kW w* E&\
\ No newline at end of file
Dd 2sJ5TܢaJ}i K| ֤>kR4k%3\7
\ No newline at end of file
D} G1 ֍<FköQ?Πhͥ|zցbx>jj
\ No newline at end of file
O`1Iw }<Sn ,%]>:zJf_РkG;\{\-aUp3l}ND)˲^#
\ No newline at end of file
D$9YF[cVle9WhouќN3kP)J _&ͽ'N^ws$`<
\ No newline at end of file
DJ!I:@nIWV?~W!pj
HytMh2\"
\ No newline at end of file
DVUEn[Hlb/c!X4'y sVJG~/
\ No newline at end of file
Do!o99]f%#8=/^lW[?w 3
\ No newline at end of file
Dx"v<<VMri78 s4R~T[Uk8De=Ň
\ No newline at end of file
D*P`xܝ ]&EC=rg VVQ%;5pC-u|ز^%
\ No newline at end of file
D%Vd
-f B1EkeǛ7KLyXT-ܱy'bA+B$Cf
\ No newline at end of file
L=f۠f@a&f~R!Zvf> y݂۸q3>qTDo[KkN
\ No newline at end of file
D%5RoV4ySDGbp۔Z^Gv@
'+2@(D+o"0KVα3
\ No newline at end of file
DVUEn[Hlb/c! e_TH¥:yr4>.7
\ No newline at end of file
Gꀠ~~aއ"8a>#|ځ(BL/9H4H+dP<{8؀p
\ No newline at end of file
G8.P/w EWLh^ے>'huKWwHLև)!ǧP
\ No newline at end of file
D홷xe&n?6凥b<F"Lƅ/ׅٚ" G.Nn
\ No newline at end of file
Db:7" d՚7aJÀ{
GTJiJrRݚϘp WՁqWӳ[aK
\ No newline at end of file
DVT$jE*ETfzvoK&^5j]tVib n%k\o
\ No newline at end of file
DYvN\# GL-|%䨨Vqdi4EYk*Nn F*wM6ah_0u
\ No newline at end of file
DR֞lM,).d ]޶zt04)Y 8uk;;'oC
\ No newline at end of file
DyZȤd8same!4=}LwvG6O&'I$W|\
\ No newline at end of file
DVUEn[Hlb/c!,beUz-<bF%mA,;#
\ No newline at end of file
DӢhR<7*rmg{9"aS7OId(:*Woླݧ*U
\ No newline at end of file
DlIgg-
+m2B<}F@eBvYtȣ=hN|!c.d0
\ No newline at end of file
L:GQ\ml>p^:$WG&+3" \ \l<^}np]LDT
\ No newline at end of file
D欅B>OmMID=v$Q-1/86I$kPkdoAH
\ No newline at end of file
Du=0"Ccyq]Iς̠@=e y|ıu]="^T
\ No newline at end of file
D&2 fPI='V-`9ھL틸m )#o>o~G¸
\ No newline at end of file
D5C;ܜ,q֓S Կ@=e y|ıu]="^T
\ No newline at end of file
package state
import "github.com/ethereum/go-ethereum/common"
// TODO: add oracle calls here
// wrapper for the oracle
type Database struct {
}
// ContractCode retrieves a particular contract's code.
func (db *Database) ContractCode(addrHash, codeHash common.Hash) ([]byte, error) {
return nil, nil
}
// ContractCodeSize retrieves a particular contracts code's size.
func (db *Database) ContractCodeSize(addrHash, codeHash common.Hash) (int, error) {
return 0, nil
}
......@@ -27,8 +27,6 @@ import (
"github.com/ethereum/go-ethereum/rlp"
)
var emptyRoot = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
var emptyCodeHash = crypto.Keccak256(nil)
type Code []byte
......@@ -265,3 +263,36 @@ func (s *stateObject) Nonce() uint64 {
func (s *stateObject) Value() *big.Int {
panic("Value on stateObject should never be called")
}
// Code returns the contract code associated with this object, if any.
func (s *stateObject) Code(db Database) []byte {
if s.code != nil {
return s.code
}
if bytes.Equal(s.CodeHash(), emptyCodeHash) {
return nil
}
code, err := db.ContractCode(s.addrHash, common.BytesToHash(s.CodeHash()))
if err != nil {
s.setError(fmt.Errorf("can't load code hash %x: %v", s.CodeHash(), err))
}
s.code = code
return code
}
// CodeSize returns the size of the contract code associated with this object,
// or zero if none. This method is an almost mirror of Code, but uses a cache
// inside the database to avoid loading codes seen recently.
func (s *stateObject) CodeSize(db Database) int {
if s.code != nil {
return len(s.code)
}
if bytes.Equal(s.CodeHash(), emptyCodeHash) {
return 0
}
size, err := db.ContractCodeSize(s.addrHash, common.BytesToHash(s.CodeHash()))
if err != nil {
s.setError(fmt.Errorf("can't load code size %x: %v", s.CodeHash(), err))
}
return size
}
......@@ -11,7 +11,14 @@ import (
"github.com/ethereum/go-ethereum/rlp"
)
var (
// emptyRoot is the known root hash of an empty trie.
emptyRoot = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
)
type StateDB struct {
db Database
blockNumber *big.Int
stateRoot common.Hash
......@@ -20,6 +27,15 @@ type StateDB struct {
// Per-transaction access list
accessList *accessList
logs map[common.Hash][]*types.Log
logSize uint
thash common.Hash
txIndex int
// The refund counter, also used by state transitioning.
refund uint64
}
func NewStateDB(header types.Header) *StateDB {
......@@ -30,6 +46,88 @@ func NewStateDB(header types.Header) *StateDB {
}
}
func (s *StateDB) AddLog(log *types.Log) {
log.TxHash = s.thash
log.TxIndex = uint(s.txIndex)
log.Index = s.logSize
s.logs[s.thash] = append(s.logs[s.thash], log)
s.logSize++
}
// AddRefund adds gas to the refund counter
func (s *StateDB) AddRefund(gas uint64) {
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) {
if gas > s.refund {
panic(fmt.Sprintf("Refund counter below zero (gas: %d > refund: %d)", gas, s.refund))
}
s.refund -= gas
}
// Exist reports whether the given account address exists in the state.
// Notably this also returns true for suicided accounts.
func (s *StateDB) Exist(addr common.Address) bool {
return s.getStateObject(addr) != nil
}
// Empty returns whether the state object is either non-existent
// or empty according to the EIP161 specification (balance = nonce = code = 0)
func (s *StateDB) Empty(addr common.Address) bool {
so := s.getStateObject(addr)
return so == nil || so.empty()
}
// GetBalance retrieves the balance from the given address or 0 if object not found
func (s *StateDB) GetBalance(addr common.Address) *big.Int {
stateObject := s.getStateObject(addr)
if stateObject != nil {
return stateObject.Balance()
}
return common.Big0
}
func (s *StateDB) GetNonce(addr common.Address) uint64 {
stateObject := s.getStateObject(addr)
if stateObject != nil {
return stateObject.Nonce()
}
return 0
}
// TxIndex returns the current transaction index set by Prepare.
func (s *StateDB) TxIndex() int {
return s.txIndex
}
func (s *StateDB) GetCode(addr common.Address) []byte {
stateObject := s.getStateObject(addr)
if stateObject != nil {
return stateObject.Code(s.db)
}
return nil
}
func (s *StateDB) GetCodeSize(addr common.Address) int {
stateObject := s.getStateObject(addr)
if stateObject != nil {
return stateObject.CodeSize(s.db)
}
return 0
}
func (s *StateDB) GetCodeHash(addr common.Address) common.Hash {
stateObject := s.getStateObject(addr)
if stateObject == nil {
return common.Hash{}
}
return common.BytesToHash(stateObject.CodeHash())
}
// AddAddressToAccessList adds the given address to the access list
func (s *StateDB) AddAddressToAccessList(addr common.Address) {
}
......@@ -44,10 +142,6 @@ func (s *StateDB) SubBalance(addr common.Address, amount *big.Int) {
fmt.Println("SubBalance", addr, amount)
}
func (s *StateDB) AddLog(log *types.Log) {
fmt.Println("AddLog", log)
}
// IntermediateRoot computes the current root hash of the state trie.
// It is called in between transactions to get the root hash that
// goes into transaction receipts.
......@@ -69,17 +163,6 @@ func (s *StateDB) AddPreimage(hash common.Hash, preimage []byte) {
fmt.Println("AddPreimage", hash)
}
// AddRefund adds gas to the refund counter
func (s *StateDB) AddRefund(gas uint64) {
fmt.Println("AddRefund", 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) {
fmt.Println("SubRefund", gas)
}
// AddSlotToAccessList adds the given (address, slot)-tuple to the access list
func (s *StateDB) AddSlotToAccessList(addr common.Address, slot common.Hash) {
s.accessList.AddSlot(addr, slot)
......@@ -103,49 +186,10 @@ func (s *StateDB) CreateAccount(addr common.Address) {
func (s *StateDB) Finalise(deleteEmptyObjects bool) {
}
// TxIndex returns the current transaction index set by Prepare.
func (s *StateDB) TxIndex() int {
return 0
}
// Exist reports whether the given account address exists in the state.
// Notably this also returns true for suicided accounts.
func (s *StateDB) Exist(addr common.Address) bool {
return s.getStateObject(addr) != nil
}
// Empty returns whether the state object is either non-existent
// or empty according to the EIP161 specification (balance = nonce = code = 0)
func (s *StateDB) Empty(addr common.Address) bool {
so := s.getStateObject(addr)
return so == nil || so.empty()
}
func (db *StateDB) ForEachStorage(addr common.Address, cb func(key, value common.Hash) bool) error {
return nil
}
// GetBalance retrieves the balance from the given address or 0 if object not found
func (s *StateDB) GetBalance(addr common.Address) *big.Int {
fmt.Println("GetBalance", addr)
return big.NewInt(1e18)
}
func (s *StateDB) GetCode(addr common.Address) []byte {
fmt.Println("GetCode", addr)
return nil
}
func (s *StateDB) GetCodeSize(addr common.Address) int {
fmt.Println("GetCodeSize", addr)
return 0
}
func (s *StateDB) GetCodeHash(addr common.Address) common.Hash {
fmt.Println("GetCodeHash", addr)
return common.HexToHash("0x0")
}
// GetCommittedState retrieves a value from the given account's committed storage trie.
func (s *StateDB) GetCommittedState(addr common.Address, hash common.Hash) common.Hash {
fmt.Println("GetCommittedState", addr, hash)
......@@ -158,18 +202,6 @@ func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash {
return common.Hash{}
}
func (s *StateDB) GetNonce(addr common.Address) uint64 {
fmt.Println("GetNonce", addr)
//return 2122
stateObject := s.getStateObject(addr)
if stateObject != nil {
return stateObject.Nonce()
}
return 0
}
// GetRefund returns the current value of the refund counter.
func (s *StateDB) GetRefund() uint64 {
fmt.Println("GetRefund")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment