Merge remote-tracking branch 'origin/master' into close-write

This commit is contained in:
hanabi1224 2023-01-02 16:42:21 +08:00
commit 83554afebc
27 changed files with 3384 additions and 1979 deletions

View File

@ -12,16 +12,6 @@ executors:
ubuntu:
docker:
- image: ubuntu:20.04
packer:
description: |
The HashiCorp provided Packer container
parameters:
packer-version:
type: string
default: "1.8"
docker:
- image: hashicorp/packer:<< parameters.packer-version >>
commands:
prepare:
@ -109,25 +99,6 @@ commands:
name: fetch all tags
command: |
git fetch --all
packer_build:
description: "Run a packer build"
parameters:
template:
description: |
The name of the packer template file
type: string
default: packer.json
args:
description: |
Arguments to pass to the packer build command
type: string
default: ""
steps:
- run:
name: "Run a packer build"
command: packer build << parameters.args >> << parameters.template >>
no_output_timeout: 1h
jobs:
mod-tidy-check:
@ -596,8 +567,8 @@ jobs:
command: |
docker push filecoin/<<parameters.image>>:<<parameters.channel>>
if [[ ! -z $CIRCLE_SHA ]]; then
docker image tag filecoin/<<parameters.image>>:<<parameters.channel>>-<<parameters.network>> filecoin/<<parameters.image>>:"${CIRCLE_SHA}"
docker push filecoin/<<parameters.image>>:"${CIRCLE_SHA}"
docker image tag filecoin/<<parameters.image>>:<<parameters.channel>>> filecoin/<<parameters.image>>:"${CIRCLE_SHA:0:7}"
docker push filecoin/<<parameters.image>>:"${CIRCLE_SHA:0:7}"
fi
if [[ ! -z $CIRCLE_TAG ]]; then
docker image tag filecoin/<<parameters.image>>:<<parameters.channel>> filecoin/<<parameters.image>>:"${CIRCLE_TAG}"
@ -626,8 +597,8 @@ jobs:
command: |
docker push filecoin/<<parameters.image>>:<<parameters.channel>>-<<parameters.network>>
if [[ ! -z $CIRCLE_SHA ]]; then
docker image tag filecoin/<<parameters.image>>:<<parameters.channel>>-<<parameters.network>> filecoin/<<parameters.image>>:"${CIRCLE_SHA}"-<<parameters.network>>
docker push filecoin/<<parameters.image>>:"${CIRCLE_SHA}"-<<parameters.network>>
docker image tag filecoin/<<parameters.image>>:<<parameters.channel>>-<<parameters.network>> filecoin/<<parameters.image>>:"${CIRCLE_SHA:0:7}"-<<parameters.network>>
docker push filecoin/<<parameters.image>>:"${CIRCLE_SHA:0:7}"-<<parameters.network>>
fi
if [[ ! -z $CIRCLE_TAG ]]; then
docker image tag filecoin/<<parameters.image>>:<<parameters.channel>>-<<parameters.network>> filecoin/<<parameters.image>>:"${CIRCLE_TAG}"-<<parameters.network>>
@ -640,15 +611,6 @@ jobs:
image: filecoin/<<parameters.image>>
extra_build_args: --target <<parameters.image>> --build-arg GOFLAGS=-tags=<<parameters.network>>
publish-packer-snap:
description: build packer image with snap. mainnet only.
executor:
name: packer
steps:
- checkout
- packer_build:
template: tools/packer/lotus-snap.pkr.hcl
workflows:
version: 2.1
ci:
@ -1389,13 +1351,3 @@ workflows:
channel: nightly
network: debug
push: true
biweekly:
triggers:
- schedule:
cron: "0 0 1,15 * *"
filters:
branches:
only:
- master
jobs:
- publish-packer-snap

View File

