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

IBC transfer precompile #1459

Closed
wants to merge 16 commits into from
Closed

Conversation

dssei
Copy link
Contributor

@dssei dssei commented Mar 21, 2024

Describe your changes and provide context

  • Adding precompile for IBC transfer
  • Moved some common methods to common/precompiles.go

Testing performed to validate your change

  • Unit testing
  • local e2e testing in progress

@dssei dssei requested review from codchen and Kbhat1 March 21, 2024 21:49
@@ -0,0 +1,46 @@
[
Copy link
Contributor Author

Choose a reason for hiding this comment

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

keeping formatted for readability for now (will flatten when code is post-draft)

}

// RequiredGas returns the required bare minimum gas to execute the precompile.
func (p Precompile) RequiredGas(input []byte) uint64 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Kbhat1 @codchen for IBC transfer, will this have to be hardcoded as for other precompiles? Any suggested value?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is IBC gas consumption pretty constant or can vary from call-to-call quite a bit? If the latter we can report gas consumption dynamically similar to https://github.com/sei-protocol/sei-chain/blob/seiv2/precompiles/wasmd/wasmd.go#L111-L135

return
}
func (p Precompile) transfer(ctx sdk.Context, method *abi.Method, args []interface{}) ([]byte, error) {
pcommon.AssertArgsLength(args, 6)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Kbhat1 @codchen do we need to do other validations?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see that from is set an arg. Can anyone trigger an IBC transfer on anyone else's behalf? If not then we should be looking at caller in https://github.com/sei-protocol/sei-chain/pull/1459/files#diff-3c39140061c990bd99f477fe4dbc73c0eaac283bfa477c1ba439016daf6fe688R87 to use as the from address instead

Copy link
Contributor

Choose a reason for hiding this comment

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

Amount: sdk.NewIntFromBigInt(amount),
}

height := clienttypes.Height{}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@codchen @Kbhat1 Not sure what values should be here...or should they be provided by the caller via ABI?

Copy link
Collaborator

Choose a reason for hiding this comment

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

will to defer to kartik here since it's IBC domain knowledge

Copy link
Contributor

Choose a reason for hiding this comment

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

That's the timeout height, we can pass that in as a parameter in the transfer method and update the abi

@codecov-commenter
Copy link

codecov-commenter commented Mar 21, 2024

Codecov Report

Attention: Patch coverage is 46.90722% with 103 lines in your changes are missing coverage. Please review.

Project coverage is 62.84%. Comparing base (c932310) to head (9a40d9b).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              evm    #1459      +/-   ##
==========================================
- Coverage   63.16%   62.84%   -0.32%     
==========================================
  Files         350      351       +1     
  Lines       23760    23934     +174     
==========================================
+ Hits        15008    15042      +34     
- Misses       7896     8017     +121     
- Partials      856      875      +19     
Files Coverage Δ
precompiles/wasmd/wasmd.go 72.39% <100.00%> (-1.88%) ⬇️
app/app.go 68.35% <50.00%> (-0.07%) ⬇️
x/evm/keeper/keeper.go 81.35% <40.00%> (-2.58%) ⬇️
precompiles/common/precompiles.go 9.83% <0.00%> (-2.93%) ⬇️
precompiles/ibc/ibc.go 50.00% <50.00%> (ø)

... and 5 files with indirect coverage changes

Comment on lines +63 to +68
for name, m := range newAbi.Methods {
switch name {
case TransferMethod:
p.TransferID = m.ID
}
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

address constant BANK_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000001008;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we udpate this to 0x0000000000000000000000000000000000001009 ? Oracle is about to be merged #1445

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@dssei dssei marked this pull request as ready for review March 25, 2024 15:25
@dssei dssei requested review from besated and codebycarson March 25, 2024 15:30
@dssei dssei changed the base branch from evm to seiv2 March 27, 2024 00:18
@dssei dssei changed the base branch from seiv2 to evm March 27, 2024 00:21
@dssei dssei closed this Mar 27, 2024
@dssei dssei mentioned this pull request Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants