diff --git a/contracts/contracts/ccip/fee_quoter/contract.tolk b/contracts/contracts/ccip/fee_quoter/contract.tolk index 29cf1b1c4..d31724e99 100644 --- a/contracts/contracts/ccip/fee_quoter/contract.tolk +++ b/contracts/contracts/ccip/fee_quoter/contract.tolk @@ -16,7 +16,7 @@ import "../../lib/math"; import "../router/messages" import "../ccipsend_executor/messages" -const CONTRACT_VERSION = "1.6.0"; +const CONTRACT_VERSION = "1.6.1"; const RESERVE = ton("1"); // TODO: set correct value fun onInternalMessage(in: InMessage) { @@ -536,7 +536,8 @@ fun sendExcessesTo(sendExcessesTo: address?, sender: address) { dest: receiver, body: createEmptyCell(), }); - returnExcesses.send(SEND_MODE_CARRY_ALL_REMAINING_MESSAGE_VALUE); + reserveToncoinsOnBalance(0, RESERVE_MODE_INCREASE_BY_ORIGINAL_BALANCE); + returnExcesses.send(SEND_MODE_CARRY_ALL_BALANCE); } get fun tokenPrice(token: address): TimestampedPrice { @@ -662,7 +663,10 @@ get fun reserve(): coins { } @method_id(1000) -fun migrate(storage: cell, version: slice): cell { throw Upgradeable_Error.VersionMismatch; } +fun migrate(storage: cell, version: slice): cell { + assert(version.bitsEqual(CONTRACT_VERSION), Upgradeable_Error.VersionMismatch); + return storage; +} @method_id(1001) fun version(): slice { return CONTRACT_VERSION; } diff --git a/contracts/contracts/ccip/fee_quoter/messages.tolk b/contracts/contracts/ccip/fee_quoter/messages.tolk index 4a76ffa2a..7b23856fb 100644 --- a/contracts/contracts/ccip/fee_quoter/messages.tolk +++ b/contracts/contracts/ccip/fee_quoter/messages.tolk @@ -80,5 +80,5 @@ fun FeeQuoter_Costs.GetValidatedFee(): int { fun FeeQuoter_Costs.updatePrices(): int { // when we support token transfers the message value amount should depend on the quantity of supported tokens - return ton("0.01"); + return ton("0.02"); } diff --git a/contracts/contracts/ccip/offramp/contract.tolk b/contracts/contracts/ccip/offramp/contract.tolk index 5d9bfdb8a..8c79aaea5 100644 --- a/contracts/contracts/ccip/offramp/contract.tolk +++ b/contracts/contracts/ccip/offramp/contract.tolk @@ -234,7 +234,10 @@ fun onUpgrade(msg: Upgradeable_Upgrade) { } @method_id(1000) -fun migrate(storage: cell, version: slice): cell { throw Upgradeable_Error.VersionMismatch; } +fun migrate(storage: cell, version: slice): cell { + assert(version.bitsEqual(CONTRACT_VERSION), Upgradeable_Error.VersionMismatch); + return storage; +} @method_id(1001) fun version(): slice { return CONTRACT_VERSION; } diff --git a/contracts/tests/ccip/feequoter/FeeQuoter.updatePrices.spec.ts b/contracts/tests/ccip/feequoter/FeeQuoter.updatePrices.spec.ts index 24fcfe087..f697136ba 100644 --- a/contracts/tests/ccip/feequoter/FeeQuoter.updatePrices.spec.ts +++ b/contracts/tests/ccip/feequoter/FeeQuoter.updatePrices.spec.ts @@ -319,6 +319,35 @@ describe('FeeQuoter UpdatePrices', () => { }) }) + it('should not end up with lower balance than initial balance after returning excess', async () => { + const contract = await blockchain.getContract(setup.bind.feeQuoter.address) + const initialBalance = contract.balance + + const priceUpdates: feeQuoter.PriceUpdates = { + tokenPricesUpdates: [{ token: FeeQuoterSetup.NATIVE_TON.token, price: 4000000000000000000n }], + gasPricesUpdates: [], + } + + const updateResult = await setup.bind.feeQuoter.sendUpdatePrices(setup.acc.owner.getSender(), { + value: toNano('0.01'), + msg: { updates: priceUpdates, sendExcessesTo: setup.acc.deployer.address }, + }) + + expect(updateResult.transactions).toHaveTransaction({ + to: setup.bind.feeQuoter.address, + success: true, + }) + + expect(updateResult.transactions).toHaveTransaction({ + from: setup.bind.feeQuoter.address, + to: setup.acc.deployer.address, + success: true, + }) + + const finalBalance = (await blockchain.getContract(setup.bind.feeQuoter.address)).balance + expect(finalBalance).toEqual(initialBalance) + }) + afterAll(async () => { if (process.env['COVERAGE'] === 'true') { const testSuitePrefix = 'feeQuoter_update_prices_suite' diff --git a/contracts/wrappers/ccip/FeeQuoter.ts b/contracts/wrappers/ccip/FeeQuoter.ts index 0626499ad..22818ef44 100644 --- a/contracts/wrappers/ccip/FeeQuoter.ts +++ b/contracts/wrappers/ccip/FeeQuoter.ts @@ -29,7 +29,7 @@ import * as upgradeable from '../libraries/versioning/Upgradeable' import * as typeAndVersion from '../libraries/versioning/TypeAndVersion' import * as rt from './Router' -export const FEE_QUOTER_CONTRACT_VERSION = '1.6.0' +export const FEE_QUOTER_CONTRACT_VERSION = '1.6.1' export const FACILITY_NAME = 'link.chain.ton.ccip.FeeQuoter' export const FACILITY_ID = facilityId(crc32(FACILITY_NAME)) diff --git a/pkg/ccip/ocr/config.go b/pkg/ccip/ocr/config.go index 35a5630f6..61a25da6b 100644 --- a/pkg/ccip/ocr/config.go +++ b/pkg/ccip/ocr/config.go @@ -16,8 +16,8 @@ type Config struct { } var DefaultConfigSet = Config{ - CommitPriceUpdateOnlyCostTON: 0.03, - CommitPriceAndRootCostTON: 0.05, + CommitPriceUpdateOnlyCostTON: 0.04, + CommitPriceAndRootCostTON: 0.06, ExecuteCostTON: 0.085, }