我遇到了ganache和testRPC的问题,只有在使用web3提供程序时才会出现out of gas
错误,但在使用Javascript VM或使用松露javascript测试时则不会出现错误。
我的映射设置如下:
mapping (uint => address) public reservers;
mapping (uint => Reservation) public reservations;
mapping (uint => address) public bidders;
mapping (uint => Bid) public bids;
mapping (uint => uint) public lastSoldFor;
抛出VM Exception while processing transaction: out of gas
的方法是:
function sell(uint rId) public {
reservations[rId].publicKey = bids[rId].publicKey;
reservers[rId] = bidders[rId];
lastSoldFor[rId] = bids[rId].price;
delete bids[rId];
delete bidders[rId];
}
如果我注释掉它成功运行的两条delete
行。但是,如果我使用delete
,或者即使我只是重新分配它们,它们也会失败。
当通过Truffle的测试套件运行它时,它可以工作,并且当使用Javascript VM通过Remix手动提交这些操作时,它也可以工作。只有当它连接到testRPC或ganache时才会失败。
其他所有方法似乎都可以从ganache中正常工作,但它似乎只有删除问题。我也看到一些提到这是因为天然气被退还,而且由于这种方法的汽油价格相当低,因此会引起一些古怪的ganache。有没有针对此的解决方法,每次我想要进行更改时都不必将合同上传到测试网络?
编辑:似乎我可以证明这与低气体消耗无关,而是与清除映射指数有关。我在方法中添加了一些大量的气体消耗量,它仍然以相同的气体误差退出。
新状态变量:
uint[] memorysink;
然后在我添加的方法中
memorysink.push(200000000);
memorysink.push(200000000);
memorysink.push(200000000);
memorysink.push(200000000);
memorysink.push(200000000);
将耗气量从43279
转移到141513
但是它仍然提供了气体错误。
答案 0 :(得分:0)
As @AdamKipnis has suggested we can get around the issue using a heightened gasLimit. This isn't currently possible from within Remix itself however specifying an additional 50-100k gasLimit from MetaMask when interacting with that method did indeed solve the problem and provide a work-around for the issue in it's current state. However, this is still just a band-aid and more in-depth tests will be needed to find a proper solution to the core issue.