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
MX-14120: repopulate tokens supplies #5204
MX-14120: repopulate tokens supplies #5204
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## rc/v1.6.0 #5204 +/- ##
=============================================
+ Coverage 79.59% 79.70% +0.10%
=============================================
Files 680 682 +2
Lines 88012 88183 +171
=============================================
+ Hits 70053 70283 +230
+ Misses 12837 12780 -57
+ Partials 5122 5120 -2
☔ View full report in Codecov by Sentry. |
…ies' into MX-14120-repopulate-tokens-supplies
@@ -13,7 +13,7 @@ require ( | |||
github.com/google/gops v0.3.18 | |||
github.com/gorilla/websocket v1.5.0 | |||
github.com/mitchellh/mapstructure v1.5.0 | |||
github.com/multiversx/mx-chain-core-go v1.2.1 | |||
github.com/multiversx/mx-chain-core-go v1.2.2-0.20230428142157-76e19ecd04ac |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proper release after testing
@@ -1227,7 +1228,7 @@ func (nr *nodeRunner) CreateManagedProcessComponents( | |||
ImportStartHandler: importStartHandler, | |||
WorkingDir: configs.FlagsConfig.WorkingDir, | |||
HistoryRepo: historyRepository, | |||
SnapshotsEnabled: configs.FlagsConfig.SnapshotsEnabled, | |||
FlagsConfig: *configs.FlagsConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not pass config by value? I consider this a safer way to pass arguments so no overwriting mistakes will have effects upstream. Also, WorkingDir also uses the configs.FlagsConfig.WorkingDir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is already passed by value. updated the other fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
suffix := append(userLeaf.Key(), userAccount.AddressBytes()...) | ||
value, errVal := userLeaf.ValueWithoutSuffix(suffix) | ||
if errVal != nil { | ||
log.Warn("cannot get value without suffix", "error", errVal, "key", userLeaf.Key()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log & return error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the log and wrapped the error
return err | ||
} | ||
|
||
tokenName := string(tokenKey)[lenESDTPrefix:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we test here that the tokenKey contains the ESDTPrefix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need, since we have this at the beginning of the for
loop:
if !bytes.HasPrefix(userLeaf.Key(), esdtPrefix) {
continue
}
and also this: lenESDTPrefix := len(esdtPrefix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@@ -136,7 +136,10 @@ func (ccf *consensusComponentsFactory) Create() (*consensusComponents, error) { | |||
return nil, err | |||
} | |||
|
|||
cc.bootstrapper.StartSyncingBlocks() | |||
err = cc.bootstrapper.StartSyncingBlocks() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -173,7 +171,6 @@ type processComponentsFactory struct { | |||
txLogsProcessor process.TransactionLogProcessor | |||
version string | |||
importStartHandler update.ImportStartHandler | |||
workingDir string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we removed the workingDir
but not the version
. The code will compile with an empty version string as you delete L221. Let's also remove this field and use the provided version instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very good catch. fixed
@@ -1227,7 +1228,7 @@ func (nr *nodeRunner) CreateManagedProcessComponents( | |||
ImportStartHandler: importStartHandler, | |||
WorkingDir: configs.FlagsConfig.WorkingDir, | |||
HistoryRepo: historyRepository, | |||
SnapshotsEnabled: configs.FlagsConfig.SnapshotsEnabled, | |||
FlagsConfig: *configs.FlagsConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
return err | ||
} | ||
|
||
tokenName := string(tokenKey)[lenESDTPrefix:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
userAcc.SetDataTrie(&trie.TrieStub{ | ||
GetAllLeavesOnChannelCalled: func(leavesChannels *common.TrieIteratorChannels, ctx context.Context, rootHash []byte, keyBuilder common.KeyBuilder) error { | ||
esToken := &esdt.ESDigitalToken{ | ||
Value: big.NewInt(37), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
…ies' into MX-14120-repopulate-tokens-supplies
"github.com/multiversx/mx-chain-go/trie/keyBuilder" | ||
) | ||
|
||
type tokensSuppliesProcessor struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed
tokenIDStr := string(tokenID) | ||
if nonce > 0 { | ||
t.putInSuppliesMap(string(tokenID), value) // put for collection as well | ||
nonceStr := fmt.Sprintf("%d", nonce) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed
nonceStr := fmt.Sprintf("%d", nonce) | |
nonceStr := hex.EncodeToString(big.NewInt(int64(nonce)).Bytes()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,245 @@ | |||
package trieIterators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code coverage can be increased to close to 100% on this package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
96.2% now
go boot.syncBlocks(ctx) | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add new line before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
@@ -12,4 +12,5 @@ message SupplyESDT { | |||
bytes Supply = 1 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; | |||
bytes Burned = 2 [(gogoproto.jsontag) = "burned", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; | |||
bytes Minted = 3 [(gogoproto.jsontag) = "minted", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; | |||
bool RecomputedSupply = 4 [(gogoproto.jsontag) = "RecomputedSupply"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool RecomputedSupply = 4 [(gogoproto.jsontag) = "RecomputedSupply"]; | |
bool RecomputedSupply = 4 [(gogoproto.jsontag) = "recomputedSupply"]; |
to align with the others
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good find. fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System test passed
7029a48
Reasoning behind the pull request
import-db
which could have taken a few days, so we needed a faster mechanism for computing the tokens suppliesProposed changes
--repopulate-tokens-supplies
that will clear the existing supplies database, will iterate over the trie and recompute the supplies and then save them to the dbNOTE: this feature does not compute the
minted
andburned
values. They will be later indexed via the indexerTesting procedure
--repopulate-tokens-supplies
and then compare the supplies obtained by comparing the proxy instances via the/network/esdt/supply/<token>
endpointPre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
feat
branch created?feat
branch merging, do all satellite projects have a proper tag insidego.mod
?