Skip to content

[NONEVM-5091] Migrate contracts to 1.4#747

Open
patricios-space wants to merge 19 commits into
mainfrom
chore/contracts/upgrade-tolk-1.3.0-1.4.0
Open

[NONEVM-5091] Migrate contracts to 1.4#747
patricios-space wants to merge 19 commits into
mainfrom
chore/contracts/upgrade-tolk-1.3.0-1.4.0

Conversation

@patricios-space
Copy link
Copy Markdown
Collaborator

@patricios-space patricios-space commented May 22, 2026

NONEVM-5091

Requirements:

  • external interface (that’s messages and getters) need to be backwards compatible
  • we expect to do an in-place upgrade on original contracts?

DoD

@patricios-space patricios-space force-pushed the chore/contracts/upgrade-tolk-1.3.0-1.4.0 branch from e74f579 to d4f4898 Compare May 22, 2026 17:42
Comment thread contracts/contracts/mcms/mcms.tolk Outdated
// NOTE: inlined getFacilityId because compiler doesn't allow custom compile time functions

const MCMS_ERROR_CODE = MCMS_FACILITY_ID * 100;
const CONTRACT_VERSION = "0.0.4";
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Shouldn't this be a 1.x version?

@patricios-space patricios-space force-pushed the chore/contracts/upgrade-tolk-1.3.0-1.4.0 branch 4 times, most recently from 270e789 to 77f702e Compare May 27, 2026 22:45
@patricios-space patricios-space requested a review from Copilot May 27, 2026 22:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the TON contracts/tooling to Tolk 1.4.1 (and related TON TypeScript tooling updates), refreshes dependency locks, and extends wrapper/test support for contract versioning & upgrades (including adding a new release artifact path for 1.6.2).

Changes:

  • Update TON toolchain versions (e.g., @ton/tolk-js 1.4.1, @ton/core 0.63.1, @ton/sandbox 0.42.0) and add axios resolution pinning.
  • Migrate Tolk contracts to 1.4.1 syntax/stdlib changes (arrays/lisp-lists, .crc32(), .sha256(), .literalSlice(), etc.) and bump contract version constants.
  • Add/enable upgrade-path tests for CCIP wrappers and introduce PATH_CONTRACTS_1_6_2 artifact loading support.

Reviewed changes