@ -12,16 +12,6 @@ executors:
ubuntu:
docker:
- image: ubuntu:20.04
packer:
description: |
The HashiCorp provided Packer container
parameters:
packer-version:
type: string
default: "1.8"
docker:
- image: hashicorp/packer:<< parameters.packer-version >>
commands:
prepare:
@ -109,25 +99,6 @@ commands:
name: fetch all tags
command: |
git fetch --all
packer_build:
description: "Run a packer build"
parameters:
template:
description: |
The name of the packer template file
type: string
default: packer.json
args:
description: |
Arguments to pass to the packer build command
type: string
default: ""
steps:
- run:
name: "Run a packer build"
command: packer build << parameters.args >> << parameters.template >>
no_output_timeout: 1h
jobs:
mod-tidy-check:
@ -596,8 +567,8 @@ jobs:
command: |
docker push filecoin/<<parameters.image>>:<<parameters.channel>>
if [["[[ ! -z $CIRCLE_SHA ]]"]]; then
docker image tag filecoin/<<parameters.image>>:<<parameters.channel>>-<<parameters.network>> filecoin/<<parameters.image>>:"${CIRCLE_SHA}"
docker push filecoin/<<parameters.image>>:"${CIRCLE_SHA}"
docker image tag filecoin/<<parameters.image>>:<<parameters.channel>>> filecoin/<<parameters.image>>:"${CIRCLE_SHA:0:7}"
docker push filecoin/<<parameters.image>>:"${CIRCLE_SHA:0:7}"
fi
if [["[[ ! -z $CIRCLE_TAG ]]"]]; then
docker image tag filecoin/<<parameters.image>>:<<parameters.channel>> filecoin/<<parameters.image>>:"${CIRCLE_TAG}"
@ -626,8 +597,8 @@ jobs:
command: |
docker push filecoin/<<parameters.image>>:<<parameters.channel>>-<<parameters.network>>
if [["[[ ! -z $CIRCLE_SHA ]]"]]; then
docker image tag filecoin/<<parameters.image>>:<<parameters.channel>>-<<parameters.network>> filecoin/<<parameters.image>>:"${CIRCLE_SHA}"-<<parameters.network>>
docker push filecoin/<<parameters.image>>:"${CIRCLE_SHA}"-<<parameters.network>>
docker image tag filecoin/<<parameters.image>>:<<parameters.channel>>-<<parameters.network>> filecoin/<<parameters.image>>:"${CIRCLE_SHA:0:7}"-<<parameters.network>>
docker push filecoin/<<parameters.image>>:"${CIRCLE_SHA:0:7}"-<<parameters.network>>
fi
if [["[[ ! -z $CIRCLE_TAG ]]"]]; then
docker image tag filecoin/<<parameters.image>>:<<parameters.channel>>-<<parameters.network>> filecoin/<<parameters.image>>:"${CIRCLE_TAG}"-<<parameters.network>>
@ -640,15 +611,6 @@ jobs:
image: filecoin/<<parameters.image>>
extra_build_args: --target <<parameters.image>> --build-arg GOFLAGS=-tags=<<parameters.network>>
publish-packer-snap:
description: build packer image with snap. mainnet only.
executor:
name: packer
steps:
- checkout
- packer_build:
template: tools/packer/lotus-snap.pkr.hcl
workflows:
version: 2.1
ci:
@ -903,13 +865,3 @@ workflows:
network: [[.]]
push: true
[[- end]]
biweekly:
triggers:
- schedule:
cron: "0 0 1,15 * *"
filters:
branches:
only:
- master
jobs:
- publish-packer-snap

View File

@ -24,8 +24,6 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/protocol"
"github.com/multiformats/go-multiaddr"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
@ -458,8 +456,8 @@ func exampleStruct(method string, t, parent reflect.Type) interface{} {
if f.Type == parent {
continue
}
caser := cases.Title(language.English)
if caser.String(f.Name) == f.Name {
if f.IsExported() {
ns.Elem().Field(i).Set(reflect.ValueOf(ExampleValue(method, f.Type, t)))
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -443,8 +443,12 @@ func New(ctx context.Context, api Provider, ds dtypes.MetadataDS, us stmgr.Upgra
return mp, nil
}
func (mp *MessagePool) ForEachPendingMessage(f func(cid.Cid) error) error {
mp.lk.Lock()
func (mp *MessagePool) TryForEachPendingMessage(f func(cid.Cid) error) error {
// avoid deadlocks in splitstore compaction when something else needs to access the blockstore
// while holding the mpool lock
if !mp.lk.TryLock() {
return xerrors.Errorf("mpool TryForEachPendingMessage: could not acquire lock")
}
defer mp.lk.Unlock()
for _, mset := range mp.pending {

File diff suppressed because it is too large Load Diff

View File

@ -75,10 +75,10 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
},
1,
"sealing",
@ -93,7 +93,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -108,14 +108,16 @@ Response:
```json
{
"Hostname": "string value",
"IgnoreResources": false,
"IgnoreResources": true,
"Resources": {
"MemPhysical": 0,
"MemUsed": 0,
"MemSwap": 0,
"MemSwapUsed": 0,
"CPUs": 0,
"GPUs": null,
"MemPhysical": 42,
"MemUsed": 42,
"MemSwap": 42,
"MemSwapUsed": 42,
"CPUs": 42,
"GPUs": [
"string value"
],
"Resources": {
"post/v0/windowproof": {
"0": {
@ -1421,11 +1423,11 @@ Response:
```json
[
{
"ID": "",
"ID": "76f1988b-ef30-4d7e-b3ec-9a627f4ba5a8",
"Weight": 42,
"LocalPath": "",
"CanSeal": false,
"CanStore": false
"LocalPath": "string value",
"CanSeal": true,
"CanStore": true
}
]
```
@ -1490,10 +1492,10 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
},
[
1024
@ -1510,7 +1512,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -1538,7 +1540,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -1555,10 +1557,10 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
},
true,
{
@ -1578,7 +1580,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -1595,10 +1597,10 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
}
]
```
@ -1610,7 +1612,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -1624,10 +1626,10 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
}
]
```
@ -1639,7 +1641,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -1656,10 +1658,10 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
},
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
@ -1674,7 +1676,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -1690,9 +1692,11 @@ Inputs:
1000,
[
{
"SealProof": 0,
"SectorNumber": 0,
"SealedCID": null,
"SealProof": 8,
"SectorNumber": 9,
"SealedCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"Challenge": [
42
],
@ -1708,8 +1712,8 @@ Response:
```json
{
"PoStProofs": {
"PoStProof": 0,
"ProofBytes": null
"PoStProof": 8,
"ProofBytes": "Ynl0ZSBhcnJheQ=="
},
"Skipped": [
{
@ -1732,9 +1736,11 @@ Inputs:
1000,
[
{
"SealProof": 0,
"SectorNumber": 0,
"SealedCID": null,
"SealProof": 8,
"SectorNumber": 9,
"SealedCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"Challenge": [
42
],
@ -1749,8 +1755,8 @@ Response:
```json
[
{
"PoStProof": 0,
"ProofBytes": null
"PoStProof": 8,
"ProofBytes": "Ynl0ZSBhcnJheQ=="
}
]
```
@ -1768,10 +1774,10 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
},
1
]
@ -1784,7 +1790,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -1815,10 +1821,10 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
},
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
@ -1839,7 +1845,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -1853,10 +1859,10 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
},
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
@ -1880,7 +1886,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -1897,10 +1903,10 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
},
[
{
@ -1918,7 +1924,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -1935,15 +1941,17 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
},
[
{
"Size": 1032,
"PieceCID": null
"PieceCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
}
]
]
@ -1956,7 +1964,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -1973,17 +1981,19 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
},
"Bw==",
"Bw==",
[
{
"Size": 1032,
"PieceCID": null
"PieceCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
}
],
{
@ -2004,7 +2014,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -2018,10 +2028,10 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
},
"Bw=="
]
@ -2034,7 +2044,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -2048,16 +2058,18 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
},
"Bw==",
[
{
"Size": 1032,
"PieceCID": null
"PieceCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
}
]
]
@ -2070,7 +2082,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -2084,10 +2096,10 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
},
"Bw=="
]
@ -2100,7 +2112,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```
@ -2251,10 +2263,10 @@ Inputs:
[
{
"ID": {
"Miner": 0,
"Number": 0
"Miner": 1000,
"Number": 9
},
"ProofType": 0
"ProofType": 8
},
1040384,
1024,
@ -2272,7 +2284,7 @@ Response:
"Miner": 1000,
"Number": 9
},
"ID": "00000000-0000-0000-0000-000000000000"
"ID": "07070707-0707-0707-0707-070707070707"
}
```

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2
go.mod
View File

@ -156,7 +156,6 @@ require (
golang.org/x/net v0.0.0-20220920183852-bf014ff85ad5
golang.org/x/sync v0.0.0-20220907140024-f12130a52804
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8
golang.org/x/text v0.3.7
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9
golang.org/x/tools v0.1.12
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2
@ -335,6 +334,7 @@ require (
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 // indirect
google.golang.org/grpc v1.45.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect

View File

@ -37,7 +37,7 @@ func TestWindowPostNoMinerStorage(t *testing.T) {
Worker(&miner, &sealw, kit.ThroughRPC(), kit.WithSealWorkerTasks).
Start()
ens.InterconnectAll().BeginMiningMustPost(2 * time.Millisecond)
ens.InterconnectAll().BeginMiningMustPost(10 * time.Millisecond)
miner.PledgeSectors(ctx, sealSectors, 0, nil)

View File

@ -69,7 +69,7 @@ func MessagePool(lc fx.Lifecycle, mctx helpers.MetricsCtx, us stmgr.UpgradeSched
return mp.Close()
},
})
protector.AddProtector(mp.ForEachPendingMessage)
protector.AddProtector(mp.TryForEachPendingMessage)
return mp, nil
}

