From e1338060ad3991543d6f3d9b6a481454dbc75f75 Mon Sep 17 00:00:00 2001 From: Soph <35721420+sophoah@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:34:18 +0700 Subject: [PATCH 1/4] add hip30 testing for devnet/partner network (#4525) --- core/state_processor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/state_processor.go b/core/state_processor.go index bed7bbf1b..544ac0bc2 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -569,7 +569,7 @@ func MayBalanceMigration( } } // for testing balance migration on devnet - isDevnet := nodeconfig.GetDefaultConfig().GetNetworkType() == nodeconfig.Devnet + isDevnet := nodeconfig.GetDefaultConfig().GetNetworkType() == nodeconfig.Partner isLocalnet := nodeconfig.GetDefaultConfig().GetNetworkType() == nodeconfig.Localnet if isDevnet || isLocalnet { if config.IsOneEpochBeforeHIP30(header.Epoch()) { From d2743d9cc86ea8e3314fb64dac12d69aedf5bddc Mon Sep 17 00:00:00 2001 From: Diego Nava <8563843+diego1q2w@users.noreply.github.com> Date: Wed, 11 Oct 2023 10:42:43 +0200 Subject: [PATCH 2/4] enable hip30 epoch for testnet (#4526) * enable hip30 epoch for testnet * fix date comment * set blockgas30M epoch --- core/state_processor.go | 4 +++- internal/params/config.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/state_processor.go b/core/state_processor.go index 544ac0bc2..6ea9e244a 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -568,10 +568,12 @@ func MayBalanceMigration( } } } + // for testing balance migration on testnet + isTestnet := nodeconfig.GetDefaultConfig().GetNetworkType() == nodeconfig.Testnet // for testing balance migration on devnet isDevnet := nodeconfig.GetDefaultConfig().GetNetworkType() == nodeconfig.Partner isLocalnet := nodeconfig.GetDefaultConfig().GetNetworkType() == nodeconfig.Localnet - if isDevnet || isLocalnet { + if isDevnet || isLocalnet || isTestnet { if config.IsOneEpochBeforeHIP30(header.Epoch()) { if myShard := chain.ShardID(); myShard != shard.BeaconChainShardID { parentRoot := chain.GetBlockByHash( diff --git a/internal/params/config.go b/internal/params/config.go index afdf92b5b..dd795183e 100644 --- a/internal/params/config.go +++ b/internal/params/config.go @@ -116,8 +116,8 @@ var ( LeaderRotationExternalBeaconLeaders: EpochTBD, FeeCollectEpoch: big.NewInt(1296), // 2023-04-28 07:14:20+00:00 ValidatorCodeFixEpoch: big.NewInt(1296), // 2023-04-28 07:14:20+00:00 - HIP30Epoch: EpochTBD, - BlockGas30MEpoch: EpochTBD, + HIP30Epoch: big.NewInt(2176), // 2023-10-12 10:00:00+00:00 + BlockGas30MEpoch: big.NewInt(2176), // 2023-10-12 10:00:00+00:00 } // PangaeaChainConfig contains the chain parameters for the Pangaea network. // All features except for CrossLink are enabled at launch. From 88e033af4f8487a5221c8c313a7b2697f452a494 Mon Sep 17 00:00:00 2001 From: Diego Nava <8563843+diego1q2w@users.noreply.github.com> Date: Wed, 11 Oct 2023 10:43:12 +0200 Subject: [PATCH 3/4] enable hip30 and gas30m epoch for mainnet (#4528) --- internal/params/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/params/config.go b/internal/params/config.go index dd795183e..a9aa715d1 100644 --- a/internal/params/config.go +++ b/internal/params/config.go @@ -73,8 +73,8 @@ var ( LeaderRotationExternalBeaconLeaders: EpochTBD, FeeCollectEpoch: big.NewInt(1535), // 2023-07-20 05:51:07+00:00 ValidatorCodeFixEpoch: big.NewInt(1535), // 2023-07-20 05:51:07+00:00 - HIP30Epoch: EpochTBD, - BlockGas30MEpoch: EpochTBD, + HIP30Epoch: big.NewInt(1673), // 2023-11-02 17:30:00+00:00 + BlockGas30MEpoch: big.NewInt(1673), // 2023-11-02 17:30:00+00:00 } // TestnetChainConfig contains the chain parameters to run a node on the harmony test network. From b143085c2d34c99114c13b0c70b816eb451b0fad Mon Sep 17 00:00:00 2001 From: Diego Nava <8563843+diego1q2w@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:51:29 +0200 Subject: [PATCH 4/4] fix preimage import bugs (#4529) * fix preimage import bugs * fix typo --- core/preimages.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/preimages.go b/core/preimages.go index 8605271a7..5034cc0e9 100644 --- a/core/preimages.go +++ b/core/preimages.go @@ -17,6 +17,7 @@ import ( "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/internal/utils" "github.com/pkg/errors" + "github.com/syndtr/goleveldb/leveldb" ) // ImportPreimages is public so `main.go` can call it directly` @@ -42,7 +43,9 @@ func ImportPreimages(chain BlockChain, path string) error { // set this value in database, and prometheus, if needed prev, err := rawdb.ReadPreimageImportBlock(dbReader) if err != nil { - return fmt.Errorf("no prior value found, overwriting: %s", err) + if !errors.Is(err, leveldb.ErrNotFound) { + return fmt.Errorf("no prior value found, overwriting: %s", err) + } } if blockNumber > prev { if rawdb.WritePreimageImportBlock(dbReader, blockNumber) != nil { @@ -230,7 +233,7 @@ func GeneratePreimages(chain BlockChain, start, end uint64) error { if stateAt != nil { if root, err := endingState.Commit(false); err != nil { - return fmt.Errorf("unabe to commit state for block '%d': %w", i, err) + return fmt.Errorf("unable to commit state for block '%d': %w", i, err) } else if root.Hex() != block.Root().Hex() { return fmt.Errorf("block root hashes different after commit commitRoot='%s' blockRoot='%s'", root.Hex(), block.Root().Hex()) } @@ -245,10 +248,11 @@ func GeneratePreimages(chain BlockChain, start, end uint64) error { } // force any pre-images in memory so far to go to disk, if they haven't already fmt.Println("committing images") - if _, err := endingState.Commit(false); err != nil { - return fmt.Errorf("unabe to commit state for block: %w", err) + if endingState != nil { + if _, err := endingState.Commit(false); err != nil { + return fmt.Errorf("unable to commit state for block: %w", err) + } } - if err := chain.CommitPreimages(); err != nil { return fmt.Errorf("error committing preimages %s", err) }