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

Genesis accounts with esdt balances #5871

Merged

Conversation

mariusmihaic
Copy link
Contributor

@mariusmihaic mariusmihaic commented Jan 25, 2024

Reasoning behind the pull request

  • Distribute initial esdt token balances to genesis accounts
  • The ticker for esdt genesis token is found in config
  • Each genesis tx to distribute esdt tokens is executed as a cross shard txs, similar way sovereign chain receives esdt tokens with deposit identifier from main chain

Proposed changes

Testing procedure

DEBUG[2024-01-31 18:43:36.591] [genesis/process]    [0/0/0/]       creating genesis initial esdt balance    address = erd10erltt5dtz8c8wtdjc8rzwkqaxug0zgqcys5v4f69j4603qfep9svkwjat balance = 9997500000000000000000000 tokenID = WEGLD-bd4d79 
DEBUG[2024-01-31 18:43:36.592] [genesis/process]    [0/0/0/]       creating genesis initial esdt balance    address = erd1l3j5va778tusj5mrppfn8pyx2k6hjagcy6aetqd0fyl5kfqcpnfs2fjpna balance = 9997500000000000000000000 tokenID = WEGLD-bd4d79 

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?

@mariusmihaic mariusmihaic self-assigned this Jan 25, 2024
Copy link

codecov bot commented Jan 26, 2024

Codecov Report

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

Comparison is base (aabf75f) 79.38% compared to head (46897e5) 79.41%.
Report is 1 commits behind head on feat/chain-go-sdk.

Files Patch % Lines
genesis/process/sovereignGenesisBlockCreator.go 91.37% 3 Missing and 2 partials ⚠️
genesis/process/shardGenesisBlockCreator.go 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           feat/chain-go-sdk    #5871      +/-   ##
=====================================================
+ Coverage              79.38%   79.41%   +0.02%     
=====================================================
  Files                    790      789       -1     
  Lines                  98473    98514      +41     
=====================================================
+ Hits                   78176    78231      +55     
+ Misses                 14817    14803      -14     
  Partials                5480     5480              

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

@mariusmihaic mariusmihaic changed the base branch from feat/sovereign-esdt-native-payment to feat/chain-go-sdk January 31, 2024 14:06
@mariusmihaic mariusmihaic changed the base branch from feat/chain-go-sdk to feat/sovereign-esdt-native-payment January 31, 2024 14:07
@mariusmihaic mariusmihaic changed the base branch from feat/sovereign-esdt-native-payment to feat/chain-go-sdk January 31, 2024 16:36
@mariusmihaic mariusmihaic marked this pull request as ready for review January 31, 2024 16:39
@@ -55,8 +62,27 @@ func (gbc *sovereignGenesisBlockCreator) CreateGenesisBlocks() (map[uint32]data.
return gbc.createSovereignHeaders(argsCreateBlock)
}

func (gbc *sovereignGenesisBlockCreator) initGenesisAccounts() error {
acc, err := gbc.arg.Accounts.LoadAccount(core.SystemAccountAddress)
Copy link
Contributor

Choose a reason for hiding this comment

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

why are you loading and saving the same accounts without any changes ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is mandatory at genesis to have accounts initialized.

@@ -77,6 +103,12 @@ func (gbc *sovereignGenesisBlockCreator) createSovereignEmptyGenesisBlocks() (ma
return mapEmptyGenesisBlocks, nil
}

func createSovereignGenesisConfig() config.EnableEpochs {
cfg := createGenesisConfig()
cfg.ESDTMultiTransferEnableEpoch = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could return error if the config is wrong. instead of setting it to 0 here.

Copy link
Contributor Author

@mariusmihaic mariusmihaic Feb 19, 2024

Choose a reason for hiding this comment

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

This is not the loaded config from config.toml.
This is a "mocked" created config for sovereign bootStrapping at genesis.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we'll make the chain start correctly with every flag on epoch 0, we should also change this mocked config to return everything with enable epoch 0 as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add a task for this

…esdt-tokens

# Conflicts:
#	genesis/process/sovereignGenesisBlockCreator.go
#	genesis/process/sovereignGenesisBlockCreator_test.go
@mariusmihaic mariusmihaic merged commit c3189a3 into feat/chain-go-sdk Feb 19, 2024
7 checks passed
@mariusmihaic mariusmihaic deleted the MX-15080-genesis-accounts-with-esdt-tokens branch February 19, 2024 14:07
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.

3 participants