You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a proposal for changing the _check() method to be an independent smart contract (Checker). We must understand the trade-offs mainly in reuse of gatekeepers, DX and gas consumption. This alternative is going to be executed on the ar/checker-contract branch.
The text was updated successfully, but these errors were encountered:
After some discussions & feedbacks and classic trial-and-error approach, the drafty new core structure including a Checker contract will be something similar to the following.
// Base interface.interfaceIChecker {
function check(addresspasserby, bytesmemorydata) externalview;
}
// Simple Checker for base use cases.abstractcontractSimpleCheckerisIChecker {
function check(addresspasserby, bytesmemorydata) externalviewvirtual {
_check(passerby, data);
}
function _check(addresspasserby, bytesmemorydata) internalviewvirtual;
}
// Advanced Checker for complex flows// Used MAIN instead of CONTINUE for// PRE-MAIN-POST and main check can be done >= 1 times.abstractcontractAdvancedCheckerisIChecker {
enum Phase { PRE, MAIN, POST }
struct CheckStatus {
bool preExecuted;
bool mainExecuted;
bool postExecuted;
}
mapping(address=> CheckStatus) public checkStatus;
uint8public configFlags;
function check(addresspasserby, bytesmemorydata) externalviewoverride {
if (!_shouldSkipPhase(Phase.PRE)) {
_checkPre(passerby, data);
}
_checkMain(passerby, data);
if (!_shouldSkipPhase(Phase.POST)) {
_checkPost(passerby, data);
}
}
function _checkPre(addresspasserby, bytesmemorydata) internalviewvirtual {}
function _checkMain(addresspasserby, bytesmemorydata) internalviewvirtual;
function _checkPost(addresspasserby, bytesmemorydata) internalviewvirtual {}
}
// Factory pattern for checker creation.contractCheckerFactory {
function createSimpleChecker() externalreturns (address);
function createAdvancedChecker(uint8configFlags) externalreturns (address);
}
// Modified Excubia base.abstractcontractExcubiaisIExcubia {
IChecker publicimmutable checker;
constructor(IChecker _checker) {
checker = _checker;
}
function pass(addresspasserby, bytescalldatadata) externalvirtual onlyGate {
checker.check(passerby, data);
emitGatePassed(passerby, gate);
}
}
0xjei
linked a pull request
Nov 6, 2024
that will
close
this issue
There's a proposal for changing the
_check()
method to be an independent smart contract (Checker
). We must understand the trade-offs mainly in reuse of gatekeepers, DX and gas consumption. This alternative is going to be executed on thear/checker-contract
branch.The text was updated successfully, but these errors were encountered: