-
Notifications
You must be signed in to change notification settings - Fork 149
Transact from eth to sub #1141
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
Closed
Closed
Transact from eth to sub #1141
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
55cc688
Change for contracts
yrong 07395ce
Convert logic for transact command
yrong d41bd08
Reuse msg.sender for both originKinds
yrong 16e7cbe
Revert to burn&teleport
yrong a01aaab
Update contract bindings
yrong b660ea8
Update sdk
yrong 89feaf3
Merge branch 'main' into ron/transact-from-eth-to-sub
yrong a94183a
Remove unused
yrong 7a110d3
Add smoke test
yrong b57f0c1
Improve smoke test
yrong 3ad5b7d
Add polkadot-sdk as soft link
yrong e93c725
Revert typos config
yrong 65714ef
Add valid check
yrong 4719a42
Remove TransactMessage and inline the params
yrong a78b1f9
Remove from .gitignore
yrong c192361
Add quoteTransactFee
yrong acf2362
Rename to destinationFee
yrong 207460d
Test quoteTransactFee
yrong f8f0f57
Check call length
yrong 00abc13
Initialize ticket with explicit cost
yrong 5084432
Rename to sendCall
yrong d7cc7d8
Reuse weight type with compact u64 encode support
yrong 2f3560c
Fix smoke test with sovereign account of the sender
yrong e99ce53
Fix generate inbound fixture
yrong 2e4140c
Merge branch 'main' into ron/transact-from-eth-to-sub
yrong dd3378e
Merge branch 'main' into ron/transact-from-eth-to-sub
yrong 3d91da4
Support TransactFeeMode
yrong ac7e1f5
Merge branch 'main' into ron/transact-from-eth-to-sub
yrong 72f6d3e
Merge branch 'main' into ron/transact-from-eth-to-sub
yrong 68a567f
Remove prefunding mode
yrong 923187e
Merge branch 'main' into ron/transact-from-eth-to-sub
yrong 3dd1adc
Add param checks back
yrong f07507f
Remove script unused
yrong 70413d8
Remove the fund script not in use
yrong a364298
Update relayer
yrong bdf4c71
Merge branch 'bridge-next-gen' into ron/transact-from-eth-to-sub
yrong 748eea4
Add rfc doc
yrong e27c0eb
Ignore destination fee for the transact
yrong e5c1a70
Update rfc
yrong 53791d2
Update rfc with fee section
yrong 61d5ea5
Cleanup
yrong dfa331d
Merge branch 'bridge-next-gen' into ron/transact-from-eth-to-sub
yrong b935ca8
Update rfc doc
yrong 2847751
Update rfc
yrong bfdff26
Remove unused destinationFee
yrong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| // SPDX-FileCopyrightText: 2023 Snowfork <[email protected]> | ||
| pragma solidity 0.8.23; | ||
|
|
||
| import {OperatingMode, InboundMessage, ParaID, ChannelID, MultiAddress} from "../Types.sol"; | ||
| import {OperatingMode, InboundMessage, ParaID, ChannelID, MultiAddress, OriginKind, Weight} from "../Types.sol"; | ||
| import {Verification} from "../Verification.sol"; | ||
| import {UD60x18} from "prb/math/src/UD60x18.sol"; | ||
|
|
||
|
|
@@ -102,4 +102,16 @@ interface IGateway { | |
| uint128 destinationFee, | ||
| uint128 amount | ||
| ) external payable; | ||
|
|
||
vgeddes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// @dev Call transact in destinationChain | ||
| function sendCall( | ||
| ParaID destinationChain, | ||
| OriginKind originKind, | ||
| uint128 destinationFee, | ||
| Weight calldata weightAtMost, | ||
| bytes calldata call | ||
| ) external payable; | ||
|
|
||
| /// @dev Quote a fee in Ether for transact | ||
| function quoteSendCallFee() external view returns (uint256); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,11 @@ | |
| // SPDX-FileCopyrightText: 2023 Snowfork <[email protected]> | ||
| pragma solidity 0.8.23; | ||
|
|
||
| import {Math} from "./Math.sol"; | ||
|
|
||
| library ScaleCodec { | ||
| using Math for uint64; | ||
|
|
||
| error UnsupportedCompactEncoding(); | ||
|
|
||
| uint256 internal constant MAX_COMPACT_ENCODABLE_UINT = 2 ** 30 - 1; | ||
|
|
@@ -126,4 +130,20 @@ library ScaleCodec { | |
| } | ||
| return encodeCompactU32(uint32(value)); | ||
| } | ||
|
|
||
| // Supports compact encoding of integers in [0, uint64.MAX] | ||
| function encodeCompactU64(uint64 value) internal pure returns (bytes memory) { | ||
| if (value <= 2 ** 30 - 1) { | ||
| return encodeCompactU32(uint32(value)); | ||
| } else { | ||
| uint8 countOfZeros = value.leadingZeros(); | ||
| uint8 bytesNeeded = 8 - countOfZeros / 8; | ||
| bytes memory result = abi.encodePacked(3 + ((bytesNeeded - 4) << 2)); | ||
| for (uint8 i = 0; i < bytesNeeded; i++) { | ||
| result = bytes.concat(result, abi.encodePacked(uint8(value))); | ||
| value >>= 8; | ||
| } | ||
| return result; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,4 +47,16 @@ contract ScaleCodecTest is Test { | |
| vm.expectRevert(ScaleCodec.UnsupportedCompactEncoding.selector); | ||
| ScaleCodec.checkedEncodeCompactU32(uint256(type(uint32).max) + 1); | ||
| } | ||
|
|
||
| function testEncodeCompactU64() public { | ||
| assertEq(ScaleCodec.encodeCompactU64(0), hex"00"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
| assertEq(ScaleCodec.encodeCompactU64(63), hex"fc"); | ||
| assertEq(ScaleCodec.encodeCompactU64(64), hex"0101"); | ||
| assertEq(ScaleCodec.encodeCompactU64(16383), hex"fdff"); | ||
| assertEq(ScaleCodec.encodeCompactU64(16384), hex"02000100"); | ||
| assertEq(ScaleCodec.encodeCompactU64(1073741823), hex"feffffff"); | ||
| assertEq(ScaleCodec.encodeCompactU64(1073741824), hex"0300000040"); | ||
| assertEq(ScaleCodec.encodeCompactU64(type(uint32).max), hex"03ffffffff"); | ||
| assertEq(ScaleCodec.encodeCompactU64(type(uint64).max), hex"13ffffffffffffffff"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.