Skip to content

Commit 2598b28

Browse files
vicentevieyteshuangzhen1997archseernicolasgnrCopilot
authored
Vv/offramp message values (#318)
* wip: route through router CCIPReceive * get offramp to compile * update wrappers and test Router UpdateOffRamps message * namespace FeeQuoter_Error * test flow going through route for CCIPReceive * fmt * update router storage * add updateOfframps operation to deployment sequences * use router instead of offramp address in receiver bindings * format * fmt view/common.go * bump contract versions * update receiver code and fix assertion in cs_test * fix receiver test * fmt * fix goimports * bump version in wrappers * update router opcodes to use crc32 * bump versions * fmt typescript * remove a few unnecesary todos * remove get prefix from receiver getters * move MR wrappers to their corresponding file and fix bindings * fix import in offramp.spec.ts * fix merkleroot deploy test * fmt * move imports * fix broken offramp test * add test for tree with 2 leaves * fmt * fix unused imports in router * remove todo and unused dir in router test and contract * use storeMaybeBuilder * Fix tests * Fix deployment/ compilation * yarn fmt * fmt * use Deployable<MerkleRootId> and Deployable<ReceiveExecutorId> * use id type alias also in Router * enable gasLimit * fix compilation errors * get message hasher compatibility test to pass * fix golints * set expected value for hash in ts test, and comment console.log * fix attempt * test hardcoding message value to 10 * test adjusting message value amounts * test increase the value in message from transmitter to 1000000 * test deploying OffRamp with more baseline TON coins * test setting decimals to 9 on execute codec * revert testing changes * bump core version * add logs to txm and transmitter contract * rename log * some cleanup and debug for any2tvm ramp * fix * add execute report test * implement and test manual exec works * add test that gasOverride is ignored if lower than original gaslimit * increase the tx amount to 0.1 ton * hard code gas limit * revert the hard coded gas limit * OffRamp flow value checks * fix merge errors * debugging exit code 37 when both price updates and root are comitted * get tests to pass * fmt * do not use SEND_MODE_REGULAR where possible * use SEND_MODE_REGULAR on feeQuoter message * adjust offchain transmitter values * increment baseAmount for both reports * add debug trace to txm loop * transmit only once * revert on-chain change to test * try reverting to previous values in transmitter and contract costs * fix * use SEND_MODE_REGULAR again * use SEND_MODE_REGULAR on notification flow * use SEND_MODE_REGULAR for validate as well * add comment * try using PAY_FEES_SEPARATELY * increase cost for MerkleRoot_Validate * increase deployment amount for contracts * increase amount needed for ReceiveExecutor_Confirm * reduce ExecuteValidate and Validate costs slightly * reduce amount sent by transmitter on Execute to 0.085 * use PAY_FEES_SEPARATELY on markState * refactor: move Costs structs to their corresponding contracts * remove TODOs and comments * add comment on pkg/ccip/ocr/transmitter * remove ActionExitCode from MsgInfo * use MustAdd instead of Add in contract_transmitter * fix linter warnings * noop change to dispatch ci again * use PAY_FEES_SEPARATELY on receive executor deployment * fix: SEND_MODE_PAY_... * Update pkg/txm/txm.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove newline to pass tests * deployment revert values --------- Co-authored-by: Joe Huang <joe.huang@smartcontract.com> Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> Co-authored-by: Nicolas Mouso <nicolasgnr@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 30edd33 commit 2598b28

File tree

22 files changed

+255
-115
lines changed

22 files changed

+255
-115
lines changed

contracts/contracts/ccip/fee_quoter/contract.tolk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,20 @@ fun onInternalMessage(in: InMessage) {
4040
assert(st.allowedPriceUpdaters.exists(in.senderAddress) || st.ownable.owner == in.senderAddress, FeeQuoter_Error.UnauthorizedPriceUpdater);
4141
updatePrices(mutate st, msg.updates);
4242
st.store();
43+
44+
val returnValueResponse = createMessage({
45+
bounce: false,
46+
value: 0,
47+
dest: in.senderAddress,
48+
body: createEmptyCell(),
49+
});
50+
returnValueResponse.send(SEND_MODE_CARRY_ALL_REMAINING_MESSAGE_VALUE);
4351
}
4452
FeeQuoter_UpdateFeeTokens => {
4553
var st = lazy Storage.load();
4654
st.ownable.requireOwner(in.senderAddress);
4755
updateFeeTokens(mutate st, msg);
56+
4857
st.store();
4958
}
5059
FeeQuoter_UpdateTokenTransferFeeConfigs => {
@@ -206,6 +215,8 @@ fun updatePrices(mutate st: Storage, priceUpdates: PriceUpdates) {
206215
})
207216
}
208217
}
218+
219+
209220
}
210221

211222
// apply_premium_multiplier_wei_per_eth_updates??

