Skip to content

Commit

Permalink
Merge pull request #6673 from multiversx/merge-master-inro-feat-state…
Browse files Browse the repository at this point in the history
…-changes

Merge master into feat state changes
  • Loading branch information
AdoAdoAdo authored Dec 12, 2024
2 parents 5450ae1 + 3d30a70 commit 2b41727
Show file tree
Hide file tree
Showing 193 changed files with 4,152 additions and 5,120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ jobs:
- name: Upload test report
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: pytest-report-${{ github.run_id }}
path: reports/report.html
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
strategy:
matrix:
runs-on: [ubuntu-latest, macos-13, macos-13-xlarge]
runs-on: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.runs-on }}
name: Build
steps:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
build:
strategy:
matrix:
runs-on: [ubuntu-latest, macos-13, macos-13-xlarge]
runs-on: [ubuntu-latest]
runs-on: ${{ matrix.runs-on }}
name: Build
steps:
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
zip -r -j ${ARCHIVE} ${BUILD_DIR}
- name: Save artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE }}
path: ${{ env.ARCHIVE }}
Expand All @@ -145,7 +145,7 @@ jobs:
# https://docs.github.com/en/free-pro-team@latest/actions/guides/storing-workflow-data-as-artifacts#downloading-or-deleting-artifacts
# A directory for each artifact is created using its name
- name: Download all workflow run artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
path: assets

Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/docker-keygenerator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Build & push keygenerator docker image

on:
workflow_dispatch:
pull_request:

