[NONEVM-5091] Migrate contracts to 1.4#747
Conversation
e74f579 to
d4f4898
Compare
| // 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"; |
There was a problem hiding this comment.
Shouldn't this be a 1.x version?
270e789 to
77f702e
Compare
There was a problem hiding this comment.
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-js1.4.1,@ton/core0.63.1,@ton/sandbox0.42.0) and addaxiosresolution 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_2artifact 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.
bbb017f to
47fcd85
Compare
47fcd85 to
b91e3d0
Compare
b91e3d0 to
66f488c
Compare
66f488c to
4175940
Compare
| 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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
- Computation is done - result published
- Can be double checked (e.g., linter)
vs. now where we do these computations inline (duplicated) and no way to check them easily.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Can you expand more on your second point? As I understand this, we have two options
- Assign value, comment computation
- 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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
c85e421 to
f09de13
Compare
53e5ed3 to
fe0002e
Compare
NONEVM-5091
Requirements:
DoD
tupletolisp_listorarray///doc comments