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
As it stands, the trait machinery in mintscript is rather elaborate. Would be nice to put some thought into simplifyintg them.
A chunk of the complexity stems from the fact that as it stands, there are two verification modes: full check and timelock-only check. If these could be unified in some way, it would immediately reduce complexity significantly. However, the two have different requirements on the kind of information needed from the context, which makes it not completely trivial.
There are two parts to the issue: extraction of script from transaction inputs (mintscript::translate module) and script verification (in mintscript::checkers). Let's briefly discuss the two in turn.
Script translation
Script translation currently has three modes:
Regular transaction
Block reward
Timelock-only
The modes are distinguished using a type-based tag. In retrospect, this is probably an overkill. It is somewhat useful to distinguish between the transaction mode and the reward mode at type level. The transaction verifier is parametrized by the kind of transaction (regular/reward) that's being verified so the type helps to pick the correct implementation there. The timelock-only mode, however, could be just a standalone function without much loss.
Script verification
We currently expose the ScriptChecker object, which is paramtetrised by various "sub-checkers" for verifying timelocks, signatures, hashlocks, etc. It seems sufficient to expose just a pair of functions for full script checking and for timelock-only checking:
This is much less flexible than the current approach with parametrized types but may be good enough. Presumably, the FullContext trait would be a subtrait of TimelockContext. As now, these provide the information about the transaction needed to verify it that is not directly part of the script.
The code may need refactoring to avoid duplication of shared parts. Alternatively, the functions may be implemented in terms of the current checkers, just exposing the simplified interface externally.
The text was updated successfully, but these errors were encountered:
As it stands, the trait machinery in mintscript is rather elaborate. Would be nice to put some thought into simplifyintg them.
A chunk of the complexity stems from the fact that as it stands, there are two verification modes: full check and timelock-only check. If these could be unified in some way, it would immediately reduce complexity significantly. However, the two have different requirements on the kind of information needed from the context, which makes it not completely trivial.
There are two parts to the issue: extraction of script from transaction inputs (
mintscript::translate
module) and script verification (inmintscript::checkers
). Let's briefly discuss the two in turn.Script translation
Script translation currently has three modes:
The modes are distinguished using a type-based tag. In retrospect, this is probably an overkill. It is somewhat useful to distinguish between the transaction mode and the reward mode at type level. The transaction verifier is parametrized by the kind of transaction (regular/reward) that's being verified so the type helps to pick the correct implementation there. The timelock-only mode, however, could be just a standalone function without much loss.
Script verification
We currently expose the
ScriptChecker
object, which is paramtetrised by various "sub-checkers" for verifying timelocks, signatures, hashlocks, etc. It seems sufficient to expose just a pair of functions for full script checking and for timelock-only checking:This is much less flexible than the current approach with parametrized types but may be good enough. Presumably, the
FullContext
trait would be a subtrait ofTimelockContext
. As now, these provide the information about the transaction needed to verify it that is not directly part of the script.The code may need refactoring to avoid duplication of shared parts. Alternatively, the functions may be implemented in terms of the current checkers, just exposing the simplified interface externally.
The text was updated successfully, but these errors were encountered: