tempo icon indicating copy to clipboard operation
tempo copied to clipboard

Make precompiles initialize themselves

Open klkvr opened this issue 1 month ago • 0 comments

Describe the feature

Right now we need to do a bunch of manual initializations when generating genesis here https://github.com/tempoxyz/tempo/blob/bb95e8f46bfe1e455c4349843cdcff1e51919163/xtask/src/genesis_args.rs#L202-L221

This introduces extra complications for tooling because even when importing and using TempoEvm you need to pre-initialize a specific state for precompiles to work correctly.

What we can do is instead initialize precompiles lazily when they are invoked. This should be as simple as calling storage.set_code("0xef") or self.initialize once the precompile is called.

Note that this logic should only set code if it was not set before. Otherwise we might have weird issues when transactions revert because revm does not support changing one non-empty code to another and would simply wipe the contract on revert/

Additional context

No response

klkvr avatar Dec 05 '25 14:12 klkvr