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
f8e72465
Commit
f8e72465
authored
Sep 14, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wow statedb is complex
parent
d6da4342
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
175 additions
and
0 deletions
+175
-0
blockchain.go
minigeth/core/blockchain.go
+21
-0
statedb.go
minigeth/core/state/statedb.go
+154
-0
No files found.
minigeth/core/blockchain.go
View file @
f8e72465
package
core
package
core
import
(
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
)
type
BlockChain
struct
{
type
BlockChain
struct
{
// TODO: write stub BlockChain
// TODO: write stub BlockChain
chainConfig
*
params
.
ChainConfig
// Chain & network configuration
engine
consensus
.
Engine
}
// Config retrieves the chain's fork configuration.
func
(
bc
*
BlockChain
)
Config
()
*
params
.
ChainConfig
{
return
bc
.
chainConfig
}
// Engine retrieves the blockchain's consensus engine.
func
(
bc
*
BlockChain
)
Engine
()
consensus
.
Engine
{
return
bc
.
engine
}
// GetHeader retrieves a block header from the database by hash and number,
// caching it if found.
func
(
bc
*
BlockChain
)
GetHeader
(
hash
common
.
Hash
,
number
uint64
)
*
types
.
Header
{
return
nil
}
}
minigeth/core/state/statedb.go
View file @
f8e72465
package
state
package
state
import
(
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)
type
StateDB
struct
{
type
StateDB
struct
{
// TODO: write stub StateDB
// TODO: write stub StateDB
}
}
// AddAddressToAccessList adds the given address to the access list
func
(
s
*
StateDB
)
AddAddressToAccessList
(
addr
common
.
Address
)
{
}
// AddBalance adds amount to the account associated with addr.
func
(
s
*
StateDB
)
AddBalance
(
addr
common
.
Address
,
amount
*
big
.
Int
)
{
}
// SubBalance subtracts amount from the account associated with addr.
func
(
s
*
StateDB
)
SubBalance
(
addr
common
.
Address
,
amount
*
big
.
Int
)
{
}
// 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.
func
(
s
*
StateDB
)
IntermediateRoot
(
deleteEmptyObjects
bool
)
common
.
Hash
{
return
common
.
HexToHash
(
"0x0"
)
}
func
(
s
*
StateDB
)
AddLog
(
log
*
types
.
Log
)
{
}
func
(
s
*
StateDB
)
GetLogs
(
hash
common
.
Hash
,
blockHash
common
.
Hash
)
[]
*
types
.
Log
{
return
nil
}
// AddPreimage records a SHA3 preimage seen by the VM.
func
(
s
*
StateDB
)
AddPreimage
(
hash
common
.
Hash
,
preimage
[]
byte
)
{
}
// AddRefund adds gas to the refund counter
func
(
s
*
StateDB
)
AddRefund
(
gas
uint64
)
{
}
// SubRefund removes gas from the refund counter.
// This method will panic if the refund counter goes below zero
func
(
s
*
StateDB
)
SubRefund
(
gas
uint64
)
{
}
// AddSlotToAccessList adds the given (address, slot)-tuple to the access list
func
(
s
*
StateDB
)
AddSlotToAccessList
(
addr
common
.
Address
,
slot
common
.
Hash
)
{
}
// AddressInAccessList returns true if the given address is in the access list.
func
(
s
*
StateDB
)
AddressInAccessList
(
addr
common
.
Address
)
bool
{
return
false
}
func
(
s
*
StateDB
)
CreateAccount
(
addr
common
.
Address
)
{
}
// Finalise finalises the state by removing the s destructed objects and clears
// the journal as well as the refunds. Finalise, however, will not push any updates
// into the tries just yet. Only IntermediateRoot or Commit will do that.
func
(
s
*
StateDB
)
Finalise
(
deleteEmptyObjects
bool
)
{
}
// TxIndex returns the current transaction index set by Prepare.
func
(
s
*
StateDB
)
TxIndex
()
int
{
return
0
}
// 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
{
return
true
}
// 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
true
}
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
{
return
nil
}
func
(
s
*
StateDB
)
GetCode
(
addr
common
.
Address
)
[]
byte
{
return
nil
}
func
(
s
*
StateDB
)
GetCodeSize
(
addr
common
.
Address
)
int
{
return
0
}
func
(
s
*
StateDB
)
GetCodeHash
(
addr
common
.
Address
)
common
.
Hash
{
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
{
return
common
.
Hash
{}
}
// GetState retrieves a value from the given account's storage trie.
func
(
s
*
StateDB
)
GetState
(
addr
common
.
Address
,
hash
common
.
Hash
)
common
.
Hash
{
return
common
.
Hash
{}
}
func
(
s
*
StateDB
)
GetNonce
(
addr
common
.
Address
)
uint64
{
return
0
}
// GetRefund returns the current value of the refund counter.
func
(
s
*
StateDB
)
GetRefund
()
uint64
{
return
0
}
func
(
s
*
StateDB
)
Suicide
(
addr
common
.
Address
)
bool
{
return
true
}
func
(
s
*
StateDB
)
HasSuicided
(
addr
common
.
Address
)
bool
{
return
false
}
func
(
s
*
StateDB
)
PrepareAccessList
(
sender
common
.
Address
,
dst
*
common
.
Address
,
precompiles
[]
common
.
Address
,
list
types
.
AccessList
)
{
}
// RevertToSnapshot reverts all state changes made since the given revision.
func
(
s
*
StateDB
)
RevertToSnapshot
(
revid
int
)
{
}
func
(
s
*
StateDB
)
SetCode
(
addr
common
.
Address
,
code
[]
byte
)
{
}
func
(
s
*
StateDB
)
SetNonce
(
addr
common
.
Address
,
nonce
uint64
)
{
}
func
(
s
*
StateDB
)
SetState
(
addr
common
.
Address
,
key
,
value
common
.
Hash
)
{
}
// SlotInAccessList returns true if the given (address, slot)-tuple is in the access list.
func
(
s
*
StateDB
)
SlotInAccessList
(
addr
common
.
Address
,
slot
common
.
Hash
)
(
addressPresent
bool
,
slotPresent
bool
)
{
return
true
,
true
}
func
(
s
*
StateDB
)
Snapshot
()
int
{
return
0
}
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