Copilot reviewed 73 out of 74 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
yarn.lock Dependency lock updates (TON tooling + misc JS deps).
package.json Add root resolutions pin for axios.
contracts/wrappers/examples/Receiver.ts Add artifact name + supported previous versions + version bump.
contracts/wrappers/examples/Counter.ts Add exported CONTRACT_VERSION constant for tests.
contracts/wrappers/codeLoader.ts Add release_1_6_2 contract-code loader from env.
contracts/wrappers/ccip/Router.ts Add artifact name + supported previous versions + version bump.
contracts/wrappers/ccip/ReceiveExecutor.ts Bump version constants.
contracts/wrappers/ccip/OnRamp.ts Add artifact name + supported previous versions + version bump.
contracts/wrappers/ccip/OffRamp.ts Add artifact name + supported previous versions + version bump.
contracts/wrappers/ccip/MerkleRoot.ts Bump contract version.
contracts/wrappers/ccip/FeeQuoter.ts Adjust supported versions, typing cleanup, align with new getter encodings.
contracts/wrappers/ccip/CCIPSendExecutor.ts Bump contract version.
contracts/tsconfig.base.json Add types: ["node","jest"] and normalize comment quoting.
contracts/tests/Counter.spec.ts Assert contract version via wrapper constant.
contracts/tests/ccip/router/Router.spec.ts Enable upgrade tests using wrapper-supported previous versions.
contracts/tests/ccip/router/Router.Setup.ts Allow code override for deploying previous-version code in tests.
contracts/tests/ccip/Receiver.spec.ts Add upgrade tests + allow code override deployment.
contracts/tests/ccip/receiveExecutor/ReceiveExecutor.spec.ts Update previous version loader reference.
contracts/tests/ccip/onramp/OnRamp.spec.ts Enable upgrade tests using wrapper-supported previous versions.
contracts/tests/ccip/onramp/OnRamp.Setup.ts Add flexible deploy helper accepting code override; deprecate old helper.
contracts/tests/ccip/OffRamp.spec.ts Switch upgrade tests to use wrapper-supported previous versions.
contracts/tests/ccip/feequoter/FeeQuoter.spec.ts Switch upgrade tests to use wrapper-supported previous versions.
contracts/shell.nix Add PATH_CONTRACTS_1_6_2 env var for release artifact loading.
contracts/package.json Add axios resolution; pin TON devDependencies to newer versions.
contracts/lock.nix Update Nix yarn-deps hash.
contracts/default.nix Add Nix package for contracts_1_6_2 and pass into shell.
contracts/contracts/test/mock/relay.tolk Update tolk version directive to 1.4.1.
contracts/contracts/test/examples/versioning/upgrades/wrong_version.tolk Update string literal handling for 1.4.1.
contracts/contracts/test/examples/versioning/upgrades/upgradeable_counter/v2/contract.tolk Migrate literals/comments + crc32 helpers for 1.4.1.
contracts/contracts/test/examples/versioning/upgrades/upgradeable_counter/v1/contract.tolk Migrate literals/comments + crc32 helpers for 1.4.1.
contracts/contracts/test/examples/ocr3_base.tolk Update getter return types to lisp-list forms.
contracts/contracts/test/examples/funding/withdrawable_wallet.tolk Migrate literals + crc32 helpers for 1.4.1.
contracts/contracts/mcms/rbac_timelock.tolk Migrate to tolk 1.4.1 + inline facility id/error code derivation + map/array changes.
contracts/contracts/mcms/mcms.tolk Migrate to tolk 1.4.1 + inline facility id/error code derivation + map/array changes.
contracts/contracts/lib/versioning/upgradeable.tolk Inline facility constants for error code calculation.
contracts/contracts/lib/utils.tolk Update facility id derivation, iterators (tuple→array), lisp-list helpers, comment out RemainingBitsOrRef packing helpers.
contracts/contracts/lib/receiver/errors.tolk Inline facility id derivation and use error code constant.
contracts/contracts/lib/ocr/types.tolk Replace createEmptyMap() with [] for maps in 1.4.1.
contracts/contracts/lib/ocr/multi_ocr3_base.tolk Replace stringCrc32() with .crc32() helpers.
contracts/contracts/lib/ocr/errors.tolk Inline facility name/id for error code calculation.
contracts/contracts/lib/funding/withdrawable.tolk Migrate to tolk 1.4.1 + inline facility constants for error codes.
contracts/contracts/lib/deployable/types.tolk Inline facility id derivation.
contracts/contracts/lib/deployable/contract.tolk Update literalSlice usage and crc32 helper call.
contracts/contracts/lib/crypto/merkle_proof.tolk Update tolk version directive to 1.4.1.
contracts/contracts/lib/crypto/merkle_multi_proof.tolk Inline facility constants, tuple→array hashing pipeline updates.
contracts/contracts/lib/access/ownable_2step.tolk Inline facility name/id derivation.
contracts/contracts/lib/access/access_control.tolk Migrate to tolk 1.4.1 + inline facility constants + map defaults.
contracts/contracts/firedrill/firedrill_onramp.tolk Add contract header metadata + map literal changes + typeAndVersion literalSlice.
contracts/contracts/firedrill/firedrill_offramp.tolk Add contract header metadata + tuple→array/lisp-list changes + typeAndVersion literalSlice.
contracts/contracts/firedrill/firedrill_entrypoint.tolk Add contract header metadata + map literal changes + typeAndVersion literalSlice.
contracts/contracts/examples/counter.tolk Migrate to tolk 1.4.1 + version bump + typeAndVersion literalSlice.
contracts/contracts/ccip/test/receiver/types.tolk Inline facility id derivation.
contracts/contracts/ccip/test/receiver/contract.tolk Migrate to tolk 1.4.1 + contract metadata header + upgrade migration check updates.
contracts/contracts/ccip/router/types.tolk Inline facility id derivation.
contracts/contracts/ccip/router/events.tolk Replace stringCrc32() with .crc32() helpers.
contracts/contracts/ccip/router/contract.tolk Migrate to tolk 1.4.1 + contract metadata header + migrate implementation + lisp-list getters.
contracts/contracts/ccip/receive_executor/types.tolk Inline facility id derivation.
contracts/contracts/ccip/receive_executor/contract.tolk Migrate to tolk 1.4.1 + contract metadata header + typeAndVersion literalSlice.
contracts/contracts/ccip/onramp/types.tolk Inline facility id derivation.
contracts/contracts/ccip/onramp/events.tolk Replace stringCrc32() with .crc32() helpers.
contracts/contracts/ccip/onramp/contract.tolk Migrate to tolk 1.4.1 + contract metadata header + migrate implementation.
contracts/contracts/ccip/offramp/types.tolk Inline facility id derivation + sha256 helper.
contracts/contracts/ccip/offramp/events.tolk Replace stringCrc32() with .crc32() helpers.
contracts/contracts/ccip/offramp/contract.tolk Migrate to tolk 1.4.1 + contract metadata header + migrate implementation + array-based merkle root input.
contracts/contracts/ccip/merkle_root/types.tolk Inline facility id derivation.
contracts/contracts/ccip/merkle_root/contract.tolk Migrate to tolk 1.4.1 + contract metadata header + typeAndVersion literalSlice.
contracts/contracts/ccip/fee_quoter/types.tolk Inline facility id derivation.
contracts/contracts/ccip/fee_quoter/events.tolk Replace stringCrc32() with .crc32() helpers.
contracts/contracts/ccip/fee_quoter/contract.tolk Migrate to tolk 1.4.1 + contract metadata header + migrate constraints + tuple→array in getters.
contracts/contracts/ccip/common/types.tolk Replace stringHexToSlice() with .hexToSlice() helper.
contracts/contracts/ccip/common/cross_chain_address_validation.tolk Update tolk version directive to 1.4.1.
contracts/contracts/ccip/ccipsend_executor/types.tolk Inline facility id derivation.
contracts/contracts/ccip/ccipsend_executor/contract.tolk Migrate to tolk 1.4.1 + contract metadata header + typeAndVersion literalSlice.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread contracts/wrappers/examples/Receiver.ts
Comment thread contracts/wrappers/ccip/Router.ts
Comment thread contracts/wrappers/ccip/OnRamp.ts
Comment thread contracts/contracts/ccip/onramp/contract.tolk
Comment thread contracts/tests/ccip/Receiver.spec.ts Outdated
Comment thread contracts/tests/ccip/Receiver.spec.ts
Comment thread contracts/tests/ccip/router/Router.spec.ts
Comment thread contracts/tests/ccip/onramp/OnRamp.spec.ts
@patricios-space patricios-space force-pushed the chore/contracts/upgrade-tolk-1.3.0-1.4.0 branch from bbb017f to 47fcd85 Compare May 27, 2026 23:29
@patricios-space patricios-space requested a review from Copilot May 27, 2026 23:37
@patricios-space patricios-space marked this pull request as ready for review May 27, 2026 23:39
@patricios-space patricios-space requested a review from a team as a code owner May 27, 2026 23:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 73 out of 74 changed files in this pull request and generated 4 comments.

