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

Initial wallet keys #5709

Merged
merged 3 commits into from Nov 16, 2023
Merged

Conversation

miiu96
Copy link
Contributor

@miiu96 miiu96 commented Nov 15, 2023

Reasoning behind the pull request

  • When the chain simulator starts will generate genesis addresses with balance for every shard
  • Small refactoring ( removed testdata package)

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

@miiu96 miiu96 self-assigned this Nov 15, 2023
@sstanculeanu sstanculeanu self-requested a review November 15, 2023 09:46
Copy link

codecov bot commented Nov 15, 2023

Codecov Report

Attention: 71 lines in your changes are missing coverage. Please review.

Comparison is base (15f81f1) 78.89% compared to head (af0fd9f) 78.88%.
Report is 2 commits behind head on feat/test-only-processor-node.

❗ Current head af0fd9f differs from pull request most recent head 5d3fbef. Consider uploading reports for the commit 5d3fbef to get more accurate results

Files Patch % Lines
node/chainSimulator/configs/configs.go 0.00% 69 Missing ⚠️
node/chainSimulator/chainSimulator.go 75.00% 2 Missing ⚠️
Additional details and impacted files
@@                        Coverage Diff                        @@
##           feat/test-only-processor-node    #5709      +/-   ##
=================================================================
- Coverage                          78.89%   78.88%   -0.01%     
=================================================================
  Files                                729      729              
  Lines                              95721    95769      +48     
=================================================================
+ Hits                               75516    75551      +35     
- Misses                             14846    14859      +13     
  Partials                            5359     5359              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

sstanculeanu
sstanculeanu previously approved these changes Nov 15, 2023
ShardWallets: make(map[uint32]*dtos.WalletKey),
}

initialAddressWithStake, err := generateWalletKeyForShard(0, args.NumOfShards, addressConverter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might extract the 0 into a const. Something like: walletShardIdForStake

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

}

balanceForAddress := big.NewInt(0).Set(walletBalance)
if shardID == args.NumOfShards-1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be taken out of the for loop and moved after the for finishes:

firstShardBalance := initialWalletKeys.ShardWallets[0].Balance
firstShardBalance.Add(firstShardBalance, remainder)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored


return &dtos.WalletKey{
Address: address,
PrivateKeyHex: hex.EncodeToString(privateKeyBytes[:32]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the trim really necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because the part[32:len(privateKeyBytes]contains the public key bytes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it doesn't matter, anyway

}

// InitialWalletKeys holds the initial wallet keys
type InitialWalletKeys struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

sstanculeanu
sstanculeanu previously approved these changes Nov 15, 2023
})

initialWalletKeys.ShardWallets[shardID] = walletKey
}

addresses[1].Balance.Add(walletBalance, remainder)
addresses[1].Supply.Add(walletBalance, remainder)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@miiu96 miiu96 merged commit fa60054 into feat/test-only-processor-node Nov 16, 2023
5 checks passed
@miiu96 miiu96 deleted the initial-wallet-keys branch November 16, 2023 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants