Skip to content

chore: merge #353

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

Draft
wants to merge 162 commits into
base: main
Choose a base branch
from
Draft

chore: merge #353

wants to merge 162 commits into from

Conversation

aljo242
Copy link
Contributor

@aljo242 aljo242 commented Jul 24, 2025

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the main branch

Reviewers Checklist

All items are required.
Please add a note if the item is not applicable
and please add your handle next to the items reviewed
if you only reviewed selected items.

I have...

  • added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • confirmed all author checklist items have been addressed
  • confirmed that this PR does not change production code
  • reviewed content
  • tested instructions (if applicable)
  • confirmed all CI checks have passed

vladjdk and others added 30 commits June 2, 2025 15:21
Fixed based on standard OZ convention: "the return value is optional (in rare cases), but if data is returned, it must not be false".

Requiring the Transfer event to be emitted in these cases, since we can scan and check for that.
- remove estimation on internal calls
- use max limit on internal calls
- set refund quotient to 1 on internal calls
- consume gas on CallEVMWithData
- consume full gas on CallEVMWithData failures to match EVM standard
* add to invalid block params case

* add test for filter error case

* lint fix
* edit configs

* lint-fix

* fix

* nl

* to

* to

* cache

* fix

* fix

* stupid

* attempt fix flake test

---------

Co-authored-by: Tyler <[email protected]>
@aljo242 aljo242 changed the title Merch3 chore: merge Jul 24, 2025

/// @title ERC20TestCaller
/// @author Evmos Core Team
/// @author Erric
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Erric

if err != nil {
return nil, err
}
blockEnd = int64(blockNumber) //#nosec G115 -- checked for int overflow already

Check failure

Code scanning / CodeQL

Incorrect conversion between integer types High

Incorrect conversion of an unsigned 64-bit integer from
strconv.ParseUint
to a lower bit size type int64 without an upper bound check.

Copilot Autofix

AI 1 day ago

To fix the issue, we need to add an explicit bounds check before converting the uint64 value to int64. Specifically:

  1. Ensure that the value is less than or equal to math.MaxInt64 (2^63 - 1) before performing the conversion.
  2. If the value exceeds this limit, return an appropriate error or handle the case gracefully.

The changes will be made in the rpc/backend/chain_info.go file where the conversion occurs. Additionally, we will ensure that the strconv.ParseUint usage in rpc/backend/blocks.go is consistent with this fix.


Suggested changeset 2
rpc/backend/chain_info.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/rpc/backend/chain_info.go b/rpc/backend/chain_info.go
--- a/rpc/backend/chain_info.go
+++ b/rpc/backend/chain_info.go
@@ -158,3 +158,6 @@
 		}
-		blockEnd = int64(blockNumber) //#nosec G115 -- checked for int overflow already
+		if blockNumber > math.MaxInt64 {
+			return nil, fmt.Errorf("block number %d exceeds maximum value for int64", blockNumber)
+		}
+		blockEnd = int64(blockNumber)
 	}
EOF
@@ -158,3 +158,6 @@
}
blockEnd = int64(blockNumber) //#nosec G115 -- checked for int overflow already
if blockNumber > math.MaxInt64 {
return nil, fmt.Errorf("block number %d exceeds maximum value for int64", blockNumber)
}
blockEnd = int64(blockNumber)
}
rpc/backend/blocks.go
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/rpc/backend/blocks.go b/rpc/backend/blocks.go
--- a/rpc/backend/blocks.go
+++ b/rpc/backend/blocks.go
@@ -46,2 +46,8 @@
 	}
+	if height > math.MaxInt64 {
+		return 0, fmt.Errorf("block height %d exceeds maximum value for int64", height)
+	}
+	if err != nil {
+		return 0, fmt.Errorf("failed to parse block height: %w", err)
+	}
 
EOF
@@ -46,2 +46,8 @@
}
if height > math.MaxInt64 {
return 0, fmt.Errorf("block height %d exceeds maximum value for int64", height)
}
if err != nil {
return 0, fmt.Errorf("failed to parse block height: %w", err)
}

Copilot is powered by AI and may make mistakes. Always verify output.
@@ -5,7 +5,7 @@
"errors"
"io"
"os"
"runtime" // #nosec G702
"runtime"

Check notice

Code scanning / CodeQL

Sensitive package import Note

Certain system packages contain functions which may be a possible source of non-determinism
@@ -22,6 +26,7 @@
nonce uint64 = 10
balance = uint256.NewInt(100)
emptyCodeHash = crypto.Keccak256(nil)
totalBalance = math.NewInt(100)

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning test

