filecoin-project / lotus

Reference implementation of the Filecoin protocol, written in Go
https://lotus.filecoin.io/
Other
2.84k stars 1.26k forks source link

Mock Drand to enable offline devnet #9059

Open geoff-vball opened 2 years ago

geoff-vball commented 2 years ago

Checklist

Lotus component

What is the motivation behind this feature request? Is your feature request related to a problem? Please describe.

Right now, devnets use the mainnet drand beacon. This means we cannot run a devnet without being connected to the internet.

Describe the solution you'd like

Mock the beacon to enable the use of devnets offline.

Describe alternatives you've considered

No response

Additional context

No response

f8-ptrk commented 2 years ago

can this be moved out of the lotus scope to a standalone project?

Stebalien commented 5 months ago

@f8-ptrk is right.

IMO, the right way to do this is to:

  1. Generate "public" "private" keys for a drand test network.
  2. Create a simple stand-alone drand beacon server container using those keys.
  3. Create a lotus network config that connects to some fixed port on localhost as a drand source (the server from step 2). Possibly allow overriding this with an environment variable.

That way you can get actual (but totally insecure) drand in an isolated environment.

parthshah1 commented 1 month ago

@geoff-vball. I am not sure if this is already solved, but I have a solution which I use in continuous testing. I use cluster of nodes in docker-compose similar to simulate the network.

  1. Create multiple drand nodes. Perform DKG and let it run.
  2. Patch lotus using git apply lotus.patch to use the chaininfo from your local drand nodes. lotus.patch.
  3. During lotus startup, add a script to
    curl 10.20.20.21/info | jq -c > chain_info 
    export DRAND_CHAIN_INFO=chain_info

P.S. Give drand some time to perform DKG. Let me know if you've any questions or want help with this.

Thanks.