carlosfaria94 / blocksim

A discrete event Blockchain Simulator
MIT License
66 stars 32 forks source link

parameter interval in transaction_factory.broadcast function does not work #7

Open Jiali-Xing opened 4 years ago

Jiali-Xing commented 4 years ago

Hi Carlos Faria,

I like this simulator a lot and is going to use/modify it for my research. I have a question about your implementation of transaction_factory.broadcast after run/read your code (I'm using the config.json in your current github repo):

It seems that the increase of interval parameter (interval in seconds between each batch) doesn't change the simulation results? Isn't it supposed to have less transactions done if I set the interval sufficiently large relative to duration?

Best,

carlosfaria94 commented 4 years ago

Hi @Jiali-Xing

Thanks for your interest in my work.

Yes, it is supposed to have less transactions inserted in blocks if we increase interval with a smaller duration.

Can you send me the config.json you setup?

I will check this - it's been a long time since I don't touch on this :)

Jiali-Xing commented 4 years ago

Thanks for replying. I am using the config.json provided in your repo, i.e.

{
  "blockchain": "ethereum",
  "locations": ["Tokyo", "Ohio", "Ireland"],
  "bitcoin": {
    "block_size_limit_mb": 1,
    "number_transactions_per_block": {
      "name": "beta",
      "parameters": "(3.4538110963361333, 4.240939683805738, 705.4815204696233, 2159.387403502942)"
    },
    "orphan_blocks_probability": 0.0174,
    "message_size_kB": {
      "header": 0.024,
      "version": 0.095,
      "verack": 0,
      "inv_vector": 0.036,
      "tx": 0.44,
      "block_base": 0.082
    }
  },
  "ethereum": {
    "block_gas_limit": 2100000,
    "tx_gas_limit": 21000,
    "orphan_blocks_probability": 0.0174,
    "message_size_kB": {
      "status": 0.2,
      "hash_size": 0.042,
      "tx": 0.2,
      "get_headers": 0.054,
      "header": 0.09,
      "block_bodies": 0.045
    }
  }
}

And the output/report.json doesn't change anyhow I increase the interval: Even when interval is set to be incredibly large, e.g., transaction_factory.broadcast(100, 400, 1e10, nodes_list), and we expect less transactions generated/queued, created_transactions (as well as number_of_transactions_queue) are still almost full (full meaning = #batch times #tx_per_batch).

Thanks for looking into it, I have been trying to fix it for a long time but still didn't find any bugs.

Jiali-Xing commented 4 years ago

Is there any progress w.r.t. the transactions? :smiley: I have been working on BlockSim for a while now, and really appreciate its great customizability. I feel like the BlockSim is not processing transactions and blocks synchronously. Blocks start to be broadcast after all tx have been broadcast, which seems weird for me. I wonder if it is by design or a bug?

carlosfaria94 commented 4 years ago

Sorry for the delay on the response, I changed jobs and had some vacations.

It's ok for blocks to be broadcasted without transactions, it is the "heartbeat" of most of PoW blockchain networks. That's simulation design that we choose.

Let me know if it answer your question, or I misunderstood the issue

It seems that the increase of interval parameter (interval in seconds between each batch) doesn't change the simulation results? Isn't it supposed to have less transactions done if I set the interval sufficiently large relative to duration?

With regards this issue, have you figured out some bug or fix, the issue still persist?

Jiali-Xing commented 4 years ago

It seems that the increase of interval parameter (interval in seconds between each batch) doesn't change the simulation results? Isn't it supposed to have less transactions done if I set the interval sufficiently large relative to duration?

With regards this issue, have you figured out some bug or fix, the issue still persist?

Yes, I think it is a bug in transaction_factory. When we debug it, it turns out that all transactions of all nodes are broadcast at the very beginning of any simulation: the interval parameter is thus void.

We fixed it by modifying the transaction_factory, and we plan to release our code (BlockSim for a permissioned blockchain) later.

m0bi5 commented 2 years ago

@Jiali-Xing I noticed the same issue, it seems like the transaction_validation parameter in the delays.json file does not seem to be used anywhere (used in Consensus.validate_transaction() but this is not called anywhere). Has your code been released?

Jiali-Xing commented 2 years ago

@m0bi5 I think your observation is correct. We fixed it to some extent and implemented Talaria, a permissioned blockchain simulation based on this repo.