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
{{ message }}
Repository navigation
Charge for compiling a contract's regular expressions at registration #5894
Registering or updating a data contract compiles its regular expressions: every string property's pattern, and every regexPattern of a contested index's fieldMatches. Nothing charges for that work. This issue tracks adding a price for it to the fee schedule.
Where patterns are compiled today
From protocol version 15 a contract's patterns are compiled in three passes, none of them charged:
The index parser compiles every regexPattern of a contested index.
The schema builders compile every pattern for the validator documents are checked with.
The registration fee is computed from the number of document types, indexes and tokens, plus the keywords, while validation operations are charged by schema size and property count. A contract refused because a pattern does not compile pays only the base costs of its transition, not for the patterns compiled before the refusal.
Why it is bounded already
From protocol version 15 a contract holds at most 32 patterns (max_contract_schema_patterns), each compiling within 128 KiB, so one pass costs at most about 11 ms and 4 MiB. check_tx holds a contract to the same bound at every protocol version. So this is about charging for bounded work, not about bounding it.
Proposal
Add a compile operation to a new FEE_VERSION schedule, recorded as a ProtocolValidationOperation by each pass that compiles a pattern, including a compile that fails, so that a contract refused for a pattern pays for the compiles before the refusal.
Select it only from the protocol version that adopts it, so blocks of earlier versions keep their fees.
Open questions
A flat rate per pattern, or one in proportion to the compiled size the regex crate accounts?
Charge each pass, or once for each distinct pattern?
Activity