Skip to content

[Fil 1351] rkhportal add method to add dc not set issue on metaalocator refreshes#88

Open
RafalMagrys wants to merge 7 commits intofidlabs:masterfrom
RafalMagrys:FIL-1351-rkhportal-add-method-to-add-dc-not-set-issue-on-metaalocator-refreshes
Open

[Fil 1351] rkhportal add method to add dc not set issue on metaalocator refreshes#88
RafalMagrys wants to merge 7 commits intofidlabs:masterfrom
RafalMagrys:FIL-1351-rkhportal-add-method-to-add-dc-not-set-issue-on-metaalocator-refreshes

Conversation

@RafalMagrys
Copy link
Copy Markdown
Collaborator

@RafalMagrys RafalMagrys commented Mar 16, 2026

RKH flow:

  • It is impossible to add allowance to contract using addVerifier method without onchain changes, so I proposed a workaround. When user selects Add, I sum current datacap of the contract and input value. Then I use this sum to proposeAddVerifier.

Allocator flow:

  • Since it was super easy, I added this also for automated allocators (all I needed was to add one ABI).

[edit]

  • I decided not to convert the initial value obtained from RPC (it is now added as a bigint, passed through the function and added at the end of the process).
  • Value is converted only for display purpose with rounded value to not break the layout

@RafalMagrys RafalMagrys self-assigned this Mar 16, 2026
@RafalMagrys RafalMagrys requested a review from JAG-UK March 18, 2026 08:54
proposeTransaction({ address, datacap: dataCap }).catch(error => {
async ({ dataCap, method }: ChangeDatacapFormValues) => {
const datacapForSubmit =
method === 'add' ? Number(dataCap) + Number(verifierData?.datacap || 0) : Number(dataCap);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should error out rather than || 0 - otherwise it will be more surprising than the original behaviour!

In other words, if we don't know how much datacap they currently have, we can't possibly add!

metaAllocatorContractAddress: '0xB6F5d279AEad97dFA45209F3E53969c2EF43C21d',
githubOwner: 'filecoin-project',
safeAddress: '0x2e25A2f6bC2C0b7669DFB25180Ed57e07dAabe9e',
safeAddress: '0xa6d01c6e053170cff6de826116949d0a315aae80',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a mistake/residue from testing

);

const datacap = await (api as any).client.stateVerifierStatus(actorId, null);
const datacapInPiB = BigInt(datacap.toString()) / BigInt(1_125_899_906_842_624);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this have to be an Int? It's extremely unusual for an Allocator to have an exact round number of PiB left.

SO long as it's not used for any actual allocation calculations this is minor, but we have to use the proper fractional numbers in any area of consequence.

const datacapInPiB = BigInt(datacap.toString()) / BigInt(1_125_899_906_842_624);

return {
datacap: Number(datacapInPiB),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comment on line 386 - I think this will cause rounding issues in allocations

@RafalMagrys RafalMagrys requested a review from JAG-UK March 20, 2026 09:22
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