Skip to content

Move device definitions and vehicle attributes off-chain#220

Draft
elffjs wants to merge 14 commits into
devfrom
device-definitions-offchain
Draft

Move device definitions and vehicle attributes off-chain#220
elffjs wants to merge 14 commits into
devfrom
device-definitions-offchain

Conversation

@elffjs

@elffjs elffjs commented Apr 30, 2026

Copy link
Copy Markdown
Member

Two commits, both on the same theme: vehicles no longer carry device-definition or attribute (Make/Model/Year) state on-chain. The off-chain document is the source of truth.

Commit 1 — device definitions off-chain

  • Vehicle.solmintVehicleWithDeviceDefinition* (4 variants) → mintVehicle (2: with-SnId, with-SnId+SACD); mintVehicleWithDeviceDefinitionSign* (2 variants) → mintVehicleSign (1: with-SnId). The deprecated no-storageNodeId variants are pruned. getDeviceDefinitionIdByVehicleId is kept and now reads from the renamed legacy field for vehicles minted before this change.
  • MultipleMinter.sol — six mintVehicleAndSdWithDeviceDefinition* variants reshaped into mintVehicleAndSdSignAndSacd(MintVehicleAndSdInputWithSnId, SacdInput) and mintVehicleAndSdSignBatch(MintVehicleAndSdInputWithSnIdBatch[]). The two existing no-DD mintVehicleAndSdSign overloads are untouched.
  • VehicleStorage.solvehicleIdToDeviceDefinitionId_deprecated_vehicleIdToDeviceDefinitionId. The mapping is the trailing struct field; reusing this slot for a future mapping(uint256 => *) would alias the orphaned data via keccak256(tokenId, baseSlot), which the deprecation marker prevents.
  • VehicleInternal.sol — drops MINT_VEHICLE_WITH_DD_TYPEHASH and the VehicleNodeMintedWithDeviceDefinition event.
  • Types.sol — drops the four MintVehicleAndSdWithDdInput* structs; adds MintVehicleAndSdInputWithSnIdBatch.
  • DevAdmin.soladminSetVehicleDDs and the burn cleanups now point at the renamed legacy field; the admin tool stays available for repairing pre-migration data.

Commit 2 — vehicle attributes off-chain

Vehicle attributes (Make/Model/Year) conflict with the off-chain DD, so the on-chain whitelist + per-vehicle info storage is gone too.

  • Vehicle.sol — drops addVehicleAttribute, setVehicleInfo, _setInfos, _resetInfos, VehicleAttributeAdded event. mintVehicle (2 overloads), mintVehicleSign, mintVehicleAndSdSignAndSacd, mintVehicleAndSdSignBatch no longer take an AttributeInfoPair[] for the vehicle. Burn paths no longer reset attributes — legacy data is orphaned in NodesStorage and unreachable through the contract surface.
  • VehicleInternal.sol — drops _setInfosHash and VehicleAttributeSet. MINT_VEHICLE_TYPEHASH simplified to MintVehicleSign(uint256 manufacturerNode,address owner).
  • MultipleMinter.sol — drops the _setInfosHash + attributesHash/infosHash step in all four vehicle-and-SD mint paths.
  • Types.sol — drops attrInfoPairsVehicle from MintVehicleAndSdInput, MintVehicleAndSdInputWithSnId, MintVehicleAndSdInputWithSnIdBatch. SD attributes (attrInfoPairsDevice) are unchanged.
  • VehicleStorage.solwhitelistedAttributes_deprecated_whitelistedAttributes. Not a trailing field; can't remove without aliasing the deprecated DD mapping.
  • DevAdmin.sol — drops adminRemoveVehicleAttribute, _resetVehicleInfos, and VehicleAttributeRemoved/VehicleAttributeSet events.
  • Roles.sol — drops SET_VEHICLE_INFO_ROLE and DEV_REMOVE_ATTR. TS deployment scripts left untouched; the role grants now hash to no-op constants.

Selectors.md, abis/, and registry.go are regenerated and included.

Not yet done — follow-ups before merge

  • Migrate test suite. 14 test files reference removed surface (~300 call sites). Most are mechanical rename-and-drop-DD-arg + drop the attribute array; a portion of Vehicle.test.ts and MultipleMinter.test.ts test DD-specific or attribute-specific behavior and need to be deleted rather than migrated. Files: test/nodes/Vehicle.test.ts, test/MultipleMinter.test.ts, test/nodes/AftermarketDevice.test.ts, test/nodes/SyntheticDevice.test.ts, test/DevAdmin.test.ts, test/streamr/VehicleStream.test.ts, test/storageNode/StorageNodeRegistry.test.ts, test/Multicall.test.ts, test/DimoForwarder.test.ts, test/NFTs/{VehicleId,AftermarketDeviceId,SyntheticDeviceId}.test.ts.
  • Off-chain doc producer/consumer side (out of scope for this repo).

