Move device definitions and vehicle attributes off-chain#220
Draft
elffjs wants to merge 14 commits into
Draft
Conversation
Connections on prod
Replace roles by SACD when SD minting
fix devAdmin events
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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.sol—mintVehicleWithDeviceDefinition*(4 variants) →mintVehicle(2: with-SnId, with-SnId+SACD);mintVehicleWithDeviceDefinitionSign*(2 variants) →mintVehicleSign(1: with-SnId). The deprecated no-storageNodeId variants are pruned.getDeviceDefinitionIdByVehicleIdis kept and now reads from the renamed legacy field for vehicles minted before this change.MultipleMinter.sol— sixmintVehicleAndSdWithDeviceDefinition*variants reshaped intomintVehicleAndSdSignAndSacd(MintVehicleAndSdInputWithSnId, SacdInput)andmintVehicleAndSdSignBatch(MintVehicleAndSdInputWithSnIdBatch[]). The two existing no-DDmintVehicleAndSdSignoverloads are untouched.VehicleStorage.sol—vehicleIdToDeviceDefinitionId→_deprecated_vehicleIdToDeviceDefinitionId. The mapping is the trailing struct field; reusing this slot for a futuremapping(uint256 => *)would alias the orphaned data viakeccak256(tokenId, baseSlot), which the deprecation marker prevents.VehicleInternal.sol— dropsMINT_VEHICLE_WITH_DD_TYPEHASHand theVehicleNodeMintedWithDeviceDefinitionevent.Types.sol— drops the fourMintVehicleAndSdWithDdInput*structs; addsMintVehicleAndSdInputWithSnIdBatch.DevAdmin.sol—adminSetVehicleDDsand 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— dropsaddVehicleAttribute,setVehicleInfo,_setInfos,_resetInfos,VehicleAttributeAddedevent.mintVehicle(2 overloads),mintVehicleSign,mintVehicleAndSdSignAndSacd,mintVehicleAndSdSignBatchno longer take anAttributeInfoPair[]for the vehicle. Burn paths no longer reset attributes — legacy data is orphaned inNodesStorageand unreachable through the contract surface.VehicleInternal.sol— drops_setInfosHashandVehicleAttributeSet.MINT_VEHICLE_TYPEHASHsimplified toMintVehicleSign(uint256 manufacturerNode,address owner).MultipleMinter.sol— drops the_setInfosHash+attributesHash/infosHashstep in all four vehicle-and-SD mint paths.Types.sol— dropsattrInfoPairsVehiclefromMintVehicleAndSdInput,MintVehicleAndSdInputWithSnId,MintVehicleAndSdInputWithSnIdBatch. SD attributes (attrInfoPairsDevice) are unchanged.VehicleStorage.sol—whitelistedAttributes→_deprecated_whitelistedAttributes. Not a trailing field; can't remove without aliasing the deprecated DD mapping.DevAdmin.sol— dropsadminRemoveVehicleAttribute,_resetVehicleInfos, andVehicleAttributeRemoved/VehicleAttributeSetevents.Roles.sol— dropsSET_VEHICLE_INFO_ROLEandDEV_REMOVE_ATTR. TS deployment scripts left untouched; the role grants now hash to no-op constants.Selectors.md,abis/, andregistry.goare regenerated and included.Not yet done — follow-ups before merge
Vehicle.test.tsandMultipleMinter.test.tstest 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.Test plan
npm run buildsucceeds (compile + ABI regen + Go bindings)mintVehicle(uint256,address,uint256,(address,uint256,uint256,string)), confirmVehicleNodeMintedfires, no DD storage write, no per-attribute storage writegetDeviceDefinitionIdByVehicleIdstill returns the legacy DD for a pre-migration vehicleId on a forkIDimoRegistry.getInfo(vehicleProxy, legacyTokenId, "Make")still returns legacy attribute data on a forkDevAdmin.adminSetVehicleDDsstill functions for repairing legacy DD data🤖 Generated with Claude Code