Skip to content
This repository was archived by the owner on May 15, 2024. It is now read-only.

Move SP config to yaml file #234

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 1 addition & 54 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# The version of singularity you will use to make deals. Generally, this should not change
SINGULARITY_REF=:v0.5.9

# Comma seperated list of storage providers motion should make storage deals with
# You must set this value to contain at least one storage provider for motion to
# work
MOTION_STORAGE_PROVIDERS=

# The private key of the wallet you will use with motion, in hexadecimal format.
# This is the output of `lotus wallet export ~address~` if you are using lotus
# If you are obtaining a wallet through another method follow your wallet providers
Expand All @@ -14,52 +9,7 @@ MOTION_STORAGE_PROVIDERS=
# to ensure it is on chain.
MOTION_WALLET_KEY=

# This is the domain/IP you will expose publicly to transfer data to storage providers
# When you initialize the singularity docker setup, it will start a server to deliver
# content to storage providers on localhost:7778. However, you will need to either
# open this specific port on your firewall, and set this value to http://~your-static-ip~:7778
# or you will need to setup reverse proxying from a dedicated web server like NGinx
SINGULARITY_CONTENT_PROVIDER_DOMAIN=

# Additional configuration parameters, sorted by the likelyhood you will want to set
# custom configuration values on your motion instance. In general, most of these should
# not need to change.

# Frequency (as a cron tab expression) with which motion should attempt to make
# new Filecoin deals. Defaults to every minute
#MOTION_SINGULARITY_SCHEDULE_CRON="* * * * *"

# Maximum number of deals motion should attempt to make when checking for new deals.
# Defaults to 1
#MOTION_SINGULARITY_SCHEDULE_DEAL_NUMBER=1

# Specifies whether motion deals are made with FIL+ Data Cap allocation. In order to use this, you must apply for
# and receive a data cap allocation for your deals. In general, we recommend only those familiar with the Fil+
# application process use FIL+, and instead contract out of band with storage providers to make non verified (non Fil+)
# deals.
#MOTION_VERIFIED_DEAL=false

# ON-CHAIN price per gigabyte for motion deals
# In general, paid deals for motion should be negotiated in out of band contracts
# and there is no reason to change this value
#MOTION_PRICE_PER_GIB_EPOCH=0

# Another way to specify on-chain pricing for deals. There is no reason to change this value
#MOTION_PRICE_PER_GIB=0

# Another way to specify on-chain pricing for deals. There is no reason to change this value
#MOTION_PRICE_PER_DEAL=0

# Maximum delay time (in nanoseconds) between when a motion deal is proposed and when it's expected to be on chain.
# Defaults to 72 hours. In general, you should not change this unless your contract specifies something
# different.
#MOTION_DEAL_START_DELAY=259200000000000

# Initial total duration for motion deals stored on filecoin (specified in nanoseconds).
# Defaults to 1 year. In general, you should not change this unless your contracts specify something different
#MOTION_DEAL_DURATION=31536000000000000

# Specifies hether this operation of motion is running on mainnet or a testnet.
# Specifies whether this operation of motion is running on mainnet or a testnet.
# Should be left to false unless you are a developer
#LOTUS_TEST=false

Expand All @@ -77,6 +27,3 @@ SINGULARITY_CONTENT_PROVIDER_DOMAIN=
# Threshold for the minimum amount of data (in bytes) to trigger a motion
# deal on filecoin. Defaults to 16GiB. You should not need to change this
#MOTION_SINGULARITY_PACK_THRESHOLD=17179869184

# Max number of replicas per each PieceCID
#MOTION_REPLICATION_FACTOR=
99 changes: 14 additions & 85 deletions cmd/motion/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func main() {
if _, set := os.LookupEnv("GOLOG_LOG_LEVEL"); !set {
_ = log.SetLogLevel("*", "INFO")
}
pwd, err := os.Getwd()
if err != nil {
logger.Fatal(err)
}
app := cli.App{
Name: "motion",
Usage: "Propelling data onto Filecoin",
Expand All @@ -37,6 +41,13 @@ func main() {
Value: os.TempDir(),
EnvVars: []string{"MOTION_STORE_DIR"},
},
&cli.StringFlag{
Name: "configDir",
Usage: "The path at which to store Motion config, e.g. sps.yml",
DefaultText: "Current directory",
Value: pwd,
EnvVars: []string{"MOTION_CONFIG_DIR"},
},
&cli.Int64Flag{
Name: "minFreeDiskSpace",
Usage: "Minumum amount of free space that must remaio on disk after writing blob. Set -1 to disable checks.",
Expand All @@ -60,13 +71,6 @@ func main() {
DefaultText: "use singularity as a code library",
EnvVars: []string{"MOTION_EXPERIMENTAL_REMOTE_SINGULARITY_API_URL"},
},
&cli.StringSliceFlag{
Name: "storageProvider",
Aliases: []string{"sp"},
Usage: "Storage providers to which to make deals with. Multiple providers may be specified.",
DefaultText: "No deals are made to replicate data onto storage providers.",
EnvVars: []string{"MOTION_STORAGE_PROVIDERS"},
},
&cli.BoolFlag{
Name: "lotus-test",
Category: "Lotus",
Expand All @@ -77,35 +81,6 @@ func main() {
Usage: "The number of desired replicas per blob",
DefaultText: "Number of storage providers; see 'storageProvider' flag.",
},
&cli.Float64Flag{
Name: "pricePerGiBEpoch",
Usage: "The maximum price per GiB per Epoch in attoFIL.",
EnvVars: []string{"MOTION_PRICE_PER_GIB_EPOCH"},
},
&cli.Float64Flag{
Name: "pricePerGiB",
Usage: "The maximum price per GiB in attoFIL.",
EnvVars: []string{"MOTION_PRICE_PER_GIB"},
},
&cli.Float64Flag{
Name: "pricePerDeal",
Usage: "The maximum price per deal in attoFIL.",
EnvVars: []string{"MOTION_PRICE_PER_DEAL"},
},
&cli.DurationFlag{
Name: "dealStartDelay",
Usage: "The deal start epoch delay.",
DefaultText: "72 hours",
Value: 72 * time.Hour,
EnvVars: []string{"MOTION_DEAL_START_DELAY"},
},
&cli.DurationFlag{
Name: "dealDuration",
Usage: "The duration of deals made on Filecoin",
DefaultText: "One year (356 days)",
Value: 356 * 24 * time.Hour,
EnvVars: []string{"MOTION_DEAL_DURATION"},
},
&cli.StringFlag{
Name: "singularityMaxCarSize",
Usage: "The maximum Singularity generated CAR size",
Expand All @@ -126,33 +101,6 @@ func main() {
Value: 24 * time.Hour,
EnvVars: []string{"MOTION_SINGULARITY_FORCE_PACK_AFTER"},
},
&cli.BoolFlag{
Name: "verifiedDeal",
Usage: "whether deals made with motion should be verified deals",
DefaultText: "Deals are verified",
Value: false,
EnvVars: []string{"MOTION_VERIFIED_DEAL"},
},
&cli.StringFlag{
Name: "experimentalSingularityContentURLTemplate",
Usage: "When using a singularity as the storage engine, if set, setups up online deals to use the given url template for making online deals",
DefaultText: "make offline deals",
EnvVars: []string{"MOTION_SINGULARITY_CONTENT_URL_TEMPLATE"},
},
&cli.StringFlag{
Name: "experimentalSingularityScheduleCron",
Usage: "When using a singularity as the storage engine, if set, setups up the cron schedule to send out batch deals.",
DefaultText: "runs every minute",
Value: "* * * * *",
EnvVars: []string{"MOTION_SINGULARITY_SCHEDULE_CRON"},
},
&cli.IntFlag{
Name: "experimentalSingularityScheduleDealNumber",
Usage: "When using a singularity as the storage engine, if set, setups up the max deal number per triggered schedule.",
DefaultText: "1 per trigger",
Value: 1,
EnvVars: []string{"MOTION_SINGULARITY_SCHEDULE_DEAL_NUMBER"},
},
&cli.DurationFlag{
Name: "experimentalSingularityCleanupInterval",
Usage: "How often to check for and delete files from the local store that have already had deals made",
Expand All @@ -168,6 +116,7 @@ func main() {
address.CurrentNetwork = address.Mainnet
}
storeDir := cctx.String("storeDir")
configDir := cctx.String("configDir")
var store blob.Store
if cctx.Bool("experimentalSingularityStore") {
singularityAPIUrl := cctx.String("experimentalRemoteSingularityAPIUrl")
Expand All @@ -182,34 +131,14 @@ func main() {
return fmt.Errorf("singularity API URL is required")
}

// Parse any configured storage provider addresses.
sps := cctx.StringSlice("storageProvider")
spAddrs := make([]address.Address, 0, len(sps))
for _, sp := range sps {
spAddr, err := address.NewFromString(sp)
if err != nil {
return fmt.Errorf("storage provider '%s' is not a valid address: %w", sp, err)
}
spAddrs = append(spAddrs, spAddr)
}
singularityStore, err := singularity.NewStore(
singularity.WithStoreDir(cctx.String("storeDir")),
singularity.WithStorageProviders(spAddrs...),
singularity.WithReplicationFactor(cctx.Uint("replicationFactor")),
singularity.WithPricePerGiBEpoch(attoFilToTokenAmount(cctx.Float64("pricePerGiBEpoch"))),
singularity.WithPricePerGiB(attoFilToTokenAmount(cctx.Float64("pricePerGiB"))),
singularity.WithPricePerDeal(attoFilToTokenAmount(cctx.Float64("pricePerDeal"))),
singularity.WithDealStartDelay(durationToFilecoinEpoch(cctx.Duration("dealStartDelay"))),
singularity.WithDealDuration(durationToFilecoinEpoch(cctx.Duration("dealDuration"))),
singularity.WithStoreDir(storeDir),
singularity.WithConfigDir(configDir),
singularity.WithSingularityClient(singClient),
singularity.WithWalletKey(cctx.String("walletKey")),
singularity.WithMaxCarSize(cctx.String("singularityMaxCarSize")),
singularity.WithPackThreshold(cctx.Int64("singularityPackThreshold")),
singularity.WithForcePackAfter(cctx.Duration("singularityForcePackAfter")),
singularity.WithScheduleUrlTemplate(cctx.String("experimentalSingularityContentURLTemplate")),
singularity.WithScheduleCron(cctx.String("experimentalSingularityScheduleCron")),
singularity.WithScheduleDealNumber(cctx.Int("experimentalSingularityScheduleDealNumber")),
singularity.WithVerifiedDeal(cctx.Bool("verifiedDeal")),
singularity.WithCleanupInterval(cctx.Duration("experimentalSingularityCleanupInterval")),
singularity.WithMinFreeSpace(cctx.Int64("minFreeDiskSpace")),
)
Expand Down
13 changes: 3 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,26 +113,19 @@ services:

motion:
image: ghcr.io/filecoin-project/motion:main
entrypoint: motion --experimentalSingularityStore --experimentalRemoteSingularityAPIUrl=singularity_api:9090 --experimentalSingularityContentURLTemplate=${SINGULARITY_CONTENT_PROVIDER_DOMAIN:-http://singularity_content_provider:7778}/piece/{PIECE_CID}
entrypoint: motion --experimentalSingularityStore --experimentalRemoteSingularityAPIUrl=singularity_api:9090
ports:
- 40080:40080
environment:
- MOTION_STORE_DIR=/usr/src/app/storage
- MOTION_CONFIG_DIR=/usr/src/app/config
- LOTUS_TEST
- MOTION_STORAGE_PROVIDERS
- MOTION_PRICE_PER_GIB_EPOCH
- MOTION_PRICE_PER_GIB
- MOTION_PRICE_PER_DEAL
- MOTION_DEAL_START_DELAY
- MOTION_DEAL_DURATION
- MOTION_SINGULARITY_MAX_CAR_SIZE
- MOTION_SINGULARITY_PACK_THRESHOLD
- MOTION_SINGULARITY_SCHEDULE_CRON
- MOTION_SINGULARITY_SCHEDULE_DEAL_NUMBER
- MOTION_WALLET_KEY
- MOTION_VERIFIED_DEAL
volumes:
- motion-singularity-volume:/usr/src/app/storage
- ./sps.yml:/usr/src/app/config/sps.yml
depends_on:
singularity_api:
condition: service_healthy
Expand Down
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ github.com/glebarez/sqlite v1.8.0 h1:02X12E2I/4C1n+v90yTqrjRa8yuo7c3KeHI3FRznCvc
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
Expand Down Expand Up @@ -342,11 +343,14 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
Expand Down Expand Up @@ -439,6 +443,7 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
Expand Down Expand Up @@ -482,6 +487,7 @@ github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXS
github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE=
github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8=
github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo=
github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
Expand Down Expand Up @@ -636,6 +642,7 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20210118024343-169e9d70c0c2/go.mod h1:f
github.com/whyrusleeping/cbor-gen v0.0.0-20210303213153-67a261a1d291/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
github.com/whyrusleeping/cbor-gen v0.0.0-20230818171029-f91ae536ca25 h1:yVYDLoN2gmB3OdBXFW8e1UwgVbmCvNlnAKhvHPaNARI=
github.com/whyrusleeping/cbor-gen v0.0.0-20230818171029-f91ae536ca25/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc/go.mod h1:bopw91TMyo8J3tvftk8xmU2kPmlrt4nScJQZU2hE5EM=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
Expand Down
Loading