-
Notifications
You must be signed in to change notification settings - Fork 12
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
fix: account is contract #523
Conversation
WalkthroughThe recent updates focus on enhancing the Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant User
participant BridgeModule
participant EVMKeeper
User ->> BridgeModule: Initiates Bridge Call
BridgeModule ->> EVMKeeper: IsContract(to)
EVMKeeper -->> BridgeModule: true/false
alt Is Contract
BridgeModule ->> EVMKeeper: Proceed with Call
EVMKeeper -->> BridgeModule: Call Success/Failure
else Not a Contract
BridgeModule -->> User: Error: Not a Contract
end
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- x/crosschain/keeper/bridge_call_in.go (1 hunks)
- x/crosschain/keeper/bridge_call_in_test.go (1 hunks)
- x/crosschain/keeper/bridge_call_refund.go (1 hunks)
- x/crosschain/mock/expected_keepers_mocks.go (2 hunks)
- x/crosschain/types/expected_keepers.go (2 hunks)
- x/evm/keeper/statedb.go (1 hunks)
Additional comments not posted (6)
x/evm/keeper/statedb.go (1)
61-64
: The implementation ofIsContract
appears correct and efficient.x/crosschain/keeper/bridge_call_refund.go (1)
47-47
: Ensure the new contract check integrates well with the rest of the system.Verification successful
The
IsContract
check withinHandleOutgoingBridgeCallRefund
ensures that operations are only performed on contract addresses. The usages inabci.go
andbridge_call_out.go
rely on this check and do not require additional handling for non-contract addresses.
x/crosschain/keeper/abci.go
x/crosschain/keeper/bridge_call_out.go
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify integration of IsContract check in HandleOutgoingBridgeCallRefund. # Test: Search for usage of HandleOutgoingBridgeCallRefund. Expect: Proper handling of non-contract addresses. rg --type go $'HandleOutgoingBridgeCallRefund'Length of output: 604
Script:
#!/bin/bash # Description: Verify handling of non-contract addresses in HandleOutgoingBridgeCallRefund usage. # Inspect usage in abci.go rg --type go --context 5 'HandleOutgoingBridgeCallRefund' x/crosschain/keeper/abci.go # Inspect usage in bridge_call_out.go rg --type go --context 5 'HandleOutgoingBridgeCallRefund' x/crosschain/keeper/bridge_call_out.goLength of output: 884
x/crosschain/keeper/bridge_call_in_test.go (1)
48-48
: The addition of theIsContract
expectation in the test is appropriate. Consider adding more comprehensive tests around this functionality.x/crosschain/types/expected_keepers.go (1)
77-77
: The update to theEVMKeeper
interface is consistent with the new functionality.x/crosschain/keeper/bridge_call_in.go (1)
83-85
: The addition of the contract check inBridgeCallTransferAndCallEvm
is crucial for ensuring that operations are only performed on contract addresses.Verification successful
The
IsContract
method inx/evm/keeper/statedb.go
correctly identifies contract addresses by checking if the account is not nil and if it is a contract. This ensures that theBridgeCallTransferAndCallEvm
function only operates on valid contract addresses.
x/evm/keeper/statedb.go:61-64
: Implementation ofIsContract
method.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify integration of IsContract check in BridgeCallTransferAndCallEvm. # Test: Search for usage of BridgeCallTransferAndCallEvm. Expect: Proper handling of non-contract addresses. rg --type go $'BridgeCallTransferAndCallEvm'Length of output: 320
Script:
#!/bin/bash # Description: Locate the implementation of the IsContract method. # Search for the IsContract method in the codebase. ast-grep --lang go --pattern $'func (k Keeper) IsContract(ctx sdk.Context, address sdk.AccAddress) bool { $$$ }'Length of output: 115
Script:
#!/bin/bash # Description: Locate the implementation of the IsContract method with a broader search pattern. # Search for the IsContract method in the codebase. rg --type go 'func.*IsContract'Length of output: 387
Script:
#!/bin/bash # Description: Extract and review the implementation of the IsContract method in x/evm/keeper/statedb.go. # Extract the implementation of the IsContract method. ast-grep --lang go --pattern $'func (k *Keeper) IsContract(ctx sdk.Context, account common.Address) bool { $$$ }' x/evm/keeper/statedb.goLength of output: 414
x/crosschain/mock/expected_keepers_mocks.go (1)
660-664
: The implementation ofIsContract
inMockEVMKeeper
and its recorder appears correctly aligned with GoMock conventions.Also applies to: 668-671
mg |
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
GetAccount
method withIsContract
in various components for more accurate contract verification.