@@ -254,26 +254,6 @@ pub mod pallet {
254254 #[ pallet:: getter( fn zos_version) ]
255255 pub type ZosVersion < T > = StorageValue < _ , Vec < u8 > , ValueQuery > ;
256256
257- // Keyed by node_id. Present = node has opted out of v3 billing.
258- #[ pallet:: storage]
259- #[ pallet:: getter( fn node_v3_billing_opt_out) ]
260- pub type NodeV3BillingOptOut < T > =
261- StorageMap < _ , Blake2_128Concat , u32 , u64 , OptionQuery > ;
262-
263- // Keyed by node_id. Stores optional metadata for opted-out nodes (e.g. v4 account).
264- // Max 256 bytes of arbitrary UTF-8 content. Node must be opted out before metadata can be set.
265- #[ pallet:: storage]
266- #[ pallet:: getter( fn node_v3_opt_out_metadata) ]
267- pub type NodeV3OptOutMetadata < T > =
268- StorageMap < _ , Blake2_128Concat , u32 , BoundedVec < u8 , ConstU32 < 256 > > , OptionQuery > ;
269-
270- // Global list of accounts authorized to deploy on opted-out nodes.
271- // None = list not initialized (treat as empty = no one allowed).
272- // Bounded to prevent unbounded storage growth.
273- #[ pallet:: storage]
274- #[ pallet:: getter( fn allowed_twin_admins) ]
275- pub type AllowedTwinAdmins < T : Config > =
276- StorageValue < _ , BoundedVec < T :: AccountId , T :: MaxTwinAdmins > , OptionQuery > ;
277257
278258 // This storage map maps a node ID to a power state, they node can modify this state
279259 // to indicate that it has shut down or came back alive
@@ -312,6 +292,27 @@ pub mod pallet {
312292 pub type PendingTransferByTwin < T : Config > =
313293 StorageMap < _ , Blake2_128Concat , u32 , u64 , OptionQuery > ;
314294
295+ // Keyed by node_id. Present = node has opted out of v3 billing.
296+ #[ pallet:: storage]
297+ #[ pallet:: getter( fn node_v3_billing_opt_out) ]
298+ pub type NodeV3BillingOptOut < T > =
299+ StorageMap < _ , Blake2_128Concat , u32 , u64 , OptionQuery > ;
300+
301+ // Keyed by node_id. Stores optional metadata for opted-out nodes (e.g. v4 account).
302+ // Max 256 bytes of arbitrary UTF-8 content. Node must be opted out before metadata can be set.
303+ #[ pallet:: storage]
304+ #[ pallet:: getter( fn node_v3_opt_out_metadata) ]
305+ pub type NodeV3OptOutMetadata < T > =
306+ StorageMap < _ , Blake2_128Concat , u32 , BoundedVec < u8 , ConstU32 < 256 > > , OptionQuery > ;
307+
308+ // Global list of accounts authorized to deploy on opted-out nodes.
309+ // None = list not initialized (treat as empty = no one allowed).
310+ // Bounded to prevent unbounded storage growth.
311+ #[ pallet:: storage]
312+ #[ pallet:: getter( fn allowed_twin_admins) ]
313+ pub type AllowedTwinAdmins < T : Config > =
314+ StorageValue < _ , BoundedVec < T :: AccountId , T :: MaxTwinAdmins > , OptionQuery > ;
315+
315316 #[ pallet:: config]
316317 pub trait Config : frame_system:: Config + pallet_timestamp:: Config {
317318 type RuntimeEvent : From < Event < Self > > + IsType < <Self as frame_system:: Config >:: RuntimeEvent > ;
@@ -494,12 +495,6 @@ pub mod pallet {
494495 power_state : PowerState < BlockNumberFor < T > > ,
495496 } ,
496497
497- // V3 billing opt-out
498- NodeV3BillingOptedOut { node_id : u32 , opted_out_at : u64 } ,
499- NodeV3OptOutMetadataSet { node_id : u32 , metadata : Vec < u8 > } ,
500- NodeV3OptOutMetadataCleared { node_id : u32 } ,
501- TwinAdminAdded ( T :: AccountId ) ,
502- TwinAdminRemoved ( T :: AccountId ) ,
503498
504499 // Twin ownership transfer lifecycle
505500 TwinTransferRequested {
@@ -520,6 +515,12 @@ pub mod pallet {
520515 from : T :: AccountId ,
521516 to : T :: AccountId ,
522517 } ,
518+
519+ // V3 billing opt-out
520+ NodeV3BillingOptedOut { node_id : u32 , opted_out_at : u64 } ,
521+ TwinAdminAdded ( T :: AccountId ) ,
522+ TwinAdminRemoved ( T :: AccountId ) ,
523+ NodeV3OptOutMetadataUpdated { node_id : u32 , metadata : Option < Vec < u8 > > } ,
523524 }
524525
525526 #[ pallet:: error]
@@ -664,11 +665,11 @@ pub mod pallet {
664665
665666 // V3 billing opt-out errors
666667 NodeV3BillingOptOutAlreadyEnabled ,
667- NodeNotOptedOutOfV3Billing ,
668- NodeV3OptOutMetadataTooLong ,
669668 AlreadyTwinAdmin ,
670669 NotTwinAdmin ,
671670 TwinAdminListFull ,
671+ NodeNotOptedOutOfV3Billing ,
672+ NodeV3OptOutMetadataTooLong ,
672673 }
673674
674675 #[ pallet:: genesis_config]
@@ -1375,20 +1376,6 @@ pub mod pallet {
13751376 Self :: _opt_out_of_v3_billing ( account_id, node_id)
13761377 }
13771378
1378- // Farmer sets metadata for an opted-out node (e.g. v4 account address).
1379- // Node must already be opted out. Caller must be the farm owner.
1380- // Pass empty metadata to clear.
1381- #[ pallet:: call_index( 46 ) ]
1382- #[ pallet:: weight( <T as Config >:: WeightInfo :: set_node_v3_opt_out_metadata( ) ) ]
1383- pub fn set_node_v3_opt_out_metadata (
1384- origin : OriginFor < T > ,
1385- node_id : u32 ,
1386- metadata : Vec < u8 > ,
1387- ) -> DispatchResultWithPostInfo {
1388- let account_id = ensure_signed ( origin) ?;
1389- Self :: _set_node_v3_opt_out_metadata ( account_id, node_id, metadata)
1390- }
1391-
13921379 // Council adds an account to the twin admin list (allowed to deploy on opted-out nodes)
13931380 #[ pallet:: call_index( 44 ) ]
13941381 #[ pallet:: weight( <T as Config >:: WeightInfo :: add_twin_admin( ) ) ]
@@ -1410,5 +1397,19 @@ pub mod pallet {
14101397 T :: RestrictedOrigin :: ensure_origin ( origin) ?;
14111398 Self :: _remove_twin_admin ( account)
14121399 }
1400+
1401+ // Farmer sets metadata for an opted-out node (e.g. v4 account address).
1402+ // Node must already be opted out. Caller must be the farm owner.
1403+ // Pass empty metadata to clear.
1404+ #[ pallet:: call_index( 46 ) ]
1405+ #[ pallet:: weight( <T as Config >:: WeightInfo :: set_node_v3_opt_out_metadata( ) ) ]
1406+ pub fn set_node_v3_opt_out_metadata (
1407+ origin : OriginFor < T > ,
1408+ node_id : u32 ,
1409+ metadata : Vec < u8 > ,
1410+ ) -> DispatchResultWithPostInfo {
1411+ let account_id = ensure_signed ( origin) ?;
1412+ Self :: _set_node_v3_opt_out_metadata ( account_id, node_id, metadata)
1413+ }
14131414 }
14141415}
0 commit comments