jarry-xiao / candyland

Proof of concept program for compressing NFTs
GNU Affero General Public License v3.0
111 stars 13 forks source link

Gumball Machine: Initialize Indices in Chunks #139

Closed samwise2 closed 2 years ago

samwise2 commented 2 years ago

A computational bottleneck in the GumballMachine program is initializing the fisher yates indices which are used to provide on-chain randomness for minting NFTs. This initialization requires is O(max_items) in time, which is problematic for projects at large scale (we run out of compute trying to initialize all indices on the gumball machine account in one go). For this reason, we've chunked the initialization into segments, so that all of the indices can be initialized via multiple transactions.

Indices are initialized in chunks of at most 250,000 unites, to stay within compute budget.

We've added a CLI instruction that will automatically send n transactions to the network to fully initialize all indices for a gumball machine (so the user doesn't have to concern themselves with the chunking mechanism).

We've also added support for gumball machines without config lines. By setting extension_len to 0, and fully initializing your indices, you enable users to mint NFTs from your machine without config lines. You could then use an off-chain mapping of NFT index -> arweave identifier, etc. to provide meaning to these config lines.