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

Fix after review pubkeyconverter #5098

Merged
merged 3 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 0 additions & 9 deletions cmd/keygenerator/converter/pidPubkeyConverter.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package converter

import (
"encoding/hex"
"runtime/debug"

crypto "github.com/multiversx/mx-chain-crypto-go"
"github.com/multiversx/mx-chain-crypto-go/signing"
"github.com/multiversx/mx-chain-crypto-go/signing/secp256k1"
Expand Down Expand Up @@ -36,12 +33,6 @@ func (converter *pidPubkeyConverter) Decode(_ string) ([]byte, error) {
func (converter *pidPubkeyConverter) Encode(pkBytes []byte) (string, error) {
pidString, err := converter.encode(pkBytes)
if err != nil {
log.Warn("pidPubkeyConverter.Encode encode",
"hex buff", hex.EncodeToString(pkBytes),
"error", err,
"stack trace", string(debug.Stack()),
)

return "", err
}

Expand Down
Binary file removed cmd/node/node
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Binary file not shown.
65 changes: 65 additions & 0 deletions config/tomlConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,143 +493,208 @@ func TestEnableEpochConfig(t *testing.T) {
[EnableEpochs]
# SCDeployEnableEpoch represents the epoch when the deployment of smart contracts will be enabled
SCDeployEnableEpoch = 1

# BuiltInFunctionsEnableEpoch represents the epoch when the built in functions will be enabled
BuiltInFunctionsEnableEpoch = 2

# RelayedTransactionsEnableEpoch represents the epoch when the relayed transactions will be enabled
RelayedTransactionsEnableEpoch = 3

# PenalizedTooMuchGasEnableEpoch represents the epoch when the penalization for using too much gas will be enabled
PenalizedTooMuchGasEnableEpoch = 4

# SwitchJailWaitingEnableEpoch represents the epoch when the system smart contract processing at end of epoch is enabled
SwitchJailWaitingEnableEpoch = 5

# BelowSignedThresholdEnableEpoch represents the epoch when the change for computing rating for validators below signed rating is enabled
BelowSignedThresholdEnableEpoch = 6

# SwitchHysteresisForMinNodesEnableEpoch represents the epoch when the system smart contract changes its config to consider
# also (minimum) hysteresis nodes for the minimum number of nodes
SwitchHysteresisForMinNodesEnableEpoch = 7

# TransactionSignedWithTxHashEnableEpoch represents the epoch when the node will also accept transactions that are
# signed with the hash of transaction
TransactionSignedWithTxHashEnableEpoch = 8

# MetaProtectionEnableEpoch represents the epoch when the transactions to the metachain are checked to have enough gas
MetaProtectionEnableEpoch = 9

# AheadOfTimeGasUsageEnableEpoch represents the epoch when the cost of smart contract prepare changes from compiler per byte to ahead of time prepare per byte
AheadOfTimeGasUsageEnableEpoch = 10

# GasPriceModifierEnableEpoch represents the epoch when the gas price modifier in fee computation is enabled
GasPriceModifierEnableEpoch = 11

# RepairCallbackEnableEpoch represents the epoch when the callback repair is activated for scrs
RepairCallbackEnableEpoch = 12

# BlockGasAndFeesReCheckEnableEpoch represents the epoch when gas and fees used in each created or processed block are re-checked
BlockGasAndFeesReCheckEnableEpoch = 13

# BalanceWaitingListsEnableEpoch represents the epoch when the shard waiting lists are balanced at the start of an epoch
BalanceWaitingListsEnableEpoch = 14

# ReturnDataToLastTransferEnableEpoch represents the epoch when returned data is added to last output transfer for callbacks
ReturnDataToLastTransferEnableEpoch = 15

# SenderInOutTransferEnableEpoch represents the epoch when the feature of having different senders in output transfer is enabled
SenderInOutTransferEnableEpoch = 16

# StakeEnableEpoch represents the epoch when staking is enabled
StakeEnableEpoch = 17

# StakingV2EnableEpoch represents the epoch when staking v2 is enabled
StakingV2EnableEpoch = 18

DoubleKeyProtectionEnableEpoch = 19

# ESDTEnableEpoch represents the epoch when ESDT is enabled
ESDTEnableEpoch = 20

# GovernanceEnableEpoch represents the epoch when governance is enabled
GovernanceEnableEpoch = 21

# DelegationManagerEnableEpoch represents the epoch when the delegation manager is enabled
# epoch should not be 0
DelegationManagerEnableEpoch = 22

# DelegationSmartContractEnableEpoch represents the epoch when delegation smart contract is enabled
# epoch should not be 0
DelegationSmartContractEnableEpoch = 23

# CorrectLastUnjailedEnableEpoch represents the epoch when the fix regaring the last unjailed node should apply
CorrectLastUnjailedEnableEpoch = 24

# RelayedTransactionsV2EnableEpoch represents the epoch when the relayed transactions V2 will be enabled
RelayedTransactionsV2EnableEpoch = 25

# UnbondTokensV2EnableEpoch represents the epoch when the new implementation of the unbond tokens function is available
UnbondTokensV2EnableEpoch = 26

# SaveJailedAlwaysEnableEpoch represents the epoch when saving jailed status at end of epoch will happen in all cases
SaveJailedAlwaysEnableEpoch = 27

# ReDelegateBelowMinCheckEnableEpoch represents the epoch when the check for the re-delegated value will be enabled
ReDelegateBelowMinCheckEnableEpoch = 28

# ValidatorToDelegationEnableEpoch represents the epoch when the validator-to-delegation feature will be enabled
ValidatorToDelegationEnableEpoch = 29

# WaitingListFixEnableEpoch represents the epoch when the 6 epoch waiting list fix is enabled
WaitingListFixEnableEpoch = 30

# IncrementSCRNonceInMultiTransferEnableEpoch represents the epoch when the fix for preventing the generation of the same SCRs
# is enabled. The fix is done by adding an extra increment.
IncrementSCRNonceInMultiTransferEnableEpoch = 31

# ESDTMultiTransferEnableEpoch represents the epoch when esdt multitransfer built in function is enabled
ESDTMultiTransferEnableEpoch = 32

# GlobalMintBurnDisableEpoch represents the epoch when the global mint and burn functions are disabled
GlobalMintBurnDisableEpoch = 33

# ESDTTransferRoleEnableEpoch represents the epoch when esdt transfer role set is enabled
ESDTTransferRoleEnableEpoch = 34

# BuiltInFunctionOnMetaEnableEpoch represents the epoch when built in function processing on metachain is enabled
BuiltInFunctionOnMetaEnableEpoch = 35

# ComputeRewardCheckpointEnableEpoch represents the epoch when compute rewards checkpoint epoch is enabled
ComputeRewardCheckpointEnableEpoch = 36

# SCRSizeInvariantCheckEnableEpoch represents the epoch when the scr size invariant check is enabled
SCRSizeInvariantCheckEnableEpoch = 37

# BackwardCompSaveKeyValueEnableEpoch represents the epoch when backward compatibility save key value is enabled
BackwardCompSaveKeyValueEnableEpoch = 38

# ESDTNFTCreateOnMultiShardEnableEpoch represents the epoch when esdt nft creation on multiple shards is enabled
ESDTNFTCreateOnMultiShardEnableEpoch = 39

# MetaESDTSetEnableEpoch represents the epoch when the backward compatibility for save key value error is enabled
MetaESDTSetEnableEpoch = 40

# AddTokensToDelegationEnableEpoch represents the epoch when adding tokens to delegation is enabled for whitelisted address
AddTokensToDelegationEnableEpoch = 41

# MultiESDTTransferFixOnCallBackOnEnableEpoch represents the epoch when multi esdt transfer on callback fix is enabled
MultiESDTTransferFixOnCallBackOnEnableEpoch = 42

# OptimizeGasUsedInCrossMiniBlocksEnableEpoch represents the epoch when gas used in cross shard mini blocks will be optimized
OptimizeGasUsedInCrossMiniBlocksEnableEpoch = 43

# FixOOGReturnCodeEnableEpoch represents the epoch when the backward compatibility returning out of gas error is enabled
FixOOGReturnCodeEnableEpoch = 44

# RemoveNonUpdatedStorageEnableEpoch represents the epoch when the backward compatibility for removing non updated storage is enabled
RemoveNonUpdatedStorageEnableEpoch = 45

# OptimizeNFTStoreEnableEpoch represents the epoch when optimizations on NFT metadata store and send are enabled
OptimizeNFTStoreEnableEpoch = 46

# CreateNFTThroughExecByCallerEnableEpoch represents the epoch when nft creation through execution on destination by caller is enabled
CreateNFTThroughExecByCallerEnableEpoch = 47

# IsPayableBySCEnableEpoch represents the epoch when a new flag isPayable by SC is enabled
IsPayableBySCEnableEpoch = 48

# CleanUpInformativeSCRsEnableEpoch represents the epoch when the scrs which contain only information are cleaned from miniblocks and logs are created from it
CleanUpInformativeSCRsEnableEpoch = 49

# StorageAPICostOptimizationEnableEpoch represents the epoch when new storage helper functions are enabled and cost is reduced in Wasm VM
StorageAPICostOptimizationEnableEpoch = 50

# TransformToMultiShardCreateEnableEpoch represents the epoch when the new function on esdt system sc is enabled to transfer create role into multishard
TransformToMultiShardCreateEnableEpoch = 51

# ESDTRegisterAndSetAllRolesEnableEpoch represents the epoch when new function to register tickerID and set all roles is enabled
ESDTRegisterAndSetAllRolesEnableEpoch = 52

# FailExecutionOnEveryAPIErrorEnableEpoch represent the epoch when new protection in VM is enabled to fail all wrong API calls
FailExecutionOnEveryAPIErrorEnableEpoch = 53

# ManagedCryptoAPIsEnableEpoch represents the epoch when the new managed crypto APIs are enabled
ManagedCryptoAPIsEnableEpoch = 54

# ESDTMetadataContinuousCleanupEnableEpoch represents the epoch when esdt metadata is automatically deleted according to inshard liquidity
ESDTMetadataContinuousCleanupEnableEpoch = 55

# FixAsyncCallBackArgsListEnableEpoch represents the epoch when the async callback arguments lists fix will be enabled
FixAsyncCallBackArgsListEnableEpoch = 56

# FixOldTokenLiquidityEnableEpoch represents the epoch when the fix for old token liquidity is enabled
FixOldTokenLiquidityEnableEpoch = 57

# SetSenderInEeiOutputTransferEnableEpoch represents the epoch when setting the sender in eei output transfers will be enabled
SetSenderInEeiOutputTransferEnableEpoch = 58

# MaxBlockchainHookCountersEnableEpoch represents the epoch when the max blockchainhook counters are enabled
MaxBlockchainHookCountersEnableEpoch = 59

# WipeSingleNFTLiquidityDecreaseEnableEpoch represents the epoch when the system account liquidity is decreased for wipeSingleNFT as well
WipeSingleNFTLiquidityDecreaseEnableEpoch = 60

# AlwaysSaveTokenMetaDataEnableEpoch represents the epoch when the token metadata is always saved
AlwaysSaveTokenMetaDataEnableEpoch = 61

# RuntimeCodeSizeFixEnableEpoch represents the epoch when the code size fix in the VM is enabled
RuntimeCodeSizeFixEnableEpoch = 62

# RuntimeMemStoreLimitEnableEpoch represents the epoch when the condition for Runtime MemStore is enabled
RuntimeMemStoreLimitEnableEpoch = 63

# MaxNodesChangeEnableEpoch holds configuration for changing the maximum number of nodes and the enabling epoch
MaxNodesChangeEnableEpoch = [
{ EpochEnable = 44, MaxNumNodes = 2169, NodesToShufflePerShard = 80 },
{ EpochEnable = 45, MaxNumNodes = 3200, NodesToShufflePerShard = 80 }
]

BLSMultiSignerEnableEpoch = [
{EnableEpoch = 0, Type = "no-KOSK"},
{EnableEpoch = 3, Type = "KOSK"}
]

[GasSchedule]
GasScheduleByEpochs = [
{ StartEpoch = 46, FileName = "gasScheduleV1.toml" },
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0
github.com/multiversx/mx-chain-core-go v1.1.36-0.20230308081722-5262fb09cb9a
github.com/multiversx/mx-chain-crypto-go v1.2.5
github.com/multiversx/mx-chain-es-indexer-go v1.3.13-0.20230216143122-cee11ea0d0f5
github.com/multiversx/mx-chain-es-indexer-go v1.3.15-0.20230314084119-a2c2cfc569e3
github.com/multiversx/mx-chain-logger-go v1.0.11
github.com/multiversx/mx-chain-p2p-go v1.0.13
github.com/multiversx/mx-chain-storage-go v1.0.7
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,8 @@ github.com/multiversx/mx-chain-core-go v1.1.36-0.20230308081722-5262fb09cb9a h1:
github.com/multiversx/mx-chain-core-go v1.1.36-0.20230308081722-5262fb09cb9a/go.mod h1:8gGEQv6BWuuJwhd25qqhCOZbBSv9mk+hLeKvinSaSMk=
github.com/multiversx/mx-chain-crypto-go v1.2.5 h1:tuq3BUNMhKud5DQbZi9DiVAAHUXypizy8zPH0NpTGZk=
github.com/multiversx/mx-chain-crypto-go v1.2.5/go.mod h1:teqhNyWEqfMPgNn8sgWXlgtJ1a36jGCnhs/tRpXW6r4=
github.com/multiversx/mx-chain-es-indexer-go v1.3.13-0.20230216143122-cee11ea0d0f5 h1:zpLIFFryEqlPVwkE8IA5CvsEpy+S+QklJCpjQ6HfDBU=
github.com/multiversx/mx-chain-es-indexer-go v1.3.13-0.20230216143122-cee11ea0d0f5/go.mod h1:lp2IyG55Y2NOhJGkmCbMAsYizU5Wff4+x8lHsTO3gUc=
github.com/multiversx/mx-chain-es-indexer-go v1.3.15-0.20230314084119-a2c2cfc569e3 h1:ZoVFq3GLuWjrYxZcHehWfW2d0yIaQRRgCSB9RJGdN/s=
github.com/multiversx/mx-chain-es-indexer-go v1.3.15-0.20230314084119-a2c2cfc569e3/go.mod h1:lp2IyG55Y2NOhJGkmCbMAsYizU5Wff4+x8lHsTO3gUc=
github.com/multiversx/mx-chain-logger-go v1.0.11 h1:DFsHa+sc5fKwhDR50I8uBM99RTDTEW68ESyr5ALRDwE=
github.com/multiversx/mx-chain-logger-go v1.0.11/go.mod h1:1srDkP0DQucWQ+rYfaq0BX2qLnULsUdRPADpYUTM6dA=
github.com/multiversx/mx-chain-p2p-go v1.0.13 h1:woIlYkDFCKYyJQ5urDcOzz8HUFGsSEhTfUXDDxNI2zM=
Expand Down
10 changes: 4 additions & 6 deletions integrationTests/consensus/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func initNodesAndTest(
roundTime uint64,
consensusType string,
numKeysOnEachNode int,
) (map[uint32][]*integrationTests.TestConsensusNode, error) {
) map[uint32][]*integrationTests.TestConsensusNode {

fmt.Println("Step 1. Setup nodes...")

Expand Down Expand Up @@ -98,7 +98,7 @@ func initNodesAndTest(
}
}

return nodes, nil
return nodes
}

func startNodesWithCommitBlock(nodes []*integrationTests.TestConsensusNode, mutex *sync.Mutex, nonceForRoundMap map[uint64]uint64, totalCalled *int) error {
Expand Down Expand Up @@ -229,8 +229,7 @@ func runFullConsensusTest(t *testing.T, consensusType string, numKeysOnEachNode
"consensusSize", consensusSize,
)

nodes, err := initNodesAndTest(numMetaNodes, numNodes, consensusSize, numInvalid, roundTime, consensusType, numKeysOnEachNode)
assert.Nil(t, err)
nodes := initNodesAndTest(numMetaNodes, numNodes, consensusSize, numInvalid, roundTime, consensusType, numKeysOnEachNode)

defer func() {
for shardID := range nodes {
Expand Down Expand Up @@ -292,8 +291,7 @@ func runConsensusWithNotEnoughValidators(t *testing.T, consensusType string) {
consensusSize := uint32(4)
numInvalid := uint32(2)
roundTime := uint64(1000)
nodes, err := initNodesAndTest(numMetaNodes, numNodes, consensusSize, numInvalid, roundTime, consensusType, 1)
assert.Nil(t, err)
nodes := initNodesAndTest(numMetaNodes, numNodes, consensusSize, numInvalid, roundTime, consensusType, 1)

defer func() {
for shardID := range nodes {
Expand Down
12 changes: 5 additions & 7 deletions node/external/transactionAPI/apiTransactionProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ func (atp *apiTransactionProcessor) GetTransaction(txHash string, withResults bo

tx.Hash = txHash
atp.PopulateComputedFields(tx)
atp.gasUsedAndFeeProcessor.computeAndAttachGasUsedAndFee(tx)

if withResults {
atp.gasUsedAndFeeProcessor.computeAndAttachGasUsedAndFee(tx)
}

if withResults {
atp.gasUsedAndFeeProcessor.computeAndAttachGasUsedAndFee(tx)
Expand Down Expand Up @@ -322,12 +317,15 @@ func (atp *apiTransactionProcessor) extractRequestedTxInfo(wrappedTx *txcache.Wr
if requestedFieldsHandler.HasNonce {
tx.TxFields[nonceField] = wrappedTx.Tx.GetNonce()
}

if requestedFieldsHandler.HasSender {
tx.TxFields[senderField] = atp.addressPubKeyConverter.SilentEncode(wrappedTx.Tx.GetSndAddr(), log)
tx.TxFields[senderField], _ = atp.addressPubKeyConverter.Encode(wrappedTx.Tx.GetSndAddr())
}

if requestedFieldsHandler.HasReceiver {
tx.TxFields[receiverField] = atp.addressPubKeyConverter.SilentEncode(wrappedTx.Tx.GetRcvAddr(), log)
tx.TxFields[receiverField], _ = atp.addressPubKeyConverter.Encode(wrappedTx.Tx.GetRcvAddr())
}

if requestedFieldsHandler.HasGasLimit {
tx.TxFields[gasLimitField] = wrappedTx.Tx.GetGasLimit()
}
Expand Down
3 changes: 3 additions & 0 deletions node/external/transactionAPI/apiTransactionProcessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,9 @@ func TestApiTransactionProcessor_GetTransactionsPoolForSender(t *testing.T) {
DecodeCalled: func(humanReadable string) ([]byte, error) {
return []byte(humanReadable), nil
},
EncodeCalled: func(pkBytes []byte) (string, error) {
return string(pkBytes), nil
},
SilentEncodeCalled: func(pkBytes []byte, log core.Logger) string {
return string(pkBytes)
},
Expand Down
5 changes: 2 additions & 3 deletions node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,7 @@ func TestNode_GetAllESDTTokensShouldReturnEsdtAndFormattedNft(t *testing.T) {
esdtToken := "TKKR-7q8w9e"
esdtKey := []byte(core.ProtectedKeyPrefix + core.ESDTKeyIdentifier + esdtToken)

esdtMetaData := &esdt.MetaData{Creator: []byte("12345678901234567890123456789012")}
esdtData := &esdt.ESDigitalToken{Value: big.NewInt(10), TokenMetaData: esdtMetaData}
esdtData := &esdt.ESDigitalToken{Value: big.NewInt(10)}
marshalledData, _ := getMarshalizer().Marshal(esdtData)
suffix := append(esdtKey, acc.AddressBytes()...)

Expand Down Expand Up @@ -876,7 +875,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["TKKR-7q8w9e-"])
assert.Equal(t, esdtData, tokens[esdtToken])

// check that the NFT was formatted correctly
expectedNftFormattedKey := "TCKR-67tgv3-01"
Expand Down
18 changes: 5 additions & 13 deletions outport/process/alteredaccounts/alteredAccountsProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,12 @@ func (aap *alteredAccountsProvider) addTokensDataForMarkedAccount(
return nil
}

metaData, err := aap.convertMetaData(esdtToken.TokenMetaData)
if err != nil {
return err
}

accountTokenData := &outportcore.AccountTokenData{
Identifier: tokenID,
Balance: esdtToken.Value.String(),
Nonce: nonce,
Properties: hex.EncodeToString(esdtToken.Properties),
MetaData: metaData,
MetaData: aap.convertMetaData(esdtToken.TokenMetaData),
}
if options.WithAdditionalOutportData {
accountTokenData.AdditionalData = &outportcore.AdditionalAccountTokenData{
Expand All @@ -235,15 +230,12 @@ func (aap *alteredAccountsProvider) addTokensDataForMarkedAccount(
return nil
}

func (aap *alteredAccountsProvider) convertMetaData(metaData *esdt.MetaData) (*outportcore.TokenMetaData, error) {
func (aap *alteredAccountsProvider) convertMetaData(metaData *esdt.MetaData) *outportcore.TokenMetaData {
if metaData == nil {
return nil, nil
return nil
}

metaDataCreatorAddr, err := aap.addressConverter.Encode(metaData.Creator)
if err != nil {
return nil, fmt.Errorf("%w while encoding metadata creator", err)
}
metaDataCreatorAddr := aap.addressConverter.SilentEncode(metaData.Creator, log)

return &outportcore.TokenMetaData{
Nonce: metaData.Nonce,
Expand All @@ -253,7 +245,7 @@ func (aap *alteredAccountsProvider) convertMetaData(metaData *esdt.MetaData) (*o
Hash: metaData.Hash,
URIs: metaData.URIs,
Attributes: metaData.Attributes,
}, nil
}
}

func (aap *alteredAccountsProvider) extractAddressesWithBalanceChange(
Expand Down
Loading