Problem
After upgrading from v3.1.0 to v3.2.0, our Token contract (extends CMTATBaseRuleEngine) exceeds the EIP-170 24,576 byte limit.
The v3.2.0 changelog states:
DocumentEngine and SnapshotEngine removed from constructors and initialization
(#343) to simplify deployment and reduce bytecode size.
However, DocumentEngineModule and the new ERC20EnforcementModule (ERC-7943) are still compiled into every token that inherits CMTATBaseCommon, even if never initialized or called. The init parameter removal saves a few bytes, but the new ERC-7943 module adds significantly more.
Root Cause
CMTATBaseCommon unconditionally inherits both modules:
abstract contract CMTATBaseCommon is
VersionModule,
ERC20MintModule,
ERC20BurnModule,
ERC20BaseModule,
SnapshotEngineModule,
ERC20EnforcementModule, // ← always compiled in (new in v3.2.0)
DocumentEngineModule, // ← always compiled in
ExtraInformationModule,
IBurnMintERC20,
IERC5679
Any token extending CMTATBaseRuleEngine → CMTATBaseAccessControl → CMTATBaseCommon pays the bytecode cost for both modules regardless of usage.
Proposal
Introduce a CMTATBaseCommonLight (or similar) that includes SnapshotEngineModule but excludes DocumentEngineModule and ERC20EnforcementModule:
CMTATBaseCore — minimal (no snapshot, no doc, no enforcement)
CMTATBaseCommonLight — Core + SnapshotEngine + ExtraInformation
CMTATBaseCommon — full (snapshot + doc + ERC-7943 enforcement)
Alternativess
Make DocumentEngineModule and ERC20EnforcementModule opt-in mixins that consumers add to their own inheritance
The corresponding CMTATBaseAccessControl and CMTATBaseRuleEngine would
need light variants too, or they could be parameterized.
Problem
After upgrading from v3.1.0 to v3.2.0, our Token contract (extends
CMTATBaseRuleEngine) exceeds the EIP-170 24,576 byte limit.The v3.2.0 changelog states:
However,
DocumentEngineModuleand the newERC20EnforcementModule(ERC-7943) are still compiled into every token that inheritsCMTATBaseCommon, even if never initialized or called. The init parameter removal saves a few bytes, but the new ERC-7943 module adds significantly more.Root Cause
CMTATBaseCommonunconditionally inherits both modules:Any token extending
CMTATBaseRuleEngine → CMTATBaseAccessControl → CMTATBaseCommonpays the bytecode cost for both modules regardless of usage.Proposal
Introduce a
CMTATBaseCommonLight(or similar) that includesSnapshotEngineModulebut excludesDocumentEngineModuleandERC20EnforcementModule:CMTATBaseCore— minimal (no snapshot, no doc, no enforcement)CMTATBaseCommonLight— Core + SnapshotEngine + ExtraInformationCMTATBaseCommon— full (snapshot + doc + ERC-7943 enforcement)Alternativess
Make
DocumentEngineModuleandERC20EnforcementModuleopt-in mixins that consumers add to their own inheritanceThe corresponding
CMTATBaseAccessControlandCMTATBaseRuleEnginewouldneed light variants too, or they could be parameterized.