contracts/contracts/ccip/fee_quoter/messages.tolk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,9 @@ fun FeeQuoter_Costs.GetValidatedFee(): int {
6868
+ SendExecutor_Costs.MessageValidationFailed()
6969
);
7070
}
71+
72+
fun FeeQuoter_Costs.updatePrices() {
73+
// when we support token transfers the message value amount will depend on the quantity of supported tokens
74+
return ton("0.002");
75+
}
76+

contracts/contracts/ccip/merkle_root/contract.tolk

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import "../../lib/funding/withdrawable"
1212
// Root is commited on Commit Reports and the existence of this contract is used to validate Execute Reports
1313

1414
const CONTRACT_VERSION = "0.0.9";
15-
const RESERVE = ton("1"); // TODO: set correct value
1615

1716
fun onInternalMessage(in: InMessage) {
1817
val msg = lazy MerkleRoot_InMessage.fromSlice(in.body);
@@ -39,8 +38,6 @@ fun _markState(msg: MerkleRoot_MarkState, sender: address) {
3938
// only offramp owned message is allowed
4039
assert(sender == st.owner, MerkleRoot_Error.NotOwner);
4140

42-
// TODO: manually executing an inProgress message if the receiver doesn't correctly ack the message can be problematic
43-
4441
// validate we're transitioning states correctly: success is final
4542
val previousState= st.getMessageState(msg.seqNum);
4643
assert(previousState != ExecutionState.Success, MerkleRoot_Error.InvalidState);
@@ -90,7 +87,7 @@ fun _initExecute(msg: MerkleRoot_Validate, sender: address) {
9087

9188
val executeValidated = createMessage({
9289
bounce: true,
93-
value: ton("0.02"),
90+
value: 0,
9491
dest: st.owner,
9592
body: OffRamp_ExecuteValidated {
9693
message: message.toCell(),
@@ -100,7 +97,7 @@ fun _initExecute(msg: MerkleRoot_Validate, sender: address) {
10097
executionState: state,
10198
}
10299
});
103-
executeValidated.send(SEND_MODE_REGULAR);
100+
executeValidated.send(SEND_MODE_CARRY_ALL_REMAINING_MESSAGE_VALUE);
104101
}
105102

106103
get fun typeAndVersion(): (slice, slice) {

contracts/contracts/ccip/merkle_root/messages.tolk

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "../offramp/types"
2-
import "../receive_executor/types"
2+
import "../offramp/messages"
33

44
type MerkleRoot_InMessage = MerkleRoot_Validate | MerkleRoot_MarkState;
55

@@ -11,7 +11,23 @@ struct (0x038ede91) MerkleRoot_Validate {
1111
gasOverride: coins?,
1212
}
1313

14-
struct (0x01234567) MerkleRoot_MarkState {
14+
//crc32('MerkleRoot_MarkState')
15+
struct (0x019f4cd2) MerkleRoot_MarkState {
1516
seqNum: uint64,
1617
state: ExecutionState
1718
}
19+
20+
struct MerkleRoot_Costs{}
21+
22+
fun MerkleRoot_Costs.validate(){
23+
val baseFee = MERKLE_ROOT_COSTS_VALIDATE_FEE; // validateFees
24+
return baseFee + OffRamp_Costs.executeValidated();
25+
}
26+
27+
fun MerkleRoot_Costs.markState() {
28+
return MERKLE_ROOT_COSTS_MARK_STATE_FEE;
29+
}
30+
31+
const MERKLE_ROOT_COSTS_MARK_STATE_FEE = ton("0.005");
32+
const MERKLE_ROOT_COSTS_VALIDATE_FEE = ton("0.012");
33+

contracts/contracts/ccip/merkle_root/storage.tolk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fun MerkleRoot_Storage.expectedMessages(self) {
2424
}
2525

2626
fun MerkleRoot_Storage.setMessageState(mutate self, seqNum: uint64, executionState: ExecutionState) {
27-
assert(seqNum >= self.minMsgNr && seqNum <= self.maxMsgNr, MerkleRoot_Error.SeqNumOutOfBounds); // Out of bounds
27+
assert(seqNum >= self.minMsgNr && seqNum <= self.maxMsgNr, MerkleRoot_Error.SeqNumOutOfBounds);
2828
val i = seqNum - self.minMsgNr;
2929
assert(i < 64, MerkleRoot_Error.SeqNumOutOfBounds);
3030

@@ -35,7 +35,7 @@ fun MerkleRoot_Storage.setMessageState(mutate self, seqNum: uint64, executionSta
3535
}
3636

3737
fun MerkleRoot_Storage.getMessageState(self, seqNum: uint64): ExecutionState {
38-
assert(seqNum >= self.minMsgNr && seqNum <= self.maxMsgNr, MerkleRoot_Error.SeqNumOutOfBounds); // Out of bounds
38+
assert(seqNum >= self.minMsgNr && seqNum <= self.maxMsgNr, MerkleRoot_Error.SeqNumOutOfBounds);
3939
val i= seqNum - self.minMsgNr;
4040
assert(i < 64, MerkleRoot_Error.SeqNumOutOfBounds);
4141

0 commit comments

Comments
 (0)