This definition of totalBalance is never used.

Copilot Autofix

AI 3 days ago

To fix the issue, the unused variable totalBalance should be removed from the code. This involves deleting its definition on line 29. No additional changes are required, as the variable is not referenced elsewhere in the provided snippet.


Suggested changeset 1
tests/integration/x/erc20/test_dynamic_precompiles.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/integration/x/erc20/test_dynamic_precompiles.go b/tests/integration/x/erc20/test_dynamic_precompiles.go
--- a/tests/integration/x/erc20/test_dynamic_precompiles.go
+++ b/tests/integration/x/erc20/test_dynamic_precompiles.go
@@ -28,3 +28,2 @@
 		emptyCodeHash        = crypto.Keccak256(nil)
-		totalBalance         = math.NewInt(100)
 	)
EOF
@@ -28,3 +28,2 @@
emptyCodeHash = crypto.Keccak256(nil)
totalBalance = math.NewInt(100)
)
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +28 to +29
(bool success, ) = payable(msg.sender).call{value: amount}("");
require(success, "failed to withdraw to sender");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -301,6 +301,7 @@ func (suite *ICS20TransferTestSuite) TestHandleMsgTransfer() {
suite.Require().ErrorContains(err, vm.ErrExecutionReverted.Error())
revertErr := chainutil.DecodeRevertReason(*evmRes)
suite.Require().Contains(revertErr.Error(), "invalid denom trace hash")
ctxB.GasMeter().RefundGas(ctxB.GasMeter().Limit(), "refund after error")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this correct?

@@ -307,6 +307,7 @@ func (suite *ICS20TransferV2TestSuite) TestHandleMsgTransfer() {
suite.Require().ErrorContains(err, vm.ErrExecutionReverted.Error())
revertErr := chainutil.DecodeRevertReason(*evmRes)
suite.Require().Contains(revertErr.Error(), "invalid denom trace hash")
ctxB.GasMeter().RefundGas(ctxB.GasMeter().Limit(), "refund after error")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this correct?

return
}
// fetch block
for blockID := blockStart; blockID <= blockEnd; blockID++ {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unsure which one to accept here

@@ -147,13 +153,13 @@ func (b *Backend) GetTransactionReceipt(hash common.Hash) (map[string]interface{
res, err := b.GetTxByEthHash(hash)
if err != nil {
b.Logger.Debug("tx not found", "hash", hexTx, "error", err.Error())
return nil, nil
return nil, err
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vladjdk @technicallyty should we be returning errors in this file or should we just exit?

Copy link
Member

Choose a reason for hiding this comment

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

returning errors is fine

Copy link
Member

@almk-dev almk-dev Jul 25, 2025

Choose a reason for hiding this comment

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

@vladjdk Isn't this the one that was supposed to have been reverted as it was breaking things?'

Copy link
Contributor

@technicallyty technicallyty Jul 25, 2025

Choose a reason for hiding this comment

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

we should not return an error when that call fails. this breaks compatibility with how Geth handles this case. https://github.com/ethereum/go-ethereum/blob/615d29f7c2d5aed84cf8c7ec952d9f9a9f706e4b/internal/ethapi/api.go#L1376-L1384

Copy link
Contributor

@technicallyty technicallyty Jul 25, 2025

Choose a reason for hiding this comment

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

changing it to return an error also breaks solidity tests.

from, err := resolveSpecial(f.criteria.FromBlock.Int64())
if err != nil {
return nil, err
head := header.Number.Int64()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this the right diff to accept?

Copy link
Contributor

Choose a reason for hiding this comment

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

seems need resolveSpecial?

Comment on lines +102 to +106
// DefaultBatchRequestLimit is the default maximum batch request limit.
DefaultBatchRequestLimit = 1000

// DefaultBatchResponseMaxSize is the default maximum batch response size.
DefaultBatchResponseMaxSize = 25 * 1000 * 1000
Copy link
Contributor Author

Choose a reason for hiding this comment

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

do these need to be configurable via the toml template?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, it's better to be configurable in toml or via flag

Comment on lines +457 to +460
if len(req.Predecessors) > maxTracePredecessors {
return nil, status.Errorf(codes.InvalidArgument, "too many predecessors, got %d: limit %d", len(req.Predecessors), maxTracePredecessors)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

this is not the right fix, the final result was limiting gas. see here: https://github.com/cosmos/evm-internal/pull/43

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.

7 participants