-
Notifications
You must be signed in to change notification settings - Fork 2
Add manual execution to offramp #249
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
archseer
wants to merge
7
commits into
main
Choose a base branch
from
manual-execute
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2520535
Add manual execution to offramp
archseer 350ce85
Address review
archseer 9593081
Fix receiver deploy
archseer 1ed32b7
fix compilation
archseer 9920fa6
yarn fmt
archseer 37c0d0e
Bump versions
archseer 4d088a7
Remove stale TODO
archseer 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import "../../lib/utils" | ||
|
||
enum Error { | ||
StateIsNotUntouched = 47900; // Facility ID * 100 | ||
AlreadyAttempted = 47900; // Facility ID * 100 | ||
UpdatingStateOfNonExecutedMessage; | ||
NotificationFromInvalidReceiver; | ||
NotOwner; | ||
ManualExecutionNotYetEnabled; | ||
SkippedAlreadyExecutedMessage; | ||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -9,5 +9,3 @@ enum Error { | |
InvalidOnRampUpdate | ||
} | ||
|
||
|
||
|
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 |
---|---|---|
|
@@ -10,15 +10,19 @@ import "../../../lib/receiver/types"; | |
import "../../../lib/utils"; | ||
import "../../../ccip/offramp/messages"; | ||
|
||
const CONTRACT_VERSION = "0.0.1"; | ||
const CONTRACT_VERSION = "0.0.2"; | ||
|
||
const RECEIVED_MESSAGE_TOPIC = 0xc5a40ab3; //crc32('Receiver_CCIPMessageReceived') | ||
|
||
struct CCIPMessageReceived { | ||
message: Any2TVMMessage | ||
} | ||
|
||
type Msg = Receiver_CCIPReceive; | ||
struct (0x00000001) SetRejectAll { | ||
rejectAll: bool; | ||
} | ||
|
||
type Msg = Receiver_CCIPReceive | SetRejectAll; | ||
|
||
fun onInternalMessage(in: InMessage) { | ||
val msg = lazy Msg.fromSlice(in.body); | ||
|
@@ -27,8 +31,9 @@ fun onInternalMessage(in: InMessage) { | |
// Standard for every receiver to implement: | ||
// - Check CCIPReceive only comes from offRamp/ router | ||
// - Send CCIPReceiveConfirm to msg.callback | ||
assert(in.senderAddress == Storage.load().offRamp, Error.Unauthorized); | ||
|
||
val st = Storage.load(); | ||
assert(in.senderAddress == st.offRamp, Error.Unauthorized); | ||
assert(!st.rejectAll, Error.Rejected); | ||
val receiveConfirm = createMessage({ | ||
bounce: true, | ||
value: ton("0.05"), //TODO how much do we need to send | ||
|
@@ -43,6 +48,11 @@ fun onInternalMessage(in: InMessage) { | |
message: msg.message, | ||
}); | ||
} | ||
SetRejectAll => { | ||
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. @nicolasgnr like Solana the new receiver supports toggling a receiver to deliberately fail. I didn't add any access control checks since this shouldn't be used outside of testnet? |
||
var st = Storage.load(); | ||
st.rejectAll = msg.rejectAll; | ||
st.store(); | ||
} | ||
else => { | ||
// ignore empty messages, "wrong opcode" for others | ||
assert (in.body.isEmpty()) throw 0xFFFF | ||
|
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,5 +2,6 @@ import "../../../lib/utils" | |
|
||
enum Error { | ||
Unauthorized = 34600; // Facility ID * 100 | ||
Rejected; | ||
} | ||
|
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
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.
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.
I think we can just pass through all TON value specified on the call here and avoid this override
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.
Agree, but then we have to change the logic where we check
msg.gasOverride != null
and instead add a specific handler for manual exec in the MerkleRoot