Metamask-extension: sendTransaction returns transaction ID but doesn't actually propagate it to the blockchain

Created on 24 Oct 2016  路  13Comments  路  Source: MetaMask/metamask-extension

I am sending a transaction to my contract via web3.js and it returns successful with a transaction ID. However, when I look up that transaction ID in Etherscan it doesn't actually exist. If I send the transaction using the Ethereum Wallet App or run my dApp in Mist, it works just fine. This is on the Morden Test Network.

Javascript:

var contractAbi = [ { "constant": false, "inputs": [ { "name": "_title", "type": "string" }, { "name": "_body", "type": "string" } ], "name": "submitQuestion", "outputs": [], "payable": true, "type": "function" }, { "constant": false, "inputs": [], "name": "kill", "outputs": [], "payable": false, "type": "function" }, { "inputs": [], "type": "constructor" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "_from", "type": "address" }, { "indexed": false, "name": "_exchange", "type": "address" } ], "name": "KnowledgeExchangeEvent", "type": "event" } ];

knowledgeManager = web3.eth.contract(contractAbi).at('0x4390D90185A5f6387aD6cBA06c31144b2951D59B');
knowledgeManager.submitQuestion(title, description, {from: account}, function(error, txId) {
  if (error) {
    console.log(error);
  } else {
    console.log(txId); //This returns a transaction ID
  }
});

Contract:

pragma solidity ^0.4.2;

contract KnowledgeExchangeManager {

    address owner;

    event KnowledgeExchangeEvent(
        address indexed _from,
        address _exchange
    );

    function KnowledgeExchangeManager() {

        owner = msg.sender;

    }

    function submitQuestion(string _title, string _body) payable {

        KnowledgeExchange exchangeContract = new KnowledgeExchange(msg.sender, _title, _body);

        KnowledgeExchangeEvent(msg.sender, exchangeContract);

    }

    function kill() { 
        if (msg.sender == owner) selfdestruct(owner); 
    }

}

contract KnowledgeExchange {

    event BountyClaimed(
        address indexed _owner
    );

    struct Question {
        address owner;
        string title;
        string body;
    }

    struct Answer {
        address owner;
        string body;
    }

    Question question;
    Answer answer;
    bool public answered;

    function KnowledgeExchange(address questioner, string _title, string _body) payable {

        question = Question(questioner, _title, _body);
        answered = false;

    }

    function getQuestionDetails() constant returns (address, string, string, uint256) {

        return (question.owner, question.title, question.body, this.balance);
    } 

    function submitAnswer(string _body) {

        bool success = msg.sender.send(this.balance);
        if (!success) {
            throw;
        }
        answered = true;
        answer = Answer(msg.sender, _body);
        BountyClaimed(msg.sender);

    }

    function getAnswerDetails() constant returns (address, string) {

        return (answer.owner, answer.body);
    }

    function getBounty() constant returns (uint256) {
        return this.balance;
    } 

    function kill() { 
        if (msg.sender == question.owner) selfdestruct(question.owner); 
    }

}
T00-bug

All 13 comments

Could be infura, could be us, we need to investigate more, thanks for the great reproduction steps!

If this is an Infura bug, we need to ensure they re-send transactions until they've been committed to the blockchain.

I wonder if this is the result of a network attack, we saw a lot of transactions getting dropped in the last few weeks, but that wouldn't explain why it works fine with Mist.

Ok, interesting, I'm not an expert at using Ethereum, only started reading up and developing a dApp a few weeks ago. I'd be happy to further debug something for you though.

As an FYI, I just tested again and the first transaction propagated but then failed as it ran out of gas. I think I need to increase the gas limit of my transaction. I tried it again after increasing the gas limit and this time it didn't propagate at all.

Worth noting that we don't have a gas limit field in the plugin itself, we just have a Transaction Cost/Gas Price slider, which won't fix OOG (out of gas) errors, it will only increase your transaction's priority to miners.

To customize your sent gas limit, you'd have to submit a custom gas value as part of your transaction programmatically, using the injected web3 object in the browser's context.

We do plan to allow custom gas limits from our UI, but it's also a bit surprising that you're running out of gas, we should be estimating accurately.

There _are_ actually other people having Morden-transaction-propogating issues though, so hopefully this is just a backend problem entirely, where some of our hosted nodes are not quite synchronized or something, and could be fixed soon.

Yup, I am doing it programmatically with:

knowledgeManager.submitQuestion(title, description, {from: account, gas: 900000}, function(error, txId) {

I'll keep trying occasionally with MetaMask to see if the issue resolves itself. Also, thanks so much for the product, it's great not to have to ask users to download Mist, and then wait a couple hours for their node to sync before they can test my app.

Just wanted to give an update. I published my dApp. Feel free to use it and submit a question. When you submit a question it will display the transaction ID on screen for you to do a check to see if it was actually submitted to the blockchain.

https://mbase1.herokuapp.com/index.html

Two things:

  • We tried this, and were unable to reproduce the bug. I think this may have been a problem with our backend, Infura, who is working hard at preventing this type of problem in the future. Let us know if you see it again?
  • Also, sometimes when clicking on a question on your index page, we get taken to the wrong question. Just FYI!

Marking can't reproduce right now, if we can't reproduce soon, I'm just going to close this until we ever see this again. Hopefully this is a fix Infura is working on.

Infura will be tracking this bug here:
https://github.com/INFURA/infura/issues/5

Same here: after a few successful sends, Metamasks drops all transactions and I have to restart the plugin, then it works again. This shows that it's not an Infura problem.

That sounds like a new issue to me, @rolandkofler. This issue is about transactions that return success but never reach the network.

Would you mind describing your experience in more detail on a new issue? If you could, include any dapps that consistently demonstrate this behavior.

I haven't had any issues with complete failure to propagate but i have had really long propagation times (time from submission to metamask backend to showing up on etherscan).

Metamasks drops all transactions and I have to restart the plugin, then it works again. This shows that it's not an Infura problem.

This sounds like an issue with the nonce getting out of sync - its supposed to reset itself on error, but maybe there is some other issue there

geth was returning 0x00000000000 for the block hash when tx was pending. we were interpreting this as a valid block hash and assuming the tx was confirmed. we were then permanently caching that value, making the tx seem to never be confirmed.

coming soon to a metamask near you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

glitch003 picture glitch003  路  3Comments

kumavis picture kumavis  路  3Comments

aakilfernandes picture aakilfernandes  路  3Comments

whyrusleeping picture whyrusleeping  路  3Comments

hellobart picture hellobart  路  3Comments