diff --git a/Gopkg.lock b/Gopkg.lock index 0bb388f3..863d9d51 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -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 diff --git a/Gopkg.toml b/Gopkg.toml index 3618d30b..bcdf8cf6 100644 --- a/Gopkg.toml +++ b/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 diff --git a/blockchain b/blockchain new file mode 100755 index 00000000..d40ec83f Binary files /dev/null and b/blockchain differ diff --git a/core/chain.go b/core/chain.go index c461b3ec..f8869507 100644 --- a/core/chain.go +++ b/core/chain.go @@ -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 } diff --git a/main.go b/main.go index a030e0b9..c4ae31de 100644 --- a/main.go +++ b/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 } }