trufflesuite / truffle

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
14.02k stars 2.32k forks source link

ipfs-mini reports status 429 on Truffle publish #1023

Closed skmgoldin closed 5 years ago

skmgoldin commented 6 years ago

Reproduce, step 1:

git clone git@github.com:skmgoldin/tcr.git
git checkout d202c5bb4a3637e0bec7afbba3a172c50e123a08
npm i
npx truffle compile

Now delete every network that isn't Ropsten from the truffle.js (see this bug). You'll also need a Ropsten-funded secrets.json or a MNEMONIC environmental variable.

Finally, npx truffle publish to reproduce the error.

Truffle 4.1.11, Ubuntu 16.

cgewecke commented 6 years ago

I'm getting a different error and don't want to mess up the publication in case it magically works for some reason :)

Error: Could not publish package. Please check version number and ensure it was not previously published.
    at /Users/cgewecke/code/consensys/minibug/tcr/node_modules/truffle/build/webpack:/~/ethpm-registry/lib/registry.js:109:1
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

My truffle.js for comparison. Only difference I see from what's in the repo is the addition of an infura API key. Is that possible?

/*
 * A bug in truffle-hdwallet-provider 0.0.5 makes `truffle compile` hang
 * indefinitely when truffle-hdwallet-provider 0.0.5 is imported into the
 * truffle.js. To use networks in this truffle.js, compile your code first
 * and then uncomment the content of this file.
 */

// UNCOMMENT EVERYTHING BELOW THIS LINE TO USE THESE NETWORKS

const HDWalletProvider = require('truffle-hdwallet-provider');
const fs = require('fs');

let mnemonic = '';

if (fs.existsSync('secrets.json')) {
  const secrets = JSON.parse(fs.readFileSync('secrets.json', 'utf8'));
  ({ mnemonic } = secrets);
}

mnemonic = 'grateful dead shoreline 1977 etc ....';

module.exports = {
  networks: {
    /*mainnet: {
      provider: function() { return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io') },
      network_id: '1',
      gas: 4500000,
      gasPrice: 10000000000,
    },
    ganache: {
      provider: function() { return new HDWalletProvider(mnemonic, 'http://localhost:8545') },
      network_id: '*',
      gas: 6000000,
      gasPrice: 25000000000,
    },
    rinkeby: {
      provider: function() { return new HDWalletProvider(mnemonic, 'https://rinkeby.infura.io') },
      network_id: '*',
      gas: 4500000,
      gasPrice: 25000000000,
    },*/
    ropsten: {
      provider: function() { return new HDWalletProvider(mnemonic, 'https://ropsten.infura.io/<infurakey>') },
      network_id: '*',
      gas: 4500000,
      gasPrice: 25000000000,
    },
    // config for solidity-coverage
    /*coverage: {
      host: 'localhost',
      network_id: '*',
      port: 7545, // <-- If you change this, also set the port option in .solcover.js.
      gas: 0xfffffffffff, // <-- Use this high gas value
      gasPrice: 0x01, // <-- Use this low gas price
    },*/
  },
};
cgewecke commented 6 years ago

Stealing your config warning for truffle init right now.

cgewecke commented 6 years ago

Oh one more difference - I ran this, not sure if that matters:

$ npx truffle publish -n ropsten
cgewecke commented 6 years ago

Lastly my txs on ropsten

skmgoldin commented 6 years ago

WOAH. Looks like the office I'm in was actually being rate-limited. I VPN'd out and it worked. Sorry for wasting your time!

cgewecke commented 6 years ago

No worries at all!

kronosapiens commented 6 years ago

@cgewecke Noting that I'm also running into this error. I know error code 429 is rate limiting, but I've tried using three different networks and two API keys at different times of day, so... 😭

You can reproduce by:

git clone git@github.com:JoinColony/colonyToken.git
cd colonyToken
git checkout 297a1aad2f1845bba4b9c9592e282478246f0162
yarn
git submodule update --init
./node_modules/.bin/truffle compile
./node_modules/.bin/truffle publish

Truffle 4.1.14, OSX 10.11.6

As an aside, the doc say that truffle publish takes no arguments, but you mention passing the -n ropsten argument: https://truffleframework.com/docs/truffle/reference/truffle-commands#publish

cgewecke commented 6 years ago

@kronosapiens Confirmed! It's broken. . .

However, I'm able to publish something small (like a single file) so it looks like repository size might be a factor.

@skmgoldin Have you seen this error recently and do you know if there's a data cap upstream somewhere?

Also just a heads up - truffle@next has a separate problem with 'publish' that's provider related. Just opened an issue for that at #1209.

jeichel-miovision commented 6 years ago

I've been running into the Error: [ipfs-mini] status 429 error as well. While looking into it, I think I may have found a few bugs in truffle-core...

https://github.com/trufflesuite/truffle/blob/develop/packages/truffle-core/lib/package.js#L220 There are references to data.contract_name and data.unlinked_binary that are not compatible with the solc compiler that ships with the truffle npm package (tested on version 4.1.14). At least for my build, I think they should be data.contractName and data.bytecode.

@kronosapiens - I don't think the -n will do anything with the truffle publish command. https://github.com/trufflesuite/truffle/blob/master/packages/truffle-core/lib/package.js#L108 shows that this command will always use the ropsten network, presumably since EthPM is currently hosted on Ropsten.

I've also tried changing some of the entries in my truffle.js config file, to try different ipfs hosts...

module.exports = {
  networks: {
    ropsten: {
      provider: new HDWalletProvider(mnemonic, 'https://ropsten.infura.io/v3/XXXXXXXXXXXXXXXX'),
      network_id: '3'
    }
  },
  ethpm: {
    ipfs_host: "ipfs.infura.io",
    ipfs_protocol: "https",
    registry: "0x8011df4830b4f696cd81393997e5371b93338878",
    install_provider_uri: "https://ropsten.infura.io/truffle"
  }
}

However, after these changes, I'm stilling getting the 429 error. I'm going to continue to dig through code to learn more about the code base and see if there is anything else that might be causing the error. I'm still pretty new to blockchain and truffle so I'm still learning as I go.

jeichel-miovision commented 6 years ago

so with a bit more experimenting and code tracing, I agree with @cgewecke, it looks like the default IPFS gateway, ipfs.infura.io (https://github.com/search?q=org%3Aethpm+ipfs.infura.io&type=Code), might have a content-length limit or some data bandwidth cap.

When I installed a local IPFS host (https://ipfs.io/docs/getting-started/ and https://docs.ipfs.io/introduction/install/) and updated my ethpm.json config, I no longer get the 429 error.

module.exports = {
  networks: {
    ropsten: {
      provider: new HDWalletProvider(mnemonic, 'https://ropsten.infura.io/v3/XXXXXXXXXXXXXXXX'),
      network_id: '3'
    }
  },
  ethpm: {
    ipfs_host: "127.0.0.1",
    ipfs_protocol: "http",
    registry: "0x8011df4830b4f696cd81393997e5371b93338878",
    install_provider_uri: "https://ropsten.infura.io/truffle"
  }
}

I did end up with a transaction timeout error, but that might be because I'm also doing a large number of contracts at once. I need to try some smaller things first....

stale[bot] commented 5 years ago

Thank you for raising this issue! It has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you would like to keep this issue open, please respond with information about the current state of this problem.

stale[bot] commented 5 years ago

There has been no new activity on this issue since it was marked as stale 7 days ago, so it is being automatically closed. If you'd like help with this or a different problem, please open a new issue. Thanks!