From fbe5ac69d606a110aa14ac5689cb7040e6dc846c Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Fri, 6 Jul 2018 14:10:55 -0700 Subject: [PATCH 1/8] Add CODE_OF_CONDUCT.md This adds a code of conduct, same one as on `cosmos-sdk` --- CONTRIBUTING.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..754a1cd2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at jack@tendermint.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ From c2e1ab2d4a4955a64edfe4f955c3659dd4a0c32d Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 9 Jul 2018 14:24:19 -0400 Subject: [PATCH 2/8] Lock in versions of dependencies --- Gopkg.lock | 26 ++++++++------------------ Gopkg.toml | 6 +++--- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 863d9d51..2a52ade0 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -11,23 +11,22 @@ branch = "master" name = "github.com/btcsuite/btcd" packages = ["btcec"] - revision = "86fed781132ac890ee03e906e4ecd5d6fa180c64" + revision = "fdfc19097e7ac6b57035062056f5b7b4638b8898" [[projects]] branch = "master" name = "github.com/btcsuite/btcutil" packages = ["bech32"] - revision = "d4cc87b860166d00d6b5b9e0d3b3d71d6088d4d4" + revision = "ab6388e0c60ae4834a1f57511e20c17b5f78be4b" [[projects]] - branch = "develop" name = "github.com/cosmos/cosmos-sdk" packages = [ "store", "types", "wire" ] - revision = "08625633c62555cbd4ddc61238d35da520d942cb" + revision = "0d6f99d6d514916974a7cc1a7e4577c650e987e1" [[projects]] name = "github.com/davecgh/go-spew" @@ -73,8 +72,8 @@ "rpc", "trie" ] - revision = "dea1ce052a10cd7d401a5c04f83f371a06fe293c" - version = "v1.8.11" + revision = "37685930d953bcbe023f9bc65b135a8d8b8f1488" + version = "v1.8.12" [[projects]] name = "github.com/go-kit/kit" @@ -179,7 +178,7 @@ "leveldb/table", "leveldb/util" ] - revision = "0d5a0ceb10cf9ab89fdd744cc8c50a83134f6697" + revision = "c4c61651e9e37fa117f53c5a906d3b63090d8445" [[projects]] branch = "master" @@ -221,15 +220,6 @@ 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" @@ -257,7 +247,7 @@ "trace", "websocket" ] - revision = "ed29d75add3d7c4bf7ca65aac0c6df3d1420216f" + revision = "c21de06aaf072cea07f3a65d6970e5c7d8b6cd6d" [[projects]] name = "golang.org/x/text" @@ -336,6 +326,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "58fcc52223aba442a24118b546ef53abff5352bbdf306e652dee3106822bba50" + inputs-digest = "6bd7ad37cf8a53408eeb32265fbc699bf2cc4e7a15b0b98182bcebb5c887cea1" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index bcdf8cf6..4b2a42b5 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,15 +1,15 @@ [[constraint]] name = "github.com/cosmos/cosmos-sdk" - # TODO: Replace with a stable tagged version - branch = "develop" + # TODO: Replace with a stable tagged version (issue: #3) + revision = "0d6f99d6d514916974a7cc1a7e4577c650e987e1" [[override]] name = "google.golang.org/genproto" revision = "7fd901a49ba6a7f87732eb344f6e3c5b19d1b200" [[constraint]] - version = "=0.22.0-rc2" name = "github.com/tendermint/tendermint" + version = "=0.22.0-rc2" [prune] go-tests = true From 09d5888c2eb4499bfd7277f9c675a48e116d7b15 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 9 Jul 2018 14:25:00 -0400 Subject: [PATCH 3/8] Fix import paths (replace ledgerwatch with cosmos) --- core/chain.go | 2 +- main.go | 6 +++--- state/database.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/chain.go b/core/chain.go index f8869507..741b6f2a 100644 --- a/core/chain.go +++ b/core/chain.go @@ -20,7 +20,7 @@ import ( // NOTE: Ethermint will distribute the fees out to validators, so the structure // and functionality of this is a WIP and subject to change. type ChainContext struct { - Coinbase ethcommon.Address + Coinbase ethcommon.Address headersByNumber map[uint64]*ethtypes.Header } diff --git a/main.go b/main.go index c4ae31de..d61b2f52 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,8 @@ import ( "io" "os" + "github.com/cosmos/ethermint/core" + "github.com/cosmos/ethermint/state" ethcommon "github.com/ethereum/go-ethereum/common" ethmisc "github.com/ethereum/go-ethereum/consensus/misc" ethcore "github.com/ethereum/go-ethereum/core" @@ -19,8 +21,6 @@ import ( ethvm "github.com/ethereum/go-ethereum/core/vm" ethparams "github.com/ethereum/go-ethereum/params" ethrlp "github.com/ethereum/go-ethereum/rlp" - "github.com/ledgerwatch/ethermint/core" - "github.com/ledgerwatch/ethermint/state" dbm "github.com/tendermint/tendermint/libs/db" ) @@ -195,7 +195,7 @@ func main() { } n++ - if (n%100) == 0 { + if (n % 100) == 0 { fmt.Printf("processed %d blocks\n", n) } if n >= 1000 { diff --git a/state/database.go b/state/database.go index f309ed5b..b097621e 100644 --- a/state/database.go +++ b/state/database.go @@ -3,10 +3,10 @@ package state import ( "github.com/cosmos/cosmos-sdk/store" "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ethermint/core" ethcommon "github.com/ethereum/go-ethereum/common" ethstate "github.com/ethereum/go-ethereum/core/state" ethtrie "github.com/ethereum/go-ethereum/trie" - "github.com/ledgerwatch/ethermint/core" dbm "github.com/tendermint/tendermint/libs/db" ) From bb140939dcd6b8708101130d7e2194dc7ff6ba4b Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 9 Jul 2018 15:47:49 -0400 Subject: [PATCH 4/8] Add Github PR template --- .github/PULL_REQUEST_TEMPLATE.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..1fa54ff8 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,12 @@ + + +* [ ] Updated all relevant documentation in docs +* [ ] Updated all code comments where relevant +* [ ] Wrote tests +* [ ] Updated CHANGELOG.md +* [ ] Squashed all commits, uses message "Merge pull request #XYZ: [title]" ([coding standards](https://github.com/tendermint/coding/blob/master/README.md#merging-a-pr)) +* [ ] Added appropriate labels to PR (ex. wip, ready-for-review, docs) From 1960b73752efd33ba2eef5fd8aea791d740a6e95 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 9 Jul 2018 16:43:59 -0400 Subject: [PATCH 5/8] Remove CHANGELOG requirement from PR template --- .github/PULL_REQUEST_TEMPLATE.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 1fa54ff8..ee75e68f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -7,6 +7,5 @@ v If a checkbox is n/a - please still include it but + a little note why * [ ] Updated all relevant documentation in docs * [ ] Updated all code comments where relevant * [ ] Wrote tests -* [ ] Updated CHANGELOG.md * [ ] Squashed all commits, uses message "Merge pull request #XYZ: [title]" ([coding standards](https://github.com/tendermint/coding/blob/master/README.md#merging-a-pr)) * [ ] Added appropriate labels to PR (ex. wip, ready-for-review, docs) From 32e98c71f1b24f3b2ec6eb786a20821bfe7ad390 Mon Sep 17 00:00:00 2001 From: Alexey Akhunov Date: Mon, 9 Jul 2018 23:14:17 +0100 Subject: [PATCH 6/8] Add profiling flag --- main.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index d61b2f52..d36538fc 100644 --- a/main.go +++ b/main.go @@ -7,9 +7,11 @@ package main import ( "bytes" "encoding/json" + "flag" "fmt" "io" "os" + "runtime/pprof" "github.com/cosmos/ethermint/core" "github.com/cosmos/ethermint/state" @@ -24,6 +26,8 @@ import ( dbm "github.com/tendermint/tendermint/libs/db" ) +var cpuprofile = flag.String("cpuprofile", "", "write cpu profile `file`") + var ( // TODO: Document... miner501 = ethcommon.HexToAddress("0x35e8e5dC5FBd97c5b421A80B596C030a2Be2A04D") @@ -32,7 +36,21 @@ var ( // TODO: Document... func main() { - stateDB := dbm.NewDB("state", dbm.MemDBBackend, "") + flag.Parse() + if *cpuprofile != "" { + f, err := os.Create(*cpuprofile) + if err != nil { + fmt.Printf("could not create CPU profile: %v\n", err) + return + } + if err := pprof.StartCPUProfile(f); err != nil { + fmt.Printf("could not start CPU profile: %v\n", err) + return + } + defer pprof.StopCPUProfile() + } + + stateDB := dbm.NewDB("state", dbm.MemDBBackend, "") codeDB := dbm.NewDB("code", dbm.MemDBBackend, "") ethermintDB, err := state.NewDatabase(stateDB, codeDB) @@ -195,10 +213,10 @@ func main() { } n++ - if (n % 100) == 0 { + if (n % 1000) == 0 { fmt.Printf("processed %d blocks\n", n) } - if n >= 1000 { + if n >= 20000 { break } } From 9b3456d86e3f722063829b0a0de00ec77938a4d2 Mon Sep 17 00:00:00 2001 From: Alexey Akhunov Date: Tue, 10 Jul 2018 10:13:34 +0100 Subject: [PATCH 7/8] Flag to specify a different blockchain file, switch to levelDB backend --- main.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index d36538fc..bef6f3af 100644 --- a/main.go +++ b/main.go @@ -27,6 +27,7 @@ import ( ) var cpuprofile = flag.String("cpuprofile", "", "write cpu profile `file`") +var blockchain = flag.String("blockchain", "blockchain", "file containing blocks to load") var ( // TODO: Document... @@ -50,8 +51,8 @@ func main() { defer pprof.StopCPUProfile() } - stateDB := dbm.NewDB("state", dbm.MemDBBackend, "") - codeDB := dbm.NewDB("code", dbm.MemDBBackend, "") + stateDB := dbm.NewDB("state", dbm.LevelDBBackend, "") + codeDB := dbm.NewDB("code", dbm.LevelDBBackend, "") ethermintDB, err := state.NewDatabase(stateDB, codeDB) if err != nil { @@ -94,7 +95,7 @@ func main() { // command. // // TODO: Allow this to be configurable - input, err := os.Open("blockchain") + input, err := os.Open(*blockchain) if err != nil { panic(err) } @@ -213,12 +214,12 @@ func main() { } n++ - if (n % 1000) == 0 { + if (n % 10000) == 0 { fmt.Printf("processed %d blocks\n", n) } - if n >= 20000 { - break - } + //if n >= 20000 { + // break + //} } fmt.Printf("processed %d blocks\n", n) From f0ada2afca2160c120be86020eb46884ca02695b Mon Sep 17 00:00:00 2001 From: Alexey Akhunov Date: Tue, 10 Jul 2018 10:17:56 +0100 Subject: [PATCH 8/8] Timing --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index bef6f3af..43b5a3fc 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "io" "os" "runtime/pprof" + "time" "github.com/cosmos/ethermint/core" "github.com/cosmos/ethermint/state" @@ -120,6 +121,7 @@ func main() { vmConfig := ethvm.Config{} n := 0 + startTime := time.Now() for { if err = stream.Decode(&block); err == io.EOF { err = nil @@ -215,7 +217,7 @@ func main() { n++ if (n % 10000) == 0 { - fmt.Printf("processed %d blocks\n", n) + fmt.Printf("processed %d blocks, time so far: %v\n", n, time.Since(startTime)) } //if n >= 20000 { // break