You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否在同一网络中运行两个版本的Corda应用以兼容新旧数据?

Running Two Versions of a Corda App on the Same Network for Data Compatibility

Great question—this is a super common pain point when evolving Corda applications, and yes, running two versions of your CorDapp on the same network is absolutely a viable solution to keep both old and new data working smoothly. Let’s break down how to make this work, plus key pitfalls to avoid:

Core Feasibility & Implementation Steps

  • Parallel CorDapp Deployment: Corda natively supports multiple versions of the same CorDapp on a single network, as long as you distinguish them with unique cordappVersion values (use a higher version number for your updated app) and keep the cordappName consistent. Nodes will automatically load all installed CorDapp versions and handle them separately.
  • Isolate Data Structures: Instead of modifying existing state classes or schemas (which would break old data parsing), create new state classes or schema versions (e.g., MyStateV2 paired with MyStateSchemaV2) for your updated logic. Leave the original MyStateV1 and MyStateSchemaV1 untouched in the old CorDapp version—this ensures it can still read and process legacy data.
  • Cross-Version Transaction Support: If you need transactions to interact with both old and new states, ensure both CorDapp versions can validate each other’s states. For example, your new CorDapp’s contract should accept MyStateV1 as a valid input, and the old CorDapp should tolerate MyStateV2 if needed (adjust based on your business rules).

Critical Pitfalls to Avoid

  • Don’t Mix State Class Modifications: Never edit the structure of an existing state class in the new CorDapp version. This will cause the old CorDapp to fail when parsing new data, and vice versa. Always extend with new classes/schemas instead.
  • Node Installation Consistency: Nodes that need to handle both old and new data must have both CorDapp versions installed. Nodes only dealing with legacy data can stick to the old version, but any node participating in cross-version transactions needs both to avoid validation errors.
  • Contract Backward Compatibility: Your new contract logic must fully validate old states. If the new contract rejects MyStateV1, any transaction involving old data on a node with the new CorDapp will fail. You can either retain the old contract rules in the new version or use Corda’s contract upgrade mechanism (better for full migration later).
  • Plan for Migration: Parallel deployment should be a temporary transition. Use this period to gradually migrate old data to the new state structure (via dedicated migration transactions that consume MyStateV1 and create MyStateV2). Once all legacy data is migrated, you can safely remove the old CorDapp version.

Alternative: Schema Upgrades (Single CorDapp Version)

If running two versions feels overly complex, you can use Corda’s built-in schema upgrade system. This lets you add new schema versions to a single CorDapp while retaining mappings for old schemas. This works best when you’re only adding new fields (not modifying existing ones) and want to avoid managing two separate CorDapp packages.

内容的提问来源于stack exchange,提问作者Jiachuan Li

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 04:21:38