metaplex-foundation / metaplex

A directory of what the Metaplex Foundation works on!
https://metaplex.com
Apache License 2.0
3.32k stars 6.26k forks source link

Writing indices fails, encoding overruns buffer [devnet] #1006

Closed Kameeno closed 2 years ago

Kameeno commented 2 years ago

Describe the bug i'm uploading my 1300 nft's on my aws3 Bucket by running the command:

AWS_ACCESS_KEY_ID=******* AWS_SECRET_ACCESS_KEY= ******* ts-node src/candy-machine-cli.ts upload ./assets -s aws --aws-s3-bucket ***s3*buck**** --keypair ./id_candy.json --env devnet it starts to upload, after every file is uploaded it starts to write the indices and it start to write some but...

it shows this: Writing indices 990-999 saving config line 990-999 failed RangeError: encoding overruns Buffer at Blob.encode (/Users/kameeno/metaplex/js/node_modules/buffer-layout/lib/Layout.js:2334:13) at Structure.encode (/Users/kameeno/metaplex/js/node_modules/buffer-layout/lib/Layout.js:1272:26) at WrappedLayout.encode (/Users/kameeno/metaplex/js/node_modules/@project-serum/borsh/src/index.ts:96:24) at WrappedLayout.encode (/Users/kameeno/metaplex/js/node_modules/@project-serum/borsh/src/index.ts:96:24) at Structure.encode (/Users/kameeno/metaplex/js/node_modules/buffer-layout/lib/Layout.js:1272:26) at /Users/kameeno/metaplex/js/node_modules/buffer-layout/lib/Layout.js:1117:25 at Array.reduce (<anonymous>) at Sequence.encode (/Users/kameeno/metaplex/js/node_modules/buffer-layout/lib/Layout.js:1116:22) at Structure.encode (/Users/kameeno/metaplex/js/node_modules/buffer-layout/lib/Layout.js:1272:26) at WrappedLayout.encode (/Users/kameeno/metaplex/js/node_modules/@project-serum/borsh/src/index.ts:96:24) Done. Successful = false. upload was not successful, rerunning

i'm running this on Mac OS with node v16.11.1 and ts-node v10.3.0

log is here: https://pastebin.com/tgv45L3D

Schermata 2021-11-18 alle 16 52 21

is only a devnet issue?

Kameeno commented 2 years ago

https://pastebin.com/PGZMw1GB

Schermata 2021-11-18 alle 17 24 21
Kameeno commented 2 years ago

i found this: https://github.com/metaplex-foundation/metaplex/issues/919 reading the code of upload.ts allIndexesInSlice.length returns 1000 instead the right number of nft's

so i replaced the for loop after async allIndexesInSlice => { into this : for ( let offset = 0; offset < keys.length; offset += 1 ) and the const indexes = allIndexesInSlice.slice(offset, offset + 10); to const indexes = allIndexesInSlice.slice(offset, offset + 1);

it looks terribly slow and an ugly workaround but... hope it works. tomorrow i try to mint all my nft's and script a code to check the integrity of them

please let me know if it was good idea... im not sure for the risk of this

sebyx07 commented 2 years ago

first truncate your name of your nft to be <= 20

here is the code optimized for the stupid reloop. idk why they were overcomplicated. even my implemenation doesn't look right. the whole upload.ts looks kind of trash

you can replace the begining of writeIndices function

async function writeIndices({
  anchorProgram,
  cache,
  cacheName,
  env,
  config,
  walletKeyPair,
}) {
  const keys = Object.keys(cache.items);
  try {
    await Promise.all(
      chunks(Array.from(Array(keys.length).keys()), 5).map(async (indexes) => {
        const onChain = indexes.filter(i => {
          const index = keys[i];
          return cache.items[index]?.onChain || false;
        });
        const ind = keys[indexes[0]];
github-actions[bot] commented 2 years ago

This Issue has received no activity for 30 days. We will close it in 2 days, please reopen if you are still experiencing this issue.