-
Notifications
You must be signed in to change notification settings - Fork 64
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
base: main
Are you sure you want to change the base?
chore: merge #353
Conversation
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]>
) This reverts commit 6ddc28d. Co-authored-by: Vlad J <[email protected]>
chore: merge backport pr #62
|
||
/// @title ERC20TestCaller | ||
/// @author Evmos Core Team | ||
/// @author Erric |
There was a problem hiding this comment.
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
strconv.ParseUint
Show autofix suggestion
Hide autofix suggestion
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:
- Ensure that the value is less than or equal to
math.MaxInt64
(2^63 - 1) before performing the conversion. - 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.
-
Copy modified lines R159-R162
@@ -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) | ||
} |
-
Copy modified lines R47-R52
@@ -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) | ||
} | ||
|
@@ -5,7 +5,7 @@ | |||
"errors" | |||
"io" | |||
"os" | |||
"runtime" // #nosec G702 | |||
"runtime" |
Check notice
Code scanning / CodeQL
Sensitive package import Note
@@ -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
Show autofix suggestion
Hide autofix suggestion
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.
@@ -28,3 +28,2 @@ | ||
emptyCodeHash = crypto.Keccak256(nil) | ||
totalBalance = math.NewInt(100) | ||
) |
(bool success, ) = payable(msg.sender).call{value: amount}(""); | ||
require(success, "failed to withdraw to sender"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like it: https://github.com/cosmos/evm-internal/pull/35/files
@@ -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") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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++ { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returning errors is fine
There was a problem hiding this comment.
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?'
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems need resolveSpecial?
// DefaultBatchRequestLimit is the default maximum batch request limit. | ||
DefaultBatchRequestLimit = 1000 | ||
|
||
// DefaultBatchResponseMaxSize is the default maximum batch response size. | ||
DefaultBatchResponseMaxSize = 25 * 1000 * 1000 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
if len(req.Predecessors) > maxTracePredecessors { | ||
return nil, status.Errorf(codes.InvalidArgument, "too many predecessors, got %d: limit %d", len(req.Predecessors), maxTracePredecessors) | ||
} | ||
|
There was a problem hiding this comment.
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
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...
main
branchReviewers 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...
Unreleased
section inCHANGELOG.md