For an MPT node, as described in the yellow paper,
When the RLP encoded size of an MPT node exceeds 32, store the hash of the RLP encoded value of the node in the slot corresponding to its parent node, and then use the hash value to read the specific content of the node;
When the RLP encoded size of the node is less than 32, its content is stored directly in the parent's corresponding slot.
Description
The error "'MerkleTrie: ran out of proof elements'" is reported from 'MerkleTrie.get()' when the provided storage proofs contain small nodes(RLP encoded size is less than 32).
Although the above proofs list only has 8 elements, it actually represents 9 MPT nodes.
Due to the fact that proofs[7] is a fullNode that contains a child shortNode whose RLP encoded size is less than 32, the last MPT node is included in the child-slot of proofs[7].
The L1 contract fails to process the last MPT shortnode correctly when it verifies the proofs provided by the exchange via MerkleTrie.get(). The error MerkleTrie: ran out of proof elements is reported.
Context
MPT Storage
Ethereum Yellow Paper:
For an MPT node, as described in the yellow paper,
When the RLP encoded size of an MPT node exceeds 32, store the hash of the RLP encoded value of the node in the slot corresponding to its parent node, and then use the hash value to read the specific content of the node;
When the RLP encoded size of the node is less than 32, its content is stored directly in the parent's corresponding slot.
Description
The error "'MerkleTrie: ran out of proof elements'" is reported from 'MerkleTrie.get()' when the provided storage proofs contain small nodes(RLP encoded size is less than 32).
Here is an on-chain example: https://testnet.bscscan.com/tx/0xa5f9d2f9c5804391ee695e0b0c71df17e1dd4333691fb714924ff2470320dadf
There are 8 proof elements (returned via Geth's
curl https://opbnb-testnet-rpc.bnbchain.org -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getProof","id": 15198, "params": ["0x4200000000000000000000000000000000000016", ["0x5cd60ecef836e75dd12539abe8ad5f4ba0dc4fcaae2c45024c69bd9e20746eba"], "0x1115ac0" ]}' | jq '.result.storageProof'
):Although the above proofs list only has 8 elements, it actually represents 9 MPT nodes.
Due to the fact that proofs[7] is a fullNode that contains a child shortNode whose RLP encoded size is less than 32, the last MPT node is included in the child-slot of proofs[7].
The L1 contract fails to process the last MPT shortnode correctly when it verifies the proofs provided by the exchange via MerkleTrie.get(). The error MerkleTrie: ran out of proof elements is reported.
See Also