Skip to content

[EPIC] Chili: TreasureMaps con KFrags#2687

Merged
KPrasch merged 55 commits intomainfrom
chili-con-carne
Jul 12, 2021
Merged

[EPIC] Chili: TreasureMaps con KFrags#2687
KPrasch merged 55 commits intomainfrom
chili-con-carne

Conversation

@jMyles
Copy link
Copy Markdown
Contributor

@jMyles jMyles commented May 8, 2021

This replaces #2530 and incorporates subsequent work from @KPrasch (with touches from @jMyles).

Description modified from #2530:

Issues addressed:

Issues to address in a follow-up or related PR:


Note: This PR underwent a conflict-fraught rebase from 64c8a78 to f098aac. Some of @fjarri's work, particularly 26076b1, may have been impacted.

@jMyles jMyles force-pushed the chili-con-carne branch from c3f3048 to 64c8a78 Compare May 13, 2021 13:44
@jMyles jMyles force-pushed the chili-con-carne branch from 64c8a78 to f098aac Compare May 26, 2021 21:04
@jMyles jMyles force-pushed the chili-con-carne branch 2 times, most recently from f098aac to 6070910 Compare June 2, 2021 22:33
@jMyles jMyles changed the title [EPIC] [WIP] TreasureMaps con KFrags [EPIC] [WIP] Chili: TreasureMaps con KFrags Jun 3, 2021
@jMyles jMyles force-pushed the chili-con-carne branch from 6070910 to 2984265 Compare June 7, 2021 17:02
if writ_hrac != work_order.hrac: # Funky Workorder
raise Policy.Unauthorized # Bob, what the *hell* are you doing?

kfrag_checksum = keccak_digest(bytes(kfrag))[:WRIT_CHECKSUM_SIZE]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Any particular reason we're using a separate constant here instead of KECCAK_DIGEST_LENGTH?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This gives the writ checksum potential flexibility aside from other keccak digests we may be using. Do you think it's superfluous?

KPrasch added a commit that referenced this pull request Jul 3, 2021
@KPrasch KPrasch changed the title [EPIC] [WIP] Chili: TreasureMaps con KFrags [EPIC] Chili: TreasureMaps con KFrags Jul 3, 2021
@KPrasch KPrasch marked this pull request as ready for review July 3, 2021 23:28
Copy link
Copy Markdown
Member

@KPrasch KPrasch left a comment

Choose a reason for hiding this comment

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

I am one of the author's of this PR and I approve! 😅

Seriously, it's good to get a merge on this long-awaiting and impactful PR so we can begin to work with the new design assumptions.

StakerInfo,
PeriodDelta,
StakingEscrowParameters,
Policy
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like that ArrangementInfo is defined in PolicyManagerAgent, and find it a little strange that we have some other datatypes that are specific to contracts declared somewhere other than in the respective agent eg. can Policy be declared in PolicyAgent instead of in nucypher/types.py; can StakingEscrowParameters be declared in StakingEscrowAgent instead of in nucypher/types.py...?

May not apply to all classes defined in nucypher/types.py, but perhaps some/most?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, in keeping with the naming of other similar classes - wdyt about PolicyInfo instead of Policy?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In terms of composition, this might get a bit bulky. In StakingEscrow alone we have: StakingEscrowParameters, SubStakeInfo, RawSubStakeInfo, Downtime, StakerFlags, and StakerInfo. While it's strictly good encapsulation I don't think nesting so many class definitions will be very readable.

Do you have a preference for consistency? If it's the namepacing that matters most to you perhaps we make a typing module per contract?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am with Derek here regarding PolicyInfo vs Policy. We already have a Policy (defined in policies.py), which is a different type (with more complexity too, not just a collection of simple values). Makes sense to follow the example of Arrangement (a Python class) vs ArrangementInfo (a mapping of a Solidity structure).

Copy link
Copy Markdown
Member

@KPrasch KPrasch Jul 6, 2021

Choose a reason for hiding this comment

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

Renamed Policy -> PolicyInfo and relocated ArrangementInfo to types.py for now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you have a preference for consistency? If it's the namepacing that matters most to you perhaps we make a typing module per contract?

I think some sort of more direct association between the types defined and the contracts would make them more intuitive. Having them live in nucypher/types.py just seems vague; it could be a typing module per contract or even keeping it general like nucypher.blockchain.eth.types...?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

^ BTW Doesn't have to be this PR - maybe the namespacing can be looked into as part of a separate PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Filed #2739 .


if writ_hrac in self.revoked_policies:
# Note: This is only an off-chain and in-memory check.
raise Policy.Unauthorized # Denied
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we want to differentiate the reason for these raised Policy.Unauthorized exceptions (L1830, L1835, L1839) by contextualizing with a string message? Or is it unsafe to leak the reason?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You're sensing my thoughts there. Do you think there's an added advantage to provide a bob with the reason why he's been denied access over obscurity?

Copy link
Copy Markdown
Member

@derekpierre derekpierre Jul 7, 2021

Choose a reason for hiding this comment

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

Feels like it - the one raised from the VerificationError (L1835) may be interesting to know ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Alternatively, we could do sub-classes of Policy.Unauthorized if differentiation is worth it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Filed #2740.

@derekpierre
Copy link
Copy Markdown
Member

Definitely going to be conflicts after this gets merged and I rebase Porter over it 😱 😅 .

KPrasch added a commit to KPrasch/nucypher that referenced this pull request Jul 6, 2021
@KPrasch KPrasch force-pushed the chili-con-carne branch from 0cbcdd5 to 6192c34 Compare July 6, 2021 21:44
return ursula


@pytest.mark.skip("David, send help!")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@cygnusv - Heads up for you here.

return treasure_map


# FIXME: a dirty hack to make the tests pass. Fix it ASAP.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See #343 #281

Copy link
Copy Markdown
Member

@derekpierre derekpierre left a comment

Choose a reason for hiding this comment

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

🎸 - approving in the interest of time/traction; my 2 outstanding comments can be addressed (or looked into and rejected) as part of follow-up issues/PRs.

#2687 (comment) (error messages)
#2687 (comment) (namespacing of types)

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.

5 participants