diff --git a/go.mod b/go.mod index 4381aeb88e3..8d662778eea 100644 --- a/go.mod +++ b/go.mod @@ -14,9 +14,9 @@ require ( github.com/gorilla/websocket v1.5.0 github.com/mitchellh/mapstructure v1.5.0 github.com/multiversx/mx-chain-communication-go v1.0.6 - github.com/multiversx/mx-chain-core-go v1.2.14 + github.com/multiversx/mx-chain-core-go v1.2.15 github.com/multiversx/mx-chain-crypto-go v1.2.8 - github.com/multiversx/mx-chain-es-indexer-go v1.4.10 + github.com/multiversx/mx-chain-es-indexer-go v1.4.11 github.com/multiversx/mx-chain-logger-go v1.0.13 github.com/multiversx/mx-chain-scenario-go v1.2.1 github.com/multiversx/mx-chain-storage-go v1.0.12 diff --git a/go.sum b/go.sum index c70f1c9463f..5ba18f4d2c3 100644 --- a/go.sum +++ b/go.sum @@ -378,12 +378,12 @@ github.com/multiversx/concurrent-map v0.1.4 h1:hdnbM8VE4b0KYJaGY5yJS2aNIW9TFFsUY github.com/multiversx/concurrent-map v0.1.4/go.mod h1:8cWFRJDOrWHOTNSqgYCUvwT7c7eFQ4U2vKMOp4A/9+o= github.com/multiversx/mx-chain-communication-go v1.0.6 h1:f2bizRoVuJXBWc32px7pCuzMx4Pgi2tKhUt8BkFV1Fg= github.com/multiversx/mx-chain-communication-go v1.0.6/go.mod h1:+oaUowpq+SqrEmAsMPGwhz44g7L81loWb6AiNQU9Ms4= -github.com/multiversx/mx-chain-core-go v1.2.14 h1:TAfJ3aUcT54JCWtmfsSvzsVEQKfLZ0Di0bZG6XoXc1w= -github.com/multiversx/mx-chain-core-go v1.2.14/go.mod h1:BILOGHUOIG5dNNX8cgkzCNfDaVtoYrJRYcPnpxRMH84= +github.com/multiversx/mx-chain-core-go v1.2.15 h1:2qbcGP9yHi9CFeLF9xTDnDPJjvafvTmwEkitfI0wWME= +github.com/multiversx/mx-chain-core-go v1.2.15/go.mod h1:BILOGHUOIG5dNNX8cgkzCNfDaVtoYrJRYcPnpxRMH84= github.com/multiversx/mx-chain-crypto-go v1.2.8 h1:wOgVlUaO5X4L8iEbFjcQcL8SZvv6WZ7LqH73BiRPhxU= github.com/multiversx/mx-chain-crypto-go v1.2.8/go.mod h1:fkaWKp1rbQN9wPKya5jeoRyC+c/SyN/NfggreyeBw+8= -github.com/multiversx/mx-chain-es-indexer-go v1.4.10 h1:qwYWQ92PuaKhrhZEHm+blEeYSvrxtT1rG8sAL4OEzqc= -github.com/multiversx/mx-chain-es-indexer-go v1.4.10/go.mod h1:rgsFY2RwaH5Slud0i6zJbxidvf1y8LE+YOXnnny0O/c= +github.com/multiversx/mx-chain-es-indexer-go v1.4.11 h1:fL/PdXaUXMt7S12gRvTZKs2dhVOVFm24wUcNTiCYKvM= +github.com/multiversx/mx-chain-es-indexer-go v1.4.11/go.mod h1:4HIWP7q8+yee/W28s4CtpjgrIXPlPeojDTa5qUVDHO8= github.com/multiversx/mx-chain-logger-go v1.0.13 h1:eru/TETo0MkO4ZTnXsQDKf4PBRpAXmqjT02klNT/JnY= github.com/multiversx/mx-chain-logger-go v1.0.13/go.mod h1:MZJhTAtZTJxT+yK2EHc4ZW3YOHUc1UdjCD0iahRNBZk= github.com/multiversx/mx-chain-scenario-go v1.2.1 h1:9eC6VcOEAKRRKZ7EbSWPLzCdNIMWwuNBtAZlgR4cSMA= diff --git a/node/external/blockAPI/metaBlock.go b/node/external/blockAPI/metaBlock.go index 9367153e11d..ac7d71aa7cf 100644 --- a/node/external/blockAPI/metaBlock.go +++ b/node/external/blockAPI/metaBlock.go @@ -230,6 +230,13 @@ func (mbp *metaAPIBlockProcessor) convertMetaBlockBytesToAPIBlock(hash []byte, b Timestamp: time.Duration(blockHeader.GetTimeStamp()), StateRootHash: hex.EncodeToString(blockHeader.RootHash), Status: BlockStatusOnChain, + PubKeyBitmap: hex.EncodeToString(blockHeader.GetPubKeysBitmap()), + Signature: hex.EncodeToString(blockHeader.GetSignature()), + LeaderSignature: hex.EncodeToString(blockHeader.GetLeaderSignature()), + ChainID: string(blockHeader.GetChainID()), + SoftwareVersion: hex.EncodeToString(blockHeader.GetSoftwareVersion()), + ReceiptsHash: hex.EncodeToString(blockHeader.GetReceiptsHash()), + Reserved: blockHeader.GetReserved(), } addScheduledInfoInBlock(blockHeader, apiMetaBlock) diff --git a/node/external/blockAPI/metaBlock_test.go b/node/external/blockAPI/metaBlock_test.go index 256c9e922ec..3d73d2c2daa 100644 --- a/node/external/blockAPI/metaBlock_test.go +++ b/node/external/blockAPI/metaBlock_test.go @@ -549,6 +549,13 @@ func TestMetaAPIBlockProcessor_GetBlockByHashFromHistoryNodeStatusReverted(t *te DeveloperFees: big.NewInt(0), AccumulatedFeesInEpoch: big.NewInt(10), DevFeesInEpoch: big.NewInt(5), + PubKeysBitmap: []byte("010101"), + Signature: []byte("sig"), + LeaderSignature: []byte("leader"), + ChainID: []byte("1"), + SoftwareVersion: []byte("2"), + ReceiptsHash: []byte("recHash"), + Reserved: []byte("res"), } headerBytes, _ := json.Marshal(header) _ = storerMock.Put(headerHash, headerBytes) @@ -575,6 +582,13 @@ func TestMetaAPIBlockProcessor_GetBlockByHashFromHistoryNodeStatusReverted(t *te AccumulatedFeesInEpoch: "10", DeveloperFeesInEpoch: "5", Status: BlockStatusReverted, + PubKeyBitmap: "303130313031", + Signature: "736967", + LeaderSignature: "6c6561646572", + ChainID: "1", + SoftwareVersion: "32", + ReceiptsHash: "72656348617368", + Reserved: []byte("res"), } blk, err := metaAPIBlockProcessor.GetBlockByHash(headerHash, api.BlockQueryOptions{}) diff --git a/node/external/blockAPI/shardBlock.go b/node/external/blockAPI/shardBlock.go index 4f97f1af026..81fd488960c 100644 --- a/node/external/blockAPI/shardBlock.go +++ b/node/external/blockAPI/shardBlock.go @@ -221,6 +221,13 @@ func (sbp *shardAPIBlockProcessor) convertShardBlockBytesToAPIBlock(hash []byte, Timestamp: time.Duration(blockHeader.GetTimeStamp()), Status: BlockStatusOnChain, StateRootHash: hex.EncodeToString(blockHeader.GetRootHash()), + PubKeyBitmap: hex.EncodeToString(blockHeader.GetPubKeysBitmap()), + Signature: hex.EncodeToString(blockHeader.GetSignature()), + LeaderSignature: hex.EncodeToString(blockHeader.GetLeaderSignature()), + ChainID: string(blockHeader.GetChainID()), + SoftwareVersion: hex.EncodeToString(blockHeader.GetSoftwareVersion()), + ReceiptsHash: hex.EncodeToString(blockHeader.GetReceiptsHash()), + Reserved: blockHeader.GetReserved(), } addScheduledInfoInBlock(blockHeader, apiBlock) diff --git a/node/external/blockAPI/shardBlock_test.go b/node/external/blockAPI/shardBlock_test.go index 2af941eea9b..fd57c180430 100644 --- a/node/external/blockAPI/shardBlock_test.go +++ b/node/external/blockAPI/shardBlock_test.go @@ -313,6 +313,13 @@ func TestShardAPIBlockProcessor_GetBlockByNonceFromHistoryNode(t *testing.T) { }, AccumulatedFees: big.NewInt(100), DeveloperFees: big.NewInt(50), + PubKeysBitmap: []byte("010101"), + Signature: []byte("sig"), + LeaderSignature: []byte("leader"), + ChainID: []byte("1"), + SoftwareVersion: []byte("2"), + ReceiptsHash: []byte("recHash"), + Reserved: []byte("res"), } headerBytes, _ := json.Marshal(header) _ = storerMock.Put(headerHash, headerBytes) @@ -337,6 +344,13 @@ func TestShardAPIBlockProcessor_GetBlockByNonceFromHistoryNode(t *testing.T) { AccumulatedFees: "100", DeveloperFees: "50", Status: BlockStatusOnChain, + PubKeyBitmap: "303130313031", + Signature: "736967", + LeaderSignature: "6c6561646572", + ChainID: "1", + SoftwareVersion: "32", + ReceiptsHash: "72656348617368", + Reserved: []byte("res"), } blk, err := shardAPIBlockProcessor.GetBlockByNonce(1, api.BlockQueryOptions{}) diff --git a/outport/process/alteredaccounts/alteredAccountsProvider.go b/outport/process/alteredaccounts/alteredAccountsProvider.go index 3125d4f372a..e7d855b1ebf 100644 --- a/outport/process/alteredaccounts/alteredAccountsProvider.go +++ b/outport/process/alteredaccounts/alteredAccountsProvider.go @@ -141,10 +141,17 @@ func (aap *alteredAccountsProvider) addAdditionalDataInAlteredAccount(alteredAcc IsSender: markedAccount.isSender, BalanceChanged: markedAccount.balanceChanged, UserName: string(userAccount.GetUserName()), + CodeMetadata: userAccount.GetCodeMetadata(), + RootHash: userAccount.GetRootHash(), + } + + isSC := core.IsSmartContractAddress(userAccount.AddressBytes()) + if isSC { + alteredAcc.AdditionalData.CodeHash = userAccount.GetCodeHash() } ownerAddressBytes := userAccount.GetOwnerAddress() - if core.IsSmartContractAddress(userAccount.AddressBytes()) && len(ownerAddressBytes) == aap.addressConverter.Len() { + if isSC && len(ownerAddressBytes) == aap.addressConverter.Len() { alteredAcc.AdditionalData.CurrentOwner = aap.addressConverter.SilentEncode(ownerAddressBytes, log) } developerRewards := userAccount.GetDeveloperReward() diff --git a/outport/process/alteredaccounts/alteredAccountsProvider_test.go b/outport/process/alteredaccounts/alteredAccountsProvider_test.go index 51864ae0f14..7832e6e55bb 100644 --- a/outport/process/alteredaccounts/alteredAccountsProvider_test.go +++ b/outport/process/alteredaccounts/alteredAccountsProvider_test.go @@ -94,6 +94,11 @@ func TestGetAlteredAccountFromUserAccount(t *testing.T) { Owner: []byte("owner"), UserName: []byte("contract"), Address: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + CodeHash: []byte("hash"), + CodeMetadata: []byte("metadata"), + GetRootHashCalled: func() []byte { + return []byte("rootHash") + }, } res := &alteredAccount.AlteredAccount{ @@ -109,6 +114,9 @@ func TestGetAlteredAccountFromUserAccount(t *testing.T) { DeveloperRewards: "100", CurrentOwner: "6f776e6572", UserName: "contract", + CodeHash: []byte("hash"), + CodeMetadata: []byte("metadata"), + RootHash: []byte("rootHash"), }, }, res) diff --git a/testscommon/state/userAccountStub.go b/testscommon/state/userAccountStub.go index 98de99fb386..3e4278b2d38 100644 --- a/testscommon/state/userAccountStub.go +++ b/testscommon/state/userAccountStub.go @@ -20,6 +20,8 @@ type UserAccountStub struct { UserName []byte Owner []byte Address []byte + CodeMetadata []byte + CodeHash []byte AddToBalanceCalled func(value *big.Int) error DataTrieTrackerCalled func() state.DataTrieTracker @@ -97,7 +99,7 @@ func (u *UserAccountStub) AddressBytes() []byte { return u.Address } -//IncreaseNonce - +// IncreaseNonce - func (u *UserAccountStub) IncreaseNonce(_ uint64) { } @@ -121,7 +123,7 @@ func (u *UserAccountStub) SetCodeMetadata(_ []byte) { // GetCodeMetadata - func (u *UserAccountStub) GetCodeMetadata() []byte { - return nil + return u.CodeMetadata } // SetCodeHash - @@ -131,7 +133,7 @@ func (u *UserAccountStub) SetCodeHash([]byte) { // GetCodeHash - func (u *UserAccountStub) GetCodeHash() []byte { - return nil + return u.CodeHash } // SetRootHash -