Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
78e78b68
Commit
78e78b68
authored
Sep 21, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first oracle function works
parent
9b74f963
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
2 deletions
+77
-2
statedb.go
minigeth/core/state/statedb.go
+5
-1
oracle.go
minigeth/oracle/oracle.go
+72
-1
No files found.
minigeth/core/state/statedb.go
View file @
78e78b68
...
@@ -23,7 +23,11 @@ type StateDB struct {
...
@@ -23,7 +23,11 @@ type StateDB struct {
}
}
func
NewStateDB
(
header
types
.
Header
)
*
StateDB
{
func
NewStateDB
(
header
types
.
Header
)
*
StateDB
{
return
&
StateDB
{
blockNumber
:
header
.
Number
,
stateRoot
:
header
.
Root
}
return
&
StateDB
{
blockNumber
:
header
.
Number
,
stateObjects
:
make
(
map
[
common
.
Address
]
*
stateObject
),
stateRoot
:
header
.
Root
,
}
}
}
// AddAddressToAccessList adds the given address to the access list
// AddAddressToAccessList adds the given address to the access list
...
...
minigeth/oracle/oracle.go
View file @
78e78b68
package
oracle
package
oracle
import
(
import
(
"bytes"
"encoding/json"
"fmt"
"fmt"
"math/big"
"math/big"
"net/http"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rlp"
)
)
type
jsonreq
struct
{
Jsonrpc
string
`json:"jsonrpc"`
Method
string
`json:"method"`
Params
[
3
]
interface
{}
`json:"params"`
Id
uint64
`json:"id"`
}
type
jsonresp
struct
{
Jsonrpc
string
`json:"jsonrpc"`
Id
uint64
`json:"id"`
Result
AccountResult
`json:"result"`
}
// Result structs for GetProof
type
AccountResult
struct
{
Address
common
.
Address
`json:"address"`
AccountProof
[]
string
`json:"accountProof"`
Balance
*
hexutil
.
Big
`json:"balance"`
CodeHash
common
.
Hash
`json:"codeHash"`
Nonce
hexutil
.
Uint64
`json:"nonce"`
StorageHash
common
.
Hash
`json:"storageHash"`
StorageProof
[]
StorageResult
`json:"storageProof"`
}
type
StorageResult
struct
{
Key
string
`json:"key"`
Value
*
hexutil
.
Big
`json:"value"`
Proof
[]
string
`json:"proof"`
}
// Account is the Ethereum consensus representation of accounts.
// These objects are stored in the main account trie.
type
Account
struct
{
Nonce
uint64
Balance
*
big
.
Int
Root
common
.
Hash
// merkle root of the storage trie
CodeHash
[]
byte
}
func
GetProvedAccountBytes
(
blockNumber
*
big
.
Int
,
stateRoot
common
.
Hash
,
addr
common
.
Address
)
[]
byte
{
func
GetProvedAccountBytes
(
blockNumber
*
big
.
Int
,
stateRoot
common
.
Hash
,
addr
common
.
Address
)
[]
byte
{
fmt
.
Println
(
"ORACLE GetProvedAccountBytes:"
,
blockNumber
,
stateRoot
,
addr
)
fmt
.
Println
(
"ORACLE GetProvedAccountBytes:"
,
blockNumber
,
stateRoot
,
addr
)
return
[]
byte
(
"12"
)
r
:=
jsonreq
{
Jsonrpc
:
"2.0"
,
Method
:
"eth_getProof"
,
Id
:
1
}
r
.
Params
[
0
]
=
addr
r
.
Params
[
1
]
=
[]
common
.
Hash
{}
r
.
Params
[
2
]
=
fmt
.
Sprintf
(
"0x%x"
,
blockNumber
.
Int64
()
-
1
)
jsonData
,
_
:=
json
.
Marshal
(
r
)
resp
,
_
:=
http
.
Post
(
"http://192.168.1.213:8545"
,
"application/json"
,
bytes
.
NewBuffer
(
jsonData
))
defer
resp
.
Body
.
Close
()
jr
:=
jsonresp
{}
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
&
jr
)
// TODO: check proof
account
:=
Account
{
Nonce
:
uint64
(
jr
.
Result
.
Nonce
),
Balance
:
jr
.
Result
.
Balance
.
ToInt
(),
Root
:
jr
.
Result
.
StorageHash
,
CodeHash
:
jr
.
Result
.
CodeHash
.
Bytes
(),
}
/*fmt.Println(string(jsonData))
fmt.Println(resp)
fmt.Println(jr)*/
ret
,
_
:=
rlp
.
EncodeToBytes
(
account
)
return
ret
//return []byte("12")
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment