Static Precompile Registration
The mechanism for compiling a fixed set of precompiled contracts into the Maroo node binary at build time.
Static registration means the addresses and functionalities of all precompiles are defined directly in the node's source code and are available from the moment of genesis. This approach ensures that all nodes on the network have an identical, predictable set of core functionalities. It contrasts with dynamic systems where new precompiles or native contracts could be registered via on-chain governance after launch.
The Builder Pattern
Maroo uses a builder or 'chainable' pattern for registering precompiles. The
StaticPrecompiles type, which is an alias for a map, has methods like WithOkrwPrecompile and WithPclPrecompile. Each of these methods adds a new precompile to the map and returns the map itself, allowing calls to be chained together cleanly in the DefaultStaticPrecompiles function. This makes the code readable and easy to modify.The Precompile Map
The ultimate result of the registration process is a
map[common.Address]vm.PrecompiledContract. The EVM module within the node uses this map during transaction processing. When a transaction calls an address that exists as a key in this map, the EVM forgoes executing bytecode and instead invokes the Run method of the corresponding vm.PrecompiledContract Go object.Implications for Network Upgrades
Because the set of precompiles is static, adding, removing, or changing one requires a coordinated network upgrade. All validators must update their node software to a new version that includes the modified
DefaultStaticPrecompiles function. This ensures consensus is maintained across the network regarding which core functionalities are available and at which addresses.