Commit 9b74f963 authored by George Hotz's avatar George Hotz

start work on oracle

parent bf56566b
...@@ -19,7 +19,7 @@ type Account struct { ...@@ -19,7 +19,7 @@ type Account struct {
} }
// TODO: oracle for // TODO: oracle for
// getProvedAccountBytes(blockNumber, addr) -> rlpAccount // GetProvedAccountBytes(blockNumber, stateRoot, addr) -> rlpAccount
// getProvedCodeBytes(blockNumber, addr, codehash) -> []byte // GetProvedCodeBytes(blockNumber, stateRoot, addr, codehash) -> []byte
// getProvedStorage(blockNumber, addr, root, key) -> uint256 // GetProvedStorage(blockNumber, stateRoot, addr, root, key) -> uint256
// These functions access the backend oracle, and will assert if the proof is bad // These functions access the backend oracle, and will assert if the proof is bad
...@@ -7,10 +7,14 @@ import ( ...@@ -7,10 +7,14 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/oracle"
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
) )
type StateDB struct { type StateDB struct {
blockNumber *big.Int
stateRoot common.Hash
// This map holds 'live' objects, which will get modified while processing a state transition. // This map holds 'live' objects, which will get modified while processing a state transition.
stateObjects map[common.Address]*stateObject stateObjects map[common.Address]*stateObject
...@@ -18,6 +22,10 @@ type StateDB struct { ...@@ -18,6 +22,10 @@ type StateDB struct {
accessList *accessList accessList *accessList
} }
func NewStateDB(header types.Header) *StateDB {
return &StateDB{blockNumber: header.Number, stateRoot: header.Root}
}
// AddAddressToAccessList adds the given address to the access list // AddAddressToAccessList adds the given address to the access list
func (s *StateDB) AddAddressToAccessList(addr common.Address) { func (s *StateDB) AddAddressToAccessList(addr common.Address) {
} }
...@@ -242,7 +250,8 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject { ...@@ -242,7 +250,8 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject {
}*/ }*/
// TODO: call eth_getProof // TODO: call eth_getProof
// In a higher level, write getProvedAccountBytes(addr) // In a higher level, write getProvedAccountBytes(addr)
enc := []byte("12") //enc := []byte("12")
enc := oracle.GetProvedAccountBytes(s.blockNumber, s.stateRoot, addr)
if len(enc) == 0 { if len(enc) == 0 {
return nil return nil
} }
......
...@@ -14,12 +14,6 @@ import ( ...@@ -14,12 +14,6 @@ import (
) )
func main() { func main() {
bc := core.NewBlockChain()
statedb := &state.StateDB{}
vmconfig := vm.Config{}
processor := core.NewStateProcessor(params.MainnetChainConfig, bc, bc.Engine())
fmt.Println("made state processor")
// read header // read header
var header types.Header var header types.Header
{ {
...@@ -29,6 +23,12 @@ func main() { ...@@ -29,6 +23,12 @@ func main() {
rlpheader.Decode(&header) rlpheader.Decode(&header)
} }
bc := core.NewBlockChain()
statedb := state.NewStateDB(header)
vmconfig := vm.Config{}
processor := core.NewStateProcessor(params.MainnetChainConfig, bc, bc.Engine())
fmt.Println("made state processor")
// read txs // read txs
var txs []*types.Transaction var txs []*types.Transaction
{ {
......
package oracle
import (
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
)
func GetProvedAccountBytes(blockNumber *big.Int, stateRoot common.Hash, addr common.Address) []byte {
fmt.Println("ORACLE GetProvedAccountBytes:", blockNumber, stateRoot, addr)
return []byte("12")
}
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