Fixed BLOCKHASH opcode and added blockchain file for smoke testing
This commit is contained in:
parent
40ea93bd2a
commit
710282b30b
11
Gopkg.lock
generated
11
Gopkg.lock
generated
@ -221,6 +221,15 @@
|
|||||||
revision = "5923b6288fe8ce9581936ee97c2bf9cf9c02c2f4"
|
revision = "5923b6288fe8ce9581936ee97c2bf9cf9c02c2f4"
|
||||||
version = "v0.22.0-rc2"
|
version = "v0.22.0-rc2"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/tendermint/tmlibs"
|
||||||
|
packages = [
|
||||||
|
"common",
|
||||||
|
"db",
|
||||||
|
"log"
|
||||||
|
]
|
||||||
|
revision = "692f1d86a6e2c0efa698fd1e4541b68c74ffaf38"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "golang.org/x/crypto"
|
name = "golang.org/x/crypto"
|
||||||
@ -327,6 +336,6 @@
|
|||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "d2bdf0662ff705902bb01ca73dc55e89a4eb0b7f323b96d1ce84afa5d1253c0a"
|
inputs-digest = "58fcc52223aba442a24118b546ef53abff5352bbdf306e652dee3106822bba50"
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
15
Gopkg.toml
15
Gopkg.toml
@ -3,22 +3,13 @@
|
|||||||
# TODO: Replace with a stable tagged version
|
# TODO: Replace with a stable tagged version
|
||||||
branch = "develop"
|
branch = "develop"
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
name = "github.com/ethereum/go-ethereum"
|
|
||||||
version = "1.8.11"
|
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
name = "github.com/tendermint/tendermint"
|
|
||||||
version = "=0.22.0-rc2"
|
|
||||||
|
|
||||||
[[override]]
|
[[override]]
|
||||||
name = "google.golang.org/genproto"
|
name = "google.golang.org/genproto"
|
||||||
revision = "7fd901a49ba6a7f87732eb344f6e3c5b19d1b200"
|
revision = "7fd901a49ba6a7f87732eb344f6e3c5b19d1b200"
|
||||||
|
|
||||||
[[override]]
|
[[constraint]]
|
||||||
name = "github.com/tendermint/go-wire"
|
version = "=0.22.0-rc2"
|
||||||
version = "0.7.3"
|
name = "github.com/tendermint/tendermint"
|
||||||
|
|
||||||
[prune]
|
[prune]
|
||||||
go-tests = true
|
go-tests = true
|
||||||
unused-packages = true
|
|
||||||
|
BIN
blockchain
Executable file
BIN
blockchain
Executable file
Binary file not shown.
@ -21,6 +21,13 @@ import (
|
|||||||
// and functionality of this is a WIP and subject to change.
|
// and functionality of this is a WIP and subject to change.
|
||||||
type ChainContext struct {
|
type ChainContext struct {
|
||||||
Coinbase ethcommon.Address
|
Coinbase ethcommon.Address
|
||||||
|
headersByNumber map[uint64]*ethtypes.Header
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewChainContext() *ChainContext {
|
||||||
|
return &ChainContext{
|
||||||
|
headersByNumber: make(map[uint64]*ethtypes.Header),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Engine implements Ethereum's core.ChainContext interface. As a ChainContext
|
// Engine implements Ethereum's core.ChainContext interface. As a ChainContext
|
||||||
@ -29,12 +36,19 @@ func (cc *ChainContext) Engine() ethconsensus.Engine {
|
|||||||
return cc
|
return cc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cc *ChainContext) SetHeader(number uint64, header *ethtypes.Header) {
|
||||||
|
cc.headersByNumber[number] = header
|
||||||
|
}
|
||||||
|
|
||||||
// GetHeader implements Ethereum's core.ChainContext interface. It currently
|
// GetHeader implements Ethereum's core.ChainContext interface. It currently
|
||||||
// performs a no-op.
|
// performs a no-op.
|
||||||
//
|
//
|
||||||
// TODO: The Cosmos SDK supports retreiving such information in contexts and
|
// TODO: The Cosmos SDK supports retreiving such information in contexts and
|
||||||
// multi-store, so this will be need to be integrated.
|
// multi-store, so this will be need to be integrated.
|
||||||
func (cc *ChainContext) GetHeader(ethcommon.Hash, uint64) *ethtypes.Header {
|
func (cc *ChainContext) GetHeader(parentHash ethcommon.Hash, number uint64) *ethtypes.Header {
|
||||||
|
if header, ok := cc.headersByNumber[number]; ok {
|
||||||
|
return header
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
main.go
12
main.go
@ -40,8 +40,6 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("instantiating new geth state.StateDB")
|
|
||||||
|
|
||||||
// start with empty root hash (i.e. empty state)
|
// start with empty root hash (i.e. empty state)
|
||||||
gethStateDB, err := ethstate.New(ethcommon.Hash{}, ethermintDB)
|
gethStateDB, err := ethstate.New(ethcommon.Hash{}, ethermintDB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -78,7 +76,7 @@ func main() {
|
|||||||
// command.
|
// command.
|
||||||
//
|
//
|
||||||
// TODO: Allow this to be configurable
|
// TODO: Allow this to be configurable
|
||||||
input, err := os.Open("/Users/alexeyakhunov/mygit/blockchain")
|
input, err := os.Open("blockchain")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -99,7 +97,7 @@ func main() {
|
|||||||
|
|
||||||
prevRoot := genRoot
|
prevRoot := genRoot
|
||||||
ethermintDB.Tracing = true
|
ethermintDB.Tracing = true
|
||||||
chainContext := &core.ChainContext{}
|
chainContext := core.NewChainContext()
|
||||||
vmConfig := ethvm.Config{}
|
vmConfig := ethvm.Config{}
|
||||||
|
|
||||||
n := 0
|
n := 0
|
||||||
@ -118,6 +116,7 @@ func main() {
|
|||||||
|
|
||||||
header := block.Header()
|
header := block.Header()
|
||||||
chainContext.Coinbase = header.Coinbase
|
chainContext.Coinbase = header.Coinbase
|
||||||
|
chainContext.SetHeader(block.NumberU64(), header)
|
||||||
|
|
||||||
gethStateDB, err := ethstate.New(prevRoot, ethermintDB)
|
gethStateDB, err := ethstate.New(prevRoot, ethermintDB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -186,6 +185,7 @@ func main() {
|
|||||||
|
|
||||||
// commit block in Ethermint
|
// commit block in Ethermint
|
||||||
ethermintDB.Commit()
|
ethermintDB.Commit()
|
||||||
|
//fmt.Printf("commitID after block %d: %v\n", block.NumberU64(), commitID)
|
||||||
|
|
||||||
switch block.NumberU64() {
|
switch block.NumberU64() {
|
||||||
case 500:
|
case 500:
|
||||||
@ -195,10 +195,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
n++
|
n++
|
||||||
if n%10000 == 0 {
|
if (n%100) == 0 {
|
||||||
fmt.Printf("processed %d blocks\n", n)
|
fmt.Printf("processed %d blocks\n", n)
|
||||||
}
|
}
|
||||||
if n >= 100000 {
|
if n >= 1000 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user