Truffle

松露遷移到 ganache-cli (testrpc) 在部署 Migrations.sol 時掛起

  • December 4, 2021

我正在嘗試 truffle migrate Metacoin 來調試為什麼 Tuffle migrate 不能用於 testRPC/ganache-cli。它在部署 testRPC/ganache 時掛了,但如果我從 truffle develop 執行它而不指定 ganache,那麼 truffle 的內部 testRPC 它遷移得很好。

目前版本

Truffle v4.0.4 - 乙太坊的開發框架

Ganache CLI v6.0.3 (ganache-core: 2.0.2)

我正在執行以下序列:

mkdir metacoin

cd metacoin

truffle unbox metacoin

打開新標籤

ganache-cli -u 0

返回元幣選項卡

truffle compile

truffle migrate --reset --network development --verbose-rpc

沒有 –verbose-rpc 的輸出如下所示:

利用網路“發展”。

執行遷移:1_initial_migration.js 部署遷移…

使用 –verbose-rpc

      > {
  >   "jsonrpc": "2.0",
  >   "id": 1,
  >   "method": "net_version",
  >   "params": []
  > }
<   {
<     "jsonrpc": "2.0",
<     "result": "1",
<     "id": 1
<   }
Using network 'development'.

Running migration: 1_initial_migration.js
  > {
  >   "jsonrpc": "2.0",
  >   "id": 2,
  >   "method": "eth_accounts",
  >   "params": []
  > }
<   {
<     "jsonrpc": "2.0",
<     "result": [
<       "0x006faef83e11473a09e59d2d2150209f11e216f9"
<     ],
<     "id": 2
<   }
  > {
  >   "jsonrpc": "2.0",
  >   "id": 3,
  >   "method": "net_version",
  >   "params": []
  > }
<   {
<     "jsonrpc": "2.0",
<     "result": "1",
<     "id": 3
<   }
 Deploying Migrations...
  > {
  >   "jsonrpc": "2.0",
  >   "id": 4,
  >   "method": "net_version",
  >   "params": []
  > }
<   {
<     "jsonrpc": "2.0",
<     "result": "1",
<     "id": 4
<   }
  > {
  >   "jsonrpc": "2.0",
  >   "id": 5,
  >   "method": "eth_sendTransaction",
  >   "params": [
  >     {
  >       "from": "0xdcb731f4cc8349df9ef206f3c0e46ae532239917",
  >       "gas": "0x6691b7",
  >       "gasPrice": "0x174876e800",
  >       "data": "0x6060604052341561000f57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102db8061005e6000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100a05780638da5cb5b146100c9578063fdacd5761461011e575b600080fd5b341561007257600080fd5b61009e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610141565b005b34156100ab57600080fd5b6100b3610224565b6040518082815260200191505060405180910390f35b34156100d457600080fd5b6100dc61022a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012957600080fd5b61013f600480803590602001909190505061024f565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610220578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b151561020b57600080fd5b6102c65a03f1151561021c57600080fd5b5050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102ac57806001819055505b505600a165627a7a723058206d0ad850ad766994ac09fceb3b7aa1ad7e80fd8536774114e97875055355ed660029"
  >     }
  >   ]
  > }

ganache-cli 的響應(使用 -v)

eth_getBalance
  > {
  >   "id": 6578289014410835,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0x58ba5d062e2c2b14dc8b8458872afef70a9b25eb",
  >     "latest"
  >   ],
  >   "method": "eth_getBalance",
  >   "external": true
  > }
eth_getTransactionCount
  > {
  >   "id": 6578289014410836,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0x58ba5d062e2c2b14dc8b8458872afef70a9b25eb",
  >     "latest"
  >   ],
  >   "method": "eth_getTransactionCount",
  >   "external": true
  > }
<   {
<     "id": 6578289014410835,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
<   {
<     "id": 6578289014410836,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
eth_getBalance
  > {
  >   "id": 6578289014410844,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0x15528fc3cff56b4667f988c699ec5983030ce841",
  >     "latest"
  >   ],
  >   "method": "eth_getBalance",
  >   "external": true
  > }
eth_getBalance
  > {
  >   "id": 6578289014410838,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0xf45ae1668bf2a6f7175a0795384b2059789e84a5",
  >     "latest"
  >   ],
  >   "method": "eth_getBalance",
  >   "external": true
  > }
eth_getTransactionCount
  > {
  >   "id": 6578289014410839,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0xf45ae1668bf2a6f7175a0795384b2059789e84a5",
  >     "latest"
  >   ],
  >   "method": "eth_getTransactionCount",
  >   "external": true
  > }
eth_getBalance
  > {
  >   "id": 6578289014410841,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0xe4753e4dff52c272ac3f8037bc1f218e768ac66d",
  >     "latest"
  >   ],
  >   "method": "eth_getBalance",
  >   "external": true
  > }
<   {
<     "id": 6578289014410844,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
<   {
<     "id": 6578289014410838,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
<   {
<     "id": 6578289014410841,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
<   {
<     "id": 6578289014410839,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
eth_getTransactionCount
  > {
  >   "id": 6578289014410848,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0x11f2915576dc51dffb246959258e8fe5a1913161",
  >     "latest"
  >   ],
  >   "method": "eth_getTransactionCount",
  >   "external": true
  > }
eth_getBalance
  > {
  >   "id": 6578289014410850,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0xc69e35474199292ab39d047490963bd5b01fb73e",
  >     "latest"
  >   ],
  >   "method": "eth_getBalance",
  >   "external": true
  > }
eth_getTransactionCount
  > {
  >   "id": 6578289014410845,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0x15528fc3cff56b4667f988c699ec5983030ce841",
  >     "latest"
  >   ],
  >   "method": "eth_getTransactionCount",
  >   "external": true
  > }
<   {
<     "id": 6578289014410848,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
<   {
<     "id": 6578289014410850,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
<   {
<     "id": 6578289014410845,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
eth_getBalance
  > {
  >   "id": 6578289014410853,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0x0327ff417aa111b61bed5f39e77946b38d6592b3",
  >     "latest"
  >   ],
  >   "method": "eth_getBalance",
  >   "external": true
  > }
eth_getTransactionCount
  > {
  >   "id": 6578289014410854,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0x0327ff417aa111b61bed5f39e77946b38d6592b3",
  >     "latest"
  >   ],
  >   "method": "eth_getTransactionCount",
  >   "external": true
  > }
<   {
<     "id": 6578289014410853,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
<   {
<     "id": 6578289014410854,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
eth_getBalance
  > {
  >   "id": 6578289014410858,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0x58ba5d062e2c2b14dc8b8458872afef70a9b25eb",
  >     "latest"
  >   ],
  >   "method": "eth_getBalance",
  >   "external": true
  > }
eth_getTransactionCount
  > {
  >   "id": 6578289014410859,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0x58ba5d062e2c2b14dc8b8458872afef70a9b25eb",
  >     "latest"
  >   ],
  >   "method": "eth_getTransactionCount",
  >   "external": true
  > }
<   {
<     "id": 6578289014410858,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
<   {
<     "id": 6578289014410859,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
eth_getBalance
  > {
  >   "id": 6578289014410861,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0xf45ae1668bf2a6f7175a0795384b2059789e84a5",
  >     "latest"
  >   ],
  >   "method": "eth_getBalance",
  >   "external": true
  > }
eth_getTransactionCount
  > {
  >   "id": 6578289014410865,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0xe4753e4dff52c272ac3f8037bc1f218e768ac66d",
  >     "latest"
  >   ],
  >   "method": "eth_getTransactionCount",
  >   "external": true
  > }
eth_getBalance
  > {
  >   "id": 6578289014410864,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0xe4753e4dff52c272ac3f8037bc1f218e768ac66d",
  >     "latest"
  >   ],
  >   "method": "eth_getBalance",
  >   "external": true
  > }
<   {
<     "id": 6578289014410861,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
<   {
<     "id": 6578289014410865,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
<   {
<     "id": 6578289014410864,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
eth_getTransactionCount
  > {
  >   "id": 6578289014410871,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0x11f2915576dc51dffb246959258e8fe5a1913161",
  >     "latest"
  >   ],
  >   "method": "eth_getTransactionCount",
  >   "external": true
  > }
eth_getBalance
  > {
  >   "id": 6578289014410867,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0x15528fc3cff56b4667f988c699ec5983030ce841",
  >     "latest"
  >   ],
  >   "method": "eth_getBalance",
  >   "external": true
  > }
eth_getTransactionCount
  > {
  >   "id": 6578289014410868,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0x15528fc3cff56b4667f988c699ec5983030ce841",
  >     "latest"
  >   ],
  >   "method": "eth_getTransactionCount",
  >   "external": true
  > }
<   {
<     "id": 6578289014410871,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
<   {
<     "id": 6578289014410867,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
<   {
<     "id": 6578289014410868,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
eth_getTransactionCount
  > {
  >   "id": 6578289014410874,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0xc69e35474199292ab39d047490963bd5b01fb73e",
  >     "latest"
  >   ],
  >   "method": "eth_getTransactionCount",
  >   "external": true
  > }
eth_getBalance
  > {
  >   "id": 6578289014410876,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0x0327ff417aa111b61bed5f39e77946b38d6592b3",
  >     "latest"
  >   ],
  >   "method": "eth_getBalance",
  >   "external": true
  > }
eth_getTransactionCount
  > {
  >   "id": 6578289014410877,
  >   "jsonrpc": "2.0",
  >   "params": [
  >     "0x0327ff417aa111b61bed5f39e77946b38d6592b3",
  >     "latest"
  >   ],
  >   "method": "eth_getTransactionCount",
  >   "external": true
  > }
<   {
<     "id": 6578289014410874,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
<   {
<     "id": 6578289014410876,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }
<   {
<     "id": 6578289014410877,
<     "jsonrpc": "2.0",
<     "result": "0x0"
<   }

我嘗試重新安裝 truffle 和 testRPC/ganache-cli,我還注意到 truffle 遷移日誌顯示它正在獲取一個我以前從未見過的 eth_account 並且不屬於 Ganache-cli/testRPC。

我沒有額外的節點在執行(geth、parity、私有鍊等)。僅僅兩週,我將大型合約遷移到私有鏈並且沒有問題,所以這並不總是在這裡。

有什麼想法嗎?

最好的,山姆

我實際上發現它沒有遷移的原因是 Parity 有一些隱藏的非常好的程序,當我這樣做時沒有顯示出來ps -a;在找到那個奇偶程序並殺死它之後,它就像一個魅力。

我有同樣的問題。我通過將 truffle-config.js 中的氣體限制降低到 ganache 中的允許限制來解決它

引用自:https://ethereum.stackexchange.com/questions/34194