Test plan

  • npm run build succeeds (compile + ABI regen + Go bindings)
  • Test suite passes after follow-up migration
  • Spot-check on a fork: mint via mintVehicle(uint256,address,uint256,(address,uint256,uint256,string)), confirm VehicleNodeMinted fires, no DD storage write, no per-attribute storage write
  • Spot-check getDeviceDefinitionIdByVehicleId still returns the legacy DD for a pre-migration vehicleId on a fork
  • Spot-check IDimoRegistry.getInfo(vehicleProxy, legacyTokenId, "Make") still returns legacy attribute data on a fork
  • DevAdmin.adminSetVehicleDDs still functions for repairing legacy DD data

🤖 Generated with Claude Code

LorranSutter and others added 12 commits May 8, 2025 22:38
Replace roles by SACD when SD minting
Reshape mintVehicleWithDeviceDefinition* and mintVehicleAndSdWithDeviceDefinition*
into mintVehicle / mintVehicleAndSd* without the deviceDefinitionId param. DDs
are now tracked off-chain via per-vehicle documents.

- Vehicle.sol: 6 DD-bearing mints -> mintVehicle (2) + mintVehicleSign (1),
  all with-storageNodeId. Deprecated no-SnId variants pruned.
- MultipleMinter.sol: 6 DD variants -> mintVehicleAndSdSignAndSacd and
  mintVehicleAndSdSignBatch. Existing 2 mintVehicleAndSdSign untouched.
- VehicleStorage.sol: vehicleIdToDeviceDefinitionId renamed to
  _deprecated_vehicleIdToDeviceDefinitionId so the storage slot stays
  fenced off and cannot be aliased by a future field.
- VehicleInternal.sol: drop MINT_VEHICLE_WITH_DD_TYPEHASH and
  VehicleNodeMintedWithDeviceDefinition event.
- Types.sol: drop the four MintVehicleAndSdWithDdInput* structs; add
  MintVehicleAndSdInputWithSnIdBatch.
- DevAdmin.sol: adminSetVehicleDDs and burn cleanups point at the renamed
  legacy field; getDeviceDefinitionIdByVehicleId likewise (kept for
  reads of pre-migration vehicles).

Tests not yet migrated; suite will not pass until follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Vehicle attributes conflict with the (now off-chain) device definition,
so remove the on-chain whitelist + per-vehicle info storage entirely.

- Vehicle.sol: drop addVehicleAttribute, setVehicleInfo, _setInfos,
  _resetInfos, VehicleAttributeAdded event. Drop the AttributeInfoPair[]
  param from mintVehicle (2 overloads) and mintVehicleSign. Drop the
  _resetInfos calls from burn paths (legacy attribute data orphans
  in NodesStorage; harmless since no on-chain code reads it post-migration).
- VehicleInternal.sol: drop _setInfosHash and VehicleAttributeSet event.
  MINT_VEHICLE_TYPEHASH simplified to MintVehicleSign(uint256
  manufacturerNode,address owner) — no attributes/infos in the signed
  payload anymore.
- MultipleMinter.sol: drop the _setInfosHash + attributesHash + infosHash
  steps in all four vehicle-and-SD mint paths.
- Types.sol: drop attrInfoPairsVehicle from MintVehicleAndSdInput,
  MintVehicleAndSdInputWithSnId, MintVehicleAndSdInputWithSnIdBatch.
- VehicleStorage.sol: rename whitelistedAttributes to
  _deprecated_whitelistedAttributes so the slot stays fenced (it is
  not a trailing field; can't remove without aliasing the deprecated
  DD mapping).
- DevAdmin.sol: drop adminRemoveVehicleAttribute, _resetVehicleInfos,
  VehicleAttributeRemoved/VehicleAttributeSet events. Drop _resetVehicleInfos
  calls from burn paths.
- Roles.sol: drop SET_VEHICLE_INFO_ROLE and DEV_REMOVE_ATTR (no longer
  authorize anything in Solidity; TS deployment scripts left untouched —
  the role grants now hash to no-op constants).

Selectors.md, abis/, registry.go regenerated via the full build pipeline,
which also picks up the artifact regen owed by the prior commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@elffjs elffjs changed the title Move device definitions off-chain for vehicle mints Move device definitions and vehicle attributes off-chain Apr 30, 2026
elffjs and others added 2 commits April 30, 2026 15:17
The off-chain DD migration over-pruned the no-storageNodeId mint
overloads. Storage node uptake hasn't materialized, so the older
two-arg forms remain in active use and need to stay.

Adds back to Vehicle.sol:
- mintVehicle(uint256, address)
- mintVehicle(uint256, address, SacdInput)
- mintVehicleSign(uint256, address, bytes)

Adds back to MultipleMinter.sol:
- mintVehicleAndSdSignAndSacd(MintVehicleAndSdInput, SacdInput)
- mintVehicleAndSdSignBatch(MintVehicleAndSdInputBatch[])

Adds the supporting MintVehicleAndSdInputBatch struct and mirrors
it in utils/types.ts. Existing storage-node variants and selectors
are unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants