Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hip30 : localnet account migration fix #4508

Merged
merged 63 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
ea6e75a
flags: set up preimage flags
MaxMustermann2 Aug 23, 2023
b419e2f
hip30: set up preimage import, export, api
MaxMustermann2 Aug 26, 2023
d398e50
save pre-images by default
MaxMustermann2 Aug 26, 2023
97d2c06
add pre images api
MaxMustermann2 Aug 26, 2023
27b70ac
goimports
MaxMustermann2 Aug 26, 2023
20ae554
commit rpc preimages file
MaxMustermann2 Aug 26, 2023
7fae8e8
preimages: re-generate them using CLI
MaxMustermann2 Aug 26, 2023
35b0fac
add metrics and numbers for pre-images
MaxMustermann2 Aug 26, 2023
745111e
automate generation after import
MaxMustermann2 Aug 26, 2023
b9a7ba2
move from rpc to core
MaxMustermann2 Aug 26, 2023
3502603
goimports
MaxMustermann2 Aug 26, 2023
78f50b1
add back core/preimages.go file
MaxMustermann2 Aug 26, 2023
d1a7776
HIP-30: sharding configuration boilerplate
MaxMustermann2 Aug 26, 2023
c18d6c4
update comments
MaxMustermann2 Aug 26, 2023
6726974
goimports
MaxMustermann2 Aug 26, 2023
d7bd483
HIP-30: minimum validator commission of 7%
MaxMustermann2 Aug 26, 2023
41e911a
goimports
MaxMustermann2 Aug 26, 2023
a5f41ae
HIP-30: Emission split implementation
MaxMustermann2 Aug 26, 2023
e99fb7e
set up mainnet recipient of emission split
MaxMustermann2 Aug 26, 2023
ceda543
HIP-30: Emission split addresses for non mainnet
MaxMustermann2 Aug 26, 2023
4b78692
HIP-30: deactivate shard 2 and 3 validators
MaxMustermann2 Aug 26, 2023
157f5df
goimports
MaxMustermann2 Aug 26, 2023
f97504c
Merge branch 'hip30-shard-reduction' into hip30-balance-migration
MaxMustermann2 Aug 26, 2023
c3ca02f
update test
MaxMustermann2 Aug 26, 2023
f9bebe0
Merge branch 'hip30-boilerplate'
MaxMustermann2 Aug 26, 2023
0ed76aa
Merge branch 'hip30-boilerplate'
MaxMustermann2 Aug 26, 2023
72e035a
goimports
MaxMustermann2 Aug 26, 2023
149c85c
Merge branch 'hip30-preimages'
MaxMustermann2 Aug 26, 2023
676a4b1
migrate balance uring epoch T - 1
MaxMustermann2 Aug 26, 2023
f0cfd83
update test
MaxMustermann2 Aug 26, 2023
84eab4d
Merge branch 'hip30-min-commission'
MaxMustermann2 Aug 26, 2023
b18118f
export prometheus metric when no error importing preimage
sophoah Sep 4, 2023
db7c246
add comment
sophoah Sep 5, 2023
a85deac
Merge branch 'dev' into hip30-balance-migration
sophoah Sep 5, 2023
486543c
test account migration in localnet
sophoah Sep 5, 2023
80715ae
add preimages flags to rootflags
sophoah Sep 7, 2023
142e4a4
Merge branch 'hip30-preimages' into hip30-account-migration
sophoah Sep 7, 2023
dddaa0f
enable preimages on the whitelist
diego1q2w Sep 8, 2023
5f609f7
add the generate method
diego1q2w Sep 8, 2023
d07cd9a
fix cropping log
diego1q2w Sep 8, 2023
66cabb4
fix cropping log
diego1q2w Sep 8, 2023
65a2ce5
cropping startpoint when bigger than endpoint
diego1q2w Sep 8, 2023
79c3695
add support for the rpcblocknumer type
diego1q2w Sep 8, 2023
2cc35e1
enable import api
diego1q2w Sep 8, 2023
5232a9e
use earlies block
diego1q2w Sep 15, 2023
cb07954
debug logs
diego1q2w Sep 15, 2023
98c4eac
debug logs
diego1q2w Sep 15, 2023
acc21e0
debug logs
diego1q2w Sep 15, 2023
36bbf47
debug logs
diego1q2w Sep 15, 2023
620df0f
fix error catching
diego1q2w Sep 15, 2023
2c37801
fix error catching
diego1q2w Sep 15, 2023
aca5a56
make end optional for the comand line
diego1q2w Sep 15, 2023
be97bd8
fix cropping logic
diego1q2w Sep 16, 2023
2f9103f
improve error when apply message fails
diego1q2w Sep 17, 2023
edb9c86
add balance on the error
diego1q2w Sep 17, 2023
8c5048f
Merge branch 'hip30/testing' into hip30-balance-migration
diego1q2w Sep 18, 2023
a09708e
fix importing
diego1q2w Sep 18, 2023
cba5611
remove unused imports
diego1q2w Sep 18, 2023
bedc155
create preimage for genesis block
sophoah Sep 18, 2023
e43d97e
fix consensus with No Migration Possible
sophoah Sep 18, 2023
809ce39
use correct header for migration
sophoah Sep 18, 2023
b76dcb5
process all tx in all block for non shard 0
sophoah Sep 18, 2023
fc4ce72
Merge branch 'hip30-localtest' into hip30/testing
sophoah Sep 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"strings"

"github.com/ethereum/go-ethereum/common"
ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/crypto"
Expand Down Expand Up @@ -252,6 +253,12 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
for key, value := range account.Storage {
statedb.SetState(addr, key, value)
}
//statedb.AddPreimage(crypto.Keccak256Hash((addr[:])), addr.Bytes()[:])
rawdb.WritePreimages(
statedb.Database().DiskDB(), map[ethCommon.Hash][]byte{
crypto.Keccak256Hash((addr.Bytes())): addr.Bytes(),
},
)
}
root := statedb.IntermediateRoot(false)
shardStateBytes, err := shard.EncodeWrapper(g.ShardState, false)
Expand Down
2 changes: 0 additions & 2 deletions core/preimages.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"os"
"strconv"

"github.com/ethereum/go-ethereum/crypto"

ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/harmony-one/harmony/api/service/prometheus"
Expand Down
14 changes: 4 additions & 10 deletions core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (p *StateProcessor) Process(
// ran out of accounts
processTxsAndStxs = false
}
if !errors.Is(err, ErrNoMigrationRequired) {
if !errors.Is(err, ErrNoMigrationRequired) && !errors.Is(err, ErrNoMigrationPossible) {
return nil, nil, nil, nil, 0, nil, statedb, err
}
} else {
Expand Down Expand Up @@ -576,13 +576,9 @@ func MayBalanceMigration(
if isDevnet || isLocalnet {
if config.IsOneEpochBeforeHIP30(header.Epoch()) {
if myShard := chain.ShardID(); myShard != shard.BeaconChainShardID {
parent := chain.GetBlockByHash(
parentRoot := chain.GetBlockByHash(
header.ParentHash(),
)
if parent == nil {
return nil, errors.Wrap(ErrNoMigrationPossible, "parent is nil")
}
parentRoot := parent.Root()
).Root() // for examining MPT at this root, should exist
// for examining MPT at this root, should exist
cx, err := generateOneMigrationMessage(
db, parentRoot,
Expand Down Expand Up @@ -641,13 +637,11 @@ func generateOneMigrationMessage(
key := accountIterator.LeafKey()
preimage := rawdb.ReadPreimage(db, common.BytesToHash(key))
if len(preimage) == 0 {
e := errors.New(
return nil, errors.New(
fmt.Sprintf(
"cannot find preimage for %x", key,
),
)
fmt.Println(e)
continue
}
address := common.BytesToAddress(preimage)
// skip blank address
Expand Down
4 changes: 2 additions & 2 deletions internal/configs/sharding/localnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const (
localnetV1Epoch = 1

localnetEpochBlock1 = 5
localnetBlocksPerEpoch = 8
localnetBlocksPerEpochV2 = 8
localnetBlocksPerEpoch = 64
localnetBlocksPerEpochV2 = 64

localnetVdfDifficulty = 5000 // This takes about 10s to finish the vdf
)
Expand Down
1 change: 1 addition & 0 deletions node/node_newblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func (node *Node) ProposeNewBlock(commitSigs chan []byte) (*types.Block, error)
}
}

// Execute all the time except for last block of epoch for shard 0
if !shard.Schedule.IsLastBlock(header.Number().Uint64()) || node.Consensus.ShardID != 0 {
// Prepare normal and staking transactions retrieved from transaction pool
utils.AnalysisStart("proposeNewBlockChooseFromTxnPool")
Expand Down
4 changes: 1 addition & 3 deletions rpc/preimages.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package rpc

import (
"context"
"fmt"

"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/eth/rpc"
Expand All @@ -24,8 +23,7 @@ func NewPreimagesAPI(hmy *hmy.Harmony, version string) rpc.API {
}
}

func (s *PreimagesService) Export(_ context.Context, path string) error {
func (s *PreimagesService) Export(ctx context.Context, path string) error {
// these are by default not blocking
return core.ExportPreimages(s.hmy.BlockChain, path)
}