View File

@ -1,64 +0,0 @@
Your lotus node is up and running!
This image contains the two most important pieces of the lotus filecoin suite, the
daemon and the miner. The daemon is is configured to download a snapshot and start
running. In fact, by the time you read this, the daemon may already be in sync.
Go ahead and make sure everything is working correctly with the following commands.
To check if the daemon is running:
systemctl status lotus-daemon
To check if the daemon is in sync:
lotus sync status
**note: When starting lotus for the first time, it will download a chain snapshot.
This is a large download and will take several minutes to complete. During
this time, the lotus API will not be up yet. Give it time! You can see
progress by looking at the systemd journal.
To check if the daemon is connecting to other lotus nodes:
lotus net peers
No wallets are crated by default. You can view, create, and delete wallets with
the lotus command. On this image, lotus is running as the user `fc`.
Be careful, now. Don't delete a wallet with funds!
sudo -E -u fc lotus wallet list
sudo -E -u fc lotus wallet new bls
The lotus miner is also installed, but it's not running by default. If you have no
special disk or worker requirements, you can initialize the lotus-miner repo like this:
sudo -E -u fc lotus-miner init -o <wallet_you_created_before>
You only need to do this once, after which, you can enable and start the miner.
sudo systemctl enable lotus-miner
sudo systemctl start lotus-miner
Do you want to access your lotus daemon remotely? Learn how to setup token authentication
and use client libraries from lotus docs.
https://lotus.filecoin.io/reference/basics/api-access/
For more information, see https://lotus.filecoin.io/
Found a bug? let us know! https://github.com/filecoin-project/lotus
Chat with us on slack! https://filecoinproject.slack.com/archives/CEGN061C5

View File

@ -1,12 +0,0 @@
PS1="[\h \w] ⨎ "
export PROMT_DIRTRIM=1
# Where to find the lotus repo
export LOTUS_PATH=/var/lib/lotus
# The miner is not running in this image by default.
# export LOTUS_MINER_PATH=/var/lib/lotus-miner
# To access the lotus node remotely, the following environment variable may be used.
# export FULLNODE_API_INFO=<token>:/ip4/<public-ip>/tcp/1234/http

View File

@ -1,90 +0,0 @@
variable "ci_workspace_bins" {
type = string
default = "./linux"
}
variable "lotus_network" {
type = string
default = "mainnet"
}
locals {
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
}
source "amazon-ebs" "lotus" {
ami_name = "lotus-${var.lotus_network}-snap-${local.timestamp}"
ami_regions = [
"ap-east-1",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-south-1",
"ap-southeast-1",
"ap-southeast-2",
"ca-central-1",
"eu-central-1",
"eu-north-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
]
ami_groups = [
# This causes the ami to be publicly-accessable.
"all",
]
ami_description = "Lotus Filecoin AMI"
launch_block_device_mappings {
device_name = "/dev/sda1"
volume_size = 100
delete_on_termination = true
}
instance_type = "t2.micro"
source_ami_filter {
filters = {
name = "ubuntu/images/*ubuntu-focal-20.04-amd64-server-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"]
}
ssh_username = "ubuntu"
aws_polling {
delay_seconds = 60
max_attempts = 60
}
}
source "digitalocean" "lotus" {
droplet_name = "lotus-snap"
size = "s-1vcpu-1gb"
region = "nyc3"
image = "ubuntu-20-04-x64"
snapshot_name = "lotus-${var.lotus_network}-snap-${local.timestamp}"
ssh_username = "root"
}
build {
sources = [
"source.amazon-ebs.lotus",
"source.digitalocean.lotus",
]
provisioner "file" {
source = "./tools/packer/etc/motd"
destination = "motd"
}
# build it.
provisioner "shell" {
script = "./tools/packer/setup-snap.sh"
}
}

View File

