Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client to verifier balance event #1533

Merged
merged 12 commits into from
Mar 21, 2024

Conversation

aarshkshah1992
Copy link
Contributor

This is based on FIP update proposal filecoin-project/FIPs#968

Adding the 'client' field to the verifier balance event makes it easy for users to track datacap allocations by verifiers to clients.

) -> Result<ActorEvent, ActorError> {
EventBuilder::new()
.typ("verifier-balance")
.field_indexed("verifier", &verifier)
.field("balance", &BigIntSer(balance))
.field_indexed("client", &client)
Copy link
Member

Choose a reason for hiding this comment

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

Given the list-of-pairs logical and physical representation of an event, we have two ways to represent an absent field:

  • include a k/v pair but the value is nil
  • don't include the key at all

I mostly would go for omitting the key rather than including it with a nil value. One argument against this is that it would make it harder to naively splat event k/v pairs into a static structure, e.g. with the handy schema deserialisation tools in some programming languages. However that kind of static schema doesn't work generally anyway - e.g. sector activation events have repeated keys for pieces in a sector. Some custom splatting library could of course be written to interpret repeated keys into lists, etc, but such software could also handle missing keys for options.

So.... omit the field instead?

.field("balance", &BigIntSer(&(verifier_balance - allowance)))
.build()?,
);
if client_resolved.id().is_ok() {
Copy link
Member

Choose a reason for hiding this comment

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

This should probably just unwrap. If the client can't be resolved, something is wrong with the test code and it should abort (e.g. the datacap transfer should also fail).

Copy link
Member

Choose a reason for hiding this comment

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

thread 'clients::rejects_unresolved_address' panicked at 'called Result::unwrap()on anErr value: NonIDAddress', actors/verifreg/tests/harness/mod.rs:242:64

That's why it's in here. But now I don't understand why it's OK to if the emit and not have an event in this case.

actors/verifreg/tests/harness/mod.rs Outdated Show resolved Hide resolved
@rvagg rvagg force-pushed the feat/verifier-balance-client branch from aa2745a to 0aee536 Compare March 20, 2024 22:29
@rvagg rvagg force-pushed the feat/verifier-balance-client branch 4 times, most recently from 9f768be to ea9fb24 Compare March 20, 2024 22:33
@rvagg
Copy link
Member

rvagg commented Mar 20, 2024

rebased and force-pushed some changes in response to review (sorry, got changes and rebase mixed up so you own my changes now @aarshkshah1992!)

Stebalien
Stebalien previously approved these changes Mar 20, 2024
@Stebalien
Copy link
Member

But note: i agree with #1533 (comment) and would consider simply omitting nil clients (unless we expect that this will be a useful filter)?

@Stebalien Stebalien dismissed their stale review March 20, 2024 23:45

test failure

@Stebalien
Copy link
Member

Hm. It looks like that test failure is real.

@anorth
Copy link
Member

anorth commented Mar 21, 2024

It is explicitly testing unresolved address behaviour. But I think the test harness is wrong at

    let client_resolved = rt.get_id_address(client).unwrap_or(*client);

It should just not expect any calls or events if the address is unresolvable.

@rvagg
Copy link
Member

rvagg commented Mar 21, 2024

It should just not expect any calls or events if the address is unresolvable.

this is actually from a expect_abort so I think Aarsh was right here, it's expecting to get an abort from the call and it shouldn't emit the event. I'll put his if back and comment it.

@rvagg rvagg force-pushed the feat/verifier-balance-client branch from ea9fb24 to 29d7d24 Compare March 21, 2024 00:38
@rvagg
Copy link
Member

rvagg commented Mar 21, 2024

done

@rvagg rvagg force-pushed the feat/verifier-balance-client branch from 29d7d24 to 927f968 Compare March 21, 2024 01:03
@rvagg
Copy link
Member

rvagg commented Mar 21, 2024

Made "client" optional instead of nullable, so it won't appear if there is no client involved as per discussion on the FIP.

@rvagg rvagg force-pushed the feat/verifier-balance-client branch from 927f968 to a3d0403 Compare March 21, 2024 02:43
@aarshkshah1992
Copy link
Contributor Author

@rvagg Yes, we're expecting the call to abort as the test is testing the case where client can not be resolved.

@aarshkshah1992
Copy link
Contributor Author

lgtm

@rvagg rvagg force-pushed the feat/verifier-balance-client branch from a3d0403 to 8f848a0 Compare March 21, 2024 09:42
Base automatically changed from feat/actor-event-updates to release/v13 March 21, 2024 12:51
@aarshkshah1992 aarshkshah1992 merged commit 0f205c3 into release/v13 Mar 21, 2024
14 checks passed
@aarshkshah1992 aarshkshah1992 deleted the feat/verifier-balance-client branch March 21, 2024 12:52
rvagg added a commit that referenced this pull request Jun 19, 2024
* update to Actor events

* changes as per review

* remvoe clippy

* changes as per new FIP update

* Update to latest PR, remove emit:: use from testing

* all itests passing and green CI

* address review feedback, minimise diff

* feat: add term_start to claim events

* fix: claim term_start at current epoch, not at deal_start

* fix: s/deal_term/claim_term

* add client to verifier balance event

* fix: make "client" optional on verifier-balance event

---------

Co-authored-by: Rod Vagg <rod@vagg.org>
rvagg added a commit that referenced this pull request Jun 19, 2024
* update to Actor events

* changes as per review

* remvoe clippy

* changes as per new FIP update

* Update to latest PR, remove emit:: use from testing

* all itests passing and green CI

* address review feedback, minimise diff

* feat: add term_start to claim events

* fix: claim term_start at current epoch, not at deal_start

* fix: s/deal_term/claim_term

* add client to verifier balance event

* fix: make "client" optional on verifier-balance event

---------

Co-authored-by: Rod Vagg <rod@vagg.org>
rvagg added a commit that referenced this pull request Jun 19, 2024
* update to Actor events

* changes as per review

* remvoe clippy

* changes as per new FIP update

* Update to latest PR, remove emit:: use from testing

* all itests passing and green CI

* address review feedback, minimise diff

* feat: add term_start to claim events

* fix: claim term_start at current epoch, not at deal_start

* fix: s/deal_term/claim_term

* add client to verifier balance event

* fix: make "client" optional on verifier-balance event

---------

Co-authored-by: Rod Vagg <rod@vagg.org>
rvagg added a commit that referenced this pull request Jun 19, 2024
* update to Actor events

* changes as per review

* remvoe clippy

* changes as per new FIP update

* Update to latest PR, remove emit:: use from testing

* all itests passing and green CI

* address review feedback, minimise diff

* feat: add term_start to claim events

* fix: claim term_start at current epoch, not at deal_start

* fix: s/deal_term/claim_term

* add client to verifier balance event

* fix: make "client" optional on verifier-balance event

---------

Co-authored-by: Rod Vagg <rod@vagg.org>
github-merge-queue bot pushed a commit that referenced this pull request Jun 21, 2024
* Updates to Actor events based on community feedback for NV22  (#1531)

* update to Actor events

* changes as per review

* remvoe clippy

* changes as per new FIP update

* Update to latest PR, remove emit:: use from testing

* all itests passing and green CI

* address review feedback, minimise diff

* feat: add term_start to claim events

* fix: claim term_start at current epoch, not at deal_start

* fix: s/deal_term/claim_term

---------

Co-authored-by: Rod Vagg <rod@vagg.org>

* Add client to verifier balance event (#1533)

* update to Actor events

* changes as per review

* remvoe clippy

* changes as per new FIP update

* Update to latest PR, remove emit:: use from testing

* all itests passing and green CI

* address review feedback, minimise diff

* feat: add term_start to claim events

* fix: claim term_start at current epoch, not at deal_start

* fix: s/deal_term/claim_term

* add client to verifier balance event

* fix: make "client" optional on verifier-balance event

---------

Co-authored-by: Rod Vagg <rod@vagg.org>

---------

Co-authored-by: Aarsh Shah <aarshkshah1992@gmail.com>
ZenGround0 pushed a commit that referenced this pull request Jun 25, 2024
* Updates to Actor events based on community feedback for NV22  (#1531)

* update to Actor events

* changes as per review

* remvoe clippy

* changes as per new FIP update

* Update to latest PR, remove emit:: use from testing

* all itests passing and green CI

* address review feedback, minimise diff

* feat: add term_start to claim events

* fix: claim term_start at current epoch, not at deal_start

* fix: s/deal_term/claim_term

---------

Co-authored-by: Rod Vagg <rod@vagg.org>

* Add client to verifier balance event (#1533)

* update to Actor events

* changes as per review

* remvoe clippy

* changes as per new FIP update

* Update to latest PR, remove emit:: use from testing

* all itests passing and green CI

* address review feedback, minimise diff

* feat: add term_start to claim events

* fix: claim term_start at current epoch, not at deal_start

* fix: s/deal_term/claim_term

* add client to verifier balance event

* fix: make "client" optional on verifier-balance event

---------

Co-authored-by: Rod Vagg <rod@vagg.org>

---------

Co-authored-by: Aarsh Shah <aarshkshah1992@gmail.com>
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.

4 participants