3

I am hosting a private blockchain and I am testing out the Geth functionality. I have deployed a Solidity contract based on the Greeter example.

The functionality is not important, but suffice to say that I have added a rename function. I call this function from javascript using the following one-liner, where str is the the new greeting:

greeter.rename(str, {gas: 400000, gasPrice: web3.toWei(0, 'gwei'), from: addr});

I am setting a minimal gas limit of 400,000 and a gas price of zero.

Next, I have a single miner that I start using the following command line command:

geth --datadir data \
    --ipcpath geth01 --nodiscover --networkid 1234 \
    --rpc --rpccorsdomain "*" --rpcapi "db,personal,eth,net,web3,debug" \
    --gasprice "18000000000" console

As the last line shows, I am trying to limit the minimum price threshold to be very high. From what I understood, the --gasprice argument should reject the rename transaction. The transaction itself is received correctly, as shown:

[{
    blockHash: null,
    blockNumber: null,
    from: "0xf5d73b4ec4022da1217f888d821a4204b7f0a607",
    gas: 400000,
    gasPrice: 0,
    hash: "0xa585ee195bb313e063920707efc0b023a402e95e8727715106934f6e87a7da75",
    input: "0x66605ba40000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001048656c6c6f205465737420576f726c6400000000000000000000000000000000",
    nonce: 37,
    r: "0x9f179c20ba7b98257afca55ce722749e3b4e8408e6578b0a08e85636655a1c24",
    s: "0x4abfa7b5513e3da825190a882cb0ed27835675c5251a8bb8baa3f5538a53ac14",
    to: "0x76fb42360abb69f8181be55da0633c658771a4aa",
    transactionIndex: 0,
    v: "0x3e",
    value: 0
}]

However, the miner does not reject this transaction even though the price is well below what I specified when I launched it. The same happens when I deploy a new smart contract from Javascript - the transaction is always accepted. What am I doing wrong? Why are transactions with a gas price of 0 being mined?

EDIT: The transactions are being mined.

Miner settings:

geth --datadir data --ipcpath geth01 \
    --nodiscover --networkid 1234 \
    --rpc --rpccorsdomain "*" --rpcapi "db,personal,eth,net,web3,debug" \
    --gasprice "18000000000" console

Then I attach to this node and mine:

$ geth attach ./data/geth01
> miner.start(1)

Output of transaction details:

> eth.getTransaction("0x662c234d3a3eb21369becdd1022ff059293b27ac4e8a8c17dc2f650dfb0814cf")
{
    blockHash: "0xa53d4db0da2814fdecb0adfa233f99e08e89586fa38a9b09727ed75042dc0c2c",
    blockNumber: 237,
    from: "0xf5d73b4ec4022da1217f888d821a4204b7f0a607",
    gas: 400000,
    gasPrice: 0,
    hash: "0x662c234d3a3eb21369becdd1022ff059293b27ac4e8a8c17dc2f650dfb0814cf",
    input: "0x66605ba40000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000948657920576f726c640000000000000000000000000000000000000000000000",
    nonce: 43,
    r: "0x38b8e7293294dee67801165da68b1866fb721d48ef44efe714295b617dab47dd",
    s: "0x51d2c2be72565c97983432406b91704f13f803a8e36cf90c702a0be5dc860daf",
    to: "0x76fb42360abb69f8181be55da0633c658771a4aa",
    transactionIndex: 0,
    v: "0x3e",
    value: 0
}

Output of block details:

> eth.getBlock(237)
{
    difficulty: 131072,
    extraData: "0xd883010812846765746888676f312e31302e34856c696e7578",
    gasLimit: 2646181,
    gasUsed: 33534,
    hash: "0xa53d4db0da2814fdecb0adfa233f99e08e89586fa38a9b09727ed75042dc0c2c",
    logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    miner: "0x6ec1d2f7a7de99cf254ed5714a8ff76e8aa46694",
    mixHash: "0x0fb86c44b51728ee0a4d64bd3a83259559d985aad6d2297c428142de12006569",
    nonce: "0x004800583f40f2af",
    number: 237,
    parentHash: "0x4a1ac65b41f0f019f6aca3cf43acdf6571d0c1d63042a45379d1703568600442",
    receiptsRoot: "0xae6add573aa26af8b867eedffc7d7536b47a9af41f4be297993bc9587fca9b58",
    sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    size: 739,
    stateRoot: "0xad82921e1e1694821398f66a34705e0e61c8ed69d0e91f7147d16cfab88abd02",
    timestamp: 1543480637,
    totalDifficulty: 31182886,
    transactions: ["0x662c234d3a3eb21369becdd1022ff059293b27ac4e8a8c17dc2f650dfb0814cf"],
    transactionsRoot: "0x3192a3f9e958cecfef47f3e99db2c688ebb26376570943150909cf2c49bdab75",
    uncles: []
}

EDIT:

Adding --txpool.pricelimit "18000000000" does not limit the transactions that enter the pool. A transaction with a gas price of 0 is still accepted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.