@@ -17,7 +17,7 @@ import {
1717 SET_SHARES,
1818 CLAIM
1919} from "./FVMRewardMethod.sol " ;
20- import {WeightRecord, Share, PendingOp} from "./FVMRewardTypes.sol " ;
20+ import {WeightRecord, WeightRecordUpdate, Share, PendingOp} from "./FVMRewardTypes.sol " ;
2121
2222/// @notice Calls the f02 (Reward actor) methods specified by FIP-0118, for the Stream Weight
2323/// Actor (solstice#3) and Service Rewards Actor (solstice#4).
@@ -42,9 +42,6 @@ library FVMRewards {
4242 error ValueOutOfRange (int256 value );
4343 /// @dev An implicit stream (null distribution) carries no share map.
4444 error ImplicitStreamWithShares ();
45- /// @dev The wire carries one array of `[id, record]` pairs, so the two inputs must be equal in
46- /// length; a mismatch has no encoding.
47- error ArrayLengthMismatch (uint256 ids , uint256 records );
4845
4946 /// @dev Sentinel for the unexpected case where the syscall reverts or returns fewer than 32
5047 /// bytes. Kept at -1 to match `fvm-solidity`'s behavior.
@@ -274,53 +271,42 @@ library FVMRewards {
274271 // -------------------------------------------------------------------------
275272
276273 /// @notice Queues a discretionary weight-schedule write, without reverting on actor error.
277- function trySetWeightRecords (uint64 [] memory ids , WeightRecord[] memory records )
278- internal
279- returns (int256 exitCode )
280- {
281- return _tryWeightRecords (SET_WEIGHT_RECORDS, ids, records);
274+ function trySetWeightRecords (WeightRecordUpdate[] memory updates ) internal returns (int256 exitCode ) {
275+ return _tryWeightRecords (SET_WEIGHT_RECORDS, updates);
282276 }
283277
284278 /// @notice Queues a gate-originated weight-schedule write, without reverting on actor error.
285279 /// @dev Encodes identically to SetWeightRecords and differs only in dispatch, but the two are
286280 /// separate calls because f02 treats them differently: a StepWeightRecords write cannot be
287281 /// cancelled, so the discretionary path cannot revoke what the governance gate produced.
288- function tryStepWeightRecords (uint64 [] memory ids , WeightRecord[] memory records )
289- internal
290- returns (int256 exitCode )
291- {
292- return _tryWeightRecords (STEP_WEIGHT_RECORDS, ids, records);
282+ function tryStepWeightRecords (WeightRecordUpdate[] memory updates ) internal returns (int256 exitCode ) {
283+ return _tryWeightRecords (STEP_WEIGHT_RECORDS, updates);
293284 }
294285
295286 /// @dev Params CBOR: `[[[id, record], ...]]` -- one array of pairs, inside the single-field
296287 /// tuple wrapper f02's parameter struct produces.
297- function _tryWeightRecords (uint64 method , uint64 [] memory ids , WeightRecord[] memory records )
298- private
299- returns (int256 exitCode )
300- {
301- if (ids.length != records.length ) revert ArrayLengthMismatch (ids.length , records.length );
302-
288+ function _tryWeightRecords (uint64 method , WeightRecordUpdate[] memory updates ) private returns (int256 exitCode ) {
303289 // [[[id, record], ...]]
304- (uint256 base , uint256 p ) = _begin (method, MAX_HEAD_BYTES + MAX_HEAD_BYTES + ids .length * MAX_UPDATE_BYTES);
290+ (uint256 base , uint256 p ) = _begin (method, MAX_HEAD_BYTES + MAX_HEAD_BYTES + updates .length * MAX_UPDATE_BYTES);
305291 p = _writeArrayHeader (p, 1 );
306- p = _writeArrayHeader (p, ids .length );
307- for (uint256 i = 0 ; i < ids .length ; i++ ) {
292+ p = _writeArrayHeader (p, updates .length );
293+ for (uint256 i = 0 ; i < updates .length ; i++ ) {
308294 p = _writeArrayHeader (p, 2 );
309- p = _writeUint (p, ids [i]);
310- p = _writeRecord (p, records [i]);
295+ p = _writeUint (p, updates [i].id );
296+ p = _writeRecord (p, updates [i].record );
311297 }
312298 return _invoke (base, p);
313299 }
314300
315301 /// @notice Queues a discretionary weight-schedule write, reverting on actor error.
316- function setWeightRecords (uint64 [] memory ids , WeightRecord[] memory records ) internal {
317- int256 exitCode = trySetWeightRecords (ids, records );
302+ function setWeightRecords (WeightRecordUpdate [] memory updates ) internal {
303+ int256 exitCode = trySetWeightRecords (updates );
318304 require (exitCode == EXIT_SUCCESS, SetWeightRecordsFailed (exitCode));
319305 }
320306
321307 /// @notice Queues a gate-originated weight-schedule write, reverting on actor error.
322- function stepWeightRecords (uint64 [] memory ids , WeightRecord[] memory records ) internal {
323- int256 exitCode = tryStepWeightRecords (ids, records );
308+ function stepWeightRecords (WeightRecordUpdate [] memory updates ) internal {
309+ int256 exitCode = tryStepWeightRecords (updates );
324310 require (exitCode == EXIT_SUCCESS, StepWeightRecordsFailed (exitCode));
325311 }
326312
0 commit comments