Skip to content

Commit b298ab9

Browse files
authored
Merge branch 'master' into test_sc_epoch_0
2 parents 470a63f + b505135 commit b298ab9

File tree

154 files changed

+5277
-1079
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+5277
-1079
lines changed

api/groups/blockGroup.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const (
2626
urlParamTokensFilter = "tokens"
2727
urlParamWithTxs = "withTxs"
2828
urlParamWithLogs = "withLogs"
29+
urlParamForHyperblock = "forHyperblock"
2930
)
3031

3132
// blockFacadeHandler defines the methods to be implemented by a facade for handling block requests
@@ -219,7 +220,12 @@ func parseBlockQueryOptions(c *gin.Context) (api.BlockQueryOptions, error) {
219220
return api.BlockQueryOptions{}, err
220221
}
221222

222-
options := api.BlockQueryOptions{WithTransactions: withTxs, WithLogs: withLogs}
223+
forHyperBlock, err := parseBoolUrlParam(c, urlParamForHyperblock)
224+
if err != nil {
225+
return api.BlockQueryOptions{}, err
226+
}
227+
228+
options := api.BlockQueryOptions{WithTransactions: withTxs, WithLogs: withLogs, ForHyperblock: forHyperBlock}
223229
return options, nil
224230
}
225231

api/groups/blockGroup_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func TestBlockGroup_getBlockByNonce(t *testing.T) {
9090
t.Parallel()
9191

9292
providedNonce := uint64(37)
93-
expectedOptions := api.BlockQueryOptions{WithTransactions: true}
93+
expectedOptions := api.BlockQueryOptions{WithTransactions: true, ForHyperblock: true}
9494
expectedBlock := api.Block{
9595
Nonce: 37,
9696
Round: 39,
@@ -107,7 +107,7 @@ func TestBlockGroup_getBlockByNonce(t *testing.T) {
107107
loadBlockGroupResponse(
108108
t,
109109
facade,
110-
fmt.Sprintf("/block/by-nonce/%d?withTxs=true", providedNonce),
110+
fmt.Sprintf("/block/by-nonce/%d?withTxs=true&forHyperblock=true", providedNonce),
111111
"GET",
112112
nil,
113113
response,

api/groups/networkGroup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func NewNetworkGroup(facade networkFacadeHandler) (*networkGroup, error) {
117117
{
118118
Path: getNFTsPath,
119119
Method: http.MethodGet,
120-
Handler: ng.getHandlerFuncForEsdt(core.NonFungibleESDT),
120+
Handler: ng.getHandlerFuncForEsdt(core.NonFungibleESDTv2),
121121
},
122122
{
123123
Path: directStakedInfoPath,

api/groups/networkGroup_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,36 @@ func TestNetworkConfigMetrics_GasLimitGuardedTxShouldWork(t *testing.T) {
206206
assert.True(t, keyAndValueFoundInResponse)
207207
}
208208

209+
func TestNetworkConfigMetrics_GasLimitRelayedTxShouldWork(t *testing.T) {
210+
t.Parallel()
211+
212+
statusMetricsProvider := statusHandler.NewStatusMetrics()
213+
key := common.MetricExtraGasLimitRelayedTx
214+
val := uint64(123)
215+
statusMetricsProvider.SetUInt64Value(key, val)
216+
217+
facade := mock.FacadeStub{}
218+
facade.StatusMetricsHandler = func() external.StatusMetricsHandler {
219+
return statusMetricsProvider
220+
}
221+
222+
networkGroup, err := groups.NewNetworkGroup(&facade)
223+
require.NoError(t, err)
224+
225+
ws := startWebServer(networkGroup, "network", getNetworkRoutesConfig())
226+
227+
req, _ := http.NewRequest("GET", "/network/config", nil)
228+
resp := httptest.NewRecorder()
229+
ws.ServeHTTP(resp, req)
230+
231+
respBytes, _ := io.ReadAll(resp.Body)
232+
respStr := string(respBytes)
233+
assert.Equal(t, resp.Code, http.StatusOK)
234+
235+
keyAndValueFoundInResponse := strings.Contains(respStr, key) && strings.Contains(respStr, fmt.Sprintf("%d", val))
236+
assert.True(t, keyAndValueFoundInResponse)
237+
}
238+
209239
func TestNetworkStatusMetrics_ShouldWork(t *testing.T) {
210240
t.Parallel()
211241

api/groups/transactionGroup.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -720,21 +720,23 @@ func (tg *transactionGroup) getTransactionsPoolNonceGapsForSender(sender string,
720720

721721
func (tg *transactionGroup) createTransaction(receivedTx *transaction.FrontendTransaction) (*transaction.Transaction, []byte, error) {
722722
txArgs := &external.ArgsCreateTransaction{
723-
Nonce: receivedTx.Nonce,
724-
Value: receivedTx.Value,
725-
Receiver: receivedTx.Receiver,
726-
ReceiverUsername: receivedTx.ReceiverUsername,
727-
Sender: receivedTx.Sender,
728-
SenderUsername: receivedTx.SenderUsername,
729-
GasPrice: receivedTx.GasPrice,
730-
GasLimit: receivedTx.GasLimit,
731-
DataField: receivedTx.Data,
732-
SignatureHex: receivedTx.Signature,
733-
ChainID: receivedTx.ChainID,
734-
Version: receivedTx.Version,
735-
Options: receivedTx.Options,
736-
Guardian: receivedTx.GuardianAddr,
737-
GuardianSigHex: receivedTx.GuardianSignature,
723+
Nonce: receivedTx.Nonce,
724+
Value: receivedTx.Value,
725+
Receiver: receivedTx.Receiver,
726+
ReceiverUsername: receivedTx.ReceiverUsername,
727+
Sender: receivedTx.Sender,
728+
SenderUsername: receivedTx.SenderUsername,
729+
GasPrice: receivedTx.GasPrice,
730+
GasLimit: receivedTx.GasLimit,
731+
DataField: receivedTx.Data,
732+
SignatureHex: receivedTx.Signature,
733+
ChainID: receivedTx.ChainID,
734+
Version: receivedTx.Version,
735+
Options: receivedTx.Options,
736+
Guardian: receivedTx.GuardianAddr,
737+
GuardianSigHex: receivedTx.GuardianSignature,
738+
Relayer: receivedTx.RelayerAddr,
739+
RelayerSignatureHex: receivedTx.RelayerSignature,
738740
}
739741
start := time.Now()
740742
tx, txHash, err := tg.getFacade().CreateTransaction(txArgs)

cmd/node/config/config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@
386386
[TxDataPool]
387387
Name = "TxDataPool"
388388
Capacity = 600000
389-
SizePerSender = 20000
389+
SizePerSender = 5001
390390
SizeInBytes = 419430400 #400MB
391-
SizeInBytesPerSender = 12288000
391+
SizeInBytesPerSender = 12288000 #12MB
392392
Type = "TxCache"
393393
Shards = 16
394394

cmd/node/config/enableEpochs.toml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,25 +313,28 @@
313313
UseGasBoundedShouldFailExecutionEnableEpoch = 1
314314

315315
# DynamicESDTEnableEpoch represents the epoch when dynamic NFT feature is enabled
316-
DynamicESDTEnableEpoch = 4
316+
DynamicESDTEnableEpoch = 1
317317

318318
# EGLDInMultiTransferEnableEpoch represents the epoch when EGLD in multitransfer is enabled
319-
EGLDInMultiTransferEnableEpoch = 4
319+
EGLDInMultiTransferEnableEpoch = 1
320320

321321
# CryptoOpcodesV2EnableEpoch represents the epoch when BLSMultiSig, Secp256r1 and other opcodes are enabled
322-
CryptoOpcodesV2EnableEpoch = 4
322+
CryptoOpcodesV2EnableEpoch = 1
323323

324324
# UnjailCleanupEnableEpoch represents the epoch when the cleanup of the unjailed nodes is enabled
325-
UnJailCleanupEnableEpoch = 4
325+
UnJailCleanupEnableEpoch = 1
326326

327327
# FixRelayedBaseCostEnableEpoch represents the epoch when the fix for relayed base cost will be enabled
328-
FixRelayedBaseCostEnableEpoch = 4
328+
FixRelayedBaseCostEnableEpoch = 1
329329

330330
# MultiESDTNFTTransferAndExecuteByUserEnableEpoch represents the epoch when enshrined sovereign cross chain opcodes are enabled
331331
MultiESDTNFTTransferAndExecuteByUserEnableEpoch = 9999999
332332

333333
# FixRelayedMoveBalanceToNonPayableSCEnableEpoch represents the epoch when the fix for relayed move balance to non payable sc will be enabled
334-
FixRelayedMoveBalanceToNonPayableSCEnableEpoch = 4
334+
FixRelayedMoveBalanceToNonPayableSCEnableEpoch = 1
335+
336+
# RelayedTransactionsV3EnableEpoch represents the epoch when the relayed transactions v3 will be enabled
337+
RelayedTransactionsV3EnableEpoch = 1
335338

336339
# BLSMultiSignerEnableEpoch represents the activation epoch for different types of BLS multi-signers
337340
BLSMultiSignerEnableEpoch = [

cmd/node/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ func attachFileLogger(log logger.Logger, flagsConfig *config.ContextFlagsConfig)
290290
logger.ToggleCorrelation(flagsConfig.EnableLogCorrelation)
291291
logger.ToggleLoggerName(flagsConfig.EnableLogName)
292292
logLevelFlagValue := flagsConfig.LogLevel
293+
293294
err = logger.SetLogLevel(logLevelFlagValue)
294295
if err != nil {
295296
return nil, err

common/common.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package common
2+
3+
import "github.com/multiversx/mx-chain-core-go/data"
4+
5+
// IsValidRelayedTxV3 returns true if the provided transaction is a valid transaction of type relayed v3
6+
func IsValidRelayedTxV3(tx data.TransactionHandler) bool {
7+
relayedTx, isRelayedV3 := tx.(data.RelayedTransactionHandler)
8+
if !isRelayedV3 {
9+
return false
10+
}
11+
hasValidRelayer := len(relayedTx.GetRelayerAddr()) == len(tx.GetSndAddr()) && len(relayedTx.GetRelayerAddr()) > 0
12+
hasValidRelayerSignature := len(relayedTx.GetRelayerSignature()) == len(relayedTx.GetSignature()) && len(relayedTx.GetRelayerSignature()) > 0
13+
return hasValidRelayer && hasValidRelayerSignature
14+
}
15+
16+
// IsRelayedTxV3 returns true if the provided transaction is a transaction of type relayed v3, without any further checks
17+
func IsRelayedTxV3(tx data.TransactionHandler) bool {
18+
relayedTx, isRelayedV3 := tx.(data.RelayedTransactionHandler)
19+
if !isRelayedV3 {
20+
return false
21+
}
22+
23+
hasRelayer := len(relayedTx.GetRelayerAddr()) > 0
24+
hasRelayerSignature := len(relayedTx.GetRelayerSignature()) > 0
25+
return hasRelayer || hasRelayerSignature
26+
}

common/common_test.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package common
2+
3+
import (
4+
"math/big"
5+
"testing"
6+
7+
"github.com/multiversx/mx-chain-core-go/data/smartContractResult"
8+
"github.com/multiversx/mx-chain-core-go/data/transaction"
9+
"github.com/stretchr/testify/require"
10+
)
11+
12+
func TestIsValidRelayedTxV3(t *testing.T) {
13+
t.Parallel()
14+
15+
scr := &smartContractResult.SmartContractResult{}
16+
require.False(t, IsValidRelayedTxV3(scr))
17+
require.False(t, IsRelayedTxV3(scr))
18+
19+
notRelayedTxV3 := &transaction.Transaction{
20+
Nonce: 1,
21+
Value: big.NewInt(100),
22+
RcvAddr: []byte("receiver"),
23+
SndAddr: []byte("sender0"),
24+
GasPrice: 100,
25+
GasLimit: 10,
26+
Signature: []byte("signature"),
27+
}
28+
require.False(t, IsValidRelayedTxV3(notRelayedTxV3))
29+
require.False(t, IsRelayedTxV3(notRelayedTxV3))
30+
31+
invalidRelayedTxV3 := &transaction.Transaction{
32+
Nonce: 1,
33+
Value: big.NewInt(100),
34+
RcvAddr: []byte("receiver"),
35+
SndAddr: []byte("sender0"),
36+
GasPrice: 100,
37+
GasLimit: 10,
38+
Signature: []byte("signature"),
39+
RelayerAddr: []byte("relayer"),
40+
}
41+
require.False(t, IsValidRelayedTxV3(invalidRelayedTxV3))
42+
require.True(t, IsRelayedTxV3(invalidRelayedTxV3))
43+
44+
invalidRelayedTxV3 = &transaction.Transaction{
45+
Nonce: 1,
46+
Value: big.NewInt(100),
47+
RcvAddr: []byte("receiver"),
48+
SndAddr: []byte("sender0"),
49+
GasPrice: 100,
50+
GasLimit: 10,
51+
Signature: []byte("signature"),
52+
RelayerSignature: []byte("signature"),
53+
}
54+
require.False(t, IsValidRelayedTxV3(invalidRelayedTxV3))
55+
require.True(t, IsRelayedTxV3(invalidRelayedTxV3))
56+
57+
relayedTxV3 := &transaction.Transaction{
58+
Nonce: 1,
59+
Value: big.NewInt(100),
60+
RcvAddr: []byte("receiver"),
61+
SndAddr: []byte("sender1"),
62+
GasPrice: 100,
63+
GasLimit: 10,
64+
Signature: []byte("signature"),
65+
RelayerAddr: []byte("relayer"),
66+
RelayerSignature: []byte("signature"),
67+
}
68+
require.True(t, IsValidRelayedTxV3(relayedTxV3))
69+
require.True(t, IsRelayedTxV3(relayedTxV3))
70+
}

0 commit comments

Comments
 (0)