Phala-Network / phala-blockchain

The Phala Network Blockchain, pRuntime and the bridge.
https://phala.network
Apache License 2.0
332 stars 149 forks source link

pruntime: Box large value in OrdMap #1577

Closed kvinwang closed 2 months ago

kvinwang commented 2 months ago

This PR intends to solve the stack overflow issue in pRuntime by boxing the large values in OrdMap. In the previous implementation, we utilize OrdMap<H256, Contract> to store the contract info, where sizeof::<Contract> == 1064. Even though the size of Contract is approximately 1k, the OrdMap::insert demanded an over 8MB stack in certain scenarios. (Not sure why!)

After being boxed, it works fine when 200,000 contracts are deployed, with a 300k stack size.