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"
|
||||
version = "v0.22.0-rc2"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/tendermint/tmlibs"
|
||||
packages = [
|
||||
"common",
|
||||
"db",
|
||||
"log"
|
||||
]
|
||||
revision = "692f1d86a6e2c0efa698fd1e4541b68c74ffaf38"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/crypto"
|
||||
@ -327,6 +336,6 @@
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "d2bdf0662ff705902bb01ca73dc55e89a4eb0b7f323b96d1ce84afa5d1253c0a"
|
||||
inputs-digest = "58fcc52223aba442a24118b546ef53abff5352bbdf306e652dee3106822bba50"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
15
Gopkg.toml
15
Gopkg.toml
@ -3,22 +3,13 @@
|
||||
# TODO: Replace with a stable tagged version
|
||||
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]]
|
||||
name = "google.golang.org/genproto"
|
||||
revision = "7fd901a49ba6a7f87732eb344f6e3c5b19d1b200"
|
||||
|
||||
[[override]]
|
||||
name = "github.com/tendermint/go-wire"
|
||||
version = "0.7.3"
|
||||
[[constraint]]
|
||||
version = "=0.22.0-rc2"
|
||||
name = "github.com/tendermint/tendermint"
|
||||
|
||||
[prune]
|
||||
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.
|
||||
type ChainContext struct {
|
||||
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
|
||||
@ -29,12 +36,19 @@ func (cc *ChainContext) Engine() ethconsensus.Engine {
|
||||
return cc
|
||||
}
|
||||
|
||||
func (cc *ChainContext) SetHeader(number uint64, header *ethtypes.Header) {
|
||||
cc.headersByNumber[number] = header
|
||||
}
|
||||
|
||||
// GetHeader implements Ethereum's core.ChainContext interface. It currently
|
||||
// performs a no-op.
|
||||
//
|
||||
// TODO: The Cosmos SDK supports retreiving such information in contexts and
|
||||
// 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
|
||||
}
|
||||
|
||||
|
12
main.go
12
main.go
@ -40,8 +40,6 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Println("instantiating new geth state.StateDB")
|
||||
|
||||
// start with empty root hash (i.e. empty state)
|
||||
gethStateDB, err := ethstate.New(ethcommon.Hash{}, ethermintDB)
|
||||
if err != nil {
|
||||
@ -78,7 +76,7 @@ func main() {
|
||||
// command.
|
||||
//
|
||||
// TODO: Allow this to be configurable
|
||||
input, err := os.Open("/Users/alexeyakhunov/mygit/blockchain")
|
||||
input, err := os.Open("blockchain")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -99,7 +97,7 @@ func main() {
|
||||
|
||||
prevRoot := genRoot
|
||||
ethermintDB.Tracing = true
|
||||
chainContext := &core.ChainContext{}
|
||||
chainContext := core.NewChainContext()
|
||||
vmConfig := ethvm.Config{}
|
||||
|
||||
n := 0
|
||||
@ -118,6 +116,7 @@ func main() {
|
||||
|
||||
header := block.Header()
|
||||
chainContext.Coinbase = header.Coinbase
|
||||
chainContext.SetHeader(block.NumberU64(), header)
|
||||
|
||||
gethStateDB, err := ethstate.New(prevRoot, ethermintDB)
|
||||
if err != nil {
|
||||
@ -186,6 +185,7 @@ func main() {
|
||||
|
||||
// commit block in Ethermint
|
||||
ethermintDB.Commit()
|
||||
//fmt.Printf("commitID after block %d: %v\n", block.NumberU64(), commitID)
|
||||
|
||||
switch block.NumberU64() {
|
||||
case 500:
|
||||
@ -195,10 +195,10 @@ func main() {
|
||||
}
|
||||
|
||||
n++
|
||||
if n%10000 == 0 {
|
||||
if (n%100) == 0 {
|
||||
fmt.Printf("processed %d blocks\n", n)
|
||||
}
|
||||
if n >= 100000 {
|
||||
if n >= 1000 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user