Comment thread contracts/contracts/lib/access/access_control.tolk Outdated
Comment thread contracts/tests/ccip/router/Router.spec.ts
Comment thread contracts/tests/ccip/onramp/OnRamp.spec.ts
Comment thread contracts/tests/ccip/Receiver.spec.ts
@patricios-space patricios-space force-pushed the chore/contracts/upgrade-tolk-1.3.0-1.4.0 branch from 47fcd85 to b91e3d0 Compare May 28, 2026 00:03
@patricios-space patricios-space force-pushed the chore/contracts/upgrade-tolk-1.3.0-1.4.0 branch from b91e3d0 to 66f488c Compare May 28, 2026 00:06
@patricios-space patricios-space force-pushed the chore/contracts/upgrade-tolk-1.3.0-1.4.0 branch from 66f488c to 4175940 Compare May 28, 2026 00:15
export const CHAINSEL_TON = 13879075125137744094n // TODO repeated constant

// Deprecated, use deployOnRampContractW instead for more flexibility in tests. Will be removed in a future version.
// TODO: refactor existing tests to use deployOnRampContractW and remove this function.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I needed to inject code override too. Didn't want to refactor uses to keep lines changed as low as posible

import "../utils.tolk";

const Upgradeable_FACILITY_NAME = "link.chain.ton.lib.versioning.Upgradeable";
const Upgradeable_FACILITY_ID = Upgradeable_FACILITY_NAME.crc32() % 640 + 10; // 199
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We can not be doing this and inlining this code for each contract. This should be a reusable function all contracts use - what is the problem here?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

So before we had something like this:

/// Error codes used by the Timelock contract.
enum AccessControl_Error {
    UnauthorizedAccount = 47400 // AccessControl<T>.errorCode(0)
    BadConfirmation
}

This declaration basically acts as a lint rule: 47400 // AccessControl<T>.errorCode(0)

  1. Computation is done - result published
  2. Can be double checked (e.g., linter)

vs. now where we do these computations inline (duplicated) and no way to check them easily.

Copy link
Copy Markdown
Collaborator Author

@patricios-space patricios-space May 28, 2026

Choose a reason for hiding this comment

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

This should be a reusable function all contracts use - what is the problem here

Sadly, results of functions cannot be asigned to constants, even if they are pure functions

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Can you expand more on your second point? As I understand this, we have two options

  1. Assign value, comment computation
  2. Assign computation, comment value

If we were to check this with a linter, I think it would be easier to implement if it only needs to parse a number in a comment instead of parsing and simulating the computation. We leave the computation to the tolk compiler and check the expected value with our bindings. I don't feel that strong about this though. I'm just trying to understand your point better to align our criteria if we encounter similar situations in the future.


get fun typeAndVersion(): (slice, slice) {
return (FeeQuoter_FACILITY_NAME, CONTRACT_VERSION);
return (FeeQuoter_FACILITY_NAME.literalSlice(), CONTRACT_VERSION);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do we need these constants x__FACILITY_NAME and CONTRACT_VERSION - is there a specific reason we additionally need those everywhere vs. just defining the type and version once in the typeAndVersion() func?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Despite typeAndVersion being a pure and constant function that could be computed at compile time, comp-time methods like crc32 only work with constant strings.

@patricios-space patricios-space force-pushed the chore/contracts/upgrade-tolk-1.3.0-1.4.0 branch from c85e421 to f09de13 Compare May 29, 2026 13:22
@patricios-space patricios-space requested a review from Copilot May 29, 2026 13:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@patricios-space patricios-space force-pushed the chore/contracts/upgrade-tolk-1.3.0-1.4.0 branch from 53e5ed3 to fe0002e Compare May 29, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants