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
e8565f4a
Commit
e8565f4a
authored
Sep 18, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
the tx runs, but does nothing since GetCode returns nil
parent
1bc67228
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
5 deletions
+25
-5
get_block.ts
helpers/get_block.ts
+1
-0
statedb.go
minigeth/core/state/statedb.go
+23
-5
state_processor.go
minigeth/core/state_processor.go
+1
-0
No files found.
helpers/get_block.ts
View file @
e8565f4a
...
@@ -18,6 +18,7 @@ type extblock struct {
...
@@ -18,6 +18,7 @@ type extblock struct {
*/
*/
function
getTransactionRlp
(
tx
:
any
):
Buffer
{
function
getTransactionRlp
(
tx
:
any
):
Buffer
{
let
dat
:
any
let
dat
:
any
// TODO: there are also type 1 transactions
if
(
tx
.
type
==
"
0x2
"
)
{
if
(
tx
.
type
==
"
0x2
"
)
{
let
accesslist
=
tx
.
accessList
.
map
((
x
:
any
)
=>
[
x
.
address
,
x
.
storageKeys
])
let
accesslist
=
tx
.
accessList
.
map
((
x
:
any
)
=>
[
x
.
address
,
x
.
storageKeys
])
// london
// london
...
...
minigeth/core/state/statedb.go
View file @
e8565f4a
package
state
package
state
import
(
import
(
"fmt"
"math/big"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
...
@@ -17,10 +18,16 @@ func (s *StateDB) AddAddressToAccessList(addr common.Address) {
...
@@ -17,10 +18,16 @@ func (s *StateDB) AddAddressToAccessList(addr common.Address) {
// AddBalance adds amount to the account associated with addr.
// AddBalance adds amount to the account associated with addr.
func
(
s
*
StateDB
)
AddBalance
(
addr
common
.
Address
,
amount
*
big
.
Int
)
{
func
(
s
*
StateDB
)
AddBalance
(
addr
common
.
Address
,
amount
*
big
.
Int
)
{
fmt
.
Println
(
"AddBalance"
,
addr
,
amount
)
}
}
// SubBalance subtracts amount from the account associated with addr.
// SubBalance subtracts amount from the account associated with addr.
func
(
s
*
StateDB
)
SubBalance
(
addr
common
.
Address
,
amount
*
big
.
Int
)
{
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.
// IntermediateRoot computes the current root hash of the state trie.
...
@@ -30,10 +37,8 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
...
@@ -30,10 +37,8 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
return
common
.
HexToHash
(
"0x0"
)
return
common
.
HexToHash
(
"0x0"
)
}
}
func
(
s
*
StateDB
)
AddLog
(
log
*
types
.
Log
)
{
}
func
(
s
*
StateDB
)
GetLogs
(
hash
common
.
Hash
,
blockHash
common
.
Hash
)
[]
*
types
.
Log
{
func
(
s
*
StateDB
)
GetLogs
(
hash
common
.
Hash
,
blockHash
common
.
Hash
)
[]
*
types
.
Log
{
fmt
.
Println
(
"GetLogs"
,
hash
,
blockHash
)
return
nil
return
nil
}
}
...
@@ -91,45 +96,55 @@ func (db *StateDB) ForEachStorage(addr common.Address, cb func(key, value common
...
@@ -91,45 +96,55 @@ func (db *StateDB) ForEachStorage(addr common.Address, cb func(key, value common
// GetBalance retrieves the balance from the given address or 0 if object not found
// GetBalance retrieves the balance from the given address or 0 if object not found
func
(
s
*
StateDB
)
GetBalance
(
addr
common
.
Address
)
*
big
.
Int
{
func
(
s
*
StateDB
)
GetBalance
(
addr
common
.
Address
)
*
big
.
Int
{
return
nil
fmt
.
Println
(
"GetBalance"
,
addr
)
return
big
.
NewInt
(
1e18
)
}
}
func
(
s
*
StateDB
)
GetCode
(
addr
common
.
Address
)
[]
byte
{
func
(
s
*
StateDB
)
GetCode
(
addr
common
.
Address
)
[]
byte
{
fmt
.
Println
(
"GetCode"
,
addr
)
return
nil
return
nil
}
}
func
(
s
*
StateDB
)
GetCodeSize
(
addr
common
.
Address
)
int
{
func
(
s
*
StateDB
)
GetCodeSize
(
addr
common
.
Address
)
int
{
fmt
.
Println
(
"GetCodeSize"
,
addr
)
return
0
return
0
}
}
func
(
s
*
StateDB
)
GetCodeHash
(
addr
common
.
Address
)
common
.
Hash
{
func
(
s
*
StateDB
)
GetCodeHash
(
addr
common
.
Address
)
common
.
Hash
{
fmt
.
Println
(
"GetCodeHash"
,
addr
)
return
common
.
HexToHash
(
"0x0"
)
return
common
.
HexToHash
(
"0x0"
)
}
}
// GetCommittedState retrieves a value from the given account's committed storage trie.
// GetCommittedState retrieves a value from the given account's committed storage trie.
func
(
s
*
StateDB
)
GetCommittedState
(
addr
common
.
Address
,
hash
common
.
Hash
)
common
.
Hash
{
func
(
s
*
StateDB
)
GetCommittedState
(
addr
common
.
Address
,
hash
common
.
Hash
)
common
.
Hash
{
fmt
.
Println
(
"GetCommittedState"
,
addr
,
hash
)
return
common
.
Hash
{}
return
common
.
Hash
{}
}
}
// GetState retrieves a value from the given account's storage trie.
// GetState retrieves a value from the given account's storage trie.
func
(
s
*
StateDB
)
GetState
(
addr
common
.
Address
,
hash
common
.
Hash
)
common
.
Hash
{
func
(
s
*
StateDB
)
GetState
(
addr
common
.
Address
,
hash
common
.
Hash
)
common
.
Hash
{
fmt
.
Println
(
"GetState"
,
addr
,
hash
)
return
common
.
Hash
{}
return
common
.
Hash
{}
}
}
func
(
s
*
StateDB
)
GetNonce
(
addr
common
.
Address
)
uint64
{
func
(
s
*
StateDB
)
GetNonce
(
addr
common
.
Address
)
uint64
{
return
0
fmt
.
Println
(
"GetNonce"
,
addr
)
return
2122
}
}
// GetRefund returns the current value of the refund counter.
// GetRefund returns the current value of the refund counter.
func
(
s
*
StateDB
)
GetRefund
()
uint64
{
func
(
s
*
StateDB
)
GetRefund
()
uint64
{
fmt
.
Println
(
"GetRefund"
)
return
0
return
0
}
}
func
(
s
*
StateDB
)
Suicide
(
addr
common
.
Address
)
bool
{
func
(
s
*
StateDB
)
Suicide
(
addr
common
.
Address
)
bool
{
fmt
.
Println
(
"Suicide"
,
addr
)
return
true
return
true
}
}
func
(
s
*
StateDB
)
HasSuicided
(
addr
common
.
Address
)
bool
{
func
(
s
*
StateDB
)
HasSuicided
(
addr
common
.
Address
)
bool
{
fmt
.
Println
(
"HasSuicided"
,
addr
)
return
false
return
false
}
}
...
@@ -141,12 +156,15 @@ func (s *StateDB) RevertToSnapshot(revid int) {
...
@@ -141,12 +156,15 @@ func (s *StateDB) RevertToSnapshot(revid int) {
}
}
func
(
s
*
StateDB
)
SetCode
(
addr
common
.
Address
,
code
[]
byte
)
{
func
(
s
*
StateDB
)
SetCode
(
addr
common
.
Address
,
code
[]
byte
)
{
fmt
.
Println
(
"SetCode"
,
addr
,
code
)
}
}
func
(
s
*
StateDB
)
SetNonce
(
addr
common
.
Address
,
nonce
uint64
)
{
func
(
s
*
StateDB
)
SetNonce
(
addr
common
.
Address
,
nonce
uint64
)
{
fmt
.
Println
(
"SetNonce"
,
addr
,
nonce
)
}
}
func
(
s
*
StateDB
)
SetState
(
addr
common
.
Address
,
key
,
value
common
.
Hash
)
{
func
(
s
*
StateDB
)
SetState
(
addr
common
.
Address
,
key
,
value
common
.
Hash
)
{
fmt
.
Println
(
"SetState"
,
addr
,
key
)
}
}
// SlotInAccessList returns true if the given (address, slot)-tuple is in the access list.
// SlotInAccessList returns true if the given (address, slot)-tuple is in the access list.
...
...
minigeth/core/state_processor.go
View file @
e8565f4a
...
@@ -82,6 +82,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
...
@@ -82,6 +82,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
vmenv
:=
vm
.
NewEVM
(
blockContext
,
vm
.
TxContext
{},
statedb
,
p
.
config
,
cfg
)
vmenv
:=
vm
.
NewEVM
(
blockContext
,
vm
.
TxContext
{},
statedb
,
p
.
config
,
cfg
)
// Iterate over and process the individual transactions
// Iterate over and process the individual transactions
for
i
,
tx
:=
range
block
.
Transactions
()
{
for
i
,
tx
:=
range
block
.
Transactions
()
{
fmt
.
Println
(
i
,
tx
.
Hash
())
msg
,
err
:=
tx
.
AsMessage
(
types
.
MakeSigner
(
p
.
config
,
header
.
Number
),
header
.
BaseFee
)
msg
,
err
:=
tx
.
AsMessage
(
types
.
MakeSigner
(
p
.
config
,
header
.
Number
),
header
.
BaseFee
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
0
,
fmt
.
Errorf
(
"could not apply tx %d [%v]: %w"
,
i
,
tx
.
Hash
()
.
Hex
(),
err
)
return
nil
,
nil
,
0
,
fmt
.
Errorf
(
"could not apply tx %d [%v]: %w"
,
i
,
tx
.
Hash
()
.
Hex
(),
err
)
...
...
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