├── .env
├── Dockerfile
├── LICENSE
├── LOTUS_VERSION
├── Makefile
├── README.md
├── config
└── config.toml
├── docker-compose.yaml
└── scripts
├── README-Structure.md
├── bash-config
├── configure
├── healthcheck
├── launch
├── png
├── Screenshot 2023-06-23 at 18.54.00.png
├── Screenshot 2023-06-25 at 12.57.30.png
├── Screenshot 2023-06-25 at 13.00.02.png
├── Screenshot 2023-06-26 at 10.17.53.png
├── favicon-32x32.png
├── glif-protofire-logo.png
├── glif_logo.png
├── protofire.png
└── protofire_logo.png
└── run
/.env:
--------------------------------------------------------------------------------
1 |
2 | # Environment variables used to script
3 |
4 | INFRA_CLEAR_RESTART=false
5 | INFRA_IMPORT_SNAPSHOT=false
6 | INFRA_LOTUS_DAEMON=false
7 | INFRA_LOTUS_GATEWAY=false
8 | INFRA_LOTUS_HOME=/home/lotus_user
9 | INFRA_PERSISTNODEID=false
10 | INFRA_SECRETVOLUME=false
11 | INFRA_SYNC=false
12 | SNAPSHOTURL=https://forest-archive.chainsafe.dev/latest/mainnet
13 | INFRA_LOTUS_LITE=false
14 | FULLNODE_API_INFO=wss://wss.node.glif.io/apigw/lotus
15 |
16 |
17 | # Environment variables used to Lotus
18 |
19 | ALLOWED_DELAY=3
20 | GOLOG_LOG_FMT=json
21 | LOTUS_CHAINSTORE_ENABLESPLITSTORE=false
22 | LOTUS_FEVM_ENABLEETHHASHTOFILECOINCIDMAPPING=true
23 | LOTUS_FEVM_ENABLEETHRPC=true
24 | LOTUS_FEVM_ETHTXHASHMAPPINGLIFETIMEDAYS=0
25 | LOTUS_FEVM_EVENTS_FILTERTTL=504h0m0s
26 | LOTUS_FEVM_EVENTS_MAXFILTERHEIGHTRANGE=60480
27 | LOTUS_FVM_CONCURRENCY=24
28 | LOTUS_SKIP_APPLY_TS_MESSAGE_CALL_WITH_GAS=1
29 | LOTUS_VM_ENABLE_TRACING=true
30 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:1.23.7-bullseye AS lotus-build
2 |
3 | # Lotus repository
4 | ARG REPOSITORY="filecoin-project/lotus"
5 | # Git branch of the lotus repository
6 | ARG BRANCH="master"
7 | # Filecoin network. Valid values: lotus(mainnet), calibnet
8 | ARG NETWORK="lotus"
9 | # Repo folder name
10 | ARG FOLDER_NAME="lotus"
11 |
12 |
13 | # Install packages required by lotus
14 | RUN apt-get update && \
15 | apt-get install -y --no-install-recommends \
16 | mesa-opencl-icd \
17 | ocl-icd-opencl-dev \
18 | gcc \
19 | git \
20 | bzr \
21 | jq \
22 | pkg-config \
23 | curl \
24 | clang \
25 | build-essential \
26 | hwloc \
27 | libhwloc-dev \
28 | wget && \
29 | apt-get clean && \
30 | rm -rf /var/lib/apt/lists/*
31 |
32 | # Install Rust
33 | RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
34 | ENV PATH="/root/.cargo/bin:${PATH}"
35 |
36 | # Install lotus
37 | RUN git clone https://github.com/${REPOSITORY}.git --depth 1 --branch $BRANCH $FOLDER_NAME && \
38 | cd $FOLDER_NAME && \
39 | make clean && \
40 | make deps && \
41 | make $NETWORK lotus-shed lotus-gateway && \
42 | install -C ./lotus /usr/local/bin/lotus && \
43 | install -C ./lotus-gateway /usr/local/bin/lotus-gateway && \
44 | install -C ./lotus-shed /usr/local/bin/lotus-shed
45 |
46 | FROM ubuntu:20.04 AS lotus-base
47 |
48 | # Copy software dependencies
49 | COPY --from=lotus-build \
50 | /usr/lib/*/libhwloc.so.15 \
51 | /usr/lib/*/libnuma.so.1 \
52 | /usr/lib/*/libltdl.so.7 \
53 | /lib/
54 |
55 | # Copy OpenCL
56 | COPY --from=lotus-build \
57 | /usr/lib/*/libOpenCL.so.1.0.0 \
58 | /lib/libOpenCL.so.1
59 |
60 | # Copy SSL certificates
61 | COPY --from=lotus-build \
62 | /etc/ssl/certs \
63 | /etc/ssl/certs
64 |
65 | # Copy lotus binaries
66 | COPY --from=lotus-build \
67 | /usr/local/bin/lotus \
68 | /usr/local/bin/lotus-gateway \
69 | /usr/local/bin/lotus-shed \
70 | /usr/local/bin/
71 |
72 | FROM lotus-base AS lotus-runtime
73 |
74 | # Install JQ
75 | RUN apt-get update && \
76 | apt-get install -y --no-install-recommends \
77 | jq \
78 | curl \
79 | nano && \
80 | apt-get clean && \
81 | rm -rf /var/lib/apt/lists/*
82 |
83 | # Copy lotus version
84 | COPY LOTUS_VERSION /VERSION
85 |
86 | # Copy lotus config
87 | COPY config/config.toml /home/lotus_user/config.toml
88 |
89 | # Copy the healthcheck script
90 | COPY scripts/healthcheck /bin/
91 |
92 | # Copy config scripts
93 | COPY scripts/bash-config \
94 | scripts/configure \
95 | scripts/run \
96 | scripts/launch \
97 | /etc/lotus/docker/
98 |
99 | # Create lotus group
100 | RUN addgroup --gid 2000 lotus
101 |
102 | # Create lotus user
103 | RUN adduser --gid 2000 --uid 2000 --gecos "" --disabled-password --quiet lotus_user
104 |
105 | # Add permissions for the lotus_user
106 | RUN chown -R 2000:2000 /home/lotus_user
107 |
108 | # # Add permissions for the group lotus
109 | # RUN chmod 664 /home/lotus_user
110 | #
111 | # # Add permissions for the group lotus
112 | # RUN chmod g+s /home/lotus_user
113 |
114 | USER lotus_user
115 |
116 | EXPOSE 1234/tcp
117 |
118 | EXPOSE 1235/tcp
119 |
120 | ENTRYPOINT ["/etc/lotus/docker/run"]
121 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/LOTUS_VERSION:
--------------------------------------------------------------------------------
1 | 0.2.10.1
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # Git branch of the lotus repository
2 | BRANCH = master
3 | # Filecoin network. Valid values: lotus(mainnet), calibnet
4 | NETWORK := lotus
5 | # Image build architecture
6 | ARCH = arm64
7 | # Lotus repository
8 | SOURCE_DIR = "$(HOME)/lotus"
9 |
10 |
11 | # Image build
12 |
13 | .PHONY: build
14 | build:
15 | docker image build --network host --build-arg NETWORK=$(NETWORK) --build-arg BRANCH=$(BRANCH) -t glif/lotus:$(BRANCH)-$(NETWORK)-$(ARCH) .
16 |
17 | .PHONY: rebuild
18 | rebuild:
19 | docker image build --no-cache --network host --build-arg NETWORK=$(NETWORK) --build-arg BRANCH=$(BRANCH) -t glif/lotus:$(BRANCH)-$(NETWORK)-$(ARCH) .
20 |
21 | .PHONY: push
22 | push:
23 | docker push -t glif/lotus:$(BRANCH)-$(NETWORK)-$(ARCH)
24 |
25 |
26 | git-push:
27 | git commit -a -m "$(BRANCH)" && git push && git tag $(BRANCH) && git push --tags
28 |
29 | # Run docker container
30 |
31 | .PHONY: run
32 | run:
33 | docker run -d --name lotus \
34 | -p 1234:1234 -p 1235:1235 \
35 | --env-file .env \
36 | --network host \
37 | --restart always \
38 | --mount type=bind,source=$(SOURCE_DIR),target=/home/lotus_user \
39 | glif/lotus:$(BRANCH)-$(NETWORK)-$(ARCH)
40 |
41 |
42 | run-bash:
43 | docker container run -p 1235:1235 -p 1234:1234 -it --entrypoint=/bin/bash --name lotus --rm glif/lotus:$(BRANCH)-$(NETWORK)-$(ARCH)
44 |
45 | bash:
46 | docker exec -it lotus /bin/bash
47 |
48 | sync-status:
49 | docker exec -it lotus lotus sync status
50 |
51 | log:
52 | docker logs lotus -f
53 |
54 | rm:
55 | docker stop lotus
56 | docker rm lotus
57 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | filecoin-docker
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | Glif Docker images are managed by Protofire.
27 |
28 | ## TL;DR
29 |
30 | ### Launch Lotus
31 | By default `SNAPSHOTURL` environment variable uses a path for mainnet `https://forest-archive.chainsafe.dev/latest/mainnet`. It can be changed in the [.env](.env) file, or add the flag `-e`.
32 | ````shell
33 | docker run -d --name=lotus -p 1234:1234 -p 1235:1235 -v $HOME/lotus:$HOME/lotus_user --env-file .env -e INFRA_LOTUS_DAEMON="true" -e INFRA_SYNC="true" -e INFRA_IMPORT_SNAPSHOT="true" glif/lotus:${IMAGE_TAG}
34 | ````
35 | ### Launch Lotus with Gateway
36 | By default `SNAPSHOTURL` environment variable uses a path for mainnet. It can be changed in the [.env](.env) file, or add the flag `-e`.
37 | ````shell
38 | docker run -d --name=lotus -p 1234:1234 -p 1235:1235 -v $HOME/lotus:$HOME/lotus_user --env-file .env -e INFRA_LOTUS_GATEWAY="true" -e INFRA_IMPORT_SNAPSHOT="true" -e INFRA_SYNC="true" -e INFRA_LOTUS_DAEMON="true" glif/lotus:${IMAGE_TAG}
39 | ````
40 | ### Launch Lotus lite node
41 | Use case: You're blockchain developer and run your code against Lotus, this is your weapon of choice - way less resources and all write methods available.
42 | By default `FULLNODE_API_INFO` environment variable `wss://wss.node.glif.io/apigw/lotus`. It can be changed in the [.env](.env) file, or add the flag `-e`.
43 | ````shell
44 | docker run -d --name=lotus -p 1234:1234 -p 1235:1235 -v $HOME/lotus:$HOME/lotus_user --env-file .env -e INFRA_LOTUS_LITE="true" glif/lotus:${IMAGE_TAG}
45 | ````
46 | ### Launch Lotus with custom key
47 | By default `SNAPSHOTURL` environment variable uses a path for mainnet. It can be changed in the [.env](.env) file, or add the flag `-e`.
48 | We expect that the Kubernetes secret has been mounted to `/keystore` as a directory.
49 | ````shell
50 | docker run -d --name=lotus -p 1234:1234 -p 1235:1235 -v $HOME/lotus:$HOME/lotus_user --env-file .env -e INFRA_SECRETVOLUME="true" -e INFRA_PERSISTNODEID="true" -e INFRA_IMPORT_SNAPSHOT="true" -e INFRA_SYNC="true" -e INFRA_LOTUS_DAEMON="true" -e INFRA_LOTUS_GATEWAY="true" glif/lotus:${IMAGE_TAG}
51 | ````
52 |
53 | ## Prerequisites
54 |
55 | Docker has to be installed on your machine to run containers, follow the official Docker installation guide for your operating system:
56 |
57 | - [Install Docker Desktop on Mac](https://docs.docker.com/desktop/install/mac-install/)
58 | - [Install Docker Desktop on Linux](https://docs.docker.com/desktop/install/linux-install/)
59 | - [Install Docker Desktop on Windows](https://docs.docker.com/desktop/install/windows-install/)
60 |
61 |
62 |
63 | ## Use pre-built images
64 |
65 | You can find our pre-build images [here](https://hub.docker.com/r/glif/lotus/tags?page=1&ordering=last_updated)\
66 | The naming convention is as follows `glif/lotus:$(BRANCH)-$(NETWORK)-$(ARCH)`\
67 | here:
68 | - BRANCH is a git branch of the selected lotus repository (the official one or our fork [protofire/lotus](https://github.com/protofire/lotus)).
69 | - NETWORK is the Filecoin network the image is built for. Valid values: lotus (for mainnet) and calibnet.
70 | - ARCH is the CPU architecture of the host machine the image is built for. At the moment we provide images for arm64 and amd64.
71 |
72 | Example: `glif/lotus:v1.23.1-rc3-mainnet-arm64`
73 |
74 | #### To use the pre-built image you have to do the following:
75 | - Pull the image: `docker pull glif/lotus:${IMAGE_TAG}`\
76 | Before running the run command you have to specify the `Configuration options` into the [.env](.env) file.
77 | - The run command will look like the following:
78 | ````shell
79 | docker run -d --name=lotus -p 1234:1234 -p 1235:1235 -v $HOME/lotus:$HOME/lotus_user --env-file .env glif/lotus:${IMAGE_TAG}
80 | ````
81 |
82 |
83 | ## Build your own image and run the container
84 |
85 | We provide three ways you can build your own images and run the container locally:
86 | - You can build the image using the docker build command in a straight-forward and flexible way.
87 | - You can use the pre-written commands in the Makefile.
88 | - You can use docker-compose.
89 |
90 |
91 |
92 | ### Build arguments for image
93 | | Argument name | Default value | Purpose |
94 | |---------------|---------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
95 | | REPOSITORY | [filecoin-project/lotus](https://github.com/filecoin-project/lotus) | The Git repository to clone the lotus source code from. |
96 | |BRANCH| master | The Git branch of the before-mentioned repository. |
97 | |NETWORK| lotus | The Filecoin network to build the image for. Acceptable values: lotus (for mainnet) and calibnet. |
98 |
99 |
100 |
101 | ### Configuration options to run the container, follow to the file [.env](.env)
102 |
103 | | Environment variables | What data does it accept? | What is it for? |
104 | |-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
105 | | INFRA_LOTUS_DAEMON | TRUE or FALSE | Set it to TRUE to start the lotus daemon only. |
106 | | INFRA_LOTUS_GATEWAY | TRUE or FALSE | Set it to TRUE to start the lotus daemon with the lotus gateway on top. |
107 | | INFRA_CLEAR_RESTART | TRUE or FALSE | Set it to TRUE to remove the lotus folder with chainstore and statestore. Useful when resetting the node. ! CAUTION THIS VALUE WILL DROP ALL THE CHAIN STATE ON THE START, PLEASE PUT IT TO TRUE IF YOU UNDERSTAND CONSEQUENCES. |
108 | | INFRA_IMPORT_SNAPSHOT | TRUE or FALSE | Set it to TRUE to import the snapshot from the URL specified in the SNAPSHOTURL environment variable. Set to FALSE to start fetching the blockchain state from the Genesis event(:warning: it will cost you several month). |
109 | | INFRA_LOTUS_HOME | Path in the container’s filesystem. Default is: /home/lotus_user | Defines where in the container’s filesystem the .lotus folder will be created. | ||
110 | | INFRA_PERSISTNODEID | TRUE or FALSE | Set it to TRUE to copy the node ID from `/keystore/nodeid` to `$LOTUS_PATH/keystore/NRUWE4BSOAWWQ33TOQ`. This is needed for bootstrap node. |
111 | | INFRA_SECRETVOLUME | TRUE or FALSE | Set it to TRUE to copy the AUTH token from `/keystore/token` to `$LOTUS_PATH/token` and to copy the private_key from `/keystore/privatekey` to `$LOTUS_PATH/keystore/MF2XI2BNNJ3XILLQOJUXMYLUMU`. That implies that the Kubernetes secret has been mounted to `/keystore` as a directory. That allows using the same authentication token despite the node being reset over and over again. |
112 | | INFRA_SYNC | TRUE or FALSE | Set it to TRUE for the Lotus blockchain sync before the actual Lotus Daemon starts. Example of usage - Liveness probe in the k8s - you are waiting for the file `$INFRA_LOTUS_HOME/.lotus/sync-complete` and only after the file creation you add Lotus pod to the k8s service. |
113 | | SNAPSHOTURL | URL to the snapshot. The current recent state snapshots are available here: https://forest-archive.chainsafe.dev/latest/mainnet, https://forest-archive.chainsafe.dev/latest/calibnet | Set it to TRUE snapshot URL to make lotus download and import it. Can also be a path in the container’s filesystem. |
114 | | INFRA_LOTUS_LITE | TRUE or FALSE | Set it to TRUE to run the lotus daemon in the lite node mode. |
115 | | FULLNODE_API_INFO | URL of the full node: `wss://wss.node.glif.io/apigw/lotus` | You have to specify this variable if `INFRA_LOTUS_LITE` is set to true. |
116 |
117 |
118 |
119 |
120 | ## Common configuration examples
121 |
122 | This section describes a few scenarios of how you can use the environment variables to achieve different results, e.g.\
123 | running the spot recent state node, running the on-demand state node, running the lotus lite node, running the node outside of Kubernetes, etc.
124 |
125 | #### Running the spot (AWS temporary instance with discount return back anytime) recent state node
126 |
127 |
128 | When we use `INFRA_CLEAR_RESTART=true`, we expect that directory lotus is removed upon the start of the container. Then, if `INFRA_IMPORT_SNAPSHOT=true` and the `SNAPSHOTURL` is specified, the container will attempt to download and import the snapshot.
129 |
130 | - The list of env variables you should change into the file [.env](.env) is as follows, you can find more details about the environment variables in the `Configuration options` section.
131 |
132 |
133 | ````
134 | INFRA_CLEAR_RESTART=true
135 | INFRA_IMPORT_SNAPSHOT=true
136 | INFRA_LOTUS_DAEMON=true
137 | INFRA_LOTUS_GATEWAY=true
138 | INFRA_PERSISTNODEID=false
139 | INFRA_SECRETVOLUME=false
140 | INFRA_SYNC=true
141 | SNAPSHOTURL=https://forest-archive.chainsafe.dev/latest/mainnet
142 | ````
143 |
144 | #### Running the on-demand (AWS permanent instance) state node
145 |
146 | When we use `INFRA_CLEAR_RESTART=false`, we expect that directory lotus isn't removed upon the container start and data will continue to sync from the moment the sync was interrupted.
147 |
148 | - The list of env variables you should change into the file [.env](.env) is the following, you can find more details about the environment variables if follow the link `Configuration options`.
149 |
150 |
151 | ````
152 | INFRA_CLEAR_RESTART=false
153 | INFRA_IMPORT_SNAPSHOT=true
154 | INFRA_LOTUS_DAEMON=true
155 | INFRA_LOTUS_GATEWAY=true
156 | INFRA_PERSISTNODEID=false
157 | INFRA_SECRETVOLUME=false
158 | INFRA_SYNC=true
159 | SNAPSHOTURL=https://forest-archive.chainsafe.dev/latest/mainnet
160 | ````
161 |
162 |
163 | ### Using the docker build command
164 | The Dockerfile requires you to specify the following build arguments: `BRANCH`, `NETWORK`, `REPOSITORY`. You can override the default values using the `—build-arg flag` in the docker build command. Example:
165 | By default TAG of the image has the naming `glif/lotus:$(BRANCH)-$(NETWORK)`, you can change it to your custom TAG like `-t ${IMAGE_TAG}`. By the way, this parameter is `OPTIONAL`.
166 |
167 | - You can build the image using the following command:
168 | ```shell
169 | docker image build --network host --build-arg NETWORK=$(NETWORK) --build-arg BRANCH=$(BRANCH) -t glif/lotus:$(BRANCH)-$(NETWORK) .
170 | ````
171 |
172 |
173 | ### Run the container using the docker command
174 |
175 | Before running the run command you have to specify the `Configuration options`.
176 | You can build and use `your own image` or [use our pre built images](#use-pre-built-images) when specifying the image.
177 |
178 | - The run command will look like the following:
179 | ```shell
180 | docker run -d --name=lotus -p 1234:1234 -p 1235:1235 -v $HOME/lotus:$HOME/lotus_user --env-file .env glif/lotus:${IMAGE_TAG}
181 | ````
182 |
183 |
184 | ### Using the Makefile
185 |
186 | Before running any commands provided by the [Makefile](Makefile), you have to specify the `build arguments`.\
187 | You have to also specify the `ARCH` argument - it’s the CPU architecture of the host machine the image is built for. The acceptable values are: `arm64, amd64`.\
188 | The image TAG will have the name like `glif/lotus:$(BRANCH)-$(NETWORK)-$(ARCH)`, you can change it in the Makefile the `build` section to your custom TAG like `-t ${IMAGE_TAG}`. By the way, this parameter is `OPTIONAL`.
189 |
190 | - Then you could run the following command in your terminal:
191 |
192 | ````shell
193 | make build
194 | ````
195 |
196 |
197 | ### Run the container using the Makefile
198 |
199 | Before running any commands provided by the [Makefile](Makefile), you have to specify the `Configuration options`.
200 |
201 | The image that the Makefile builds looks like the following: `glif/lotus:$(BRANCH)-$(NETWORK)-$(ARCH)`, If you'd like to use a custom image, you can edit the Makefile the `run` section.
202 |
203 | Example for usage Makefile :
204 |
205 | ````
206 | docker run -d --name lotus \
207 | -p 1234:1234 -p 1235:1235 \
208 | --env-file .env \
209 | --network host \
210 | --restart always \
211 | --mount type=bind,source=$(SOURCE_DIR),target=/home/lotus_user \
212 | glif/lotus:latest
213 |
214 | ````
215 |
216 | ````shell
217 | make run
218 | ````
219 |
220 |
221 | ### Using docker-compose
222 |
223 | While running the build command you have to specify the `build arguments`.
224 | By default TAG of the image has the naming `glif/lotus:latest`, you can change it in the file [docker-compose](docker-compose.yaml) in the section `image` to your custom TAG.
225 |
226 | - The build command will look like the following:
227 | ```shell
228 | docker-compose build --build-arg NETWORK=calibnet --build-arg BRANCH=master
229 | ````
230 |
231 | ### run the container using the docker-compose
232 |
233 | Before running the run command you have to specify the `Configuration options`.
234 |
235 | - Build and run docker the container
236 |
237 | ````shell
238 | docker-compose up -d --build
239 | ````
240 | - Verify that the container is running with the following command:
241 |
242 | ```shell
243 | docker ps
244 | ```
245 |
246 |
247 |
248 | ## Troubleshooting
249 |
250 | #### Problem:
251 | `cp: cannot stat '/keystore/token': No such file or directory`
252 |
253 | #### Symptoms:
254 | if you look this in the container logs:
255 |
256 | ````
257 | ===> Configuring ...
258 | I'll remove ALL LOTUS DATA from /home/lotus_user/.lotus/
259 | -------> Removing ... <---------
260 | cp: cannot stat '/keystore/token': No such file or directory
261 |
262 | ````
263 |
264 | #### Solution:
265 |
266 | - Make sure that variables `INFRA_SECRETVOLUME`, `INFRA_PERSISTNODEID` have a value `false` into the file [.env](.env).
267 | - if secrets are used by Kubernetes:
268 | - make sure that the secret volume is really mounted `$LOTUS_PATH/keystore`
269 | - make sure that the secrets are correct `/home/lotus_user/.lotus/token`, `/home/lotus_user/.lotus/keystore/${private_key}`, `/home/lotus_user/.lotus/keystore/${node_id}`
270 | -------------------
271 |
272 | - [Use pre-built images](#use-pre-built-images)
273 | - [Build image and run the container](#build-your-own-image-and-run-the-container)
274 | - [Common configuration examples](#common-configuration-examples)
275 | - [Using the docker command](#using-the-docker-build-command)
276 | - [Using the Makefile](#using-the-makefile)
277 | - [Using docker-compose](#using-docker-compose)
278 | - [Troubleshooting](#troubleshooting)
279 |
280 |
281 | ## Summary
282 |
283 | This repository contains Docker manifest and the set of scripts that you can use to run the Lotus container.
284 |
285 | Why do we use custom scripts?
286 |
287 | - We’ve been hosting lotus in Kubernetes for 3+ years (in comparison the official lotus images have been existing for only 2 years at the moment), and as a result of our accumulated experience we’ve developed a set of scripts tailored specifically for our needs, e.g. copying Lotus tokens from Kubernetes secrets, resetting the recent state nodes when their storage is full, etc
288 |
289 | Why do we build our own images?
290 |
291 | - We've optimized Lotus images by using only the necessary libraries and binaries, like `lotus, lotus-gateway, lotus-shed`
292 |
293 | What launch scenarios do we support out-of-the-box?
294 |
295 | - We support the following launch scenarios:
296 | - launching the Lotus daemon only
297 | - launching the Lotus daemon with lotus gateway
298 | - launching a Lotus Lite node
299 |
300 |
301 | ## Structure
302 |
303 | Here's a quick guide. The main parts of the repository are:
304 |
305 | * [Dockerfile](./Dockerfile) - contains the necessary configuration to build the image and embed the scripts.
306 | * [config.toml](./config/config.toml) - the lotus configuration file. Contains only the parameters that cannot be set by the environment variables.
307 | * [Our infrastructure scripts:](./scripts) - contains scripts to build and run Lotus.
308 | * [Makefile](./Makefile) - contains a set of commands for building the Lotus image, running and operating the Lotus container.
309 | * [Docker-compose](./docker-compose.yaml) - contains a set of parameters for building the Lotus image and running the Lotus container in a docker-compose fashion.
310 |
311 | If you want to understand better scripts structure and how it works, please follow the link [Structure](scripts/README-Structure.md)
312 |
313 |
--------------------------------------------------------------------------------
/config/config.toml:
--------------------------------------------------------------------------------
1 | [API]
2 | ListenAddress = "/ip4/0.0.0.0/tcp/1234/http"
3 | Timeout = "60s"
4 | [Libp2p]
5 | ListenAddresses = ["/ip4/0.0.0.0/tcp/1235", "/ip6/::/tcp/1235"]
6 | AnnounceAddresses = []
7 | [Pubsub]
8 | RemoteTracer = ""
9 | [Chainstore]
10 | EnableSplitstore = false
--------------------------------------------------------------------------------
/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | version: "3"
2 | services:
3 | lotus:
4 | build:
5 | context: .
6 | args:
7 | - BRANCH
8 | - NETWORK
9 | image: 'glif/lotus:latest'
10 | env_file:
11 | - .env
12 | user: lotus_user
13 | volumes:
14 | - $HOME/lotus:/home/lotus_user
15 | ports:
16 | - "1234:1234"
17 | - "1235:1235"
18 |
--------------------------------------------------------------------------------
/scripts/README-Structure.md:
--------------------------------------------------------------------------------
1 | ## Structure
2 | This section describes the scripts and how they work in more detail.
3 |
4 | ````mermaid
5 | flowchart LR
6 |
7 | A[Dockerfile] -->|ENTRYPOINT /scripts/run| B{./run}
8 | B -->|run bash-config| C[./bash-config - Export ENV vars]
9 | B -->|run configure| D[./configure - Set configuration functions]
10 | B -->|run launch| E[./launch - starts the required processes]
11 |
12 | ````
13 |
14 |
15 | Here's a quick guide. The main parts of the repository are:
16 | * [Our infrastructure scripts:](./scripts)
17 | * [bash-config](bash-config) - exports environment variables and defines the utility functions that are required for the other scripts to work.
18 | * [configure](./scripts/configure) - defines and runs the configuration functions that handle our custom environment variables.
19 | * [healthcheck](./scripts/healthcheck) - contains a health check script that you can use as a readiness probe in Kubernetes to verify that the node is in the 3 [tipsets](https://docs.filecoin.io/basics/the-blockchain/tipsets/) range from the current head.
20 | * [launch](./scripts/launch) - starts the required processes according to the selected launch scenario.
21 | * [run](./scripts/run) - docker entrypoint script. Runs the before-mentioned scripts in the following order: bash-config, configure, launch.
22 |
23 |
24 | [run](run)
25 |
26 | Running the configure file and launch file
27 |
28 | [bash-config](bash-config)
29 |
30 | Besides exporting the utility environment variables, the scripts define the validation functions:
31 | `validate_env_soft` and `validate_env_hard`. Both functions check if the provided as an argument environment variable has a value, and the value is not false.\
32 | If the value is empty or false, the validate_env_soft function returns a non-zero code.\
33 | On the other hand, the validate_env_hard function under the before-mentioned conditions terminates the script execution with the non-zero code.
34 |
35 | [Launch script](launch)
36 |
37 | The script is written in a way that only one launch scenario is executed at a time. The launch scenario precedence is as follows:
38 | INFRA_LOTUS_LITE > INFRA_LOTUS_GATEWAY > INFRA_LOTUS_DAEMON.\
39 | Keep in mind that the `--api-wait-lookback-limit` and `--api-max-lookback` arguments are hardcoded as `2000` and `16h40m0s` respectively.\
40 | If you want to change this behavior, you have to edit the arguments in the `launch_gateway function`.
41 |
42 |
43 | [configure](configure)
44 |
45 | Runs scripts based on configured variables such as deleting the lotus directory, adding a secret volume, coping secrets, assigns permissions, coping the toml config, importing snapshot, launching a sync with the blockchain.
46 |
47 |
48 | [healthcheck](healthcheck)
49 |
50 | The health-check script can be used as a readiness probe for the lotus pod in Kubernetes. It compares the current chain head and the head at hand, and if the difference is more than 3 [tipsets](https://docs.filecoin.io/basics/the-blockchain/tipsets/), the pod is considered unhealthy.\
51 | The number 3 has been chosen because the epoch in Filecoin lasts 30 seconds; the average time to catch up a tipset is ~12 seconds; so, if the head at hand is 3 tipsets behind the current head, something went wrong and you have to investigate the issue.
52 |
--------------------------------------------------------------------------------
/scripts/bash-config:
--------------------------------------------------------------------------------
1 | #set -o nounset \
2 | # -o errexit
3 | set -e
4 |
5 | function show_env {
6 | env | sort | grep INFRA
7 | }
8 |
9 |
10 | function validate_env {
11 | local ENV_NAME=$1;
12 | local ENV_VALUE=$(printenv $1);
13 |
14 | local EXIT_FUNCTION=$2;
15 | local EXIT_VALUE=$3;
16 |
17 | if [[ -z "$ENV_VALUE" ]]; then
18 | echo "$ENV_NAME is empty";
19 | $EXIT_FUNCTION $EXIT_VALUE;
20 | fi
21 |
22 | if [ "$ENV_VALUE" = false ]; then
23 | echo "$ENV_NAME is disabled";
24 | $EXIT_FUNCTION $EXIT_VALUE;
25 | fi
26 |
27 | return 0;
28 | }
29 |
30 |
31 | function validate_env_hard {
32 | local ENV_NAME=$1;
33 |
34 | validate_env $ENV_NAME exit 1;
35 | }
36 |
37 |
38 | function validate_env_soft {
39 | local ENV_NAME=$1;
40 |
41 | validate_env $ENV_NAME return 1;
42 | }
43 |
44 |
45 | export LOTUS_PATH="$INFRA_LOTUS_HOME/.lotus";
46 |
47 | export LOTUS_CONFIG_SOURCE_PATH="$INFRA_LOTUS_HOME/config.toml";
48 | export LOTUS_CONFIG_TARGET_PATH="$LOTUS_PATH/config.toml";
49 |
50 | export KEYSTORE_SOURCE_DIR="/keystore";
51 | export KEYSTORE_TARGET_DIR="$LOTUS_PATH/keystore";
52 |
53 | export TOKEN_SOURCE_PATH="$KEYSTORE_SOURCE_DIR/token";
54 | export TOKEN_TARGET_PATH="$LOTUS_PATH/token";
55 |
56 | export PRIVATE_KEY_SOURCE_PATH="$KEYSTORE_SOURCE_DIR/privatekey";
57 | export PRIVATE_KEY_TARGET_PATH="$KEYSTORE_TARGET_DIR/MF2XI2BNNJ3XILLQOJUXMYLUMU";
58 |
59 | export NODE_ID_SOURCE_PATH="$KEYSTORE_SOURCE_DIR/nodeid";
60 | export NODE_ID_TARGET_PATH="$KEYSTORE_TARGET_DIR/NRUWE4BSOAWWQ33TOQ";
61 |
62 | export SNAPSHOT_DEFAULT_PATH="/chain/chain.car";
63 |
64 | export DATASTORE_TARGET_PATH="$LOTUS_PATH/datastore";
65 |
66 | export IMPORT_COMPLETE_PATH="$LOTUS_PATH/import-complete";
67 | export SYNC_COMPLETE_PATH="$LOTUS_PATH/sync-complete";
68 |
69 | if [[ -z "$INFRA_LOTUS_GW_LOOKBACK_LIMIT" ]]; then
70 | export INFRA_LOTUS_GW_LOOKBACK_LIMIT="2000";
71 | fi
72 |
73 | if [[ -z "$INFRA_LOTUS_GW_MAX_LOOKBACK" ]]; then
74 | export INFRA_LOTUS_GW_MAX_LOOKBACK="16h40m0s";
75 | fi
76 |
--------------------------------------------------------------------------------
/scripts/configure:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #set -x
3 | . /etc/lotus/docker/bash-config
4 |
5 | repeat() { while :; sleep 3; do $@ && return; done }
6 |
7 | # Handle INFRA_CLEAR_RESTART variable
8 | function run_clear_restart {
9 | echo "I'll remove ALL LOTUS DATA from $LOTUS_PATH/";
10 | echo " -------> Removing ... <---------";
11 | repeat rm -rf "$LOTUS_PATH/*";
12 | }
13 |
14 | # Handle INFRA_SECRETVOLUME variable
15 | function handle_persist_node_id {
16 | if [[ $INFRA_PERSISTNODEID = true ]]; then
17 | cp $NODE_ID_SOURCE_PATH $NODE_ID_TARGET_PATH;
18 | return 0;
19 | fi
20 |
21 | rm -f $NODE_ID_TARGET_PATH;
22 | }
23 |
24 | function copy_secrets {
25 | mkdir -p $KEYSTORE_TARGET_DIR;
26 |
27 | handle_persist_node_id;
28 |
29 | cp $TOKEN_SOURCE_PATH $TOKEN_TARGET_PATH;
30 | cp $PRIVATE_KEY_SOURCE_PATH $PRIVATE_KEY_TARGET_PATH;
31 | }
32 |
33 | # Set filesystem permissions on the copied secrets
34 | function set_secrets_permissions {
35 | # Set permissions in the keystore directory to 600
36 | if [ -d "$KEYSTORE_TARGET_DIR" ]; then
37 | find "$KEYSTORE_TARGET_DIR/" -type f -exec chmod 600 {} \;
38 | fi
39 |
40 | # Set permissions to the token file to 600
41 | if [ -f "$TOKEN_TARGET_PATH" ]; then
42 | chmod -f 600 "$TOKEN_TARGET_PATH"
43 | fi
44 | }
45 |
46 | # Copy config.toml if needed
47 | function copy_config {
48 | # If config.toml doesn't exist,
49 | # print out error message and exit.
50 | if [ ! -f "$LOTUS_CONFIG_SOURCE_PATH" ]; then
51 | echo "$LOTUS_CONFIG_SOURCE_PATH not found";
52 | return 0;
53 | fi
54 |
55 | # If the .lotus directory doesn't exist, create it.
56 | if [ ! -d "$LOTUS_PATH" ]; then
57 | mkdir "$LOTUS_PATH"
58 | fi
59 |
60 | # Copy config.toml to the .lotus directory
61 | cp $LOTUS_CONFIG_SOURCE_PATH $LOTUS_CONFIG_TARGET_PATH
62 | }
63 |
64 | # Handle INFRA_IMPORT variable
65 | function run_import {
66 | echo "Starting import...";
67 | if [ -f "$SNAPSHOT_DEFAULT_PATH" ] && [ ! -e "$DATASTORE_TARGET_PATH" ]; then
68 | lotus daemon --halt-after-import --import-chain "$SNAPSHOT_DEFAULT_PATH";
69 | touch "$IMPORT_COMPLETE_PATH";
70 | fi
71 | }
72 |
73 | function run_import_from_ipfs {
74 | echo "Fetching IPFS CID...";
75 | local CID=$(curl $SNAPSHOT_CID);
76 | echo "Fetched. CID is $CID";
77 |
78 | SNAPSHOTURL="$IPFS_GW/$CID";
79 | echo "Full URL to snapshot is $SNAPSHOTURL";
80 |
81 | INFRA_IMPORT_SNAPSHOT=true;
82 | }
83 |
84 | function run_import_snapshot {
85 | echo "Starting import...";
86 | if [ -e "$DATASTORE_TARGET_PATH" ]; then
87 | echo "Removing all chain data...";
88 | rm -rf "$DATASTORE_TARGET_PATH/chain/*";
89 | fi
90 |
91 | lotus daemon --halt-after-import --remove-existing-chain --import-snapshot $SNAPSHOTURL;
92 | touch "$IMPORT_COMPLETE_PATH";
93 | }
94 |
95 | function is_import_completed {
96 | # If there's a file at IMPORT_COMPLETE_PATH, exit.
97 | if [ -f "$IMPORT_COMPLETE_PATH" ]; then
98 | return 0;
99 | fi
100 |
101 | return 1;
102 | }
103 |
104 | function run_sync {
105 | echo "Starting sync wait...";
106 | ( repeat lotus sync wait && touch "$INFRA_LOTUS_HOME/.lotus/sync-complete" &);
107 | }
108 |
109 | # Exit if INFRA_LOTUS_HOME is not defined
110 | validate_env_hard INFRA_LOTUS_HOME;
111 |
112 | validate_env_soft INFRA_CLEAR_RESTART && run_clear_restart;
113 |
114 | validate_env_soft INFRA_SECRETVOLUME && copy_secrets;
115 |
116 | set_secrets_permissions;
117 |
118 | copy_config;
119 |
120 | validate_env_soft INFRA_IMPORT && run_import;
121 |
122 | validate_env_soft INFRA_IMPORT_SNAPSHOT_FROM_IPFS && run_import_from_ipfs;
123 |
124 | is_import_completed || (validate_env_soft INFRA_IMPORT_SNAPSHOT && run_import_snapshot || echo "Do not run import");
125 |
126 | validate_env_soft INFRA_SYNC && run_sync || echo "Do not run sync";
127 |
--------------------------------------------------------------------------------
/scripts/healthcheck:
--------------------------------------------------------------------------------
1 | #!/bin/bash -e
2 |
3 | if [ ! -f "$INFRA_LOTUS_HOME/.lotus/sync-complete" ]; then
4 | exit 1
5 | fi
6 |
7 |
8 | ALLOWED_DELAY=${ALLOWED_DELAY:=3}
9 | #BLOCK_TIME=$(cat /networks/${NETWORK}.json | jq .NetworkParameters.EpochDurationSeconds -r)
10 | BLOCK_TIME=30
11 | GENESIS_TIMESTAMP=$(timeout -k3 3 curl -s http://127.0.0.1:1234/rpc/v0 -X POST -H "Content-Type: application/json" --data '{ "jsonrpc": "2.0", "id":1, "method": "Filecoin.ChainGetGenesis", "params": [] }' | jq '.result.Blocks[0].Timestamp')
12 | CURRENT_TIMESTAMP=$(date +"%s")
13 | DIFFERENCE_IN_TIME=$(( $CURRENT_TIMESTAMP - $GENESIS_TIMESTAMP ))
14 | MIN_ALLOWED_BLOCK=$(( $DIFFERENCE_IN_TIME / $BLOCK_TIME - $ALLOWED_DELAY ))
15 | OUR_BLOCK=$(curl -s --max-time 3 localhost:1234/debug/metrics | grep ^lotus_chain_node_worker_height | awk '{print $2}')
16 | THE_BLOCK=$(curl -s -X POST -H "Content-type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params":[]}' localhost:1234/rpc/v1 | awk -F '"' '{print $8}')
17 |
18 | if [ ! -z $(echo $OUR_BLOCK | grep "e+") ]
19 | then OUR_BLOCK=$(printf "%0.f" $OUR_BLOCK)
20 | fi
21 |
22 | # If local block is lower than minimum allowed block or we can't get block data - the health is bad
23 | if [[ "$OUR_BLOCK" -ge "$MIN_ALLOWED_BLOCK" && ! -z "$OUR_BLOCK" && ! -z "$MIN_ALLOWED_BLOCK" && ! -z "$THE_BLOCK" ]] && \
24 | # Fail readiness probe if Filecoin.EthGetLogs method request takes longer than 10 seconds
25 | timeout 10 curl -s -X POST -H 'Content-Type: application/json' -d "{\"jsonrpc\":\"2.0\",\"method\":\"Filecoin.EthGetLogs\",\"params\":[{\"fromBlock\":\"$THE_BLOCK\",\"toBlock\":\"$THE_BLOCK\"}],\"id\":1}" http://127.0.0.1:1234/rpc/v1; then
26 | exit 0
27 | else
28 | exit 1
29 | fi
30 |
--------------------------------------------------------------------------------
/scripts/launch:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | . /etc/lotus/docker/bash-config
4 |
5 | # Start the daemon process
6 | function launch_daemon {
7 | echo "Starting lotus daemon...";
8 |
9 | lotus daemon;
10 | }
11 |
12 | function launch_daemon_follower {
13 | lotus daemon --follower;
14 | }
15 |
16 | function launch_gateway {
17 | launch_daemon &
18 |
19 | echo "Starting lotus gateway...";
20 | lotus wait-api --timeout 30m && lotus-gateway run --api-wait-lookback-limit $INFRA_LOTUS_GW_LOOKBACK_LIMIT --api-max-lookback $INFRA_LOTUS_GW_MAX_LOOKBACK;
21 | }
22 |
23 | function launch_follower {
24 | launch_daemon_follower &
25 |
26 | echo "Starting lotus follower...";
27 | lotus wait-api --timeout 30m && lotus-gateway run --api-wait-lookback-limit $INFRA_LOTUS_GW_LOOKBACK_LIMIT --api-max-lookback $INFRA_LOTUS_GW_MAX_LOOKBACK;
28 | }
29 |
30 | function launch_daemon_lite {
31 | echo "Starting lotus daemon in lite mode...";
32 |
33 | lotus daemon --lite;
34 | }
35 |
36 | # Launch lotus in the selected mode
37 | function launch {
38 | if [ "$INFRA_LOTUS_FOLLOWER" = true ]; then
39 | launch_follower;
40 | elif [ "$INFRA_LOTUS_LITE" = true ]; then
41 | validate_env_hard FULLNODE_API_INFO && launch_daemon_lite || echo "FULLNODE_API_INFO is invalid";
42 | elif [ "$INFRA_LOTUS_GATEWAY" = true ]; then
43 | launch_gateway;
44 | elif [ "$INFRA_LOTUS_DAEMON" = true ]; then
45 | launch_daemon;
46 | fi
47 | }
48 |
49 | launch;
50 |
--------------------------------------------------------------------------------
/scripts/png/Screenshot 2023-06-23 at 18.54.00.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glifio/filecoin-docker/c99f331b1ea7fb577a6dd048fa23d455b983adfe/scripts/png/Screenshot 2023-06-23 at 18.54.00.png
--------------------------------------------------------------------------------
/scripts/png/Screenshot 2023-06-25 at 12.57.30.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glifio/filecoin-docker/c99f331b1ea7fb577a6dd048fa23d455b983adfe/scripts/png/Screenshot 2023-06-25 at 12.57.30.png
--------------------------------------------------------------------------------
/scripts/png/Screenshot 2023-06-25 at 13.00.02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glifio/filecoin-docker/c99f331b1ea7fb577a6dd048fa23d455b983adfe/scripts/png/Screenshot 2023-06-25 at 13.00.02.png
--------------------------------------------------------------------------------
/scripts/png/Screenshot 2023-06-26 at 10.17.53.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glifio/filecoin-docker/c99f331b1ea7fb577a6dd048fa23d455b983adfe/scripts/png/Screenshot 2023-06-26 at 10.17.53.png
--------------------------------------------------------------------------------
/scripts/png/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glifio/filecoin-docker/c99f331b1ea7fb577a6dd048fa23d455b983adfe/scripts/png/favicon-32x32.png
--------------------------------------------------------------------------------
/scripts/png/glif-protofire-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glifio/filecoin-docker/c99f331b1ea7fb577a6dd048fa23d455b983adfe/scripts/png/glif-protofire-logo.png
--------------------------------------------------------------------------------
/scripts/png/glif_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glifio/filecoin-docker/c99f331b1ea7fb577a6dd048fa23d455b983adfe/scripts/png/glif_logo.png
--------------------------------------------------------------------------------
/scripts/png/protofire.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glifio/filecoin-docker/c99f331b1ea7fb577a6dd048fa23d455b983adfe/scripts/png/protofire.png
--------------------------------------------------------------------------------
/scripts/png/protofire_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glifio/filecoin-docker/c99f331b1ea7fb577a6dd048fa23d455b983adfe/scripts/png/protofire_logo.png
--------------------------------------------------------------------------------
/scripts/run:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | . /etc/lotus/docker/bash-config
4 |
5 | # Set environment values if they exist as arguments
6 | if [ $# -ne 0 ]; then
7 | echo "===> Overriding env params with args ..."
8 | for var in "$@"
9 | do
10 | export "$var"
11 | done
12 | fi
13 |
14 | echo "===> ENV Variables ..."
15 | show_env
16 |
17 | echo "===> Configuring ..."
18 | /etc/lotus/docker/configure
19 |
20 |
21 | echo "===> Launching ... "
22 | exec /etc/lotus/docker/launch
23 |
--------------------------------------------------------------------------------