Could the interim policy automatically register a new recipient in afterTransfer when a FORCED transfer gives them a positive balance?
Otherwise a legitimate enforcement transfer just before the final install could make it revert until someone registers that holder. The enforcer does not need to be malicious for this race to happen.
Just a thought. Would automatic registration preserve completion once the existing holders have all been registered?
Thanks Dmitry, yes. As the draft stands, a FORCED transfer to a new account that lands just before the final install makes it revert, and it only goes through once someone registers that holder. With a TimelockController or a Governor the operation stays ready after a failed execute, so it’s a retry rather than another delay, but it’s a failure that doesn’t need to happen.
Registering the receiver in afterTransfer fixes it. When a FORCED movement leaves an unregistered account with a balance, the interim policy registers it in the same call, adding its balance after the move to the sum and one to the count. Using the balance after the move also covers an existing holder that wasn’t registered yet. Once every existing holder is registered, ordinary movements can’t create a holder and FORCED registers the one it creates, so the sum stays equal to totalSupply() and the install completes whenever it runs.
Automatic registration addresses the race I meant. Using the full post-transfer balance also covers an existing holder that has not been registered yet. Thanks for clarifying that a failed execution remains ready for retry. That resolves my concern.
canSend(address(0)) and canReceive(address(0)) now return true without calling the policy. ERC-7943 requires canTransfer to run both checks with no exception for zero, and xaler suggested this instead of skipping them. Policies and the interface didn’t change.
data for TRANSFER, MINT and BURN used to have to be empty. It can now hold values the token derives from its own state, such as balances before the movement, as long as canTransfer builds the same thing. It still can’t hold anything the caller supplied. The reference still passes empty data.
afterTransfer must not enforce a rule on a TRANSFER, MINT or BURN. A rule that can reject belongs in checkTransfer, because canTransfer doesn’t call afterTransfer, and ERC-7943 wants canTransfer to be false when a rule would stop the transfer. A revert from a bug or out of gas still fails the movement.
The rule that an installation can’t depend on the outgoing policy now binds only the calls the token makes. As written it conflicted with a policy reading its predecessor in onInstall, which the staged install relies on.
A policy with no state may do nothing else in onInstall, but it still has to check its caller.
Access control on any function that causes a movement stays outside the token’s own checks, not only on mint and burn. Balances stay outside the token’s own checks rather than all of canTransfer, because a policy can still reject for a lock-up.
A single-party forcedTransfer should still apply the token’s own conditions on to, as ERC-7943 says.
These fix or add text without changing a rule:
The draft said a proxied token could install from its initializer. That fails if the proxy’s constructor runs the initializer, because the proxy has no code yet. It has to be called after deployment.
The fuzzed parity bullet in Test Cases now states the balance shortfall exception. It was out of date.
In the staged install, it’s the second installation’s onInstall that checks the sum, not the interim policy.
The rationale now says why MINT and BURN come before EXECUTED, and that a pause changes canTransfer but not canSend or canReceive.
The kinds table has a new row: an agent’s transfer under an ERC-8226 mandate, through the base transfer functions, is a TRANSFER.
A claim-by-claim check against the code and the cited ERCs also found smaller wording errors, which are fixed.
I also added a test for a check that runs out of gas. It was missing: a token that permitted on a failed call with no return data passed the whole suite.
One thing #24 left out, and it’s the part I’d most like eyes on: the reference now has an EXECUTED path.
Carlos made the case in #2 for keeping EXECUTED in the base set, but until now those rules were only text. In ExampleExecutorToken, an account with an executor role carries out a holder’s signed EIP-712 instruction, data carries the reference and deadline, and canExecute is the pre-flight.
Building it found nothing that can’t be met, but it did find gaps, mostly in check rule 6:
It didn’t say where operator comes from. The pre-flight is now told the executing account.
It only constrained the context, so a pre-flight could ignore the pause and still conform. Now it can’t say yes when the token’s checks or the policy would reject.
Kind rule 4 didn’t say what “verified itself” means for a holder that’s a contract. An ERC-1271 answer now counts.
For EXECUTED, checkTransfer shouldn’t depend on state the operation changes first, like the record that an instruction was used, and afterTransfer shouldn’t enforce a rule. A pre-flight can’t see either one. Both are SHOULD NOTs.
Security Considerations also has a new section on signed instructions: replay, what the signature has to cover, and expiry. The ERC leaves the instruction itself to the token, so that’s where those points go.
If anyone here has built a settlement channel, I’d like to know whether this instruction matches how you’d do it.
Thanks Carlos and Dmitry, most of the install section came out of your reviews.
Replay, domain and deadline read right to me. The part I’d change is that the instruction doesn’t name who executes it.
Any account with EXECUTOR_ROLE can carry out any holder’s instruction, and the policy then decides on that account as operator. ExecutedRulesPolicy in your tests already allows one executor and rejects the other, and nothing the holder signed picks between them. With one channel that’s fine. With two that have different windows or cut-offs, once channel A’s transaction is in the mempool, channel B can submit the same instruction and signature first and settle it under its own rules. An optional executor field, zero meaning any account with the role, checked in _instructionCheck, covers it, and the Binding bullet could add operator to what the signature should cover when the policy treats executors differently. Kind rule 4 may need a few words too, since “only an account the instruction names … does not qualify” reads as if naming the executor on top of the role check takes the movement out of EXECUTED.
The missing cancel also weighs more than the deadline alone suggests. A rejected movement leaves the instruction usable, so one refused because the window was closed or the receiver wasn’t eligible yet can still be carried out once the window opens or the receiver is onboarded, any time before the deadline. A contract holder can stop that by changing its ERC-1271 answer. An EOA can’t, short of moving its balance away. A cancelInstruction(bytes32 instructionRef) that sets instructionUsed[_msgSender()][instructionRef] is a few lines, and since it writes the record executeInstruction already checks, canExecute and the replay tests need nothing new.
An instruction can now name its executor. Zero means any account with the role, and the role is still required, so the name only narrows who can call. The signature covers the field, so another executor can’t clear it or put itself there. The race doesn’t need the mempool either: channel B can settle whenever it has the signature, for example while A’s window is closed. The Binding bullet now says the signature should also cover operator where a policy treats executors differently.
Kind rule 4 read the way you said. It now says “that an account the instruction names may call without that capability”, and the Rationale had the same phrase, so that changed too. The rule means what it meant.
cancelInstruction(bytes32 instructionRef) works as you described, writing the record executeInstruction already checks. I added an event, and a revert if the reference was already used, so a holder whose cancel lost the race finds out and one reference never shows up as both executed and cancelled. The Expiry bullet now says a refused instruction can still settle before its deadline, and how each kind of holder stops that. It says “an account without code” rather than EOA, because SignatureChecker sends an EIP-7702 account to ERC-1271.
A small addition to the draft. “Decisions and reason codes” said to hash an upper-case name for each reason and gave one example, so two policies that reject for the same reason could still return different values. A wallet then can’t explain a rejection without knowing which policy it came from.
The draft now lists seven names, and a policy should use the listed one when it rejects for that reason:
SENDER_NOT_ELIGIBLE and RECEIVER_NOT_ELIGIBLE, for an account that fails a requirement such as identity or jurisdiction, from checkSend, checkReceive or checkTransfer
LOCKED_UP, for tokens still in a lock-up or holding period
MAX_HOLDERS, for a movement that would take the number of holders above a cap
WINDOW_CLOSED, for a movement outside the hours or dates the policy allows
KIND_NOT_ALLOWED, for a kind the policy doesn’t allow, such as a plain TRANSFER when holders can only move tokens through an executor
OPERATOR_NOT_ALLOWED, for an EXECUTED or FORCED movement whose operator the policy doesn’t accept
The first five names cover the rules the Motivation lists. The last two only exist because of this ERC’s kinds and operator.
It’s a SHOULD, not a registry, and any other reason still gets its own name. Pause and frozen amounts aren’t on the list because they’re the token’s own checks, not the policy’s, and the token reports them with its own errors. I also left out credential expiry, minimum positions and supply caps to keep the list short. A policy can still name those itself.
If you run a policy that already uses other names for these, or think a common reason is missing, I’d like to hear it while this is still a draft.
A check that couldn’t finish has no name on the list. If a policy catches a failed call to its identity registry, requirement 8 stops it returning TRANSFER_OK, and the closest listed value is RECEIVER_NOT_ELIGIBLE. A wallet then tells a verified holder they aren’t eligible, and an executor holding a signed instruction reads the same value and may drop something that would settle once the registry answers, still inside the deadline.
Letting the call revert avoids the wrong label, but then canTransfer is just false and the movement reverts with no reason. A listed CHECK_UNAVAILABLE would let a wallet say try again and let an executor keep retrying.
Thanks Carlos. You’re right, nothing on the list fits that case, and RECEIVER_NOT_ELIGIBLE tells both the wallet and the executor the wrong thing.
I added CHECK_UNAVAILABLE as the eighth name: a call the policy makes in reaching the decision reverted or ran out of gas, so it could not decide. The Rationale says a wallet can suggest trying again and an executor can hold on to the instruction until its deadline, and that the name promises nothing about the next attempt. It only covers failures the policy catches. A check that itself reverts or runs out of gas still returns nothing, so the movement reverts without a reason and canTransfer is false.
Your example also showed a conflict in the draft. Requirement 2 said a check’s result must not depend on the remaining gas, but a policy that catches an out-of-gas call and rejects, as requirement 8 asks, does exactly that. Requirement 2 now says the remaining gas can make a policy reject, never permit.