jobs:
build-docker-image:
Expand All @@ -19,7 +18,6 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Log into Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand All @@ -32,5 +30,5 @@ jobs:
context: .
file: ./docker/keygenerator/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
push: true
tags: multiversx/chain-keygenerator:latest
2 changes: 1 addition & 1 deletion api/groups/networkGroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func NewNetworkGroup(facade networkFacadeHandler) (*networkGroup, error) {
{
Path: getNFTsPath,
Method: http.MethodGet,
Handler: ng.getHandlerFuncForEsdt(core.NonFungibleESDT),
Handler: ng.getHandlerFuncForEsdt(core.NonFungibleESDTv2),
},
{
Path: directStakedInfoPath,
Expand Down
128 changes: 20 additions & 108 deletions api/groups/transactionGroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,23 +197,7 @@ func (tg *transactionGroup) simulateTransaction(c *gin.Context) {
return
}

innerTxs, err := tg.extractInnerTransactions(ftx.InnerTransactions)
if err != nil {
c.JSON(
http.StatusBadRequest,
shared.GenericAPIResponse{
Data: nil,
Error: fmt.Sprintf("%s: %s", errors.ErrTxGenerationFailed.Error(), err.Error()),
Code: shared.ReturnCodeRequestError,
},
)
return
}

if len(innerTxs) == 0 {
innerTxs = nil
}
tx, txHash, err := tg.createTransaction(&ftx, innerTxs)
tx, txHash, err := tg.createTransaction(&ftx)
if err != nil {
c.JSON(
http.StatusBadRequest,
Expand Down Expand Up @@ -283,23 +267,7 @@ func (tg *transactionGroup) sendTransaction(c *gin.Context) {
return
}

innerTxs, err := tg.extractInnerTransactions(ftx.InnerTransactions)
if err != nil {
c.JSON(
http.StatusBadRequest,
shared.GenericAPIResponse{
Data: nil,
Error: fmt.Sprintf("%s: %s", errors.ErrTxGenerationFailed.Error(), err.Error()),
Code: shared.ReturnCodeRequestError,
},
)
return
}

if len(innerTxs) == 0 {
innerTxs = nil
}
tx, txHash, err := tg.createTransaction(&ftx, innerTxs)
tx, txHash, err := tg.createTransaction(&ftx)
if err != nil {
c.JSON(
http.StatusBadRequest,
Expand Down Expand Up @@ -378,23 +346,7 @@ func (tg *transactionGroup) sendMultipleTransactions(c *gin.Context) {
var start time.Time
txsHashes := make(map[int]string)
for idx, receivedTx := range ftxs {
innerTxs, errExtractInnerTransactions := tg.extractInnerTransactions(receivedTx.InnerTransactions)
if errExtractInnerTransactions != nil {
c.JSON(
http.StatusBadRequest,
shared.GenericAPIResponse{
Data: nil,
Error: fmt.Sprintf("%s: %s", errors.ErrTxGenerationFailed.Error(), err.Error()),
Code: shared.ReturnCodeInternalError,
},
)
return
}

if len(innerTxs) == 0 {
innerTxs = nil
}
tx, txHash, err = tg.createTransaction(&receivedTx, innerTxs)
tx, txHash, err = tg.createTransaction(&receivedTx)
if err != nil {
continue
}
Expand Down Expand Up @@ -556,23 +508,7 @@ func (tg *transactionGroup) computeTransactionGasLimit(c *gin.Context) {
return
}

innerTxs, errExtractInnerTransactions := tg.extractInnerTransactions(ftx.InnerTransactions)
if errExtractInnerTransactions != nil {
c.JSON(
http.StatusBadRequest,
shared.GenericAPIResponse{
Data: nil,
Error: fmt.Sprintf("%s: %s", errors.ErrTxGenerationFailed.Error(), errExtractInnerTransactions.Error()),
Code: shared.ReturnCodeInternalError,
},
)
return
}

if len(innerTxs) == 0 {
innerTxs = nil
}
tx, _, err := tg.createTransaction(&ftx, innerTxs)
tx, _, err := tg.createTransaction(&ftx)
if err != nil {
c.JSON(
http.StatusInternalServerError,
Expand Down Expand Up @@ -782,25 +718,23 @@ func (tg *transactionGroup) getTransactionsPoolNonceGapsForSender(sender string,
)
}

func (tg *transactionGroup) createTransaction(receivedTx *transaction.FrontendTransaction, innerTxs []*transaction.Transaction) (*transaction.Transaction, []byte, error) {
func (tg *transactionGroup) createTransaction(receivedTx *transaction.FrontendTransaction) (*transaction.Transaction, []byte, error) {
txArgs := &external.ArgsCreateTransaction{
Nonce: receivedTx.Nonce,
Value: receivedTx.Value,
Receiver: receivedTx.Receiver,
ReceiverUsername: receivedTx.ReceiverUsername,
Sender: receivedTx.Sender,
SenderUsername: receivedTx.SenderUsername,
GasPrice: receivedTx.GasPrice,
GasLimit: receivedTx.GasLimit,
DataField: receivedTx.Data,
SignatureHex: receivedTx.Signature,
ChainID: receivedTx.ChainID,
Version: receivedTx.Version,
Options: receivedTx.Options,
Guardian: receivedTx.GuardianAddr,
GuardianSigHex: receivedTx.GuardianSignature,
Relayer: receivedTx.Relayer,
InnerTransactions: innerTxs,
Nonce: receivedTx.Nonce,
Value: receivedTx.Value,
Receiver: receivedTx.Receiver,
ReceiverUsername: receivedTx.ReceiverUsername,
Sender: receivedTx.Sender,
SenderUsername: receivedTx.SenderUsername,
GasPrice: receivedTx.GasPrice,
GasLimit: receivedTx.GasLimit,
DataField: receivedTx.Data,
SignatureHex: receivedTx.Signature,
ChainID: receivedTx.ChainID,
Version: receivedTx.Version,
Options: receivedTx.Options,
Guardian: receivedTx.GuardianAddr,
GuardianSigHex: receivedTx.GuardianSignature,
}
start := time.Now()
tx, txHash, err := tg.getFacade().CreateTransaction(txArgs)
Expand Down Expand Up @@ -906,28 +840,6 @@ func (tg *transactionGroup) getFacade() transactionFacadeHandler {
return tg.facade
}

func (tg *transactionGroup) extractInnerTransactions(
innerTransactions []*transaction.FrontendTransaction,
) ([]*transaction.Transaction, error) {
innerTxs := make([]*transaction.Transaction, 0, len(innerTransactions))
if len(innerTransactions) != 0 {
for _, innerTx := range innerTransactions {
if len(innerTx.InnerTransactions) != 0 {
return innerTxs, errors.ErrRecursiveRelayedTxIsNotAllowed
}

newInnerTx, _, err := tg.createTransaction(innerTx, nil)
if err != nil {
return innerTxs, err
}

innerTxs = append(innerTxs, newInnerTx)
}
}

return innerTxs, nil
}

// UpdateFacade will update the facade
func (tg *transactionGroup) UpdateFacade(newFacade interface{}) error {
if newFacade == nil {
Expand Down
62 changes: 0 additions & 62 deletions api/groups/transactionGroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ func TestTransactionGroup_sendTransaction(t *testing.T) {
expectedErr,
)
})
t.Run("recursive relayed v3 should error", testRecursiveRelayedV3("/transaction/send"))
t.Run("should work", func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -591,7 +590,6 @@ func TestTransactionGroup_computeTransactionGasLimit(t *testing.T) {
expectedErr,
)
})
t.Run("recursive relayed v3 should error", testRecursiveRelayedV3("/transaction/cost"))
t.Run("should work", func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -712,7 +710,6 @@ func TestTransactionGroup_simulateTransaction(t *testing.T) {
expectedErr,
)
})
t.Run("recursive relayed v3 should error", testRecursiveRelayedV3("/transaction/simulate"))
t.Run("should work", func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -1201,62 +1198,3 @@ func getTransactionRoutesConfig() config.ApiRoutesConfig {
},
}
}

func testRecursiveRelayedV3(url string) func(t *testing.T) {
return func(t *testing.T) {
t.Parallel()

facade := &mock.FacadeStub{
CreateTransactionHandler: func(txArgs *external.ArgsCreateTransaction) (*dataTx.Transaction, []byte, error) {
txHash, _ := hex.DecodeString(hexTxHash)
return nil, txHash, nil
},
SendBulkTransactionsHandler: func(txs []*dataTx.Transaction) (u uint64, err error) {
return 1, nil
},
ValidateTransactionHandler: func(tx *dataTx.Transaction) error {
return nil
},
}

userTx1 := fmt.Sprintf(`{"nonce": %d, "sender":"%s", "receiver":"%s", "value":"%s", "signature":"%s"}`,
nonce,
sender,
receiver,
value,
signature,
)
userTx2 := fmt.Sprintf(`{"nonce": %d, "sender":"%s", "receiver":"%s", "value":"%s", "signature":"%s", "innerTransactions":[%s]}`,
nonce,
sender,
receiver,
value,
signature,
userTx1,
)
tx := fmt.Sprintf(`{"nonce": %d, "sender":"%s", "receiver":"%s", "value":"%s", "signature":"%s", "innerTransactions":[%s]}`,
nonce,
sender,
receiver,
value,
signature,
userTx2,
)

transactionGroup, err := groups.NewTransactionGroup(facade)
require.NoError(t, err)

ws := startWebServer(transactionGroup, "transaction", getTransactionRoutesConfig())

req, _ := http.NewRequest("POST", url, bytes.NewBuffer([]byte(tx)))
resp := httptest.NewRecorder()
ws.ServeHTTP(resp, req)

txResp := shared.GenericAPIResponse{}
loadResponse(resp.Body, &txResp)

assert.Equal(t, http.StatusBadRequest, resp.Code)
assert.True(t, strings.Contains(txResp.Error, apiErrors.ErrRecursiveRelayedTxIsNotAllowed.Error()))
assert.Empty(t, txResp.Data)
}
}
7 changes: 2 additions & 5 deletions cmd/node/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@
[TxDataPool]
Name = "TxDataPool"
Capacity = 600000
SizePerSender = 20000
SizePerSender = 5001
SizeInBytes = 419430400 #400MB
SizeInBytesPerSender = 12288000
SizeInBytesPerSender = 12288000 #12MB
Type = "TxCache"
Shards = 16

Expand Down Expand Up @@ -949,6 +949,3 @@
# MaxRoundsOfInactivityAccepted defines the number of rounds missed by a main or higher level backup machine before
# the current machine will take over and propose/sign blocks. Used in both single-key and multi-key modes.
MaxRoundsOfInactivityAccepted = 3

[RelayedTransactionConfig]
MaxTransactionsAllowed = 50
18 changes: 9 additions & 9 deletions cmd/node/config/enableEpochs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -309,29 +309,29 @@
# AlwaysMergeContextsInEEIEnableEpoch represents the epoch in which the EEI will always merge the contexts
AlwaysMergeContextsInEEIEnableEpoch = 1

# UseGasBoundedShouldFailExecutionEnableEpoch represents the epoch when use bounded gas function should fail execution in case of error
UseGasBoundedShouldFailExecutionEnableEpoch = 1

# DynamicESDTEnableEpoch represents the epoch when dynamic NFT feature is enabled
DynamicESDTEnableEpoch = 4
DynamicESDTEnableEpoch = 1

# EGLDInMultiTransferEnableEpoch represents the epoch when EGLD in multitransfer is enabled
EGLDInMultiTransferEnableEpoch = 4
EGLDInMultiTransferEnableEpoch = 1

# CryptoOpcodesV2EnableEpoch represents the epoch when BLSMultiSig, Secp256r1 and other opcodes are enabled
CryptoOpcodesV2EnableEpoch = 4
CryptoOpcodesV2EnableEpoch = 1

# UnjailCleanupEnableEpoch represents the epoch when the cleanup of the unjailed nodes is enabled
UnJailCleanupEnableEpoch = 4

# RelayedTransactionsV3EnableEpoch represents the epoch when the relayed transactions V3 will be enabled
RelayedTransactionsV3EnableEpoch = 7
UnJailCleanupEnableEpoch = 1

# FixRelayedBaseCostEnableEpoch represents the epoch when the fix for relayed base cost will be enabled
FixRelayedBaseCostEnableEpoch = 7
FixRelayedBaseCostEnableEpoch = 1

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

# FixRelayedMoveBalanceToNonPayableSCEnableEpoch represents the epoch when the fix for relayed move balance to non payable sc will be enabled
FixRelayedMoveBalanceToNonPayableSCEnableEpoch = 7
FixRelayedMoveBalanceToNonPayableSCEnableEpoch = 1

# BLSMultiSignerEnableEpoch represents the activation epoch for different types of BLS multi-signers
BLSMultiSignerEnableEpoch = [
Expand Down
Loading

0 comments on commit 2b41727

Please sign in to comment.