@@ -433,6 +433,9 @@ where
433
433
GatekeeperEvent :: _RepairV
434
434
| GatekeeperEvent :: _PhalaLaunched
435
435
| GatekeeperEvent :: _UnrespFix => unreachable ! ( ) ,
436
+ GatekeeperEvent :: SetStaticV { .. } => {
437
+ // Handled by ComputingEconomics
438
+ }
436
439
}
437
440
}
438
441
@@ -1178,14 +1181,19 @@ impl<MsgChan: MessageChannel<Signer = Sr25519Signer>> ComputingEconomics<MsgChan
1178
1181
GatekeeperEvent :: _RepairV
1179
1182
| GatekeeperEvent :: _PhalaLaunched
1180
1183
| GatekeeperEvent :: _UnrespFix => unreachable ! ( ) ,
1184
+ GatekeeperEvent :: SetStaticV { enabled } => {
1185
+ if origin. is_pallet ( ) {
1186
+ self . tokenomic_params . set_static_v ( enabled) ;
1187
+ }
1188
+ }
1181
1189
}
1182
1190
}
1183
1191
1184
1192
pub fn update_tokenomic_parameters (
1185
1193
& mut self ,
1186
1194
params : phala_types:: messaging:: TokenomicParameters ,
1187
1195
) {
1188
- self . tokenomic_params = params . into ( ) ;
1196
+ self . tokenomic_params . update ( params ) ;
1189
1197
info ! (
1190
1198
target: "gk_computing" ,
1191
1199
"Tokenomic parameter updated: {:#?}" ,
@@ -1348,13 +1356,16 @@ mod tokenomic {
1348
1356
#[ serde( with = "serde_fp" ) ]
1349
1357
payout_ration : FixedPoint ,
1350
1358
pub heartbeat_window : u32 ,
1359
+ /// The V won't increase on IDLE if set to true
1360
+ #[ serde( default ) ]
1361
+ static_v : bool ,
1351
1362
}
1352
1363
1353
- impl From < TokenomicParameters > for Params {
1354
- fn from ( params : TokenomicParameters ) -> Self {
1364
+ impl Params {
1365
+ pub fn update ( & mut self , params : TokenomicParameters ) {
1355
1366
let treasury_ration = FixedPoint :: from_bits ( params. treasury_ratio ) ;
1356
1367
let payout_ration = fp ! ( 1 ) - treasury_ration;
1357
- Params {
1368
+ * self = Params {
1358
1369
rho : FixedPoint :: from_bits ( params. rho ) ,
1359
1370
slash_rate : FixedPoint :: from_bits ( params. slash_rate ) ,
1360
1371
budget_per_block : FixedPoint :: from_bits ( params. budget_per_block ) ,
@@ -1364,7 +1375,12 @@ mod tokenomic {
1364
1375
treasury_ration,
1365
1376
payout_ration,
1366
1377
heartbeat_window : params. heartbeat_window ,
1367
- }
1378
+ static_v : self . static_v ,
1379
+ } ;
1380
+ }
1381
+
1382
+ pub fn set_static_v ( & mut self , enabled : bool ) {
1383
+ self . static_v = enabled;
1368
1384
}
1369
1385
}
1370
1386
@@ -1379,6 +1395,7 @@ mod tokenomic {
1379
1395
treasury_ration : fp ! ( 0.2 ) ,
1380
1396
payout_ration : fp ! ( 0.8 ) ,
1381
1397
heartbeat_window : 10 ,
1398
+ static_v : false ,
1382
1399
}
1383
1400
}
1384
1401
@@ -1393,6 +1410,9 @@ mod tokenomic {
1393
1410
1394
1411
/// case1: Idle, no event
1395
1412
pub fn update_v_idle ( & mut self , params : & Params ) {
1413
+ if params. static_v {
1414
+ return ;
1415
+ }
1396
1416
let cost_idle = params. cost_k * self . p_bench + params. cost_b ;
1397
1417
let perf_multiplier = if self . p_bench == fp ! ( 0 ) {
1398
1418
fp ! ( 1 )
@@ -1418,7 +1438,7 @@ mod tokenomic {
1418
1438
if sum_share == fp ! ( 0 ) {
1419
1439
return NO_UPDATE ;
1420
1440
}
1421
- if self . v_deductible == fp ! ( 0 ) {
1441
+ if !params . static_v && self . v_deductible == fp ! ( 0 ) {
1422
1442
return NO_UPDATE ;
1423
1443
}
1424
1444
if block_number <= self . v_update_block {
@@ -1434,10 +1454,11 @@ mod tokenomic {
1434
1454
let actual_payout = budget * params. payout_ration ;
1435
1455
let actual_treasury = budget * params. treasury_ration ;
1436
1456
1437
- let actual_v_deduct = self . v_deductible . clamp ( fp ! ( 0 ) , actual_payout) ;
1438
- self . v -= actual_v_deduct;
1439
-
1440
- self . v_deductible = fp ! ( 0 ) ;
1457
+ if !params. static_v {
1458
+ let actual_v_deduct = self . v_deductible . clamp ( fp ! ( 0 ) , actual_payout) ;
1459
+ self . v -= actual_v_deduct;
1460
+ self . v_deductible = fp ! ( 0 ) ;
1461
+ }
1441
1462
self . v_update_at = now_ms;
1442
1463
self . v_update_block = block_number;
1443
1464
0 commit comments