From 398841911f421882363318c7b9abba631bcfe83d Mon Sep 17 00:00:00 2001 From: Slava Karpenko Date: Wed, 11 Nov 2020 21:13:12 +0100 Subject: [PATCH 1/8] consensus/ethash: use 64bit indexes for the DAG generation (#21793) * Bit boundary fix for the DAG generation routine * Fix unnecessary conversion warnings Co-authored-by: Sergey Pavlov --- consensus/ethash/algorithm.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/consensus/ethash/algorithm.go b/consensus/ethash/algorithm.go index d6c871092ed3..eb94d136b91a 100644 --- a/consensus/ethash/algorithm.go +++ b/consensus/ethash/algorithm.go @@ -304,16 +304,16 @@ func generateDataset(dest []uint32, epoch uint64, cache []uint32) { keccak512 := makeHasher(sha3.NewLegacyKeccak512()) // Calculate the data segment this thread should generate - batch := uint32((size + hashBytes*uint64(threads) - 1) / (hashBytes * uint64(threads))) - first := uint32(id) * batch + batch := (size + hashBytes*uint64(threads) - 1) / (hashBytes * uint64(threads)) + first := uint64(id) * batch limit := first + batch - if limit > uint32(size/hashBytes) { - limit = uint32(size / hashBytes) + if limit > size/hashBytes { + limit = size / hashBytes } // Calculate the dataset segment percent := uint32(size / hashBytes / 100) for index := first; index < limit; index++ { - item := generateDatasetItem(cache, index, keccak512) + item := generateDatasetItem(cache, uint32(index), keccak512) if swapped { swap(item) } From ff365d19a5f6bb91805a183dcb0b39264806868c Mon Sep 17 00:00:00 2001 From: Uh Sado Date: Wed, 25 Nov 2020 09:11:08 +0000 Subject: [PATCH 2/8] version is now 0.9.7 --- params/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/params/version.go b/params/version.go index a05c2f5fec20..59d8b5882db7 100644 --- a/params/version.go +++ b/params/version.go @@ -23,7 +23,7 @@ import ( const ( VersionMajor = 0 // Major version component of the current release VersionMinor = 9 // Minor version component of the current release - VersionPatch = 6 // Patch version component of the current release + VersionPatch = 7 // Patch version component of the current release VersionMeta = "stable" // Version metadata to append to the version string ) From b3c90123028c6b98f2ccedc16da35d1a776ef674 Mon Sep 17 00:00:00 2001 From: seunghwalee Date: Fri, 15 Jan 2021 16:12:30 +0900 Subject: [PATCH 3/8] Fix missing ,(comma) --- metadium/scripts/deploy-governance.js | 2 +- metadium/scripts/genesis-template.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metadium/scripts/deploy-governance.js b/metadium/scripts/deploy-governance.js index c123e2732e06..6fb3534f02a2 100644 --- a/metadium/scripts/deploy-governance.js +++ b/metadium/scripts/deploy-governance.js @@ -100,7 +100,7 @@ var GovernanceDeployer = new function() { from: this.from, data: data, gas: this.gas, - gasPrice: this.gasPrice + gasPrice: this.gasPrice, nonce: this.nonce() } var stx = offlineWalletSignTx(this.wallet.id, tx, eth.chainId()) diff --git a/metadium/scripts/genesis-template.json b/metadium/scripts/genesis-template.json index 60fcbd83a1c5..6086ba653c9d 100644 --- a/metadium/scripts/genesis-template.json +++ b/metadium/scripts/genesis-template.json @@ -20,7 +20,7 @@ "homesteadBlock": 0, "eip150Block": 0, "eip155Block": 0, - "eip158Block": 0 + "eip158Block": 0, "byzantiumBlock": 0, "constantinopleBlock": 0, "istanbulBlock": 0, From 3a164c8d2a5dac501986be3cf354dd7a104a87c9 Mon Sep 17 00:00:00 2001 From: lukepark Date: Tue, 3 May 2022 14:54:42 +0900 Subject: [PATCH 4/8] feat: etcd compact --- metadium/admin.go | 4 ++++ metadium/etcdutil.go | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/metadium/admin.go b/metadium/admin.go index 9bf6289bf822..4933bffef97a 100644 --- a/metadium/admin.go +++ b/metadium/admin.go @@ -1101,6 +1101,10 @@ func LogBlock(height int64, hash common.Hash) { "height", height, "hash", hash, "took", time.Since(tstart)) } + // + // TODO: etcd_compact + // + admin.blocksMined++ height++ if admin.blocksMined >= admin.blocksPer && diff --git a/metadium/etcdutil.go b/metadium/etcdutil.go index bfa563c46e43..5d5c83967d3b 100644 --- a/metadium/etcdutil.go +++ b/metadium/etcdutil.go @@ -444,6 +444,21 @@ func (ma *metaAdmin) etcdLeader(locked bool) (uint64, *metaNode) { return 0, nil } +func (ma *metaAdmin) etcdCompact(rev int64) error { + if !ma.etcdIsRunning() { + return ErrNotRunning + } + + ctx, cancel := context.WithTimeout(context.Background(), + ma.etcd.Server.Cfg.ReqTimeout()) + defer cancel() + _, err := ma.etcdCli.Compact(ctx, rev) + // TODO + // * go-routine at admin.go#L1096 + // * options: physical true? false? + return err +} + func (ma *metaAdmin) etcdPut(key, value string) error { if !ma.etcdIsRunning() { return ErrNotRunning From 01a5884913daaebd3ed889f6b80d57c284ce6d91 Mon Sep 17 00:00:00 2001 From: lukepark Date: Fri, 6 May 2022 10:01:50 +0900 Subject: [PATCH 5/8] feat: applying etcdCompact at admin.go --- metadium/admin.go | 14 +++++++++----- metadium/etcdutil.go | 17 +++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/metadium/admin.go b/metadium/admin.go index 4933bffef97a..2c76fc3a695e 100644 --- a/metadium/admin.go +++ b/metadium/admin.go @@ -1093,17 +1093,21 @@ func LogBlock(height int64, hash common.Hash) { } tstart := time.Now() - if err := admin.etcdPut("metadium-work", string(work)); err != nil { + rev, err := admin.etcdPut("metadium-work", string(work)) + if err != nil { log.Error("Metadium - failed to log the latest block", "height", height, "hash", hash, "took", time.Since(tstart)) } else { log.Info("Metadium - logged the latest block", "height", height, "hash", hash, "took", time.Since(tstart)) - } - // - // TODO: etcd_compact - // + if rev%100 == 0 { + if err := admin.etcdCompact(rev); err != nil { + log.Error("Metadium - failed to compact", + "rev", rev, "took", time.Since(tstart)) + } + } + } admin.blocksMined++ height++ diff --git a/metadium/etcdutil.go b/metadium/etcdutil.go index 5d5c83967d3b..2b20fc3e43e5 100644 --- a/metadium/etcdutil.go +++ b/metadium/etcdutil.go @@ -14,6 +14,7 @@ import ( "strings" "time" + "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/embed" "github.com/coreos/etcd/etcdserver/api/membership" "github.com/coreos/etcd/etcdserver/api/v3client" @@ -452,23 +453,23 @@ func (ma *metaAdmin) etcdCompact(rev int64) error { ctx, cancel := context.WithTimeout(context.Background(), ma.etcd.Server.Cfg.ReqTimeout()) defer cancel() - _, err := ma.etcdCli.Compact(ctx, rev) - // TODO - // * go-routine at admin.go#L1096 - // * options: physical true? false? + _, err := ma.etcdCli.Compact(ctx, rev, clientv3.WithCompactPhysical()) + // WithCompactPhysical makes Compact wait until all compacted entries are + // removed from the etcd server's storage. return err } -func (ma *metaAdmin) etcdPut(key, value string) error { +func (ma *metaAdmin) etcdPut(key, value string) (int64, error) { if !ma.etcdIsRunning() { - return ErrNotRunning + return 0, ErrNotRunning } ctx, cancel := context.WithTimeout(context.Background(), ma.etcd.Server.Cfg.ReqTimeout()) defer cancel() - _, err := ma.etcdCli.Put(ctx, key, value) - return err + // _, err := ma.etcdCli.Put(ctx, key, value) + resp, err := ma.etcdCli.Put(ctx, key, value) + return resp.Header.Revision, err } func (ma *metaAdmin) etcdGet(key string) (string, error) { From 98c2e8a98de2c5e6f4045b225ecf1516f2f464a4 Mon Sep 17 00:00:00 2001 From: lukepark Date: Fri, 6 May 2022 10:04:53 +0900 Subject: [PATCH 6/8] feat: variabalize etcdCompact period --- metadium/admin.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metadium/admin.go b/metadium/admin.go index 2c76fc3a695e..3f17d31ef081 100644 --- a/metadium/admin.go +++ b/metadium/admin.go @@ -103,6 +103,8 @@ var ( ErrNotRunning = errors.New("Not Running") ErrAlreadyRunning = errors.New("Already Running") + + etcdCompactFrequency = int64(100) ) func (n *metaNode) eq(m *metaNode) bool { @@ -1101,7 +1103,7 @@ func LogBlock(height int64, hash common.Hash) { log.Info("Metadium - logged the latest block", "height", height, "hash", hash, "took", time.Since(tstart)) - if rev%100 == 0 { + if rev%etcdCompactFrequency == 0 { if err := admin.etcdCompact(rev); err != nil { log.Error("Metadium - failed to compact", "rev", rev, "took", time.Since(tstart)) From 2d417966f247e1448093a515c2fabd30798f57fa Mon Sep 17 00:00:00 2001 From: lukepark Date: Fri, 6 May 2022 10:16:53 +0900 Subject: [PATCH 7/8] feat: applying goroutine --- metadium/admin.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/metadium/admin.go b/metadium/admin.go index 3f17d31ef081..43dc0590bda9 100644 --- a/metadium/admin.go +++ b/metadium/admin.go @@ -1104,10 +1104,12 @@ func LogBlock(height int64, hash common.Hash) { "height", height, "hash", hash, "took", time.Since(tstart)) if rev%etcdCompactFrequency == 0 { - if err := admin.etcdCompact(rev); err != nil { - log.Error("Metadium - failed to compact", - "rev", rev, "took", time.Since(tstart)) - } + go func() { + if err := admin.etcdCompact(rev); err != nil { + log.Error("Metadium - failed to compact", + "rev", rev, "took", time.Since(tstart)) + } + }() } } From 35eed4a3592813303227d26975f91b808c5e7a88 Mon Sep 17 00:00:00 2001 From: lukepark Date: Fri, 6 May 2022 10:31:37 +0900 Subject: [PATCH 8/8] feat: keep last 100 revs --- metadium/admin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadium/admin.go b/metadium/admin.go index 43dc0590bda9..5787eaafa1c4 100644 --- a/metadium/admin.go +++ b/metadium/admin.go @@ -1103,7 +1103,7 @@ func LogBlock(height int64, hash common.Hash) { log.Info("Metadium - logged the latest block", "height", height, "hash", hash, "took", time.Since(tstart)) - if rev%etcdCompactFrequency == 0 { + if (rev%etcdCompactFrequency == 0) && (rev > 100) { go func() { if err := admin.etcdCompact(rev); err != nil { log.Error("Metadium - failed to compact",