-
Notifications
You must be signed in to change notification settings - Fork 3
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
Modify Excubiae
framework design improve reuse of deployed specific Excubia
contracts
#17
Conversation
…minor changes developers need to define the _check and _pass internal methods logic support for solidity >=0.8.0 with a default compiler version to 0.8.20
@sripwoud is the following CI behaviour correct? |
I think mostly correct yes. (maybe some loose ends here I need to investigate) |
sweet, tysm for the clarification here <3 btw, is this related to |
the hanging check was due to a misconfiguration of the branch protection rules. |
lovely, tysm |
@@ -57,23 +57,28 @@ yarn add @zk-kit/excubiae | |||
To build your own Excubia: | |||
|
|||
1. Inherit from the [Excubia](./Excubia.sol) abstract contract that conforms to the [IExcubia](./IExcubia.sol) interface. | |||
2. Implement the `_check()` method to define your own gatekeeping logic and to prevent unwanted access (sybils, double checks). | |||
2. Implement the `_check()` and `_pass()` methods logic defining your own checks to prevent unwanted access (sybils, double checks). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe instead of double check (which now is techincally possible by calling check directly), we should make it more clear, maybe "double pass"? or even expand a bit more and explain that ideally pass/_pass should record the data used to pass the check and prevent the same data from being used twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's a good point. In fact, the check()
is not doing besides answering with "you're eligible / you're not eligible". Therefore, instead of double check is something like "avoid to pass the gate twice".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks
Description
The actual design of Excubiae centralises the definition of the custom access control and prevention of unwanted access logic within the
_check()
method. Consequently, the developer is required to extend the Excubia contract and implement the logic for the_check()
method only.This design has several advantages, including reduced gas cost and the ease of creating one's own custom contract (one method override). However, this approach presents a significant challenge when attempting to reuse the same logic defined in an Excubia within a different contract. Indeed, interfacing with an Excubia and extending or reusing the
_check()
, would result in a tentative update to the execution of both logics (custom access control and prevention of unwanted access).This is a problematic scenario because it is undesirable for an external Excubia to have the ability to modify the status directly and thereby render any records of users who have already passed invalid. Furthermore, it would be highly limiting from the perspective of aggregating multiple Excubias.
With regard to this latter point, if it were not possible to reuse the aforementioned
_check()
, it would be necessary to deploy the precise same Excubia, which would result in increased costs and the replication of on-chain logic.In consequence, this PR introduces a novel design comprising:
_check()
, which will exclusively address custom access control logic; and_pass()
, which will exclusively prevent unwanted access.In addition, there will be two external methods (
check()
andpass()
), which can be called externally to ascertain whether the custom access control logic is eligible to be passed (without requesting to pass the gate) or to attempt to pass the gate.This approach allows for the aggregation of multiple Excubia instances and the invocation of the public interface, represented by the
check()
function. Based on the outcomes of these checks, the implementation of the logic preventing unwanted access can be initiated in the_pass()
function. This will result in a change to the state of the aggregation contract, rather than that of the individual aggregates. This approach allows for the aggregation of the aggregation contract itself, representing a significant advancement in the composability of Excubia.The following are the disadvantages for the new design:
EASExcubia
incurs an additional expense of approximately 31k gas, while the execution ofsetGate()
andpass()
requires a mere 1k and 200 gas, respectively. This is a great trade-off since you deploy once and you do not need to duplicate deploys of Excubia anymore._pass()
and_check()
methods.Other information
Additional modifications include the introduction of a 'GateSet' event to the 'setGate()' method, the adjustment of the supported Solidity version to 0.8.20, enhancements to the comments and interfaces, and the incorporation of missing tests to achieve comprehensive coverage.
Checklist
yarn format
andyarn compile
without getting any errors