aeternity / ae_mdw

Aeternity Middleware in Elixir
26 stars 10 forks source link

Setting `system.dev_mode = true` doesn't set network id to `ae_dev` #1760

Open davidyuk opened 2 months ago

davidyuk commented 2 months ago

Here is a minimum dev mode configuration of the node

docker-compose.yml

services:
  middleware:
    image: aeternity/aeternity:v7.0.0
    ports: [3013:3013]
    volumes:
      - ./docker/aeternity.yaml:/home/aeternity/node/aeternity.yaml

docker/aeternity.yaml

system:
  dev_mode: true

chain:
  persist: false
  hard_forks:
    "1": 0
    "6": 1

Here is that status endpoint returns

{
  "difficulty": 1338,
  "genesis_key_block_hash": "kh_CciVD7Zb38Dwon8AHWDpNK1LatrprLLWGDLTtkUjZqerpxS1o",
  "hashrate": 0,
  "listening": true,
  "network_id": "ae_dev",
  "node_revision": "a9498268ce1ac837e553bba94d5dc6bdc455be11",
  "node_version": "7.0.0",
  "peer_connections": {
    "inbound": 0,
    "outbound": 0
  },
  "peer_count": 0,
  "peer_pubkey": "pp_2NFQGHYHkVi4Q2BTf4xkzFh6h6JzrstdZwoonPPTpu9ZSiyfRw",
  "pending_transactions_count": 0,
  "protocols": [
    {
      "effective_at_height": 1,
      "version": 6
    },
    {
      "effective_at_height": 0,
      "version": 1
    }
  ],
  "solutions": 0,
  "sync_progress": 100.0,
  "syncing": false,
  "top_block_height": 1,
  "top_key_block_hash": "kh_2GFD3CP4djZKx3uk1s9Vjmagu5jxmb1W3GsW8ydN85iKkX6Upp",
  "uptime": "19s.610"
}

Using the same configuration with ae_mdw I'm getting different results

services:
  middleware:
    image: aeternity/ae_mdw:1.75.0
    ports: [4000:4000, 3013:3013]
    volumes:
      - ./docker/aeternity.yaml:/home/aeternity/aeternity.yaml

Firstly, the message "[info] Set app_ctrl mode: dev_mode" appears the same way as in the previous setup, but the network id reported by http://localhost:3013/v3/status is ae_mainnet, and the node starts to sync. I expect it to be in dev mode and have ae_dev network id, the same way as in plain node.

davidyuk commented 2 months ago

Also, for some reason dev mode in mdw requires mining.beneficiary to be set, otherwise

exec ae_mdw ./bin/ae_mdw rpc ':aeplugin_dev_mode_app.start_unlink()'

fails with

[debug] consensus_request(emit_kb) Failed: error {case_clause,{error,beneficiary_not_configured}} [{aec_conductor,get_next_beneficiary,2,[{file,"/home/builder/aeternity/apps/aecore/src/aec_conductor.erl"},{line,541}]},{aec_consensus_on_demand,client_request,1,[{file,"/home/builder/aeternity/apps/aecore/src/aec_consensus_on_demand.erl"},{line,85}]},{aec_conductor,consensus_request,1,[{file,"/home/builder/aeternity/apps/aecore/src/aec_conductor.erl"},{line,223}]},{aeplugin_dev_mode_emitter,init,1,[{file,"src/aeplugin_dev_mode/aeplugin_dev_mode_emitter.erl"},{line,82}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,980}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,935}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,241}]}]

dev mode in plain node works without beneficiary explicitly set 🤷‍♀️

thepiwo commented 4 weeks ago

@sborrazas any update on this?

sborrazas commented 4 weeks ago

@thepiwo I haven't looked into this yet, I'll try to look into it. Remember the way dev_mode works is extremely hack-ish due to the ae_plugin system the node has, in fact ae_mdw itself needs toa bunch of hacks in order for it to work (e.g. the plugin source code itself is copied directly into the repo so that the source is included when compiling the app)