@ -1,110 +0,0 @@
variable "ci_workspace_bins" {
type = string
default = "./linux"
}
variable "lotus_network" {
type = string
default = "mainnet"
}
variable "git_tag" {
type = string
default = ""
}
locals {
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
}
source "amazon-ebs" "lotus" {
ami_name = "lotus-${var.lotus_network}-${var.git_tag}-${local.timestamp}"
ami_regions = [
"ap-east-1",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-south-1",
"ap-southeast-1",
"ap-southeast-2",
"ca-central-1",
"eu-central-1",
"eu-north-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
]
ami_groups = [
# This causes the ami to be publicly-accessable.
"all",
]
ami_description = "Lotus Filecoin AMI"
launch_block_device_mappings {
device_name = "/dev/sda1"
volume_size = 100
delete_on_termination = true
}
instance_type = "t2.micro"
source_ami_filter {
filters = {
name = "ubuntu/images/*ubuntu-focal-20.04-amd64-server-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"]
}
ssh_username = "ubuntu"
}
build {
sources = [
"source.amazon-ebs.lotus",
]
# Lotus software (from CI workspace)
provisioner "file" {
source = "${var.ci_workspace_bins}/lotus"
destination = "lotus"
}
provisioner "file" {
source = "${var.ci_workspace_bins}/lotus-miner"
destination = "lotus-miner"
}
# First run script
provisioner "file" {
source = "./tools/packer/scripts/${var.lotus_network}/lotus-init.sh"
destination = "lotus-init.sh"
}
# Systemd service units.
provisioner "file" {
source = "./tools/packer/systemd/lotus-daemon.service"
destination = "lotus-daemon.service"
}
provisioner "file" {
source = "./tools/packer/systemd/lotus-miner.service"
destination = "lotus-miner.service"
}
provisioner "file" {
source = "./tools/packer/repo/config.toml"
destination = "config.toml"
}
provisioner "file" {
source = "./tools/packer/etc/motd"
destination = "motd"
}
provisioner "file" {
source = "./tools/packer/homedir/bashrc"
destination = ".bashrc"
}
# build it.
provisioner "shell" {
script = "./tools/packer/setup.sh"
}
}

View File

@ -1,38 +0,0 @@
[API]
ListenAddress = "/ip4/0.0.0.0/tcp/1234/http"
# RemoteListenAddress = ""
# Timeout = "30s"
#
[Libp2p]
ListenAddresses = ["/ip4/0.0.0.0/tcp/5678", "/ip6/::/tcp/5678"]
# AnnounceAddresses = []
# NoAnnounceAddresses = []
# ConnMgrLow = 150
# ConnMgrHigh = 180
# ConnMgrGrace = "20s"
#
[Pubsub]
# Bootstrapper = false
# RemoteTracer = ""
#
[Client]
# UseIpfs = false
# IpfsOnlineMode = false
# IpfsMAddr = ""
# IpfsUseForRetrieval = false
# SimultaneousTransfersForStorage = 20
# SimultaneousTransfersForStoragePerClient = 0
# SimultaneousTransfersForRetrieval = 20
#
[Metrics]
# Nickname = ""
# HeadNotifs = false
#
[Wallet]
# RemoteBackend = ""
# EnableLedger = false
# DisableLocal = false
#
[Fees]
# DefaultMaxFee = "0.007 FIL"
#

View File

@ -1,20 +0,0 @@
#!/usr/bin/env bash
# This script sets up an initial configuraiton for the lotus daemon and miner
# It will only run once.
GATE="$LOTUS_PATH"/date_initialized
# Don't init if already initialized.
if [ -f "$GATE" ]; then
echo lotus already initialized.
exit 0
fi
# Not importing snapshot on butterflynet
#
# echo importing minimal snapshot
# lotus daemon --import-snapshot https://fil-chain-snapshots-fallback.s3.amazonaws.com/mainnet/minimal_finality_stateroots_latest.car --halt-after-import
# Block future inits
date > "$GATE"

View File

@ -1,20 +0,0 @@
#!/usr/bin/env bash
# This script sets up an initial configuraiton for the lotus daemon and miner
# It will only run once.
GATE="$LOTUS_PATH"/date_initialized
# Don't init if already initialized.
if [ -f "$GATE" ]; then
echo lotus already initialized.
exit 0
fi
# Not importing snapshot on calibrationnet.
#
# echo importing minimal snapshot
# lotus daemon --import-snapshot https://fil-chain-snapshots-fallback.s3.amazonaws.com/mainnet/minimal_finality_stateroots_latest.car --halt-after-import
# Block future inits
date > "$GATE"

View File

