NFT applications make a sizeable proportion of popular DApps today. The first well-know NFT game is CryptoKitties by Dapper Labs.
First launched in 2017, CryptoKitties is still the largest nonfinancial DApp on Ethereum. It caused serious network congestion blockchain during to limited scalability of Ethereum platform.
The original CryptoKitties core developed by Dapper Labs (https://www.dapperlabs.com) The original CryptoKitties could be downloaded from https://github.com/dapperlabs/cryptokitties-bounty.
The major goal of Parallel-Kitties is to demonstrate how a typical, real-world Ethereum application may achieve dramatic performance gains with our concurrency framework. We optimized the original CryptoKitties with our concurrency framework. The optimized CryptoKitties is functionally identical to the original one, the changes are mainly focused on some internal data structures and no business logic has been changed.
The optimized source code can be found here https://github.com/arcology-network/parallel-kitties.
The original implementation of
KittyBase.sol would save the kitty information in an array. The kitties’ IDs are their index numbers. When a new kitty is born, some info needs to be appended to the back of the array. The length of the array will be used for the next kitty’s ID. We replaced this native array with a map, since native Ethereum arrays don’t support concurrent push back.
In the new implementation, kitty IDs are now the map keys that are generated by UUID generators. The map values are the kitty info. Since there is no way to get the size of a map in Solidity as of 11/2022, we added a new variable
totalBalance to keep track of total kitties, which will be updated in a deferred call.
The new version achieved some astonishing results. Our version is about ~1000x faster than the original one on Ethereum.