The account used by CoreDatastore to keep track of added preimages (and make them Merkle up to the state root) is empty as it has zero nonce, zero balance, and no bytecode. It has to be made non-empty in the genesis file or by sending some Wei to it for storage changes to persist.
There is no standardised way for a concrete rollup to expose which additional precompiles it implements and at what addresses. This is needed for (1) self-documentation and (2) introspection. Introspection makes it possible to deploy the same smart contract to a chain that supports a certain precompile and to one that does not, as the contract can check if the precompile is available and use an EVM bytecode implementation if it is not.
This PR fixes both of them by adding three built-in precompiles to concrete.
A registry of all concrete precompiles active in this chain, including itself and the two others listed below. It also exposes basic framework metadata.
A registry of all preimages added by PersistentStorage. Note getPreimage takes both the preimage hash and size (which can easily be obtained with getPreimageSize), this is so the call to RequiredGas remains stateless.
interface PreimageRegistry {
function addPreimage(bytes memory preimage) external returns (bytes32);
function hasPreimage(bytes32 _hash) external view returns (bool);
function getPreimageSize(bytes32 _hash) external view returns (uint256);
function getPreimage(
uint256 size,
bytes32 _hash
) external view returns (bytes memory);
}
Same as above but for preimages added with BigPreimageStore. e.g., api.NewPersistentBigPreimageStore(concrete, radix, leafSize).AddPreimage(preimage). Note that (persistent) BigPreimageStore uses PersistentStorage to store the nodes of a Merkle tree holding the preimage, individual nodes will be available through the PreimageRegistry precompile like any other preimage.
Right now, concrete has the following problems:
CoreDatastore
to keep track of added preimages (and make them Merkle up to the state root) is empty as it has zero nonce, zero balance, and no bytecode. It has to be made non-empty in the genesis file or by sending some Wei to it for storage changes to persist.This PR fixes both of them by adding three built-in precompiles to concrete.
PrecompileRegistry @
0xcc00000000000000000000000000000000000000
A registry of all concrete precompiles active in this chain, including itself and the two others listed below. It also exposes basic framework metadata.
PreimageRegistry @
0xcc00000000000000000000000000000000000001
A registry of all preimages added by
PersistentStorage
. NotegetPreimage
takes both the preimage hash and size (which can easily be obtained withgetPreimageSize
), this is so the call toRequiredGas
remains stateless.BigPreimageRegistry @
0xcc00000000000000000000000000000000000002
Same as above but for preimages added with
BigPreimageStore
. e.g.,api.NewPersistentBigPreimageStore(concrete, radix, leafSize).AddPreimage(preimage)
. Note that (persistent)BigPreimageStore
usesPersistentStorage
to store the nodes of a Merkle tree holding the preimage, individual nodes will be available through thePreimageRegistry
precompile like any other preimage.