@ -1,18 +0,0 @@
#!/usr/bin/env bash
# This script sets up an initial configuraiton for the lotus daemon and miner
# It will only run once.
GATE="$LOTUS_PATH"/date_initialized
# Don't init if already initialized.
if [ -f "$GATE" ]; then
echo lotus already initialized.
exit 0
fi
echo importing minimal snapshot
lotus daemon --import-snapshot https://fil-chain-snapshots-fallback.s3.amazonaws.com/mainnet/minimal_finality_stateroots_latest.car --halt-after-import
# Block future inits
date > "$GATE"

View File

@ -1,42 +0,0 @@
#!/usr/bin/env bash
# This script is executed by packer to setup the image.
# When this script is run, packer will have already copied binaries into the home directory of
# whichever user it has access too. This script is executed from within the home directory of that
# user. Bear in mind that different cloud providers, and different images on the same cloud
# provider will have a different initial user account.
set -x
# Become root, if we aren't already.
# Docker images will already be root. AMIs will have an SSH user account.
if [ x$UID != x0 ]
then
printf -v cmd_str '%q ' "$0" "$@"
exec sudo su -c "$cmd_str"
fi
set -e
MANAGED_FILES=(
/etc/motd
)
# this is required on digitalocean, which does not have snap seeded correctly at this phase.
apt-get -y -o DPkg::Lock::Timeout=3 update \
&& apt-get -y -o DPkg::Lock::Timeout=3 reinstall snapd
snap install lotus
snap alias lotus.lotus-miner lotus-miner
snap alias lotus.lotus-worker lotus-worker
# Setup firewall
yes | ufw enable
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
set +e
curl -L https://raw.githubusercontent.com/digitalocean/marketplace-partners/master/scripts/90-cleanup.sh | bash

View File

@ -1,69 +0,0 @@
#!/usr/bin/env bash
# This script is executed by packer to setup the image.
# When this script is run, packer will have already copied binaries into the home directory of
# whichever user it has access too. This script is executed from within the home directory of that
# user. Bear in mind that different cloud providers, and different images on the same cloud
# provider will have a different initial user account.
set -x
# Become root, if we aren't already.
# Docker images will already be root. AMIs will have an SSH user account.
UID=$(id -u)
if [ x$UID != x0 ]
then
printf -v cmd_str '%q ' "$0" "$@"
exec sudo su -c "$cmd_str"
fi
MANAGED_BINS=( lotus lotus-miner lotus-init.sh )
MANAGED_FILES=(
/lib/systemd/system/lotus-daemon.service
/lib/systemd/system/lotus-miner.service
/etc/motd
/var/lib/lotus/config.toml
)
# install libs.
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get -y install libhwloc15 ocl-icd-libopencl1 ufw
apt-get -y upgrade -q -y -u -o Dpkg::Options::="--force-confold"
ln -s /usr/lib/x86_64-linux-gnu/libhwloc.so.15 /usr/lib/x86_64-linux-gnu/libhwloc.so.5
# Create lotus user
useradd -c "lotus system account" -r fc
install -o fc -g fc -d /var/lib/lotus
install -o fc -g fc -d /var/lib/lotus-miner
# Install software
for i in "${MANAGED_BINS[@]}"
do
install -o root -g root -m 755 -t /usr/local/bin $i
rm $i
done
# Install systemd and other files.
# Because packer doesn't copy files with root permisison,
# files are in the home directory of the ssh user. Copy
# these files into the right position.
for i in "${MANAGED_FILES[@]}"
do
fn=$(basename $i)
install -o root -g root -m 644 $fn $i
rm $fn
done
# Enable services
systemctl daemon-reload
systemctl enable lotus-daemon
# Setup firewall
yes | ufw enable
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow 5678 #libp2p
curl -L https://raw.githubusercontent.com/digitalocean/marketplace-partners/master/scripts/90-cleanup.sh | bash

View File

@ -1,17 +0,0 @@
[Unit]
Description=Lotus Daemon
After=network.target
[Service]
User=fc
Group=fc
ExecStartPre=/usr/local/bin/lotus-init.sh
ExecStart=/usr/local/bin/lotus daemon
ExecStop=/usr/local/bin/lotus daemon stop
Environment=LOTUS_PATH=/var/lib/lotus
Restart=always
RestartSec=30
TimeoutSec=infinity
[Install]
WantedBy=multi-user.target

View File

@ -1,15 +0,0 @@
[Unit]
Description=Lotus Miner
After=network.target
[Service]
User=fc
Group=fc
ExecStart=/usr/local/bin/lotus-miner run
Environment=LOTUS_PATH=/var/lib/lotus
Environment=LOTUS_MINER_PATH=/var/lib/lotus-miner
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target