-
Notifications
You must be signed in to change notification settings - Fork 204
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
Feat/pubkeyconverter_refactor #4716
Conversation
…h32_addresses_format
Merge rcv1.5.0 2022.12.08 to pubkeyconvert-refactor
…h32_addresses_format
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## rc/v1.6.0 #4716 +/- ##
============================================
Coverage ? 70.89%
============================================
Files ? 675
Lines ? 87614
Branches ? 0
============================================
Hits ? 62118
Misses ? 20827
Partials ? 4669 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
…v_23feb merge rc/v1.6.0 in pubkeyConverter
Merge branch 'rc/v1.6.0' into feat/pubkey_conv
…3.10 # Conflicts: # cmd/keygenerator/converter/errors.go # cmd/keygenerator/converter/pidPubkeyConverter.go # cmd/keygenerator/converter/pidPubkeyConverter_test.go # cmd/keygenerator/main.go # common/enablers/enableEpochsHandler.go # common/factory/pubkeyConverterFactory.go # config/tomlConfig_test.go # examples/construction_test.go # factory/addressDecoder_test.go # factory/crypto/cryptoComponents.go # genesis/checking/nodesSetupChecker.go # genesis/checking/nodesSetupChecker_test.go # genesis/parsing/accountsParser.go # genesis/parsing/accountsParser_test.go # go.mod # go.sum # integrationTests/consensus/consensus_test.go # integrationTests/frontend/wallet/dataField_test.go # integrationTests/multiShard/txScenarios/moveBalance_test.go # integrationTests/testConsensusNode.go # integrationTests/vm/txsFee/scCalls_test.go # node/external/nodeApiResolver.go # node/external/transactionAPI/apiTransactionProcessor.go # node/external/transactionAPI/apiTransactionProcessor_test.go # node/external/transactionAPI/apiTransactionResults.go # node/external/transactionAPI/gasUsedAndFeeProcessor_test.go # node/external/transactionAPI/unmarshaller.go # node/external/transactionAPI/unmarshaller_test.go # node/trieIterators/delegatedListProcessor_test.go # node/trieIterators/directStakedListProcessor.go # node/trieIterators/directStakedListProcessor_test.go # node/trieIterators/factory/delegatedListHandlerFactory_test.go # node/trieIterators/factory/directStakedListHandlerFactory_test.go # node/trieIterators/factory/stakeValuesHandlerFactory_test.go # node/trieIterators/stakeValuesProcessor_test.go # outport/factory/outportFactory_test.go # outport/process/alteredaccounts/alteredAccountsProvider.go # outport/process/transactionsfee/transactionsFeeProcessor.go # outport/process/transactionsfee/transactionsFeeProcessor_test.go # process/block/postprocess/intermediateResults_test.go # process/block/preprocess/transactions_test.go # process/dataValidators/txValidator.go # process/factory/metachain/intermediateProcessorsContainerFactory_test.go # process/peer/validatorsProvider_test.go # process/rewardTransaction/interceptedRewardTransaction_test.go # process/smartContract/process.go # process/txsimulator/txSimulator.go # process/unsigned/interceptedUnsignedTransaction_test.go # testscommon/addresses.go # testscommon/integrationtests/stringers.go # testscommon/integrationtests/stringers_test.go # update/genesis/export_test.go # vm/systemSmartContracts/esdt_test.go
…conv-2023.03.10 Merge rc v1.6.0 feat pubkey conv 2023.03.10
go.mod
Outdated
@@ -13,13 +13,13 @@ 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.1.35 | |||
github.com/multiversx/mx-chain-core-go v1.1.36-0.20230308081722-5262fb09cb9a |
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 releases before merging
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.
immediately after review and system test 👍
@@ -41,6 +41,7 @@ const minedWalletPrefixKeys = "mined-wallet" | |||
const nopattern = "nopattern" | |||
const desiredpattern = "[0-f]+" | |||
const noshard = -1 | |||
const pubkeyHrp = "erd" |
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.
In the future, this can be received as a command line parameter.
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.
noted
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.
...or a config defined in config.toml file
state/syncer/userAccountsSyncer.go
Outdated
@@ -288,9 +288,9 @@ func (u *userAccountsSyncer) printDataTrieStatistics() { | |||
}) | |||
|
|||
for _, trieStat := range u.largeTries { | |||
address := u.pubkeyCoverter.Encode(trieStat.address) | |||
trieStatAddress := u.pubkeyCoverter.SilentEncode(trieStat.address, log) |
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.
Previous name is better (address
).
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.
changed
process/smartContract/process.go
Outdated
@@ -1800,11 +1800,15 @@ func (sc *scProcessor) printScDeployed(vmOutput *vmcommon.VMOutput, tx data.Tran | |||
continue | |||
} | |||
|
|||
scGenerated = append(scGenerated, sc.pubkeyConv.Encode(addr)) | |||
scAddress := sc.pubkeyConv.SilentEncode(addr, log) | |||
|
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.
Empty line is not necessary here.
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.
deleted
process/smartContract/process.go
Outdated
log.Debug("SmartContract deployed", | ||
"owner", sc.pubkeyConv.Encode(tx.GetSndAddr()), | ||
"owner", encodedSndAddr, |
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.
In the log on line 432, the encoding is "in-lined". Perhaps do the same here, we well?
Or, instead, perhaps rename variable to ownerAddress
?
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.
changed
node/node_test.go
Outdated
@@ -875,7 +876,7 @@ func TestNode_GetAllESDTTokensShouldReturnEsdtAndFormattedNft(t *testing.T) { | |||
tokens, _, err := n.GetAllESDTTokens(testscommon.TestAddressAlice, api.AccountQueryOptions{}, context.Background()) | |||
assert.Nil(t, err) | |||
assert.Equal(t, 2, len(tokens)) | |||
assert.Equal(t, esdtData, tokens[esdtToken]) | |||
assert.Equal(t, esdtData, tokens["TKKR-7q8w9e-"]) |
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.
I am not sure what happened here.
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.
reverted in the next PR :D
converter, _ := pubkeyConverter.NewBech32PubkeyConverter(32, "erd") | ||
|
||
receiverAddress, _ := converter.Encode(tx.RcvAddr) | ||
|
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.
Empty lines not strictly necessary here.
Events: events, | ||
} | ||
} | ||
|
||
func (converter *logsConverter) encodeAddress(pubkey []byte) string { | ||
return converter.pubKeyConverter.Encode(pubkey) | ||
return converter.pubKeyConverter.SilentEncode(pubkey, log) |
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.
👍
leaderPK := core.GetTrimmedPk(vs.pubkeyConv.Encode(consensusGroup[0].PubKey())) | ||
|
||
encodedLeaderPk := vs.pubkeyConv.SilentEncode(consensusGroup[0].PubKey(), log) | ||
|
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.
Empty line is not necessary, I think.
return nil, nil | ||
} | ||
|
||
metaDataCreatorAddr, err := aap.addressConverter.Encode(metaData.Creator) |
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.
Are we sure this should not be a silent encode? CC: @bogdan-rosianu.
@@ -96,8 +96,13 @@ func (dlp *delegatedListProcessor) getDelegatorsInfo(delegationSC []byte, delega | |||
|
|||
delegatorInfo, ok := delegatorsMap[string(delegatorAddress)] | |||
if !ok { | |||
encodedDelegatorAddress, err := dlp.publicKeyConverter.Encode(delegatorAddress) |
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.
Are we sure we don't need silent encode in this file, instead?
Fix after review pubkeyconverter
Merge branch 'rc/v1.6.0' into pubkey_15Mar
# Conflicts: # go.mod # go.sum # outport/process/transactionsfee/transactionsFeeProcessor_test.go
…bkeyconv-mar15 Merge rc/v1.6.0 into feat/pubkeyconv mar15
update core-go, vm-common-go, indexer-go versions
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
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.
go.mod looks ok 👌
Reasoning behind the pull request
The original implementation of the
pidPubkeyConverter.Encode
method did not propagate the error to its caller. Instead, it logged the error and returned an empty string. This behavior can be problematic as it might hide potential issues and security threats. Furthermore, the logger's presence in thePubKeyConverter
constructor became unnecessary, therefore thehrp
was given as input, especially considering our vision for sovereign shards where each shard could have its unique human-readable part (hrp
).Proposed changes
pidPubkeyConverter.Encode
method by returning both a string and an error.PubKeyConverter
constructor;NewPubKeyConverter
constructor is used;Testing procedure
Pre-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
?