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

Add more checks #375

Merged
merged 9 commits into from
Nov 18, 2024
Merged

Add more checks #375

merged 9 commits into from
Nov 18, 2024

Conversation

cosmatudor
Copy link

No description provided.

Comment on lines 286 to 292
if params.IsNativeOnEth {
burnAmount := initialSupply
tx2, err2 = handler.SafeContract.InitSupplyMintBurn(auth, erc20Address, zeroValueBigInt, burnAmount)
} else {
mintAmount := initialSupply
tx2, err2 = handler.SafeContract.InitSupplyMintBurn(auth, erc20Address, mintAmount, zeroValueBigInt)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps extract txInitSupplyMintBurn, errInitSupplyMintBurn := handler.SafeContract.InitSupplyMintBurn(auth, erc20Address, mintAmount, burnAmount) to be called only once after this if and only set minAmount and burnAmount here

@@ -492,6 +500,27 @@ func (handler *EthereumHandler) Mint(ctx context.Context, params TestTokenParams
handler.checkEthTxResult(ctx, tx.Hash())
}

func (handler *EthereumHandler) GetTotalBalancesForToken(ctx context.Context, address common.Address) *big.Int {
Copy link
Contributor

Choose a reason for hiding this comment

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

missing comment on all new methods

Comment on lines 806 to 840
if params.IsNativeOnMvX {
burnAmount := initialSupply
hash, txResult := handler.ChainSimulator.ScCall(
ctx,
handler.OwnerKeys.MvxSk,
handler.MultisigAddress,
zeroStringValue,
setCallsGasLimit,
initSupplyMintBurnEsdtSafe,
[]string{
hex.EncodeToString([]byte(tkData.MvxChainSpecificToken)),
hex.EncodeToString(zeroValueBigInt.Bytes()),
hex.EncodeToString(burnAmount.Bytes()),
},
)
log.Info("initial supply tx executed", "hash", hash, "status", txResult.Status,
"initial mint", "0", "initial burned", params.InitialSupplyValue)
} else {
mintAmount := initialSupply
hash, txResult := handler.ChainSimulator.ScCall(
ctx,
handler.OwnerKeys.MvxSk,
handler.MultisigAddress,
zeroStringValue,
setCallsGasLimit,
initSupplyMintBurnEsdtSafe,
[]string{
hex.EncodeToString([]byte(tkData.MvxChainSpecificToken)),
hex.EncodeToString(mintAmount.Bytes()),
hex.EncodeToString(zeroValueBigInt.Bytes()),
},
)
log.Info("initial supply tx executed", "hash", hash, "status", txResult.Status,
"initial mint", params.InitialSupplyValue, "initial burned", "0")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, you can call ScCall only once, just set the proper variables inside ifs

@@ -1043,6 +1066,33 @@ func (handler *MultiversxHandler) TransferToken(ctx context.Context, source Keys
"hash", hash, "status", txResult.Status)
}

func (handler *MultiversxHandler) GetTotalBalancesForToken(ctx context.Context, token string) *big.Int {
Copy link
Contributor

Choose a reason for hiding this comment

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

missing comments on new methods

hex.EncodeToString([]byte(token)),
}
responseData := handler.ChainSimulator.ExecuteVMQuery(ctx, handler.SafeAddress, getTotalBalances, queryParams)
value := big.NewInt(0).SetBytes(responseData[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

is there any chance that responseData is nil here, resulting in a panic while trying to access index 0?

@@ -492,6 +500,27 @@ func (handler *EthereumHandler) Mint(ctx context.Context, params TestTokenParams
handler.checkEthTxResult(ctx, tx.Hash())
}

func (handler *EthereumHandler) GetTotalBalancesForToken(ctx context.Context, address common.Address) *big.Int {
Copy link
Contributor

Choose a reason for hiding this comment

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

missing comments on exported items. Here, on L510 & L517

integrationTests/relayers/slowTests/framework/testSetup.go Outdated Show resolved Hide resolved
integrationTests/relayers/slowTests/framework/testSetup.go Outdated Show resolved Hide resolved
sstanculeanu
sstanculeanu previously approved these changes Nov 14, 2024
}

hash, txResult := handler.ChainSimulator.ScCall(
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

}

return setup.checkMvxLockedBalanceForToken(params, secondBridge)
Copy link
Contributor

Choose a reason for hiding this comment

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

mismatch between the function name and this provided parameter. Also on the next function

Base automatically changed from post-audit-testS-refactor-part1 to feat/v3-audit-tests November 14, 2024 09:23
@cosmatudor cosmatudor dismissed sstanculeanu’s stale review November 14, 2024 09:23

The base branch was changed.

sstanculeanu
sstanculeanu previously approved these changes Nov 14, 2024
Comment on lines 581 to 587
if len(operation.MvxSCCallData) > 0 || operation.MvxForceSCCall {
if operation.MvxFaultySCCall {
// the balance should be bridged back to the receiver on Ethereum - fee
totalRefund.Add(totalRefund, operation.ValueToTransferToMvx)
totalRefund.Sub(totalRefund, feeInt)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if len(operation.MvxSCCallData) > 0 || operation.MvxForceSCCall {
if operation.MvxFaultySCCall {
// the balance should be bridged back to the receiver on Ethereum - fee
totalRefund.Add(totalRefund, operation.ValueToTransferToMvx)
totalRefund.Sub(totalRefund, feeInt)
}
}
if !operation.MvxForceSCCall{
continue
}
if len(operation.MvxSCCallData) == 0l {
continue
}
if !operation.MvxFaultySCCall {
continue
}
// the balance should be bridged back to the receiver on Ethereum - fee
totalRefund.Add(totalRefund, operation.ValueToTransferToMvx)
totalRefund.Sub(totalRefund, feeInt)

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure these 2 versions behave the same. The condition from this if:
if len(operation.MvxSCCallData) > 0 || operation.MvxForceSCCall {
is passed if one of those two assertions is true.

On the other hand, using ifs in the suggested order behaves as if both conditions (operation.MvxForceSCCall being true and len(operation.MvxSCCallData) > 0) must be satisfied simultaneously

Working to refactor this logic

@cosmatudor cosmatudor merged commit 301c95a into feat/v3-audit-tests Nov 18, 2024
4 checks passed
@cosmatudor cosmatudor deleted the add-more-checks branch November 18, 2024 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants