Merge branch 'raulk/itests' into raulk/itests-refactor-kit

This commit is contained in:
Raúl Kripalani 2021-06-10 12:02:08 +01:00
commit bcbbd73d65
326 changed files with 14705 additions and 3250 deletions

View File

@ -7,7 +7,7 @@ orbs:
executors:
golang:
docker:
- image: circleci/golang:1.15.5
- image: circleci/golang:1.16.4
resource_class: 2xlarge
ubuntu:
docker:
@ -331,7 +331,7 @@ jobs:
- run: cd extern/filecoin-ffi && make
- run:
name: "go get lotus@master"
command: cd testplans/lotus-soup && go mod edit -replace=github.com/filecoin-project/lotus=../..
command: cd testplans/lotus-soup && go mod edit -replace=github.com/filecoin-project/lotus=../.. && go mod tidy
- run:
name: "build lotus-soup testplan"
command: pushd testplans/lotus-soup && go build -tags=testground .
@ -379,8 +379,8 @@ jobs:
- run:
name: Install go
command: |
curl -O https://dl.google.com/go/go1.15.5.darwin-amd64.pkg && \
sudo installer -pkg go1.15.5.darwin-amd64.pkg -target /
curl -O https://dl.google.com/go/go1.16.4.darwin-amd64.pkg && \
sudo installer -pkg go1.16.4.darwin-amd64.pkg -target /
- run:
name: Install pkg-config
command: HOMEBREW_NO_AUTO_UPDATE=1 brew install pkg-config
@ -428,6 +428,41 @@ jobs:
- "~/.rustup"
- "~/.cargo"
build-appimage:
machine:
image: ubuntu-2004:202104-01
steps:
- checkout
- attach_workspace:
at: "."
- run:
name: install appimage-builder
command: |
# docs: https://appimage-builder.readthedocs.io/en/latest/intro/install.html
sudo apt update
sudo apt install -y python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace
sudo curl -Lo /usr/local/bin/appimagetool https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
sudo chmod +x /usr/local/bin/appimagetool
sudo pip3 install appimage-builder
- run:
name: install lotus dependencies
command: sudo apt install ocl-icd-opencl-dev libhwloc-dev
- run:
name: build appimage
command: |
sed -i "s/version: latest/version: ${CIRCLE_TAG:-latest}/" AppImageBuilder.yml
make appimage
- run:
name: prepare workspace
command: |
mkdir appimage
mv Lotus-latest-x86_64.AppImage appimage
- persist_to_workspace:
root: "."
paths:
- appimage
gofmt:
executor: golang
steps:
@ -530,6 +565,34 @@ jobs:
name: Publish release
command: ./scripts/publish-release.sh
publish-snapcraft:
description: build and push snapcraft
machine:
image: ubuntu-2004:202104-01
resource_class: 2xlarge
parameters:
channel:
type: string
default: "edge"
description: snapcraft channel
steps:
- checkout
- run:
name: install snapcraft
command: sudo snap install snapcraft --classic
- run:
name: create snapcraft config file
command: |
mkdir -p ~/.config/snapcraft
echo "$SNAPCRAFT_LOGIN_FILE" | base64 -d > ~/.config/snapcraft/snapcraft.cfg
- run:
name: build snap
command: snapcraft --use-lxd
- run:
name: publish snap
command: snapcraft push *.snap --release << parameters.channel >>
build-and-push-image:
description: build and push docker images to public AWS ECR registry
executor: aws-cli/default
@ -805,10 +868,21 @@ workflows:
tags:
only:
- /^v\d+\.\d+\.\d+(-rc\d+)?$/
- build-appimage:
requires:
- test-short
filters:
branches:
ignore:
- /.*/
tags:
only:
- /^v\d+\.\d+\.\d+(-rc\d+)?$/
- publish:
requires:
- build-all
- build-macos
- build-appimage
filters:
branches:
ignore:
@ -861,3 +935,26 @@ workflows:
tags:
only:
- /^v\d+\.\d+\.\d+(-rc\d+)?$/
- publish-snapcraft:
name: publish-snapcraft-stable
channel: stable
filters:
branches:
ignore:
- /.*/
tags:
only:
- /^v\d+\.\d+\.\d+(-rc\d+)?$/
nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- master
jobs:
- publish-snapcraft:
name: publish-snapcraft-nightly
channel: edge

View File

@ -35,6 +35,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: '1.16.4'
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1

View File

@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: testground run
uses: coryschwartz/testground-github-action@v1.0
uses: coryschwartz/testground-github-action@v1.1
with:
backend_addr: ${{ matrix.backend_addr }}
backend_proto: ${{ matrix.backend_proto }}

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
/AppDir
/appimage-builder-cache
*.AppImage
/lotus
/lotus-miner
/lotus-worker

View File

@ -0,0 +1 @@
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" viewBox="0 0 127 127" xml:space="preserve" enable-background="new 0 0 127 127"><style type="text/css">.st0{fill:#00d2d6}.st1{fill:#fff}</style><g><path class="st0" d="M63.5,127C28.5,127.1-0.2,98.4,0,63.2C0.2,28.3,28.6-0.2,63.9,0c34.8,0.2,63.3,28.7,63.1,64 C126.7,98.7,98.5,127.1,63.5,127z M71.4,57.6c5.5,0.8,11,1.5,16.5,2.3c0.5-1.7,0.9-3.1,1.3-4.7c-5.7-0.8-11.2-1.7-17.1-2.5 c2-7,3.7-13.7,5.8-20.2c0.7-2.2,2.3-4.2,3.9-5.9c2.1-2.2,5-1.7,6.8,0.7c0.7,1,1.4,2.1,2.3,2.9c1.1,1.1,2.8,1.6,4,0.6 c0.8-0.7,0.7-2.4,0.8-3.6c0-0.5-0.6-1.1-1-1.6c-2-2.3-4.7-3.1-7.5-3.2c-6.3-0.3-10.9,3-14.5,7.8c-3.5,4.8-5.1,10.5-6.8,16.2 c-0.5,1.6-0.9,3.3-1.4,5.1c-6.2-0.9-12.1-1.7-18.2-2.6c-0.2,1.6-0.4,3.2-0.6,4.8c6,0.9,11.8,1.8,17.8,2.7c-0.8,3.4-1.5,6.5-2.3,9.7 c-5.8-0.8-11.4-1.6-17-2.4c-0.2,1.8-0.4,3.2-0.6,4.8c5.6,0.9,11,1.7,16.5,2.5c0,0.6,0.1,1,0,1.3c-1.7,7.4-3.4,14.8-5.3,22.2 c-0.9,3.5-2.4,6.9-5.3,9.3c-2.4,2-5,1.7-6.8-0.8c-0.8-1.1-1.5-2.5-2.6-3.3c-0.8-0.6-2.5-0.9-3.1-0.5c-0.9,0.7-1.5,2.2-1.4,3.3 c0.1,1,1,2.2,1.9,2.8c3,2.3,6.5,2.6,10,1.9c5.9-1.2,10.1-4.9,12.7-10.1c2-4.1,3.6-8.5,5-12.9c1.3-4,2.2-8,3.3-12.2 c5.8,0.8,11.5,1.7,17.3,2.5c0.5-1.7,0.9-3.2,1.4-4.8c-6.1-0.9-11.9-1.7-17.7-2.6C70.1,64,70.7,60.9,71.4,57.6z"/><path class="st1" d="M71.4,57.6c-0.7,3.3-1.3,6.4-2,9.8c5.9,0.9,11.7,1.7,17.7,2.6c-0.5,1.6-0.9,3.1-1.4,4.8 c-5.8-0.8-11.5-1.7-17.3-2.5c-1.1,4.2-2,8.3-3.3,12.2c-1.4,4.4-3,8.7-5,12.9c-2.6,5.2-6.8,8.9-12.7,10.1c-3.5,0.7-7,0.4-10-1.9 c-0.9-0.7-1.8-1.8-1.9-2.8c-0.1-1.1,0.5-2.7,1.4-3.3c0.6-0.5,2.3-0.1,3.1,0.5c1.1,0.8,1.8,2.1,2.6,3.3c1.8,2.5,4.4,2.9,6.8,0.8 c2.9-2.5,4.4-5.8,5.3-9.3c1.9-7.3,3.6-14.8,5.3-22.2c0.1-0.3,0-0.7,0-1.3c-5.4-0.8-10.8-1.7-16.5-2.5c0.2-1.6,0.4-3,0.6-4.8 c5.6,0.8,11.1,1.6,17,2.4c0.8-3.2,1.5-6.4,2.3-9.7c-6-0.9-11.7-1.8-17.8-2.7c0.2-1.6,0.4-3.2,0.6-4.8c6.1,0.9,12,1.7,18.2,2.6 c0.5-1.8,0.9-3.5,1.4-5.1c1.7-5.6,3.2-11.3,6.8-16.2c3.6-4.9,8.1-8.1,14.5-7.8c2.8,0.1,5.5,0.9,7.5,3.2c0.4,0.5,1,1.1,1,1.6 c-0.1,1.2,0,2.9-0.8,3.6c-1.1,1.1-2.8,0.5-4-0.6c-0.9-0.9-1.6-1.9-2.3-2.9c-1.8-2.4-4.7-2.9-6.8-0.7c-1.6,1.7-3.2,3.7-3.9,5.9 C75.7,39.4,74,46,72,53c5.9,0.9,11.4,1.7,17.1,2.5c-0.5,1.6-0.9,3.1-1.3,4.7C82.3,59.1,76.9,58.3,71.4,57.6z"/></g></svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

73
AppImageBuilder.yml Normal file
View File

@ -0,0 +1,73 @@
version: 1
AppDir:
path: ./AppDir
app_info:
id: io.filecoin.lotus
name: Lotus
icon: icon
version: latest
exec: usr/bin/lotus
exec_args: $@
apt:
arch: amd64
allow_unauthenticated: true
sources:
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal main restricted
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal universe
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal multiverse
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted
universe multiverse
- sourceline: deb http://security.ubuntu.com/ubuntu focal-security main restricted
- sourceline: deb http://security.ubuntu.com/ubuntu focal-security universe
- sourceline: deb http://security.ubuntu.com/ubuntu focal-security multiverse
- sourceline: deb https://cli-assets.heroku.com/apt ./
- sourceline: deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu focal main
- sourceline: deb http://ppa.launchpad.net/git-core/ppa/ubuntu focal main
- sourceline: deb http://archive.canonical.com/ubuntu focal partner
include:
- ocl-icd-libopencl1
- libhwloc15
exclude: []
files:
include:
- /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
- /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
- /usr/lib/x86_64-linux-gnu/libm-2.31.so
- /usr/lib/x86_64-linux-gnu/libdl-2.31.so
- /usr/lib/x86_64-linux-gnu/libc-2.31.so
- /usr/lib/x86_64-linux-gnu/libudev.so.1.6.17
exclude:
- usr/share/man
- usr/share/doc/*/README.*
- usr/share/doc/*/changelog.*
- usr/share/doc/*/NEWS.*
- usr/share/doc/*/TODO.*
test:
fedora:
image: appimagecrafters/tests-env:fedora-30
command: ./AppRun
use_host_x: true
debian:
image: appimagecrafters/tests-env:debian-stable
command: ./AppRun
use_host_x: true
arch:
image: appimagecrafters/tests-env:archlinux-latest
command: ./AppRun
use_host_x: true
centos:
image: appimagecrafters/tests-env:centos-7
command: ./AppRun
use_host_x: true
ubuntu:
image: appimagecrafters/tests-env:ubuntu-xenial
command: ./AppRun
use_host_x: true
AppImage:
arch: x86_64
update-information: guess
sign-key: None

View File

@ -1,4 +1,4 @@
FROM golang:1.15.6 AS builder-deps
FROM golang:1.16.4 AS builder-deps
MAINTAINER Lotus Development Team
RUN apt-get update && apt-get install -y ca-certificates build-essential clang ocl-icd-opencl-dev ocl-icd-libopencl1 jq libhwloc-dev

View File

@ -6,9 +6,9 @@ all: build
unexport GOFLAGS
GOVERSION:=$(shell go version | cut -d' ' -f 3 | sed 's/^go//' | awk -F. '{printf "%d%03d%03d", $$1, $$2, $$3}')
ifeq ($(shell expr $(GOVERSION) \< 1015005), 1)
ifeq ($(shell expr $(GOVERSION) \< 1016000), 1)
$(warning Your Golang version is go$(shell expr $(GOVERSION) / 1000000).$(shell expr $(GOVERSION) % 1000000 / 1000).$(shell expr $(GOVERSION) % 1000))
$(error Update Golang to version to at least 1.15.5)
$(error Update Golang to version to at least 1.16.0)
endif
# git modules that need to be loaded
@ -47,7 +47,6 @@ BUILD_DEPS+=ffi-version-check
.PHONY: ffi-version-check
$(MODULES): build/.update-modules ;
# dummy file that marks the last time modules were updated
build/.update-modules:
@ -81,10 +80,12 @@ nerpanet: build-devnets
butterflynet: GOFLAGS+=-tags=butterflynet
butterflynet: build-devnets
interopnet: GOFLAGS+=-tags=interopnet
interopnet: build-devnets
lotus: $(BUILD_DEPS)
rm -f lotus
go build $(GOFLAGS) -o lotus ./cmd/lotus
go run github.com/GeertJohan/go.rice/rice append --exec lotus -i ./build
.PHONY: lotus
BINS+=lotus
@ -92,21 +93,18 @@ BINS+=lotus
lotus-miner: $(BUILD_DEPS)
rm -f lotus-miner
go build $(GOFLAGS) -o lotus-miner ./cmd/lotus-storage-miner
go run github.com/GeertJohan/go.rice/rice append --exec lotus-miner -i ./build
.PHONY: lotus-miner
BINS+=lotus-miner
lotus-worker: $(BUILD_DEPS)
rm -f lotus-worker
go build $(GOFLAGS) -o lotus-worker ./cmd/lotus-seal-worker
go run github.com/GeertJohan/go.rice/rice append --exec lotus-worker -i ./build
.PHONY: lotus-worker
BINS+=lotus-worker
lotus-shed: $(BUILD_DEPS)
rm -f lotus-shed
go build $(GOFLAGS) -o lotus-shed ./cmd/lotus-shed
go run github.com/GeertJohan/go.rice/rice append --exec lotus-shed -i ./build
.PHONY: lotus-shed
BINS+=lotus-shed
@ -138,7 +136,6 @@ install-worker:
lotus-seed: $(BUILD_DEPS)
rm -f lotus-seed
go build $(GOFLAGS) -o lotus-seed ./cmd/lotus-seed
go run github.com/GeertJohan/go.rice/rice append --exec lotus-seed -i ./build
.PHONY: lotus-seed
BINS+=lotus-seed
@ -172,13 +169,11 @@ lotus-townhall-front:
.PHONY: lotus-townhall-front
lotus-townhall-app: lotus-touch lotus-townhall-front
go run github.com/GeertJohan/go.rice/rice append --exec lotus-townhall -i ./cmd/lotus-townhall -i ./build
.PHONY: lotus-townhall-app
lotus-fountain:
rm -f lotus-fountain
go build -o lotus-fountain ./cmd/lotus-fountain
go run github.com/GeertJohan/go.rice/rice append --exec lotus-fountain -i ./cmd/lotus-fountain -i ./build
.PHONY: lotus-fountain
BINS+=lotus-fountain
@ -191,28 +186,24 @@ BINS+=lotus-chainwatch
lotus-bench:
rm -f lotus-bench
go build -o lotus-bench ./cmd/lotus-bench
go run github.com/GeertJohan/go.rice/rice append --exec lotus-bench -i ./build
.PHONY: lotus-bench
BINS+=lotus-bench
lotus-stats:
rm -f lotus-stats
go build $(GOFLAGS) -o lotus-stats ./cmd/lotus-stats
go run github.com/GeertJohan/go.rice/rice append --exec lotus-stats -i ./build
.PHONY: lotus-stats
BINS+=lotus-stats
lotus-pcr:
rm -f lotus-pcr
go build $(GOFLAGS) -o lotus-pcr ./cmd/lotus-pcr
go run github.com/GeertJohan/go.rice/rice append --exec lotus-pcr -i ./build
.PHONY: lotus-pcr
BINS+=lotus-pcr
lotus-health:
rm -f lotus-health
go build -o lotus-health ./cmd/lotus-health
go run github.com/GeertJohan/go.rice/rice append --exec lotus-health -i ./build
.PHONY: lotus-health
BINS+=lotus-health
@ -303,17 +294,10 @@ clean-services: clean-all-services
buildall: $(BINS)
completions:
./scripts/make-completions.sh lotus
./scripts/make-completions.sh lotus-miner
.PHONY: completions
install-completions:
mkdir -p /usr/share/bash-completion/completions /usr/local/share/zsh/site-functions/
install -C ./scripts/bash-completion/lotus /usr/share/bash-completion/completions/lotus
install -C ./scripts/bash-completion/lotus-miner /usr/share/bash-completion/completions/lotus-miner
install -C ./scripts/zsh-completion/lotus /usr/local/share/zsh/site-functions/_lotus
install -C ./scripts/zsh-completion/lotus-miner /usr/local/share/zsh/site-functions/_lotus-miner
clean:
rm -rf $(CLEAN) $(BINS)
@ -343,6 +327,15 @@ api-gen:
goimports -w api
.PHONY: api-gen
appimage: lotus
rm -rf appimage-builder-cache || true
rm AppDir/io.filecoin.lotus.desktop || true
rm AppDir/icon.svg || true
rm Appdir/AppRun || true
mkdir -p AppDir/usr/bin
cp ./lotus AppDir/usr/bin/
appimage-builder
docsgen: docsgen-md docsgen-openrpc
docsgen-md-bin: api-gen actors-gen

View File

@ -10,7 +10,7 @@
<a href="https://circleci.com/gh/filecoin-project/lotus"><img src="https://circleci.com/gh/filecoin-project/lotus.svg?style=svg"></a>
<a href="https://codecov.io/gh/filecoin-project/lotus"><img src="https://codecov.io/gh/filecoin-project/lotus/branch/master/graph/badge.svg"></a>
<a href="https://goreportcard.com/report/github.com/filecoin-project/lotus"><img src="https://goreportcard.com/badge/github.com/filecoin-project/lotus" /></a>
<a href=""><img src="https://img.shields.io/badge/golang-%3E%3D1.15.5-blue.svg" /></a>
<a href=""><img src="https://img.shields.io/badge/golang-%3E%3D1.16-blue.svg" /></a>
<br>
</p>

View File

@ -344,6 +344,10 @@ type FullNode interface {
// ClientRetrieveWithEvents initiates the retrieval of a file, as specified in the order, and provides a channel
// of status updates.
ClientRetrieveWithEvents(ctx context.Context, order RetrievalOrder, ref *FileRef) (<-chan marketevents.RetrievalEvent, error) //perm:admin
// ClientListRetrievals returns information about retrievals made by the local client
ClientListRetrievals(ctx context.Context) ([]RetrievalInfo, error) //perm:write
// ClientGetRetrievalUpdates returns status of updated retrieval deals
ClientGetRetrievalUpdates(ctx context.Context) (<-chan RetrievalInfo, error) //perm:write
// ClientQueryAsk returns a signed StorageAsk from the specified miner.
ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Address) (*storagemarket.StorageAsk, error) //perm:read
// ClientCalcCommP calculates the CommP and data size of the specified CID

View File

@ -24,6 +24,7 @@ import (
"github.com/filecoin-project/lotus/extern/sector-storage/fsutil"
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
"github.com/filecoin-project/lotus/extern/storage-sealing/sealiface"
)
// MODIFYING THE API INTERFACE
@ -91,6 +92,16 @@ type StorageMiner interface {
// SectorTerminatePending returns a list of pending sector terminations to be sent in the next batch message
SectorTerminatePending(ctx context.Context) ([]abi.SectorID, error) //perm:admin
SectorMarkForUpgrade(ctx context.Context, id abi.SectorNumber) error //perm:admin
// SectorPreCommitFlush immediately sends a PreCommit message with sectors batched for PreCommit.
// Returns null if message wasn't sent
SectorPreCommitFlush(ctx context.Context) ([]sealiface.PreCommitBatchRes, error) //perm:admin
// SectorPreCommitPending returns a list of pending PreCommit sectors to be sent in the next batch message
SectorPreCommitPending(ctx context.Context) ([]abi.SectorID, error) //perm:admin
// SectorCommitFlush immediately sends a Commit message with sectors aggregated for Commit.
// Returns null if message wasn't sent
SectorCommitFlush(ctx context.Context) ([]sealiface.CommitBatchRes, error) //perm:admin
// SectorCommitPending returns a list of pending Commit sectors to be sent in the next aggregate message
SectorCommitPending(ctx context.Context) ([]abi.SectorID, error) //perm:admin
// WorkerConnect tells the node to connect to workers RPC
WorkerConnect(context.Context, string) error //perm:admin retry:true

View File

@ -35,13 +35,13 @@ type MsgMeta struct {
}
type Wallet interface {
WalletNew(context.Context, types.KeyType) (address.Address, error)
WalletHas(context.Context, address.Address) (bool, error)
WalletList(context.Context) ([]address.Address, error)
WalletNew(context.Context, types.KeyType) (address.Address, error) //perm:admin
WalletHas(context.Context, address.Address) (bool, error) //perm:admin
WalletList(context.Context) ([]address.Address, error) //perm:admin
WalletSign(ctx context.Context, signer address.Address, toSign []byte, meta MsgMeta) (*crypto.Signature, error)
WalletSign(ctx context.Context, signer address.Address, toSign []byte, meta MsgMeta) (*crypto.Signature, error) //perm:admin
WalletExport(context.Context, address.Address) (*types.KeyInfo, error)
WalletImport(context.Context, *types.KeyInfo) (address.Address, error)
WalletDelete(context.Context, address.Address) error
WalletExport(context.Context, address.Address) (*types.KeyInfo, error) //perm:admin
WalletImport(context.Context, *types.KeyInfo) (address.Address, error) //perm:admin
WalletDelete(context.Context, address.Address) error //perm:admin
}

View File

@ -2,7 +2,6 @@ package api
import (
"context"
"io"
"github.com/google/uuid"
"github.com/ipfs/go-cid"
@ -43,7 +42,6 @@ type Worker interface {
ReleaseUnsealed(ctx context.Context, sector storage.SectorRef, safeToFree []storage.Range) (storiface.CallID, error) //perm:admin
MoveStorage(ctx context.Context, sector storage.SectorRef, types storiface.SectorFileType) (storiface.CallID, error) //perm:admin
UnsealPiece(context.Context, storage.SectorRef, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize, abi.SealRandomness, cid.Cid) (storiface.CallID, error) //perm:admin
ReadPiece(context.Context, io.Writer, storage.SectorRef, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize) (storiface.CallID, error) //perm:admin
Fetch(context.Context, storage.SectorRef, storiface.SectorFileType, storiface.PathType, storiface.AcquireMode) (storiface.CallID, error) //perm:admin
TaskDisable(ctx context.Context, tt sealtasks.TaskType) error //perm:admin

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,6 @@ package api
import (
"context"
"io"
"time"
"github.com/filecoin-project/go-address"
@ -27,6 +26,7 @@ import (
"github.com/filecoin-project/lotus/extern/sector-storage/sealtasks"
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
"github.com/filecoin-project/lotus/extern/storage-sealing/sealiface"
marketevents "github.com/filecoin-project/lotus/markets/loggers"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/specs-storage/storage"
@ -179,6 +179,8 @@ type FullNodeStruct struct {
ClientGetDealUpdates func(p0 context.Context) (<-chan DealInfo, error) `perm:"write"`
ClientGetRetrievalUpdates func(p0 context.Context) (<-chan RetrievalInfo, error) `perm:"write"`
ClientHasLocal func(p0 context.Context, p1 cid.Cid) (bool, error) `perm:"write"`
ClientImport func(p0 context.Context, p1 FileRef) (*ImportRes, error) `perm:"admin"`
@ -189,6 +191,8 @@ type FullNodeStruct struct {
ClientListImports func(p0 context.Context) ([]Import, error) `perm:"write"`
ClientListRetrievals func(p0 context.Context) ([]RetrievalInfo, error) `perm:"write"`
ClientMinerQueryOffer func(p0 context.Context, p1 address.Address, p2 cid.Cid, p3 *cid.Cid) (QueryOffer, error) `perm:"read"`
ClientQueryAsk func(p0 context.Context, p1 peer.ID, p2 address.Address) (*storagemarket.StorageAsk, error) `perm:"read"`
@ -659,12 +663,20 @@ type StorageMinerStruct struct {
SealingSchedDiag func(p0 context.Context, p1 bool) (interface{}, error) `perm:"admin"`
SectorCommitFlush func(p0 context.Context) ([]sealiface.CommitBatchRes, error) `perm:"admin"`
SectorCommitPending func(p0 context.Context) ([]abi.SectorID, error) `perm:"admin"`
SectorGetExpectedSealDuration func(p0 context.Context) (time.Duration, error) `perm:"read"`
SectorGetSealDelay func(p0 context.Context) (time.Duration, error) `perm:"read"`
SectorMarkForUpgrade func(p0 context.Context, p1 abi.SectorNumber) error `perm:"admin"`
SectorPreCommitFlush func(p0 context.Context) ([]sealiface.PreCommitBatchRes, error) `perm:"admin"`
SectorPreCommitPending func(p0 context.Context) ([]abi.SectorID, error) `perm:"admin"`
SectorRemove func(p0 context.Context, p1 abi.SectorNumber) error `perm:"admin"`
SectorSetExpectedSealDuration func(p0 context.Context, p1 time.Duration) error `perm:"write"`
@ -731,19 +743,19 @@ type StorageMinerStub struct {
type WalletStruct struct {
Internal struct {
WalletDelete func(p0 context.Context, p1 address.Address) error ``
WalletDelete func(p0 context.Context, p1 address.Address) error `perm:"admin"`
WalletExport func(p0 context.Context, p1 address.Address) (*types.KeyInfo, error) ``
WalletExport func(p0 context.Context, p1 address.Address) (*types.KeyInfo, error) `perm:"admin"`
WalletHas func(p0 context.Context, p1 address.Address) (bool, error) ``
WalletHas func(p0 context.Context, p1 address.Address) (bool, error) `perm:"admin"`
WalletImport func(p0 context.Context, p1 *types.KeyInfo) (address.Address, error) ``
WalletImport func(p0 context.Context, p1 *types.KeyInfo) (address.Address, error) `perm:"admin"`
WalletList func(p0 context.Context) ([]address.Address, error) ``
WalletList func(p0 context.Context) ([]address.Address, error) `perm:"admin"`
WalletNew func(p0 context.Context, p1 types.KeyType) (address.Address, error) ``
WalletNew func(p0 context.Context, p1 types.KeyType) (address.Address, error) `perm:"admin"`
WalletSign func(p0 context.Context, p1 address.Address, p2 []byte, p3 MsgMeta) (*crypto.Signature, error) ``
WalletSign func(p0 context.Context, p1 address.Address, p2 []byte, p3 MsgMeta) (*crypto.Signature, error) `perm:"admin"`
}
}
@ -768,8 +780,6 @@ type WorkerStruct struct {
ProcessSession func(p0 context.Context) (uuid.UUID, error) `perm:"admin"`
ReadPiece func(p0 context.Context, p1 io.Writer, p2 storage.SectorRef, p3 storiface.UnpaddedByteIndex, p4 abi.UnpaddedPieceSize) (storiface.CallID, error) `perm:"admin"`
ReleaseUnsealed func(p0 context.Context, p1 storage.SectorRef, p2 []storage.Range) (storiface.CallID, error) `perm:"admin"`
Remove func(p0 context.Context, p1 abi.SectorID) error `perm:"admin"`
@ -1293,6 +1303,14 @@ func (s *FullNodeStub) ClientGetDealUpdates(p0 context.Context) (<-chan DealInfo
return nil, xerrors.New("method not supported")
}
func (s *FullNodeStruct) ClientGetRetrievalUpdates(p0 context.Context) (<-chan RetrievalInfo, error) {
return s.Internal.ClientGetRetrievalUpdates(p0)
}
func (s *FullNodeStub) ClientGetRetrievalUpdates(p0 context.Context) (<-chan RetrievalInfo, error) {
return nil, xerrors.New("method not supported")
}
func (s *FullNodeStruct) ClientHasLocal(p0 context.Context, p1 cid.Cid) (bool, error) {
return s.Internal.ClientHasLocal(p0, p1)
}
@ -1333,6 +1351,14 @@ func (s *FullNodeStub) ClientListImports(p0 context.Context) ([]Import, error) {
return *new([]Import), xerrors.New("method not supported")
}
func (s *FullNodeStruct) ClientListRetrievals(p0 context.Context) ([]RetrievalInfo, error) {
return s.Internal.ClientListRetrievals(p0)
}
func (s *FullNodeStub) ClientListRetrievals(p0 context.Context) ([]RetrievalInfo, error) {
return *new([]RetrievalInfo), xerrors.New("method not supported")
}
func (s *FullNodeStruct) ClientMinerQueryOffer(p0 context.Context, p1 address.Address, p2 cid.Cid, p3 *cid.Cid) (QueryOffer, error) {
return s.Internal.ClientMinerQueryOffer(p0, p1, p2, p3)
}
@ -3117,6 +3143,22 @@ func (s *StorageMinerStub) SealingSchedDiag(p0 context.Context, p1 bool) (interf
return nil, xerrors.New("method not supported")
}
func (s *StorageMinerStruct) SectorCommitFlush(p0 context.Context) ([]sealiface.CommitBatchRes, error) {
return s.Internal.SectorCommitFlush(p0)
}
func (s *StorageMinerStub) SectorCommitFlush(p0 context.Context) ([]sealiface.CommitBatchRes, error) {
return *new([]sealiface.CommitBatchRes), xerrors.New("method not supported")
}
func (s *StorageMinerStruct) SectorCommitPending(p0 context.Context) ([]abi.SectorID, error) {
return s.Internal.SectorCommitPending(p0)
}
func (s *StorageMinerStub) SectorCommitPending(p0 context.Context) ([]abi.SectorID, error) {
return *new([]abi.SectorID), xerrors.New("method not supported")
}
func (s *StorageMinerStruct) SectorGetExpectedSealDuration(p0 context.Context) (time.Duration, error) {
return s.Internal.SectorGetExpectedSealDuration(p0)
}
@ -3141,6 +3183,22 @@ func (s *StorageMinerStub) SectorMarkForUpgrade(p0 context.Context, p1 abi.Secto
return xerrors.New("method not supported")
}
func (s *StorageMinerStruct) SectorPreCommitFlush(p0 context.Context) ([]sealiface.PreCommitBatchRes, error) {
return s.Internal.SectorPreCommitFlush(p0)
}
func (s *StorageMinerStub) SectorPreCommitFlush(p0 context.Context) ([]sealiface.PreCommitBatchRes, error) {
return *new([]sealiface.PreCommitBatchRes), xerrors.New("method not supported")
}
func (s *StorageMinerStruct) SectorPreCommitPending(p0 context.Context) ([]abi.SectorID, error) {
return s.Internal.SectorPreCommitPending(p0)
}
func (s *StorageMinerStub) SectorPreCommitPending(p0 context.Context) ([]abi.SectorID, error) {
return *new([]abi.SectorID), xerrors.New("method not supported")
}
func (s *StorageMinerStruct) SectorRemove(p0 context.Context, p1 abi.SectorNumber) error {
return s.Internal.SectorRemove(p0, p1)
}
@ -3493,14 +3551,6 @@ func (s *WorkerStub) ProcessSession(p0 context.Context) (uuid.UUID, error) {
return *new(uuid.UUID), xerrors.New("method not supported")
}
func (s *WorkerStruct) ReadPiece(p0 context.Context, p1 io.Writer, p2 storage.SectorRef, p3 storiface.UnpaddedByteIndex, p4 abi.UnpaddedPieceSize) (storiface.CallID, error) {
return s.Internal.ReadPiece(p0, p1, p2, p3, p4)
}
func (s *WorkerStub) ReadPiece(p0 context.Context, p1 io.Writer, p2 storage.SectorRef, p3 storiface.UnpaddedByteIndex, p4 abi.UnpaddedPieceSize) (storiface.CallID, error) {
return *new(storiface.CallID), xerrors.New("method not supported")
}
func (s *WorkerStruct) ReleaseUnsealed(p0 context.Context, p1 storage.SectorRef, p2 []storage.Range) (storiface.CallID, error) {
return s.Internal.ReleaseUnsealed(p0, p1, p2)
}

View File

@ -5,6 +5,7 @@ import (
"fmt"
"time"
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
"github.com/filecoin-project/lotus/chain/types"
datatransfer "github.com/filecoin-project/go-data-transfer"
@ -176,3 +177,21 @@ type MessagePrototype struct {
Message types.Message
ValidNonce bool
}
type RetrievalInfo struct {
PayloadCID cid.Cid
ID retrievalmarket.DealID
PieceCID *cid.Cid
PricePerByte abi.TokenAmount
UnsealPrice abi.TokenAmount
Status retrievalmarket.DealStatus
Message string // more information about deal state, particularly errors
Provider peer.ID
BytesReceived uint64
BytesPaidFor uint64
TotalPaid abi.TokenAmount
TransferChannelID *datatransfer.ChannelID
DataTransfer *DataTransferChannel
}

View File

@ -326,6 +326,10 @@ type FullNode interface {
// of status updates.
ClientRetrieveWithEvents(ctx context.Context, order api.RetrievalOrder, ref *api.FileRef) (<-chan marketevents.RetrievalEvent, error) //perm:admin
// ClientQueryAsk returns a signed StorageAsk from the specified miner.
// ClientListRetrievals returns information about retrievals made by the local client
ClientListRetrievals(ctx context.Context) ([]api.RetrievalInfo, error) //perm:write
// ClientGetRetrievalUpdates returns status of updated retrieval deals
ClientGetRetrievalUpdates(ctx context.Context) (<-chan api.RetrievalInfo, error) //perm:write
ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Address) (*storagemarket.StorageAsk, error) //perm:read
// ClientCalcCommP calculates the CommP and data size of the specified CID
ClientDealPieceCID(ctx context.Context, root cid.Cid) (api.DataCIDSize, error) //perm:read

View File

@ -97,6 +97,8 @@ type FullNodeStruct struct {
ClientGetDealUpdates func(p0 context.Context) (<-chan api.DealInfo, error) `perm:"write"`
ClientGetRetrievalUpdates func(p0 context.Context) (<-chan api.RetrievalInfo, error) `perm:"write"`
ClientHasLocal func(p0 context.Context, p1 cid.Cid) (bool, error) `perm:"write"`
ClientImport func(p0 context.Context, p1 api.FileRef) (*api.ImportRes, error) `perm:"admin"`
@ -107,6 +109,8 @@ type FullNodeStruct struct {
ClientListImports func(p0 context.Context) ([]api.Import, error) `perm:"write"`
ClientListRetrievals func(p0 context.Context) ([]api.RetrievalInfo, error) `perm:"write"`
ClientMinerQueryOffer func(p0 context.Context, p1 address.Address, p2 cid.Cid, p3 *cid.Cid) (api.QueryOffer, error) `perm:"read"`
ClientQueryAsk func(p0 context.Context, p1 peer.ID, p2 address.Address) (*storagemarket.StorageAsk, error) `perm:"read"`
@ -716,6 +720,14 @@ func (s *FullNodeStub) ClientGetDealUpdates(p0 context.Context) (<-chan api.Deal
return nil, xerrors.New("method not supported")
}
func (s *FullNodeStruct) ClientGetRetrievalUpdates(p0 context.Context) (<-chan api.RetrievalInfo, error) {
return s.Internal.ClientGetRetrievalUpdates(p0)
}
func (s *FullNodeStub) ClientGetRetrievalUpdates(p0 context.Context) (<-chan api.RetrievalInfo, error) {
return nil, xerrors.New("method not supported")
}
func (s *FullNodeStruct) ClientHasLocal(p0 context.Context, p1 cid.Cid) (bool, error) {
return s.Internal.ClientHasLocal(p0, p1)
}
@ -756,6 +768,14 @@ func (s *FullNodeStub) ClientListImports(p0 context.Context) ([]api.Import, erro
return *new([]api.Import), xerrors.New("method not supported")
}
func (s *FullNodeStruct) ClientListRetrievals(p0 context.Context) ([]api.RetrievalInfo, error) {
return s.Internal.ClientListRetrievals(p0)
}
func (s *FullNodeStub) ClientListRetrievals(p0 context.Context) ([]api.RetrievalInfo, error) {
return *new([]api.RetrievalInfo), xerrors.New("method not supported")
}
func (s *FullNodeStruct) ClientMinerQueryOffer(p0 context.Context, p1 address.Address, p2 cid.Cid, p3 *cid.Cid) (api.QueryOffer, error) {
return s.Internal.ClientMinerQueryOffer(p0, p1, p2, p3)
}

File diff suppressed because it is too large Load Diff

View File

@ -57,8 +57,8 @@ var (
FullAPIVersion0 = newVer(1, 3, 0)
FullAPIVersion1 = newVer(2, 1, 0)
MinerAPIVersion0 = newVer(1, 0, 1)
WorkerAPIVersion0 = newVer(1, 0, 0)
MinerAPIVersion0 = newVer(1, 1, 0)
WorkerAPIVersion0 = newVer(1, 1, 0)
)
//nolint:varcheck,deadcode

View File

@ -2,28 +2,32 @@ package build
import (
"context"
"embed"
"path"
"strings"
"github.com/filecoin-project/lotus/lib/addrutil"
rice "github.com/GeertJohan/go.rice"
"github.com/libp2p/go-libp2p-core/peer"
)
//go:embed bootstrap
var bootstrapfs embed.FS
func BuiltinBootstrap() ([]peer.AddrInfo, error) {
if DisableBuiltinAssets {
return nil, nil
}
b := rice.MustFindBox("bootstrap")
if BootstrappersFile != "" {
spi := b.MustString(BootstrappersFile)
if spi == "" {
spi, err := bootstrapfs.ReadFile(path.Join("bootstrap", BootstrappersFile))
if err != nil {
return nil, err
}
if len(spi) == 0 {
return nil, nil
}
return addrutil.ParseAddresses(context.TODO(), strings.Split(strings.TrimSpace(spi), "\n"))
return addrutil.ParseAddresses(context.TODO(), strings.Split(strings.TrimSpace(string(spi)), "\n"))
}
return nil, nil

View File

@ -1,2 +1,2 @@
/dns4/bootstrap-0.butterfly.fildev.network/tcp/1347/p2p/12D3KooWRkaF18SR3E6qL6dkGrozT8QJUV5VbhE9E7BZtPmHqdWJ
/dns4/bootstrap-1.butterfly.fildev.network/tcp/1347/p2p/12D3KooWJcJUc23WJjJHGSboGcU3t76z9Lb7CghrH2tiBiDCY4ux
/dns4/bootstrap-0.butterfly.fildev.network/tcp/1347/p2p/12D3KooWBbZd7Su9XfLUQ12RynGQ3ZmGY1nGqFntmqop9pLNJE6g
/dns4/bootstrap-1.butterfly.fildev.network/tcp/1347/p2p/12D3KooWGKRzEY4tJFTmAmrYUpa1CVVohmV9YjJbC9v5XWY2gUji

View File

@ -0,0 +1,2 @@
/dns4/bootstrap-0.interop.fildev.network/tcp/1347/p2p/12D3KooWN86wA54r3v9M8bBYbc1vK9W1ehHDxVGPRaoeUYuXF8R7
/dns4/bootstrap-1.interop.fildev.network/tcp/1347/p2p/12D3KooWNZ41kev8mtBZgWe43qam1VX9pJyf87jnaisQP2urZZ2M

View File

@ -1,23 +1,23 @@
package build
import (
rice "github.com/GeertJohan/go.rice"
"embed"
"path"
logging "github.com/ipfs/go-log/v2"
)
// moved from now-defunct build/paramfetch.go
var log = logging.Logger("build")
//go:embed genesis
var genesisfs embed.FS
func MaybeGenesis() []byte {
builtinGen, err := rice.FindBox("genesis")
genBytes, err := genesisfs.ReadFile(path.Join("genesis", GenesisFile))
if err != nil {
log.Warnf("loading built-in genesis: %s", err)
return nil
}
genBytes, err := builtinGen.Bytes(GenesisFile)
if err != nil {
log.Warnf("loading built-in genesis: %s", err)
}
return genBytes
}

Binary file not shown.

Binary file not shown.

View File

@ -3,13 +3,15 @@ package build
import (
"bytes"
"compress/gzip"
"embed"
"encoding/json"
rice "github.com/GeertJohan/go.rice"
apitypes "github.com/filecoin-project/lotus/api/types"
)
//go:embed openrpc
var openrpcfs embed.FS
func mustReadGzippedOpenRPCDocument(data []byte) apitypes.OpenRPCDocument {
zr, err := gzip.NewReader(bytes.NewBuffer(data))
if err != nil {
@ -28,16 +30,25 @@ func mustReadGzippedOpenRPCDocument(data []byte) apitypes.OpenRPCDocument {
}
func OpenRPCDiscoverJSON_Full() apitypes.OpenRPCDocument {
data := rice.MustFindBox("openrpc").MustBytes("full.json.gz")
data, err := openrpcfs.ReadFile("openrpc/full.json.gz")
if err != nil {
panic(err)
}
return mustReadGzippedOpenRPCDocument(data)
}
func OpenRPCDiscoverJSON_Miner() apitypes.OpenRPCDocument {
data := rice.MustFindBox("openrpc").MustBytes("miner.json.gz")
data, err := openrpcfs.ReadFile("openrpc/miner.json.gz")
if err != nil {
panic(err)
}
return mustReadGzippedOpenRPCDocument(data)
}
func OpenRPCDiscoverJSON_Worker() apitypes.OpenRPCDocument {
data := rice.MustFindBox("openrpc").MustBytes("worker.json.gz")
data, err := openrpcfs.ReadFile("openrpc/worker.json.gz")
if err != nil {
panic(err)
}
return mustReadGzippedOpenRPCDocument(data)
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +1,19 @@
package build
import rice "github.com/GeertJohan/go.rice"
import (
_ "embed"
)
//go:embed proof-params/parameters.json
var params []byte
//go:embed proof-params/srs-inner-product.json
var srs []byte
func ParametersJSON() []byte {
return rice.MustFindBox("proof-params").MustBytes("parameters.json")
return params
}
func SrsJSON() []byte {
return srs
}

View File

@ -24,20 +24,22 @@ var UpgradeIgnitionHeight = abi.ChainEpoch(-2)
var UpgradeRefuelHeight = abi.ChainEpoch(-3)
var UpgradeTapeHeight = abi.ChainEpoch(-4)
var UpgradeActorsV2Height = abi.ChainEpoch(10)
var UpgradeLiftoffHeight = abi.ChainEpoch(-5)
var UpgradeAssemblyHeight = abi.ChainEpoch(-5)
var UpgradeLiftoffHeight = abi.ChainEpoch(-6)
var UpgradeKumquatHeight = abi.ChainEpoch(15)
var UpgradeCalicoHeight = abi.ChainEpoch(20)
var UpgradePersianHeight = abi.ChainEpoch(25)
var UpgradeOrangeHeight = abi.ChainEpoch(27)
var UpgradeClausHeight = abi.ChainEpoch(30)
var UpgradeKumquatHeight = abi.ChainEpoch(-7)
var UpgradeCalicoHeight = abi.ChainEpoch(-8)
var UpgradePersianHeight = abi.ChainEpoch(-9)
var UpgradeOrangeHeight = abi.ChainEpoch(-10)
var UpgradeClausHeight = abi.ChainEpoch(-11)
var UpgradeActorsV3Height = abi.ChainEpoch(35)
var UpgradeTrustHeight = abi.ChainEpoch(-12)
var UpgradeNorwegianHeight = abi.ChainEpoch(40)
var UpgradeNorwegianHeight = abi.ChainEpoch(-13)
var UpgradeActorsV4Height = abi.ChainEpoch(45)
var UpgradeTurboHeight = abi.ChainEpoch(-14)
var UpgradeHyperdriveHeight = abi.ChainEpoch(-15)
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
@ -68,16 +70,17 @@ func init() {
UpgradeIgnitionHeight = getUpgradeHeight("LOTUS_IGNITION_HEIGHT", UpgradeIgnitionHeight)
UpgradeRefuelHeight = getUpgradeHeight("LOTUS_REFUEL_HEIGHT", UpgradeRefuelHeight)
UpgradeTapeHeight = getUpgradeHeight("LOTUS_TAPE_HEIGHT", UpgradeTapeHeight)
UpgradeActorsV2Height = getUpgradeHeight("LOTUS_ACTORSV2_HEIGHT", UpgradeActorsV2Height)
UpgradeAssemblyHeight = getUpgradeHeight("LOTUS_ACTORSV2_HEIGHT", UpgradeAssemblyHeight)
UpgradeLiftoffHeight = getUpgradeHeight("LOTUS_LIFTOFF_HEIGHT", UpgradeLiftoffHeight)
UpgradeKumquatHeight = getUpgradeHeight("LOTUS_KUMQUAT_HEIGHT", UpgradeKumquatHeight)
UpgradeCalicoHeight = getUpgradeHeight("LOTUS_CALICO_HEIGHT", UpgradeCalicoHeight)
UpgradePersianHeight = getUpgradeHeight("LOTUS_PERSIAN_HEIGHT", UpgradePersianHeight)
UpgradeOrangeHeight = getUpgradeHeight("LOTUS_ORANGE_HEIGHT", UpgradeOrangeHeight)
UpgradeClausHeight = getUpgradeHeight("LOTUS_CLAUS_HEIGHT", UpgradeClausHeight)
UpgradeActorsV3Height = getUpgradeHeight("LOTUS_ACTORSV3_HEIGHT", UpgradeActorsV3Height)
UpgradeTrustHeight = getUpgradeHeight("LOTUS_ACTORSV3_HEIGHT", UpgradeTrustHeight)
UpgradeNorwegianHeight = getUpgradeHeight("LOTUS_NORWEGIAN_HEIGHT", UpgradeNorwegianHeight)
UpgradeActorsV4Height = getUpgradeHeight("LOTUS_ACTORSV4_HEIGHT", UpgradeActorsV4Height)
UpgradeTurboHeight = getUpgradeHeight("LOTUS_ACTORSV4_HEIGHT", UpgradeTurboHeight)
UpgradeHyperdriveHeight = getUpgradeHeight("LOTUS_HYPERDRIVE_HEIGHT", UpgradeHyperdriveHeight)
BuildType |= Build2k
}

View File

@ -23,7 +23,7 @@ const UpgradeSmokeHeight = -2
const UpgradeIgnitionHeight = -3
const UpgradeRefuelHeight = -4
var UpgradeActorsV2Height = abi.ChainEpoch(30)
var UpgradeAssemblyHeight = abi.ChainEpoch(30)
const UpgradeTapeHeight = 60
const UpgradeLiftoffHeight = -5
@ -32,9 +32,10 @@ const UpgradeCalicoHeight = 120
const UpgradePersianHeight = 150
const UpgradeClausHeight = 180
const UpgradeOrangeHeight = 210
const UpgradeActorsV3Height = 240
const UpgradeNorwegianHeight = UpgradeActorsV3Height + (builtin2.EpochsInHour * 12)
const UpgradeActorsV4Height = 8922
const UpgradeTrustHeight = 240
const UpgradeNorwegianHeight = UpgradeTrustHeight + (builtin2.EpochsInHour * 12)
const UpgradeTurboHeight = 8922
const UpgradeHyperdriveHeight = 9999999
func init() {
policy.SetConsensusMinerMinPower(abi.NewStoragePower(2 << 30))

View File

@ -25,7 +25,7 @@ const UpgradeSmokeHeight = -2
const UpgradeIgnitionHeight = -3
const UpgradeRefuelHeight = -4
var UpgradeActorsV2Height = abi.ChainEpoch(30)
var UpgradeAssemblyHeight = abi.ChainEpoch(30)
const UpgradeTapeHeight = 60
@ -40,10 +40,12 @@ const UpgradeClausHeight = 250
const UpgradeOrangeHeight = 300
const UpgradeActorsV3Height = 600
const UpgradeTrustHeight = 600
const UpgradeNorwegianHeight = 114000
const UpgradeActorsV4Height = 193789
const UpgradeTurboHeight = 193789
const UpgradeHyperdriveHeight = 9999999
func init() {
policy.SetConsensusMinerMinPower(abi.NewStoragePower(32 << 30))

104
build/params_interop.go Normal file
View File

@ -0,0 +1,104 @@
// +build interopnet
package build
import (
"os"
"strconv"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/policy"
)
const BootstrappersFile = "interopnet.pi"
const GenesisFile = "interopnet.car"
var UpgradeBreezeHeight = abi.ChainEpoch(-1)
const BreezeGasTampingDuration = 0
var UpgradeSmokeHeight = abi.ChainEpoch(-1)
var UpgradeIgnitionHeight = abi.ChainEpoch(-2)
var UpgradeRefuelHeight = abi.ChainEpoch(-3)
var UpgradeTapeHeight = abi.ChainEpoch(-4)
var UpgradeAssemblyHeight = abi.ChainEpoch(-5)
var UpgradeLiftoffHeight = abi.ChainEpoch(-6)
var UpgradeKumquatHeight = abi.ChainEpoch(-7)
var UpgradeCalicoHeight = abi.ChainEpoch(-8)
var UpgradePersianHeight = abi.ChainEpoch(-9)
var UpgradeOrangeHeight = abi.ChainEpoch(-10)
var UpgradeClausHeight = abi.ChainEpoch(-11)
var UpgradeTrustHeight = abi.ChainEpoch(-12)
var UpgradeNorwegianHeight = abi.ChainEpoch(-13)
var UpgradeTurboHeight = abi.ChainEpoch(-14)
var UpgradeHyperdriveHeight = abi.ChainEpoch(-15)
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
}
func init() {
policy.SetSupportedProofTypes(
abi.RegisteredSealProof_StackedDrg2KiBV1,
abi.RegisteredSealProof_StackedDrg8MiBV1,
abi.RegisteredSealProof_StackedDrg512MiBV1,
)
policy.SetConsensusMinerMinPower(abi.NewStoragePower(2048))
policy.SetMinVerifiedDealSize(abi.NewStoragePower(256))
policy.SetPreCommitChallengeDelay(abi.ChainEpoch(10))
getUpgradeHeight := func(ev string, def abi.ChainEpoch) abi.ChainEpoch {
hs, found := os.LookupEnv(ev)
if found {
h, err := strconv.Atoi(hs)
if err != nil {
log.Panicf("failed to parse %s env var", ev)
}
return abi.ChainEpoch(h)
}
return def
}
UpgradeBreezeHeight = getUpgradeHeight("LOTUS_BREEZE_HEIGHT", UpgradeBreezeHeight)
UpgradeSmokeHeight = getUpgradeHeight("LOTUS_SMOKE_HEIGHT", UpgradeSmokeHeight)
UpgradeIgnitionHeight = getUpgradeHeight("LOTUS_IGNITION_HEIGHT", UpgradeIgnitionHeight)
UpgradeRefuelHeight = getUpgradeHeight("LOTUS_REFUEL_HEIGHT", UpgradeRefuelHeight)
UpgradeTapeHeight = getUpgradeHeight("LOTUS_TAPE_HEIGHT", UpgradeTapeHeight)
UpgradeAssemblyHeight = getUpgradeHeight("LOTUS_ACTORSV2_HEIGHT", UpgradeAssemblyHeight)
UpgradeLiftoffHeight = getUpgradeHeight("LOTUS_LIFTOFF_HEIGHT", UpgradeLiftoffHeight)
UpgradeKumquatHeight = getUpgradeHeight("LOTUS_KUMQUAT_HEIGHT", UpgradeKumquatHeight)
UpgradeCalicoHeight = getUpgradeHeight("LOTUS_CALICO_HEIGHT", UpgradeCalicoHeight)
UpgradePersianHeight = getUpgradeHeight("LOTUS_PERSIAN_HEIGHT", UpgradePersianHeight)
UpgradeOrangeHeight = getUpgradeHeight("LOTUS_ORANGE_HEIGHT", UpgradeOrangeHeight)
UpgradeClausHeight = getUpgradeHeight("LOTUS_CLAUS_HEIGHT", UpgradeClausHeight)
UpgradeTrustHeight = getUpgradeHeight("LOTUS_ACTORSV3_HEIGHT", UpgradeTrustHeight)
UpgradeNorwegianHeight = getUpgradeHeight("LOTUS_NORWEGIAN_HEIGHT", UpgradeNorwegianHeight)
UpgradeTurboHeight = getUpgradeHeight("LOTUS_ACTORSV4_HEIGHT", UpgradeTurboHeight)
UpgradeHyperdriveHeight = getUpgradeHeight("LOTUS_HYPERDRIVE_HEIGHT", UpgradeHyperdriveHeight)
BuildType |= BuildInteropnet
SetAddressNetwork(address.Testnet)
Devnet = true
}
const BlockDelaySecs = uint64(builtin2.EpochDurationSeconds)
const PropagationDelaySecs = uint64(6)
// BootstrapPeerThreshold is the minimum number peers we need to track for a sync worker to start
const BootstrapPeerThreshold = 2
var WhitelistedBlock = cid.Undef

View File

@ -4,6 +4,7 @@
// +build !calibnet
// +build !nerpanet
// +build !butterflynet
// +build !interopnet
package build
@ -13,7 +14,6 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/actors/policy"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
)
@ -34,7 +34,7 @@ const UpgradeSmokeHeight = 51000
const UpgradeIgnitionHeight = 94000
const UpgradeRefuelHeight = 130800
const UpgradeActorsV2Height = 138720
const UpgradeAssemblyHeight = 138720
const UpgradeTapeHeight = 140760
@ -51,30 +51,27 @@ const UpgradePersianHeight = UpgradeCalicoHeight + (builtin2.EpochsInHour * 60)
const UpgradeOrangeHeight = 336458
// 2020-12-22T02:00:00Z
const UpgradeClausHeight = 343200
var UpgradeClausHeight = abi.ChainEpoch(343200)
// 2021-03-04T00:00:30Z
var UpgradeActorsV3Height = abi.ChainEpoch(550321)
const UpgradeTrustHeight = 550321
// 2021-04-12T22:00:00Z
const UpgradeNorwegianHeight = 665280
// 2021-04-29T06:00:00Z
var UpgradeActorsV4Height = abi.ChainEpoch(712320)
const UpgradeTurboHeight = 712320
// ???
var UpgradeHyperdriveHeight = abi.ChainEpoch(9999999)
func init() {
policy.SetConsensusMinerMinPower(abi.NewStoragePower(10 << 40))
if os.Getenv("LOTUS_USE_TEST_ADDRESSES") != "1" {
SetAddressNetwork(address.Mainnet)
}
if os.Getenv("LOTUS_DISABLE_V3_ACTOR_MIGRATION") == "1" {
UpgradeActorsV3Height = math.MaxInt64
}
if os.Getenv("LOTUS_DISABLE_V4_ACTOR_MIGRATION") == "1" {
UpgradeActorsV4Height = math.MaxInt64
if os.Getenv("LOTUS_DISABLE_HYPERDRIVE") == "1" {
UpgradeHyperdriveHeight = math.MaxInt64
}
Devnet = false

View File

@ -27,7 +27,7 @@ const UpgradeRefuelHeight = -3
const UpgradeLiftoffHeight = -5
const UpgradeActorsV2Height = 30 // critical: the network can bootstrap from v1 only
const UpgradeAssemblyHeight = 30 // critical: the network can bootstrap from v1 only
const UpgradeTapeHeight = 60
const UpgradeKumquatHeight = 90
@ -39,9 +39,10 @@ const UpgradeClausHeight = 250
const UpgradeOrangeHeight = 300
const UpgradeActorsV3Height = 600
const UpgradeTrustHeight = 600
const UpgradeNorwegianHeight = 201000
const UpgradeActorsV4Height = 203000
const UpgradeTurboHeight = 203000
const UpgradeHyperdriveHeight = 999999999
func init() {
// Minimum block production power is set to 4 TiB

View File

@ -25,7 +25,7 @@ const UnixfsLinksPerLevel = 1024
// Consensus / Network
const AllowableClockDriftSecs = uint64(1)
const NewestNetworkVersion = network.Version11
const NewestNetworkVersion = network.Version13
const ActorUpgradeNetworkVersion = network.Version4
// Epochs

View File

@ -82,20 +82,21 @@ var (
UpgradeBreezeHeight abi.ChainEpoch = -1
BreezeGasTampingDuration abi.ChainEpoch = 0
UpgradeSmokeHeight abi.ChainEpoch = -1
UpgradeIgnitionHeight abi.ChainEpoch = -2
UpgradeRefuelHeight abi.ChainEpoch = -3
UpgradeTapeHeight abi.ChainEpoch = -4
UpgradeActorsV2Height abi.ChainEpoch = 10
UpgradeLiftoffHeight abi.ChainEpoch = -5
UpgradeKumquatHeight abi.ChainEpoch = -6
UpgradeCalicoHeight abi.ChainEpoch = -7
UpgradePersianHeight abi.ChainEpoch = -8
UpgradeOrangeHeight abi.ChainEpoch = -9
UpgradeClausHeight abi.ChainEpoch = -10
UpgradeActorsV3Height abi.ChainEpoch = -11
UpgradeNorwegianHeight abi.ChainEpoch = -12
UpgradeActorsV4Height abi.ChainEpoch = -13
UpgradeSmokeHeight abi.ChainEpoch = -1
UpgradeIgnitionHeight abi.ChainEpoch = -2
UpgradeRefuelHeight abi.ChainEpoch = -3
UpgradeTapeHeight abi.ChainEpoch = -4
UpgradeAssemblyHeight abi.ChainEpoch = 10
UpgradeLiftoffHeight abi.ChainEpoch = -5
UpgradeKumquatHeight abi.ChainEpoch = -6
UpgradeCalicoHeight abi.ChainEpoch = -7
UpgradePersianHeight abi.ChainEpoch = -8
UpgradeOrangeHeight abi.ChainEpoch = -9
UpgradeClausHeight abi.ChainEpoch = -10
UpgradeTrustHeight abi.ChainEpoch = -11
UpgradeNorwegianHeight abi.ChainEpoch = -12
UpgradeTurboHeight abi.ChainEpoch = -13
UpgradeHyperdriveHeight abi.ChainEpoch = -13
DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,

View File

@ -0,0 +1,7 @@
{
"v28-fil-inner-product-v1.srs": {
"cid": "Qmdq44DjcQnFfU3PJcdX7J49GCqcUYszr1TxMbHtAkvQ3g",
"digest": "ae20310138f5ba81451d723f858e3797",
"sector_size": 0
}
}

View File

@ -6,11 +6,12 @@ var CurrentCommit string
var BuildType int
const (
BuildDefault = 0
BuildMainnet = 0x1
Build2k = 0x2
BuildDebug = 0x3
BuildCalibnet = 0x4
BuildDefault = 0
BuildMainnet = 0x1
Build2k = 0x2
BuildDebug = 0x3
BuildCalibnet = 0x4
BuildInteropnet = 0x5
)
func buildType() string {
@ -25,6 +26,8 @@ func buildType() string {
return "+debug"
case BuildCalibnet:
return "+calibnet"
case BuildInteropnet:
return "+interopnet"
default:
return "+huh?"
}

View File

@ -6,33 +6,26 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strconv"
"text/template"
lotusactors "github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
)
var latestVersion = 4
var versions = []int{0, 2, 3, latestVersion}
var versionImports = map[int]string{
0: "/",
2: "/v2/",
3: "/v3/",
latestVersion: "/v4/",
}
var actors = map[string][]int{
"account": versions,
"cron": versions,
"init": versions,
"market": versions,
"miner": versions,
"multisig": versions,
"paych": versions,
"power": versions,
"reward": versions,
"verifreg": versions,
"account": lotusactors.Versions,
"cron": lotusactors.Versions,
"init": lotusactors.Versions,
"market": lotusactors.Versions,
"miner": lotusactors.Versions,
"multisig": lotusactors.Versions,
"paych": lotusactors.Versions,
"power": lotusactors.Versions,
"system": lotusactors.Versions,
"reward": lotusactors.Versions,
"verifreg": lotusactors.Versions,
}
func main() {
@ -71,14 +64,14 @@ func generateAdapters() error {
}
tpl := template.Must(template.New("").Funcs(template.FuncMap{
"import": func(v int) string { return versionImports[v] },
"import": func(v int) string { return getVersionImports()[v] },
}).Parse(string(af)))
var b bytes.Buffer
err = tpl.Execute(&b, map[string]interface{}{
"versions": versions,
"latestVersion": latestVersion,
"latestVersion": lotusactors.LatestVersion,
})
if err != nil {
return err
@ -103,14 +96,14 @@ func generateState(actDir string) error {
return xerrors.Errorf("loading state adapter template: %w", err)
}
for _, version := range versions {
for _, version := range lotusactors.Versions {
tpl := template.Must(template.New("").Funcs(template.FuncMap{}).Parse(string(af)))
var b bytes.Buffer
err := tpl.Execute(&b, map[string]interface{}{
"v": version,
"import": versionImports[version],
"import": getVersionImports()[version],
})
if err != nil {
return err
@ -134,14 +127,14 @@ func generateMessages(actDir string) error {
return xerrors.Errorf("loading message adapter template: %w", err)
}
for _, version := range versions {
for _, version := range lotusactors.Versions {
tpl := template.Must(template.New("").Funcs(template.FuncMap{}).Parse(string(af)))
var b bytes.Buffer
err := tpl.Execute(&b, map[string]interface{}{
"v": version,
"import": versionImports[version],
"import": getVersionImports()[version],
})
if err != nil {
return err
@ -167,13 +160,13 @@ func generatePolicy(policyPath string) error {
}
tpl := template.Must(template.New("").Funcs(template.FuncMap{
"import": func(v int) string { return versionImports[v] },
"import": func(v int) string { return getVersionImports()[v] },
}).Parse(string(pf)))
var b bytes.Buffer
err = tpl.Execute(&b, map[string]interface{}{
"versions": versions,
"latestVersion": latestVersion,
"versions": lotusactors.Versions,
"latestVersion": lotusactors.LatestVersion,
})
if err != nil {
return err
@ -198,13 +191,13 @@ func generateBuiltin(builtinPath string) error {
}
tpl := template.Must(template.New("").Funcs(template.FuncMap{
"import": func(v int) string { return versionImports[v] },
"import": func(v int) string { return getVersionImports()[v] },
}).Parse(string(bf)))
var b bytes.Buffer
err = tpl.Execute(&b, map[string]interface{}{
"versions": versions,
"latestVersion": latestVersion,
"versions": lotusactors.Versions,
"latestVersion": lotusactors.LatestVersion,
})
if err != nil {
return err
@ -216,3 +209,16 @@ func generateBuiltin(builtinPath string) error {
return nil
}
func getVersionImports() map[int]string {
versionImports := make(map[int]string, lotusactors.LatestVersion)
for _, v := range lotusactors.Versions {
if v == 0 {
versionImports[v] = "/"
} else {
versionImports[v] = "/v" + strconv.Itoa(v) + "/"
}
}
return versionImports
}

View File

@ -1,6 +1,7 @@
package account
import (
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
@ -18,6 +19,8 @@ import (
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
)
func init() {
@ -37,6 +40,10 @@ func init() {
builtin.RegisterActorState(builtin4.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
builtin.RegisterActorState(builtin5.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}
var Methods = builtin4.MethodsAccount
@ -56,12 +63,61 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case builtin4.AccountActorCodeID:
return load4(store, act.Head)
case builtin5.AccountActorCodeID:
return load5(store, act.Head)
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, addr address.Address) (State, error) {
switch av {
case actors.Version0:
return make0(store, addr)
case actors.Version2:
return make2(store, addr)
case actors.Version3:
return make3(store, addr)
case actors.Version4:
return make4(store, addr)
case actors.Version5:
return make5(store, addr)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.AccountActorCodeID, nil
case actors.Version2:
return builtin2.AccountActorCodeID, nil
case actors.Version3:
return builtin3.AccountActorCodeID, nil
case actors.Version4:
return builtin4.AccountActorCodeID, nil
case actors.Version5:
return builtin5.AccountActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
PubkeyAddress() (address.Address, error)
GetState() interface{}
}

View File

@ -1,6 +1,7 @@
package account
import (
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
@ -34,8 +35,30 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, addr address.Address) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return make{{.}}(store, addr)
{{end}}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.AccountActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
PubkeyAddress() (address.Address, error)
GetState() interface{}
}

View File

@ -20,6 +20,12 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make{{.v}}(store adt.Store, addr address.Address) (State, error) {
out := state{{.v}}{store: store}
out.State = account{{.v}}.State{Address:addr}
return &out, nil
}
type state{{.v}} struct {
account{{.v}}.State
store adt.Store
@ -28,3 +34,7 @@ type state{{.v}} struct {
func (s *state{{.v}}) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}

View File

@ -20,6 +20,12 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make0(store adt.Store, addr address.Address) (State, error) {
out := state0{store: store}
out.State = account0.State{Address: addr}
return &out, nil
}
type state0 struct {
account0.State
store adt.Store
@ -28,3 +34,7 @@ type state0 struct {
func (s *state0) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
func (s *state0) GetState() interface{} {
return &s.State
}

View File

@ -20,6 +20,12 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make2(store adt.Store, addr address.Address) (State, error) {
out := state2{store: store}
out.State = account2.State{Address: addr}
return &out, nil
}
type state2 struct {
account2.State
store adt.Store
@ -28,3 +34,7 @@ type state2 struct {
func (s *state2) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
func (s *state2) GetState() interface{} {
return &s.State
}

View File

@ -20,6 +20,12 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make3(store adt.Store, addr address.Address) (State, error) {
out := state3{store: store}
out.State = account3.State{Address: addr}
return &out, nil
}
type state3 struct {
account3.State
store adt.Store
@ -28,3 +34,7 @@ type state3 struct {
func (s *state3) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
func (s *state3) GetState() interface{} {
return &s.State
}

View File

@ -20,6 +20,12 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make4(store adt.Store, addr address.Address) (State, error) {
out := state4{store: store}
out.State = account4.State{Address: addr}
return &out, nil
}
type state4 struct {
account4.State
store adt.Store
@ -28,3 +34,7 @@ type state4 struct {
func (s *state4) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
func (s *state4) GetState() interface{} {
return &s.State
}

View File

@ -0,0 +1,40 @@
package account
import (
"github.com/filecoin-project/go-address"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
account5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/account"
)
var _ State = (*state5)(nil)
func load5(store adt.Store, root cid.Cid) (State, error) {
out := state5{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make5(store adt.Store, addr address.Address) (State, error) {
out := state5{store: store}
out.State = account5.State{Address: addr}
return &out, nil
}
type state5 struct {
account5.State
store adt.Store
}
func (s *state5) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
func (s *state5) GetState() interface{} {
return &s.State
}

View File

@ -17,46 +17,49 @@ import (
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
smoothing4 "github.com/filecoin-project/specs-actors/v4/actors/util/smoothing"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
smoothing5 "github.com/filecoin-project/specs-actors/v5/actors/util/smoothing"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
miner4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/miner"
proof4 "github.com/filecoin-project/specs-actors/v4/actors/runtime/proof"
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
)
var SystemActorAddr = builtin4.SystemActorAddr
var BurntFundsActorAddr = builtin4.BurntFundsActorAddr
var CronActorAddr = builtin4.CronActorAddr
var SystemActorAddr = builtin5.SystemActorAddr
var BurntFundsActorAddr = builtin5.BurntFundsActorAddr
var CronActorAddr = builtin5.CronActorAddr
var SaftAddress = makeAddress("t0122")
var ReserveAddress = makeAddress("t090")
var RootVerifierAddress = makeAddress("t080")
var (
ExpectedLeadersPerEpoch = builtin4.ExpectedLeadersPerEpoch
ExpectedLeadersPerEpoch = builtin5.ExpectedLeadersPerEpoch
)
const (
EpochDurationSeconds = builtin4.EpochDurationSeconds
EpochsInDay = builtin4.EpochsInDay
SecondsInDay = builtin4.SecondsInDay
EpochDurationSeconds = builtin5.EpochDurationSeconds
EpochsInDay = builtin5.EpochsInDay
SecondsInDay = builtin5.SecondsInDay
)
const (
MethodSend = builtin4.MethodSend
MethodConstructor = builtin4.MethodConstructor
MethodSend = builtin5.MethodSend
MethodConstructor = builtin5.MethodConstructor
)
// These are all just type aliases across actor versions. In the future, that might change
// and we might need to do something fancier.
type SectorInfo = proof4.SectorInfo
type PoStProof = proof4.PoStProof
type SectorInfo = proof5.SectorInfo
type PoStProof = proof5.PoStProof
type FilterEstimate = smoothing0.FilterEstimate
func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower {
return miner4.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
return miner5.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
}
func FromV0FilterEstimate(v0 smoothing0.FilterEstimate) FilterEstimate {
@ -83,6 +86,12 @@ func FromV4FilterEstimate(v4 smoothing4.FilterEstimate) FilterEstimate {
}
func FromV5FilterEstimate(v5 smoothing5.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v5)
}
type ActorStateLoader func(store adt.Store, root cid.Cid) (cbor.Marshaler, error)
var ActorStateLoaders = make(map[cid.Cid]ActorStateLoader)
@ -114,6 +123,9 @@ func ActorNameByCode(c cid.Cid) string {
case builtin4.IsBuiltinActor(c):
return builtin4.ActorNameByCode(c)
case builtin5.IsBuiltinActor(c):
return builtin5.ActorNameByCode(c)
default:
return "<unknown>"
}
@ -137,6 +149,10 @@ func IsBuiltinActor(c cid.Cid) bool {
return true
}
if builtin5.IsBuiltinActor(c) {
return true
}
return false
}
@ -158,6 +174,10 @@ func IsAccountActor(c cid.Cid) bool {
return true
}
if c == builtin5.AccountActorCodeID {
return true
}
return false
}
@ -179,6 +199,10 @@ func IsStorageMinerActor(c cid.Cid) bool {
return true
}
if c == builtin5.StorageMinerActorCodeID {
return true
}
return false
}
@ -200,6 +224,10 @@ func IsMultisigActor(c cid.Cid) bool {
return true
}
if c == builtin5.MultisigActorCodeID {
return true
}
return false
}
@ -221,6 +249,10 @@ func IsPaymentChannelActor(c cid.Cid) bool {
return true
}
if c == builtin5.PaymentChannelActorCodeID {
return true
}
return false
}

View File

@ -6,9 +6,9 @@ import (
"golang.org/x/xerrors"
{{range .versions}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
smoothing{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/util/smoothing"
{{end}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
smoothing{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/util/smoothing"
{{end}}
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
@ -17,7 +17,7 @@ import (
"github.com/filecoin-project/lotus/chain/types"
miner{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/builtin/miner"
proof{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/runtime/proof"
proof{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/runtime/proof"
)
var SystemActorAddr = builtin{{.latestVersion}}.SystemActorAddr
@ -53,13 +53,13 @@ func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight,
}
{{range .versions}}
func FromV{{.}}FilterEstimate(v{{.}} smoothing{{.}}.FilterEstimate) FilterEstimate {
func FromV{{.}}FilterEstimate(v{{.}} smoothing{{.}}.FilterEstimate) FilterEstimate {
{{if (eq . 0)}}
return (FilterEstimate)(v{{.}}) //nolint:unconvert
{{else}}
return (FilterEstimate)(v{{.}})
{{end}}
}
return (FilterEstimate)(v{{.}}) //nolint:unconvert
{{else}}
return (FilterEstimate)(v{{.}})
{{end}}
}
{{end}}
type ActorStateLoader func(store adt.Store, root cid.Cid) (cbor.Marshaler, error)
@ -80,58 +80,58 @@ func Load(store adt.Store, act *types.Actor) (cbor.Marshaler, error) {
func ActorNameByCode(c cid.Cid) string {
switch {
{{range .versions}}
case builtin{{.}}.IsBuiltinActor(c):
return builtin{{.}}.ActorNameByCode(c)
{{end}}
{{range .versions}}
case builtin{{.}}.IsBuiltinActor(c):
return builtin{{.}}.ActorNameByCode(c)
{{end}}
default:
return "<unknown>"
}
}
func IsBuiltinActor(c cid.Cid) bool {
{{range .versions}}
if builtin{{.}}.IsBuiltinActor(c) {
return true
}
{{end}}
return false
{{range .versions}}
if builtin{{.}}.IsBuiltinActor(c) {
return true
}
{{end}}
return false
}
func IsAccountActor(c cid.Cid) bool {
{{range .versions}}
if c == builtin{{.}}.AccountActorCodeID {
return true
}
{{end}}
return false
{{range .versions}}
if c == builtin{{.}}.AccountActorCodeID {
return true
}
{{end}}
return false
}
func IsStorageMinerActor(c cid.Cid) bool {
{{range .versions}}
if c == builtin{{.}}.StorageMinerActorCodeID {
return true
}
{{end}}
return false
{{range .versions}}
if c == builtin{{.}}.StorageMinerActorCodeID {
return true
}
{{end}}
return false
}
func IsMultisigActor(c cid.Cid) bool {
{{range .versions}}
if c == builtin{{.}}.MultisigActorCodeID {
return true
}
{{end}}
return false
{{range .versions}}
if c == builtin{{.}}.MultisigActorCodeID {
return true
}
{{end}}
return false
}
func IsPaymentChannelActor(c cid.Cid) bool {
{{range .versions}}
if c == builtin{{.}}.PaymentChannelActorCodeID {
return true
}
{{end}}
return false
{{range .versions}}
if c == builtin{{.}}.PaymentChannelActorCodeID {
return true
}
{{end}}
return false
}
func makeAddress(addr string) address.Address {

View File

@ -1,10 +1,42 @@
package cron
import (
builtin{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"golang.org/x/xerrors"
"github.com/ipfs/go-cid"
{{range .versions}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{end}}
)
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return make{{.}}(store)
{{end}}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.CronActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
var (
Address = builtin{{.latestVersion}}.CronActorAddr
Methods = builtin{{.latestVersion}}.MethodsCron
)
type State interface {
GetState() interface{}
}

View File

@ -1,10 +1,72 @@
package cron
import (
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
)
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
case actors.Version0:
return make0(store)
case actors.Version2:
return make2(store)
case actors.Version3:
return make3(store)
case actors.Version4:
return make4(store)
case actors.Version5:
return make5(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.CronActorCodeID, nil
case actors.Version2:
return builtin2.CronActorCodeID, nil
case actors.Version3:
return builtin3.CronActorCodeID, nil
case actors.Version4:
return builtin4.CronActorCodeID, nil
case actors.Version5:
return builtin5.CronActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
var (
Address = builtin4.CronActorAddr
Methods = builtin4.MethodsCron
Address = builtin5.CronActorAddr
Methods = builtin5.MethodsCron
)
type State interface {
GetState() interface{}
}

View File

@ -0,0 +1,35 @@
package cron
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
cron{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/cron"
)
var _ State = (*state{{.v}})(nil)
func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
out := state{{.v}}{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make{{.v}}(store adt.Store) (State, error) {
out := state{{.v}}{store: store}
out.State = *cron{{.v}}.ConstructState(cron{{.v}}.BuiltInEntries())
return &out, nil
}
type state{{.v}} struct {
cron{{.v}}.State
store adt.Store
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}

View File

@ -0,0 +1,35 @@
package cron
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
cron0 "github.com/filecoin-project/specs-actors/actors/builtin/cron"
)
var _ State = (*state0)(nil)
func load0(store adt.Store, root cid.Cid) (State, error) {
out := state0{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make0(store adt.Store) (State, error) {
out := state0{store: store}
out.State = *cron0.ConstructState(cron0.BuiltInEntries())
return &out, nil
}
type state0 struct {
cron0.State
store adt.Store
}
func (s *state0) GetState() interface{} {
return &s.State
}

View File

@ -0,0 +1,35 @@
package cron
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
cron2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/cron"
)
var _ State = (*state2)(nil)
func load2(store adt.Store, root cid.Cid) (State, error) {
out := state2{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make2(store adt.Store) (State, error) {
out := state2{store: store}
out.State = *cron2.ConstructState(cron2.BuiltInEntries())
return &out, nil
}
type state2 struct {
cron2.State
store adt.Store
}
func (s *state2) GetState() interface{} {
return &s.State
}

View File

@ -0,0 +1,35 @@
package cron
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
cron3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/cron"
)
var _ State = (*state3)(nil)
func load3(store adt.Store, root cid.Cid) (State, error) {
out := state3{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make3(store adt.Store) (State, error) {
out := state3{store: store}
out.State = *cron3.ConstructState(cron3.BuiltInEntries())
return &out, nil
}
type state3 struct {
cron3.State
store adt.Store
}
func (s *state3) GetState() interface{} {
return &s.State
}

View File

@ -0,0 +1,35 @@
package cron
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
cron4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/cron"
)
var _ State = (*state4)(nil)
func load4(store adt.Store, root cid.Cid) (State, error) {
out := state4{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make4(store adt.Store) (State, error) {
out := state4{store: store}
out.State = *cron4.ConstructState(cron4.BuiltInEntries())
return &out, nil
}
type state4 struct {
cron4.State
store adt.Store
}
func (s *state4) GetState() interface{} {
return &s.State
}

View File

@ -0,0 +1,35 @@
package cron
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
cron5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/cron"
)
var _ State = (*state5)(nil)
func load5(store adt.Store, root cid.Cid) (State, error) {
out := state5{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make5(store adt.Store) (State, error) {
out := state5{store: store}
out.State = *cron5.ConstructState(cron5.BuiltInEntries())
return &out, nil
}
type state5 struct {
cron5.State
store adt.Store
}
func (s *state5) GetState() interface{} {
return &s.State
}

View File

@ -1,6 +1,7 @@
package init
import (
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
@ -39,6 +40,27 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, networkName string) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return make{{.}}(store, networkName)
{{end}}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.InitActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -56,5 +78,12 @@ type State interface {
// Sets the network's name. This should only be used on upgrade/fork.
SetNetworkName(name string) error
addressMap() (adt.Map, error)
// Sets the next ID for the init actor. This should only be used for testing.
SetNextID(id abi.ActorID) error
// Sets the address map for the init actor. This should only be used for testing.
SetAddressMap(mcid cid.Cid) error
AddressMap() (adt.Map, error)
GetState() interface{}
}

View File

@ -11,12 +11,12 @@ import (
)
func DiffAddressMap(pre, cur State) (*AddressMapChanges, error) {
prem, err := pre.addressMap()
prem, err := pre.AddressMap()
if err != nil {
return nil, err
}
curm, err := cur.addressMap()
curm, err := cur.AddressMap()
if err != nil {
return nil, err
}

View File

@ -1,6 +1,7 @@
package init
import (
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
@ -20,6 +21,8 @@ import (
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
)
func init() {
@ -39,11 +42,15 @@ func init() {
builtin.RegisterActorState(builtin4.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
builtin.RegisterActorState(builtin5.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}
var (
Address = builtin4.InitActorAddr
Methods = builtin4.MethodsInit
Address = builtin5.InitActorAddr
Methods = builtin5.MethodsInit
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -61,10 +68,58 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case builtin4.InitActorCodeID:
return load4(store, act.Head)
case builtin5.InitActorCodeID:
return load5(store, act.Head)
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, networkName string) (State, error) {
switch av {
case actors.Version0:
return make0(store, networkName)
case actors.Version2:
return make2(store, networkName)
case actors.Version3:
return make3(store, networkName)
case actors.Version4:
return make4(store, networkName)
case actors.Version5:
return make5(store, networkName)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.InitActorCodeID, nil
case actors.Version2:
return builtin2.InitActorCodeID, nil
case actors.Version3:
return builtin3.InitActorCodeID, nil
case actors.Version4:
return builtin4.InitActorCodeID, nil
case actors.Version5:
return builtin5.InitActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -82,5 +137,12 @@ type State interface {
// Sets the network's name. This should only be used on upgrade/fork.
SetNetworkName(name string) error
addressMap() (adt.Map, error)
// Sets the next ID for the init actor. This should only be used for testing.
SetNextID(id abi.ActorID) error
// Sets the address map for the init actor. This should only be used for testing.
SetAddressMap(mcid cid.Cid) error
AddressMap() (adt.Map, error)
GetState() interface{}
}

View File

@ -29,6 +29,26 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make{{.v}}(store adt.Store, networkName string) (State, error) {
out := state{{.v}}{store: store}
{{if (le .v 2)}}
mr, err := adt{{.v}}.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *init{{.v}}.ConstructState(mr, networkName)
{{else}}
s, err := init{{.v}}.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
{{end}}
return &out, nil
}
type state{{.v}} struct {
init{{.v}}.State
store adt.Store
@ -66,6 +86,11 @@ func (s *state{{.v}}) SetNetworkName(name string) error {
return nil
}
func (s *state{{.v}}) SetNextID(id abi.ActorID) error {
s.State.NextID = id
return nil
}
func (s *state{{.v}}) Remove(addrs ...address.Address) (err error) {
m, err := adt{{.v}}.AsMap(s.store, s.State.AddressMap{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}})
if err != nil {
@ -84,6 +109,15 @@ func (s *state{{.v}}) Remove(addrs ...address.Address) (err error) {
return nil
}
func (s *state{{.v}}) addressMap() (adt.Map, error) {
return adt{{.v}}.AsMap(s.store, s.AddressMap{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}})
func (s *state{{.v}}) SetAddressMap(mcid cid.Cid) error {
s.State.AddressMap = mcid
return nil
}
func (s *state{{.v}}) AddressMap() (adt.Map, error) {
return adt{{.v}}.AsMap(s.store, s.State.AddressMap{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}})
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}

View File

@ -25,6 +25,19 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make0(store adt.Store, networkName string) (State, error) {
out := state0{store: store}
mr, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *init0.ConstructState(mr, networkName)
return &out, nil
}
type state0 struct {
init0.State
store adt.Store
@ -62,6 +75,11 @@ func (s *state0) SetNetworkName(name string) error {
return nil
}
func (s *state0) SetNextID(id abi.ActorID) error {
s.State.NextID = id
return nil
}
func (s *state0) Remove(addrs ...address.Address) (err error) {
m, err := adt0.AsMap(s.store, s.State.AddressMap)
if err != nil {
@ -80,6 +98,15 @@ func (s *state0) Remove(addrs ...address.Address) (err error) {
return nil
}
func (s *state0) addressMap() (adt.Map, error) {
return adt0.AsMap(s.store, s.AddressMap)
func (s *state0) SetAddressMap(mcid cid.Cid) error {
s.State.AddressMap = mcid
return nil
}
func (s *state0) AddressMap() (adt.Map, error) {
return adt0.AsMap(s.store, s.State.AddressMap)
}
func (s *state0) GetState() interface{} {
return &s.State
}

View File

@ -25,6 +25,19 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make2(store adt.Store, networkName string) (State, error) {
out := state2{store: store}
mr, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *init2.ConstructState(mr, networkName)
return &out, nil
}
type state2 struct {
init2.State
store adt.Store
@ -62,6 +75,11 @@ func (s *state2) SetNetworkName(name string) error {
return nil
}
func (s *state2) SetNextID(id abi.ActorID) error {
s.State.NextID = id
return nil
}
func (s *state2) Remove(addrs ...address.Address) (err error) {
m, err := adt2.AsMap(s.store, s.State.AddressMap)
if err != nil {
@ -80,6 +98,15 @@ func (s *state2) Remove(addrs ...address.Address) (err error) {
return nil
}
func (s *state2) addressMap() (adt.Map, error) {
return adt2.AsMap(s.store, s.AddressMap)
func (s *state2) SetAddressMap(mcid cid.Cid) error {
s.State.AddressMap = mcid
return nil
}
func (s *state2) AddressMap() (adt.Map, error) {
return adt2.AsMap(s.store, s.State.AddressMap)
}
func (s *state2) GetState() interface{} {
return &s.State
}

View File

@ -27,6 +27,19 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make3(store adt.Store, networkName string) (State, error) {
out := state3{store: store}
s, err := init3.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state3 struct {
init3.State
store adt.Store
@ -64,6 +77,11 @@ func (s *state3) SetNetworkName(name string) error {
return nil
}
func (s *state3) SetNextID(id abi.ActorID) error {
s.State.NextID = id
return nil
}
func (s *state3) Remove(addrs ...address.Address) (err error) {
m, err := adt3.AsMap(s.store, s.State.AddressMap, builtin3.DefaultHamtBitwidth)
if err != nil {
@ -82,6 +100,15 @@ func (s *state3) Remove(addrs ...address.Address) (err error) {
return nil
}
func (s *state3) addressMap() (adt.Map, error) {
return adt3.AsMap(s.store, s.AddressMap, builtin3.DefaultHamtBitwidth)
func (s *state3) SetAddressMap(mcid cid.Cid) error {
s.State.AddressMap = mcid
return nil
}
func (s *state3) AddressMap() (adt.Map, error) {
return adt3.AsMap(s.store, s.State.AddressMap, builtin3.DefaultHamtBitwidth)
}
func (s *state3) GetState() interface{} {
return &s.State
}

View File

@ -27,6 +27,19 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make4(store adt.Store, networkName string) (State, error) {
out := state4{store: store}
s, err := init4.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state4 struct {
init4.State
store adt.Store
@ -64,6 +77,11 @@ func (s *state4) SetNetworkName(name string) error {
return nil
}
func (s *state4) SetNextID(id abi.ActorID) error {
s.State.NextID = id
return nil
}
func (s *state4) Remove(addrs ...address.Address) (err error) {
m, err := adt4.AsMap(s.store, s.State.AddressMap, builtin4.DefaultHamtBitwidth)
if err != nil {
@ -82,6 +100,15 @@ func (s *state4) Remove(addrs ...address.Address) (err error) {
return nil
}
func (s *state4) addressMap() (adt.Map, error) {
return adt4.AsMap(s.store, s.AddressMap, builtin4.DefaultHamtBitwidth)
func (s *state4) SetAddressMap(mcid cid.Cid) error {
s.State.AddressMap = mcid
return nil
}
func (s *state4) AddressMap() (adt.Map, error) {
return adt4.AsMap(s.store, s.State.AddressMap, builtin4.DefaultHamtBitwidth)
}
func (s *state4) GetState() interface{} {
return &s.State
}

View File

@ -0,0 +1,114 @@
package init
import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/node/modules/dtypes"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
init5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/init"
adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt"
)
var _ State = (*state5)(nil)
func load5(store adt.Store, root cid.Cid) (State, error) {
out := state5{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make5(store adt.Store, networkName string) (State, error) {
out := state5{store: store}
s, err := init5.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state5 struct {
init5.State
store adt.Store
}
func (s *state5) ResolveAddress(address address.Address) (address.Address, bool, error) {
return s.State.ResolveAddress(s.store, address)
}
func (s *state5) MapAddressToNewID(address address.Address) (address.Address, error) {
return s.State.MapAddressToNewID(s.store, address)
}
func (s *state5) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error {
addrs, err := adt5.AsMap(s.store, s.State.AddressMap, builtin5.DefaultHamtBitwidth)
if err != nil {
return err
}
var actorID cbg.CborInt
return addrs.ForEach(&actorID, func(key string) error {
addr, err := address.NewFromBytes([]byte(key))
if err != nil {
return err
}
return cb(abi.ActorID(actorID), addr)
})
}
func (s *state5) NetworkName() (dtypes.NetworkName, error) {
return dtypes.NetworkName(s.State.NetworkName), nil
}
func (s *state5) SetNetworkName(name string) error {
s.State.NetworkName = name
return nil
}
func (s *state5) SetNextID(id abi.ActorID) error {
s.State.NextID = id
return nil
}
func (s *state5) Remove(addrs ...address.Address) (err error) {
m, err := adt5.AsMap(s.store, s.State.AddressMap, builtin5.DefaultHamtBitwidth)
if err != nil {
return err
}
for _, addr := range addrs {
if err = m.Delete(abi.AddrKey(addr)); err != nil {
return xerrors.Errorf("failed to delete entry for address: %s; err: %w", addr, err)
}
}
amr, err := m.Root()
if err != nil {
return xerrors.Errorf("failed to get address map root: %w", err)
}
s.State.AddressMap = amr
return nil
}
func (s *state5) SetAddressMap(mcid cid.Cid) error {
s.State.AddressMap = mcid
return nil
}
func (s *state5) AddressMap() (adt.Map, error) {
return adt5.AsMap(s.store, s.State.AddressMap, builtin5.DefaultHamtBitwidth)
}
func (s *state5) GetState() interface{} {
return &s.State
}

View File

@ -16,6 +16,7 @@ import (
{{end}}
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
)
@ -42,6 +43,27 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return make{{.}}(store)
{{end}}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.StorageMarketActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
BalancesChanged(State) (bool, error)
@ -56,6 +78,7 @@ type State interface {
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
) (weight, verifiedWeight abi.DealWeight, err error)
NextID() (abi.DealID, error)
GetState() interface{}
}
type BalanceTable interface {
@ -93,67 +116,67 @@ type DealState struct {
}
type DealProposal struct {
PieceCID cid.Cid
PieceSize abi.PaddedPieceSize
VerifiedDeal bool
Client address.Address
Provider address.Address
Label string
StartEpoch abi.ChainEpoch
EndEpoch abi.ChainEpoch
PieceCID cid.Cid
PieceSize abi.PaddedPieceSize
VerifiedDeal bool
Client address.Address
Provider address.Address
Label string
StartEpoch abi.ChainEpoch
EndEpoch abi.ChainEpoch
StoragePricePerEpoch abi.TokenAmount
ProviderCollateral abi.TokenAmount
ClientCollateral abi.TokenAmount
ProviderCollateral abi.TokenAmount
ClientCollateral abi.TokenAmount
}
type DealStateChanges struct {
Added []DealIDState
Added []DealIDState
Modified []DealStateChange
Removed []DealIDState
Removed []DealIDState
}
type DealIDState struct {
ID abi.DealID
ID abi.DealID
Deal DealState
}
// DealStateChange is a change in deal state from -> to
type DealStateChange struct {
ID abi.DealID
ID abi.DealID
From *DealState
To *DealState
To *DealState
}
type DealProposalChanges struct {
Added []ProposalIDState
Added []ProposalIDState
Removed []ProposalIDState
}
type ProposalIDState struct {
ID abi.DealID
ID abi.DealID
Proposal DealProposal
}
func EmptyDealState() *DealState {
return &DealState{
SectorStartEpoch: -1,
SlashEpoch: -1,
SlashEpoch: -1,
LastUpdatedEpoch: -1,
}
}
// returns the earned fees and pending fees for a given deal
func (deal DealProposal) GetDealFees(height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) {
tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch)))
tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch)))
ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch)))
if ef.LessThan(big.Zero()) {
ef = big.Zero()
}
ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch)))
if ef.LessThan(big.Zero()) {
ef = big.Zero()
}
if ef.GreaterThan(tf) {
ef = tf
}
if ef.GreaterThan(tf) {
ef = tf
}
return ef, big.Sub(tf, ef)
return ef, big.Sub(tf, ef)
}

View File

@ -20,6 +20,9 @@ import (
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
@ -42,11 +45,15 @@ func init() {
builtin.RegisterActorState(builtin4.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
builtin.RegisterActorState(builtin5.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}
var (
Address = builtin4.StorageMarketActorAddr
Methods = builtin4.MethodsMarket
Address = builtin5.StorageMarketActorAddr
Methods = builtin5.MethodsMarket
)
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -64,10 +71,58 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case builtin4.StorageMarketActorCodeID:
return load4(store, act.Head)
case builtin5.StorageMarketActorCodeID:
return load5(store, act.Head)
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
case actors.Version0:
return make0(store)
case actors.Version2:
return make2(store)
case actors.Version3:
return make3(store)
case actors.Version4:
return make4(store)
case actors.Version5:
return make5(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.StorageMarketActorCodeID, nil
case actors.Version2:
return builtin2.StorageMarketActorCodeID, nil
case actors.Version3:
return builtin3.StorageMarketActorCodeID, nil
case actors.Version4:
return builtin4.StorageMarketActorCodeID, nil
case actors.Version5:
return builtin5.StorageMarketActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
BalancesChanged(State) (bool, error)
@ -82,6 +137,7 @@ type State interface {
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
) (weight, verifiedWeight abi.DealWeight, err error)
NextID() (abi.DealID, error)
GetState() interface{}
}
type BalanceTable interface {

View File

@ -26,6 +26,31 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make{{.v}}(store adt.Store) (State, error) {
out := state{{.v}}{store: store}
{{if (le .v 2)}}
ea, err := adt{{.v}}.MakeEmptyArray(store).Root()
if err != nil {
return nil, err
}
em, err := adt{{.v}}.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *market{{.v}}.ConstructState(ea, em, em)
{{else}}
s, err := market{{.v}}.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
{{end}}
return &out, nil
}
type state{{.v}} struct {
market{{.v}}.State
store adt.Store
@ -207,3 +232,7 @@ func (s *dealProposals{{.v}}) array() adt.Array {
func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) DealProposal {
return (DealProposal)(v{{.v}})
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}

View File

@ -26,6 +26,24 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make0(store adt.Store) (State, error) {
out := state0{store: store}
ea, err := adt0.MakeEmptyArray(store).Root()
if err != nil {
return nil, err
}
em, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *market0.ConstructState(ea, em, em)
return &out, nil
}
type state0 struct {
market0.State
store adt.Store
@ -207,3 +225,7 @@ func (s *dealProposals0) array() adt.Array {
func fromV0DealProposal(v0 market0.DealProposal) DealProposal {
return (DealProposal)(v0)
}
func (s *state0) GetState() interface{} {
return &s.State
}

View File

@ -26,6 +26,24 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make2(store adt.Store) (State, error) {
out := state2{store: store}
ea, err := adt2.MakeEmptyArray(store).Root()
if err != nil {
return nil, err
}
em, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *market2.ConstructState(ea, em, em)
return &out, nil
}
type state2 struct {
market2.State
store adt.Store
@ -207,3 +225,7 @@ func (s *dealProposals2) array() adt.Array {
func fromV2DealProposal(v2 market2.DealProposal) DealProposal {
return (DealProposal)(v2)
}
func (s *state2) GetState() interface{} {
return &s.State
}

View File

@ -26,6 +26,19 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make3(store adt.Store) (State, error) {
out := state3{store: store}
s, err := market3.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state3 struct {
market3.State
store adt.Store
@ -207,3 +220,7 @@ func (s *dealProposals3) array() adt.Array {
func fromV3DealProposal(v3 market3.DealProposal) DealProposal {
return (DealProposal)(v3)
}
func (s *state3) GetState() interface{} {
return &s.State
}

View File

@ -26,6 +26,19 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make4(store adt.Store) (State, error) {
out := state4{store: store}
s, err := market4.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state4 struct {
market4.State
store adt.Store
@ -207,3 +220,7 @@ func (s *dealProposals4) array() adt.Array {
func fromV4DealProposal(v4 market4.DealProposal) DealProposal {
return (DealProposal)(v4)
}
func (s *state4) GetState() interface{} {
return &s.State
}

View File

@ -0,0 +1,226 @@
package market
import (
"bytes"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
market5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/market"
adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt"
)
var _ State = (*state5)(nil)
func load5(store adt.Store, root cid.Cid) (State, error) {
out := state5{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make5(store adt.Store) (State, error) {
out := state5{store: store}
s, err := market5.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state5 struct {
market5.State
store adt.Store
}
func (s *state5) TotalLocked() (abi.TokenAmount, error) {
fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral)
fml = types.BigAdd(fml, s.TotalClientStorageFee)
return fml, nil
}
func (s *state5) BalancesChanged(otherState State) (bool, error) {
otherState5, ok := otherState.(*state5)
if !ok {
// there's no way to compare different versions of the state, so let's
// just say that means the state of balances has changed
return true, nil
}
return !s.State.EscrowTable.Equals(otherState5.State.EscrowTable) || !s.State.LockedTable.Equals(otherState5.State.LockedTable), nil
}
func (s *state5) StatesChanged(otherState State) (bool, error) {
otherState5, ok := otherState.(*state5)
if !ok {
// there's no way to compare different versions of the state, so let's
// just say that means the state of balances has changed
return true, nil
}
return !s.State.States.Equals(otherState5.State.States), nil
}
func (s *state5) States() (DealStates, error) {
stateArray, err := adt5.AsArray(s.store, s.State.States, market5.StatesAmtBitwidth)
if err != nil {
return nil, err
}
return &dealStates5{stateArray}, nil
}
func (s *state5) ProposalsChanged(otherState State) (bool, error) {
otherState5, ok := otherState.(*state5)
if !ok {
// there's no way to compare different versions of the state, so let's
// just say that means the state of balances has changed
return true, nil
}
return !s.State.Proposals.Equals(otherState5.State.Proposals), nil
}
func (s *state5) Proposals() (DealProposals, error) {
proposalArray, err := adt5.AsArray(s.store, s.State.Proposals, market5.ProposalsAmtBitwidth)
if err != nil {
return nil, err
}
return &dealProposals5{proposalArray}, nil
}
func (s *state5) EscrowTable() (BalanceTable, error) {
bt, err := adt5.AsBalanceTable(s.store, s.State.EscrowTable)
if err != nil {
return nil, err
}
return &balanceTable5{bt}, nil
}
func (s *state5) LockedTable() (BalanceTable, error) {
bt, err := adt5.AsBalanceTable(s.store, s.State.LockedTable)
if err != nil {
return nil, err
}
return &balanceTable5{bt}, nil
}
func (s *state5) VerifyDealsForActivation(
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
) (weight, verifiedWeight abi.DealWeight, err error) {
w, vw, _, err := market5.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch)
return w, vw, err
}
func (s *state5) NextID() (abi.DealID, error) {
return s.State.NextID, nil
}
type balanceTable5 struct {
*adt5.BalanceTable
}
func (bt *balanceTable5) ForEach(cb func(address.Address, abi.TokenAmount) error) error {
asMap := (*adt5.Map)(bt.BalanceTable)
var ta abi.TokenAmount
return asMap.ForEach(&ta, func(key string) error {
a, err := address.NewFromBytes([]byte(key))
if err != nil {
return err
}
return cb(a, ta)
})
}
type dealStates5 struct {
adt.Array
}
func (s *dealStates5) Get(dealID abi.DealID) (*DealState, bool, error) {
var deal5 market5.DealState
found, err := s.Array.Get(uint64(dealID), &deal5)
if err != nil {
return nil, false, err
}
if !found {
return nil, false, nil
}
deal := fromV5DealState(deal5)
return &deal, true, nil
}
func (s *dealStates5) ForEach(cb func(dealID abi.DealID, ds DealState) error) error {
var ds5 market5.DealState
return s.Array.ForEach(&ds5, func(idx int64) error {
return cb(abi.DealID(idx), fromV5DealState(ds5))
})
}
func (s *dealStates5) decode(val *cbg.Deferred) (*DealState, error) {
var ds5 market5.DealState
if err := ds5.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
ds := fromV5DealState(ds5)
return &ds, nil
}
func (s *dealStates5) array() adt.Array {
return s.Array
}
func fromV5DealState(v5 market5.DealState) DealState {
return (DealState)(v5)
}
type dealProposals5 struct {
adt.Array
}
func (s *dealProposals5) Get(dealID abi.DealID) (*DealProposal, bool, error) {
var proposal5 market5.DealProposal
found, err := s.Array.Get(uint64(dealID), &proposal5)
if err != nil {
return nil, false, err
}
if !found {
return nil, false, nil
}
proposal := fromV5DealProposal(proposal5)
return &proposal, true, nil
}
func (s *dealProposals5) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
var dp5 market5.DealProposal
return s.Array.ForEach(&dp5, func(idx int64) error {
return cb(abi.DealID(idx), fromV5DealProposal(dp5))
})
}
func (s *dealProposals5) decode(val *cbg.Deferred) (*DealProposal, error) {
var dp5 market5.DealProposal
if err := dp5.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
dp := fromV5DealProposal(dp5)
return &dp, nil
}
func (s *dealProposals5) array() adt.Array {
return s.Array
}
func fromV5DealProposal(v5 market5.DealProposal) DealProposal {
return (DealProposal)(v5)
}
func (s *state5) GetState() interface{} {
return &s.State
}

View File

@ -3,6 +3,7 @@ package miner
import (
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
@ -60,6 +61,27 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return make{{.}}(store)
{{end}}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.StorageMinerActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -79,6 +101,11 @@ type State interface {
NumLiveSectors() (uint64, error)
IsAllocated(abi.SectorNumber) (bool, error)
// Note that ProvingPeriodStart is deprecated and will be renamed / removed in a future version of actors
GetProvingPeriodStart() (abi.ChainEpoch, error)
// Testing only
EraseAllUnproven() error
LoadDeadline(idx uint64) (Deadline, error)
ForEachDeadline(cb func(idx uint64, dl Deadline) error) error
NumDeadlines() (uint64, error)
@ -95,6 +122,7 @@ type State interface {
decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error)
precommits() (adt.Map, error)
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error)
GetState() interface{}
}
type Deadline interface {

View File

@ -3,6 +3,7 @@ package miner
import (
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
@ -29,6 +30,8 @@ import (
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
)
func init() {
@ -49,9 +52,13 @@ func init() {
return load4(store, root)
})
builtin.RegisterActorState(builtin5.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}
var Methods = builtin4.MethodsMiner
var Methods = builtin5.MethodsMiner
// Unchanged between v0, v2, v3, and v4 actors
var WPoStProvingPeriod = miner0.WPoStProvingPeriod
@ -82,10 +89,58 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case builtin4.StorageMinerActorCodeID:
return load4(store, act.Head)
case builtin5.StorageMinerActorCodeID:
return load5(store, act.Head)
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
case actors.Version0:
return make0(store)
case actors.Version2:
return make2(store)
case actors.Version3:
return make3(store)
case actors.Version4:
return make4(store)
case actors.Version5:
return make5(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.StorageMinerActorCodeID, nil
case actors.Version2:
return builtin2.StorageMinerActorCodeID, nil
case actors.Version3:
return builtin3.StorageMinerActorCodeID, nil
case actors.Version4:
return builtin4.StorageMinerActorCodeID, nil
case actors.Version5:
return builtin5.StorageMinerActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -105,6 +160,11 @@ type State interface {
NumLiveSectors() (uint64, error)
IsAllocated(abi.SectorNumber) (bool, error)
// Note that ProvingPeriodStart is deprecated and will be renamed / removed in a future version of actors
GetProvingPeriodStart() (abi.ChainEpoch, error)
// Testing only
EraseAllUnproven() error
LoadDeadline(idx uint64) (Deadline, error)
ForEachDeadline(cb func(idx uint64, dl Deadline) error) error
NumDeadlines() (uint64, error)
@ -121,6 +181,7 @@ type State interface {
decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error)
precommits() (adt.Map, error)
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error)
GetState() interface{}
}
type Deadline interface {

View File

@ -35,6 +35,12 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make{{.v}}(store adt.Store) (State, error) {
out := state{{.v}}{store: store}
out.State = miner{{.v}}.State{}
return &out, nil
}
type state{{.v}} struct {
miner{{.v}}.State
store adt.Store
@ -245,6 +251,10 @@ func (s *state{{.v}}) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num))
}
func (s *state{{.v}}) GetProvingPeriodStart() (abi.ChainEpoch, error) {
return s.State.ProvingPeriodStart, nil
}
func (s *state{{.v}}) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
@ -366,6 +376,45 @@ func (s *state{{.v}}) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (Secto
return fromV{{.v}}SectorPreCommitOnChainInfo(sp), nil
}
func (s *state{{.v}}) EraseAllUnproven() error {
{{if (ge .v 2)}}
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner{{.v}}.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner{{.v}}.Partition
err = ps.ForEach(&part, func(pindx int64) error {
_ = part.ActivateUnproven()
err = ps.Set(uint64(pindx), &part)
return nil
})
if err != nil {
return err
}
dl.Partitions, err = ps.Root()
if err != nil {
return err
}
return dls.UpdateDeadline(s.store, dindx, dl)
})
return s.State.SaveDeadlines(s.store, dls)
{{else}}
// field doesn't exist until v2
{{end}}
return nil
}
func (d *deadline{{.v}}) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil {
@ -458,3 +507,7 @@ func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOn
return (SectorPreCommitOnChainInfo)(v0)
{{end}}
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}

View File

@ -32,6 +32,12 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make0(store adt.Store) (State, error) {
out := state0{store: store}
out.State = miner0.State{}
return &out, nil
}
type state0 struct {
miner0.State
store adt.Store
@ -242,6 +248,10 @@ func (s *state0) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num))
}
func (s *state0) GetProvingPeriodStart() (abi.ChainEpoch, error) {
return s.State.ProvingPeriodStart, nil
}
func (s *state0) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
@ -363,6 +373,13 @@ func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
return fromV0SectorPreCommitOnChainInfo(sp), nil
}
func (s *state0) EraseAllUnproven() error {
// field doesn't exist until v2
return nil
}
func (d *deadline0) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil {
@ -426,3 +443,7 @@ func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) Sect
return (SectorPreCommitOnChainInfo)(v0)
}
func (s *state0) GetState() interface{} {
return &s.State
}

View File

@ -30,6 +30,12 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make2(store adt.Store) (State, error) {
out := state2{store: store}
out.State = miner2.State{}
return &out, nil
}
type state2 struct {
miner2.State
store adt.Store
@ -240,6 +246,10 @@ func (s *state2) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num))
}
func (s *state2) GetProvingPeriodStart() (abi.ChainEpoch, error) {
return s.State.ProvingPeriodStart, nil
}
func (s *state2) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
@ -361,6 +371,43 @@ func (s *state2) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
return fromV2SectorPreCommitOnChainInfo(sp), nil
}
func (s *state2) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner2.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner2.Partition
err = ps.ForEach(&part, func(pindx int64) error {
_ = part.ActivateUnproven()
err = ps.Set(uint64(pindx), &part)
return nil
})
if err != nil {
return err
}
dl.Partitions, err = ps.Root()
if err != nil {
return err
}
return dls.UpdateDeadline(s.store, dindx, dl)
})
return s.State.SaveDeadlines(s.store, dls)
return nil
}
func (d *deadline2) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil {
@ -442,3 +489,7 @@ func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) Sect
}
}
func (s *state2) GetState() interface{} {
return &s.State
}

View File

@ -32,6 +32,12 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make3(store adt.Store) (State, error) {
out := state3{store: store}
out.State = miner3.State{}
return &out, nil
}
type state3 struct {
miner3.State
store adt.Store
@ -242,6 +248,10 @@ func (s *state3) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num))
}
func (s *state3) GetProvingPeriodStart() (abi.ChainEpoch, error) {
return s.State.ProvingPeriodStart, nil
}
func (s *state3) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
@ -358,6 +368,43 @@ func (s *state3) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
return fromV3SectorPreCommitOnChainInfo(sp), nil
}
func (s *state3) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner3.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner3.Partition
err = ps.ForEach(&part, func(pindx int64) error {
_ = part.ActivateUnproven()
err = ps.Set(uint64(pindx), &part)
return nil
})
if err != nil {
return err
}
dl.Partitions, err = ps.Root()
if err != nil {
return err
}
return dls.UpdateDeadline(s.store, dindx, dl)
})
return s.State.SaveDeadlines(s.store, dls)
return nil
}
func (d *deadline3) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil {
@ -443,3 +490,7 @@ func fromV3SectorPreCommitOnChainInfo(v3 miner3.SectorPreCommitOnChainInfo) Sect
}
}
func (s *state3) GetState() interface{} {
return &s.State
}

View File

@ -32,6 +32,12 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make4(store adt.Store) (State, error) {
out := state4{store: store}
out.State = miner4.State{}
return &out, nil
}
type state4 struct {
miner4.State
store adt.Store
@ -242,6 +248,10 @@ func (s *state4) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num))
}
func (s *state4) GetProvingPeriodStart() (abi.ChainEpoch, error) {
return s.State.ProvingPeriodStart, nil
}
func (s *state4) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
@ -358,6 +368,43 @@ func (s *state4) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
return fromV4SectorPreCommitOnChainInfo(sp), nil
}
func (s *state4) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner4.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner4.Partition
err = ps.ForEach(&part, func(pindx int64) error {
_ = part.ActivateUnproven()
err = ps.Set(uint64(pindx), &part)
return nil
})
if err != nil {
return err
}
dl.Partitions, err = ps.Root()
if err != nil {
return err
}
return dls.UpdateDeadline(s.store, dindx, dl)
})
return s.State.SaveDeadlines(s.store, dls)
return nil
}
func (d *deadline4) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil {
@ -443,3 +490,7 @@ func fromV4SectorPreCommitOnChainInfo(v4 miner4.SectorPreCommitOnChainInfo) Sect
}
}
func (s *state4) GetState() interface{} {
return &s.State
}

View File

@ -0,0 +1,496 @@
package miner
import (
"bytes"
"errors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/dline"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt"
)
var _ State = (*state5)(nil)
func load5(store adt.Store, root cid.Cid) (State, error) {
out := state5{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make5(store adt.Store) (State, error) {
out := state5{store: store}
out.State = miner5.State{}
return &out, nil
}
type state5 struct {
miner5.State
store adt.Store
}
type deadline5 struct {
miner5.Deadline
store adt.Store
}
type partition5 struct {
miner5.Partition
store adt.Store
}
func (s *state5) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmount, err error) {
defer func() {
if r := recover(); r != nil {
err = xerrors.Errorf("failed to get available balance: %w", r)
available = abi.NewTokenAmount(0)
}
}()
// this panics if the miner doesnt have enough funds to cover their locked pledge
available, err = s.GetAvailableBalance(bal)
return available, err
}
func (s *state5) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) {
return s.CheckVestedFunds(s.store, epoch)
}
func (s *state5) LockedFunds() (LockedFunds, error) {
return LockedFunds{
VestingFunds: s.State.LockedFunds,
InitialPledgeRequirement: s.State.InitialPledge,
PreCommitDeposits: s.State.PreCommitDeposits,
}, nil
}
func (s *state5) FeeDebt() (abi.TokenAmount, error) {
return s.State.FeeDebt, nil
}
func (s *state5) InitialPledge() (abi.TokenAmount, error) {
return s.State.InitialPledge, nil
}
func (s *state5) PreCommitDeposits() (abi.TokenAmount, error) {
return s.State.PreCommitDeposits, nil
}
func (s *state5) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) {
info, ok, err := s.State.GetSector(s.store, num)
if !ok || err != nil {
return nil, err
}
ret := fromV5SectorOnChainInfo(*info)
return &ret, nil
}
func (s *state5) FindSector(num abi.SectorNumber) (*SectorLocation, error) {
dlIdx, partIdx, err := s.State.FindSector(s.store, num)
if err != nil {
return nil, err
}
return &SectorLocation{
Deadline: dlIdx,
Partition: partIdx,
}, nil
}
func (s *state5) NumLiveSectors() (uint64, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return 0, err
}
var total uint64
if err := dls.ForEach(s.store, func(dlIdx uint64, dl *miner5.Deadline) error {
total += dl.LiveSectors
return nil
}); err != nil {
return 0, err
}
return total, nil
}
// GetSectorExpiration returns the effective expiration of the given sector.
//
// If the sector does not expire early, the Early expiration field is 0.
func (s *state5) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return nil, err
}
// NOTE: this can be optimized significantly.
// 1. If the sector is non-faulty, it will either expire on-time (can be
// learned from the sector info), or in the next quantized expiration
// epoch (i.e., the first element in the partition's expiration queue.
// 2. If it's faulty, it will expire early within the first 14 entries
// of the expiration queue.
stopErr := errors.New("stop")
out := SectorExpiration{}
err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner5.Deadline) error {
partitions, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
quant := s.State.QuantSpecForDeadline(dlIdx)
var part miner5.Partition
return partitions.ForEach(&part, func(partIdx int64) error {
if found, err := part.Sectors.IsSet(uint64(num)); err != nil {
return err
} else if !found {
return nil
}
if found, err := part.Terminated.IsSet(uint64(num)); err != nil {
return err
} else if found {
// already terminated
return stopErr
}
q, err := miner5.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant, miner5.PartitionExpirationAmtBitwidth)
if err != nil {
return err
}
var exp miner5.ExpirationSet
return q.ForEach(&exp, func(epoch int64) error {
if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil {
return err
} else if early {
out.Early = abi.ChainEpoch(epoch)
return nil
}
if onTime, err := exp.OnTimeSectors.IsSet(uint64(num)); err != nil {
return err
} else if onTime {
out.OnTime = abi.ChainEpoch(epoch)
return stopErr
}
return nil
})
})
})
if err == stopErr {
err = nil
}
if err != nil {
return nil, err
}
if out.Early == 0 && out.OnTime == 0 {
return nil, xerrors.Errorf("failed to find sector %d", num)
}
return &out, nil
}
func (s *state5) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
if !ok || err != nil {
return nil, err
}
ret := fromV5SectorPreCommitOnChainInfo(*info)
return &ret, nil
}
func (s *state5) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) {
sectors, err := miner5.LoadSectors(s.store, s.State.Sectors)
if err != nil {
return nil, err
}
// If no sector numbers are specified, load all.
if snos == nil {
infos := make([]*SectorOnChainInfo, 0, sectors.Length())
var info5 miner5.SectorOnChainInfo
if err := sectors.ForEach(&info5, func(_ int64) error {
info := fromV5SectorOnChainInfo(info5)
infos = append(infos, &info)
return nil
}); err != nil {
return nil, err
}
return infos, nil
}
// Otherwise, load selected.
infos5, err := sectors.Load(*snos)
if err != nil {
return nil, err
}
infos := make([]*SectorOnChainInfo, len(infos5))
for i, info5 := range infos5 {
info := fromV5SectorOnChainInfo(*info5)
infos[i] = &info
}
return infos, nil
}
func (s *state5) IsAllocated(num abi.SectorNumber) (bool, error) {
var allocatedSectors bitfield.BitField
if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil {
return false, err
}
return allocatedSectors.IsSet(uint64(num))
}
func (s *state5) GetProvingPeriodStart() (abi.ChainEpoch, error) {
return s.State.ProvingPeriodStart, nil
}
func (s *state5) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return nil, err
}
dl, err := dls.LoadDeadline(s.store, idx)
if err != nil {
return nil, err
}
return &deadline5{*dl, s.store}, nil
}
func (s *state5) ForEachDeadline(cb func(uint64, Deadline) error) error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
return dls.ForEach(s.store, func(i uint64, dl *miner5.Deadline) error {
return cb(i, &deadline5{*dl, s.store})
})
}
func (s *state5) NumDeadlines() (uint64, error) {
return miner5.WPoStPeriodDeadlines, nil
}
func (s *state5) DeadlinesChanged(other State) (bool, error) {
other5, ok := other.(*state5)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.Deadlines.Equals(other5.Deadlines), nil
}
func (s *state5) MinerInfoChanged(other State) (bool, error) {
other0, ok := other.(*state5)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.Info.Equals(other0.State.Info), nil
}
func (s *state5) Info() (MinerInfo, error) {
info, err := s.State.GetInfo(s.store)
if err != nil {
return MinerInfo{}, err
}
var pid *peer.ID
if peerID, err := peer.IDFromBytes(info.PeerId); err == nil {
pid = &peerID
}
mi := MinerInfo{
Owner: info.Owner,
Worker: info.Worker,
ControlAddresses: info.ControlAddresses,
NewWorker: address.Undef,
WorkerChangeEpoch: -1,
PeerId: pid,
Multiaddrs: info.Multiaddrs,
WindowPoStProofType: info.WindowPoStProofType,
SectorSize: info.SectorSize,
WindowPoStPartitionSectors: info.WindowPoStPartitionSectors,
ConsensusFaultElapsed: info.ConsensusFaultElapsed,
}
if info.PendingWorkerKey != nil {
mi.NewWorker = info.PendingWorkerKey.NewWorker
mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt
}
return mi, nil
}
func (s *state5) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) {
return s.State.RecordedDeadlineInfo(epoch), nil
}
func (s *state5) DeadlineCronActive() (bool, error) {
return s.State.DeadlineCronActive, nil
}
func (s *state5) sectors() (adt.Array, error) {
return adt5.AsArray(s.store, s.Sectors, miner5.SectorsAmtBitwidth)
}
func (s *state5) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) {
var si miner5.SectorOnChainInfo
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return SectorOnChainInfo{}, err
}
return fromV5SectorOnChainInfo(si), nil
}
func (s *state5) precommits() (adt.Map, error) {
return adt5.AsMap(s.store, s.PreCommittedSectors, builtin5.DefaultHamtBitwidth)
}
func (s *state5) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
var sp miner5.SectorPreCommitOnChainInfo
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return SectorPreCommitOnChainInfo{}, err
}
return fromV5SectorPreCommitOnChainInfo(sp), nil
}
func (s *state5) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner5.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner5.Partition
err = ps.ForEach(&part, func(pindx int64) error {
_ = part.ActivateUnproven()
err = ps.Set(uint64(pindx), &part)
return nil
})
if err != nil {
return err
}
dl.Partitions, err = ps.Root()
if err != nil {
return err
}
return dls.UpdateDeadline(s.store, dindx, dl)
})
return s.State.SaveDeadlines(s.store, dls)
return nil
}
func (d *deadline5) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil {
return nil, err
}
return &partition5{*p, d.store}, nil
}
func (d *deadline5) ForEachPartition(cb func(uint64, Partition) error) error {
ps, err := d.Deadline.PartitionsArray(d.store)
if err != nil {
return err
}
var part miner5.Partition
return ps.ForEach(&part, func(i int64) error {
return cb(uint64(i), &partition5{part, d.store})
})
}
func (d *deadline5) PartitionsChanged(other Deadline) (bool, error) {
other5, ok := other.(*deadline5)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !d.Deadline.Partitions.Equals(other5.Deadline.Partitions), nil
}
func (d *deadline5) PartitionsPoSted() (bitfield.BitField, error) {
return d.Deadline.PartitionsPoSted, nil
}
func (d *deadline5) DisputableProofCount() (uint64, error) {
ops, err := d.OptimisticProofsSnapshotArray(d.store)
if err != nil {
return 0, err
}
return ops.Length(), nil
}
func (p *partition5) AllSectors() (bitfield.BitField, error) {
return p.Partition.Sectors, nil
}
func (p *partition5) FaultySectors() (bitfield.BitField, error) {
return p.Partition.Faults, nil
}
func (p *partition5) RecoveringSectors() (bitfield.BitField, error) {
return p.Partition.Recoveries, nil
}
func fromV5SectorOnChainInfo(v5 miner5.SectorOnChainInfo) SectorOnChainInfo {
return SectorOnChainInfo{
SectorNumber: v5.SectorNumber,
SealProof: v5.SealProof,
SealedCID: v5.SealedCID,
DealIDs: v5.DealIDs,
Activation: v5.Activation,
Expiration: v5.Expiration,
DealWeight: v5.DealWeight,
VerifiedDealWeight: v5.VerifiedDealWeight,
InitialPledge: v5.InitialPledge,
ExpectedDayReward: v5.ExpectedDayReward,
ExpectedStoragePledge: v5.ExpectedStoragePledge,
}
}
func fromV5SectorPreCommitOnChainInfo(v5 miner5.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
return SectorPreCommitOnChainInfo{
Info: (SectorPreCommitInfo)(v5.Info),
PreCommitDeposit: v5.PreCommitDeposit,
PreCommitEpoch: v5.PreCommitEpoch,
DealWeight: v5.DealWeight,
VerifiedDealWeight: v5.VerifiedDealWeight,
}
}
func (s *state5) GetState() interface{} {
return &s.State
}

View File

@ -12,7 +12,8 @@ import (
"github.com/filecoin-project/go-state-types/cbor"
"github.com/ipfs/go-cid"
msig{{.latestVersion}} "github.com/filecoin-project/specs-actors/v4/actors/builtin/multisig"
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
msig{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/builtin/multisig"
{{range .versions}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{end}}
@ -40,6 +41,27 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return make{{.}}(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
{{end}}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.MultisigActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -55,9 +77,10 @@ type State interface {
transactions() (adt.Map, error)
decodeTransaction(val *cbg.Deferred) (Transaction, error)
GetState() interface{}
}
type Transaction = msig{{.latestVersion}}.Transaction
type Transaction = msig0.Transaction
var Methods = builtin{{.latestVersion}}.MethodsMultisig

View File

@ -0,0 +1,71 @@
package multisig
import (
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
init5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/init"
multisig5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/multisig"
"github.com/filecoin-project/lotus/chain/actors"
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
"github.com/filecoin-project/lotus/chain/types"
)
type message5 struct{ message0 }
func (m message5) Create(
signers []address.Address, threshold uint64,
unlockStart, unlockDuration abi.ChainEpoch,
initialAmount abi.TokenAmount,
) (*types.Message, error) {
lenAddrs := uint64(len(signers))
if lenAddrs < threshold {
return nil, xerrors.Errorf("cannot require signing of more addresses than provided for multisig")
}
if threshold == 0 {
threshold = lenAddrs
}
if m.from == address.Undef {
return nil, xerrors.Errorf("must provide source address")
}
// Set up constructor parameters for multisig
msigParams := &multisig5.ConstructorParams{
Signers: signers,
NumApprovalsThreshold: threshold,
UnlockDuration: unlockDuration,
StartEpoch: unlockStart,
}
enc, actErr := actors.SerializeParams(msigParams)
if actErr != nil {
return nil, actErr
}
// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init5.ExecParams{
CodeCID: builtin5.MultisigActorCodeID,
ConstructorParams: enc,
}
enc, actErr = actors.SerializeParams(execParams)
if actErr != nil {
return nil, actErr
}
return &types.Message{
To: init_.Address,
From: m.from,
Method: builtin5.MethodsInit.Exec,
Params: enc,
Value: initialAmount,
}, nil
}

View File

@ -12,7 +12,8 @@ import (
"github.com/filecoin-project/go-state-types/cbor"
"github.com/ipfs/go-cid"
msig4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/multisig"
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
msig5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/multisig"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
@ -22,6 +23,8 @@ import (
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
@ -45,6 +48,10 @@ func init() {
builtin.RegisterActorState(builtin4.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
builtin.RegisterActorState(builtin5.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}
func Load(store adt.Store, act *types.Actor) (State, error) {
@ -62,10 +69,58 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case builtin4.MultisigActorCodeID:
return load4(store, act.Head)
case builtin5.MultisigActorCodeID:
return load5(store, act.Head)
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
switch av {
case actors.Version0:
return make0(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version2:
return make2(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version3:
return make3(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version4:
return make4(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version5:
return make5(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.MultisigActorCodeID, nil
case actors.Version2:
return builtin2.MultisigActorCodeID, nil
case actors.Version3:
return builtin3.MultisigActorCodeID, nil
case actors.Version4:
return builtin4.MultisigActorCodeID, nil
case actors.Version5:
return builtin5.MultisigActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -81,11 +136,12 @@ type State interface {
transactions() (adt.Map, error)
decodeTransaction(val *cbg.Deferred) (Transaction, error)
GetState() interface{}
}
type Transaction = msig4.Transaction
type Transaction = msig0.Transaction
var Methods = builtin4.MethodsMultisig
var Methods = builtin5.MethodsMultisig
func Message(version actors.Version, from address.Address) MessageBuilder {
switch version {
@ -101,6 +157,9 @@ func Message(version actors.Version, from address.Address) MessageBuilder {
case actors.Version4:
return message4{message0{from}}
case actors.Version5:
return message5{message0{from}}
default:
panic(fmt.Sprintf("unsupported actors version: %d", version))
}
@ -124,12 +183,12 @@ type MessageBuilder interface {
}
// this type is the same between v0 and v2
type ProposalHashData = msig4.ProposalHashData
type ProposeReturn = msig4.ProposeReturn
type ProposeParams = msig4.ProposeParams
type ProposalHashData = msig5.ProposalHashData
type ProposeReturn = msig5.ProposeReturn
type ProposeParams = msig5.ProposeParams
func txnParams(id uint64, data *ProposalHashData) ([]byte, error) {
params := msig4.TxnIDParams{ID: msig4.TxnID(id)}
params := msig5.TxnIDParams{ID: msig5.TxnID(id)}
if data != nil {
if data.Requester.Protocol() != address.ID {
return nil, xerrors.Errorf("proposer address must be an ID address, was %s", data.Requester)

View File

@ -31,6 +31,32 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make{{.v}}(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
out := state{{.v}}{store: store}
out.State = msig{{.v}}.State{}
out.State.Signers = signers
out.State.NumApprovalsThreshold = threshold
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
{{if (le .v 2)}}
em, err := adt{{.v}}.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State.PendingTxns = em
{{else}}
em, err := adt{{.v}}.StoreEmptyMap(store, builtin{{.v}}.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
{{end}}
return &out, nil
}
type state{{.v}} struct {
msig{{.v}}.State
store adt.Store
@ -95,3 +121,7 @@ func (s *state{{.v}}) decodeTransaction(val *cbg.Deferred) (Transaction, error)
}
return tx, nil
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}

View File

@ -28,6 +28,25 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make0(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
out := state0{store: store}
out.State = msig0.State{}
out.State.Signers = signers
out.State.NumApprovalsThreshold = threshold
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State.PendingTxns = em
return &out, nil
}
type state0 struct {
msig0.State
store adt.Store
@ -92,3 +111,7 @@ func (s *state0) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
}
return tx, nil
}
func (s *state0) GetState() interface{} {
return &s.State
}

View File

@ -28,6 +28,25 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make2(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
out := state2{store: store}
out.State = msig2.State{}
out.State.Signers = signers
out.State.NumApprovalsThreshold = threshold
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State.PendingTxns = em
return &out, nil
}
type state2 struct {
msig2.State
store adt.Store
@ -92,3 +111,7 @@ func (s *state2) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
}
return tx, nil
}
func (s *state2) GetState() interface{} {
return &s.State
}

View File

@ -30,6 +30,25 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make3(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
out := state3{store: store}
out.State = msig3.State{}
out.State.Signers = signers
out.State.NumApprovalsThreshold = threshold
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt3.StoreEmptyMap(store, builtin3.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
return &out, nil
}
type state3 struct {
msig3.State
store adt.Store
@ -94,3 +113,7 @@ func (s *state3) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
}
return tx, nil
}
func (s *state3) GetState() interface{} {
return &s.State
}

View File

@ -30,6 +30,25 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make4(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
out := state4{store: store}
out.State = msig4.State{}
out.State.Signers = signers
out.State.NumApprovalsThreshold = threshold
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt4.StoreEmptyMap(store, builtin4.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
return &out, nil
}
type state4 struct {
msig4.State
store adt.Store
@ -94,3 +113,7 @@ func (s *state4) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
}
return tx, nil
}
func (s *state4) GetState() interface{} {
return &s.State
}

View File

@ -0,0 +1,119 @@
package multisig
import (
"bytes"
"encoding/binary"
adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
msig5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/multisig"
)
var _ State = (*state5)(nil)
func load5(store adt.Store, root cid.Cid) (State, error) {
out := state5{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make5(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
out := state5{store: store}
out.State = msig5.State{}
out.State.Signers = signers
out.State.NumApprovalsThreshold = threshold
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt5.StoreEmptyMap(store, builtin5.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
return &out, nil
}
type state5 struct {
msig5.State
store adt.Store
}
func (s *state5) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) {
return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil
}
func (s *state5) StartEpoch() (abi.ChainEpoch, error) {
return s.State.StartEpoch, nil
}
func (s *state5) UnlockDuration() (abi.ChainEpoch, error) {
return s.State.UnlockDuration, nil
}
func (s *state5) InitialBalance() (abi.TokenAmount, error) {
return s.State.InitialBalance, nil
}
func (s *state5) Threshold() (uint64, error) {
return s.State.NumApprovalsThreshold, nil
}
func (s *state5) Signers() ([]address.Address, error) {
return s.State.Signers, nil
}
func (s *state5) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error {
arr, err := adt5.AsMap(s.store, s.State.PendingTxns, builtin5.DefaultHamtBitwidth)
if err != nil {
return err
}
var out msig5.Transaction
return arr.ForEach(&out, func(key string) error {
txid, n := binary.Varint([]byte(key))
if n <= 0 {
return xerrors.Errorf("invalid pending transaction key: %v", key)
}
return cb(txid, (Transaction)(out)) //nolint:unconvert
})
}
func (s *state5) PendingTxnChanged(other State) (bool, error) {
other5, ok := other.(*state5)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.PendingTxns.Equals(other5.PendingTxns), nil
}
func (s *state5) transactions() (adt.Map, error) {
return adt5.AsMap(s.store, s.PendingTxns, builtin5.DefaultHamtBitwidth)
}
func (s *state5) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
var tx msig5.Transaction
if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return Transaction{}, err
}
return tx, nil
}
func (s *state5) GetState() interface{} {
return &s.State
}

View File

@ -42,6 +42,27 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return make{{.}}(store)
{{end}}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.PaymentChannelActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
// State is an abstract version of payment channel state that works across
// versions
type State interface {
@ -62,6 +83,8 @@ type State interface {
// Iterate lane states
ForEachLaneState(cb func(idx uint64, dl LaneState) error) error
GetState() interface{}
}
// LaneState is an abstract copy of the state of a single lane

View File

@ -0,0 +1,74 @@
package paych
import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
init5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/init"
paych5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/paych"
"github.com/filecoin-project/lotus/chain/actors"
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
"github.com/filecoin-project/lotus/chain/types"
)
type message5 struct{ from address.Address }
func (m message5) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych5.ConstructorParams{From: m.from, To: to})
if aerr != nil {
return nil, aerr
}
enc, aerr := actors.SerializeParams(&init5.ExecParams{
CodeCID: builtin5.PaymentChannelActorCodeID,
ConstructorParams: params,
})
if aerr != nil {
return nil, aerr
}
return &types.Message{
To: init_.Address,
From: m.from,
Value: initialAmount,
Method: builtin5.MethodsInit.Exec,
Params: enc,
}, nil
}
func (m message5) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych5.UpdateChannelStateParams{
Sv: *sv,
Secret: secret,
})
if aerr != nil {
return nil, aerr
}
return &types.Message{
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
Method: builtin5.MethodsPaych.UpdateChannelState,
Params: params,
}, nil
}
func (m message5) Settle(paych address.Address) (*types.Message, error) {
return &types.Message{
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
Method: builtin5.MethodsPaych.Settle,
}, nil
}
func (m message5) Collect(paych address.Address) (*types.Message, error) {
return &types.Message{
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
Method: builtin5.MethodsPaych.Collect,
}, nil
}

View File

@ -17,6 +17,10 @@ type mockState struct {
lanes map[uint64]paych.LaneState
}
func (ms *mockState) GetState() interface{} {
panic("implement me")
}
type mockLaneState struct {
redeemed big.Int
nonce uint64

View File

@ -23,6 +23,8 @@ import (
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
@ -46,6 +48,10 @@ func init() {
builtin.RegisterActorState(builtin4.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
builtin.RegisterActorState(builtin5.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}
// Load returns an abstract copy of payment channel state, irregardless of actor version
@ -64,10 +70,58 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case builtin4.PaymentChannelActorCodeID:
return load4(store, act.Head)
case builtin5.PaymentChannelActorCodeID:
return load5(store, act.Head)
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
case actors.Version0:
return make0(store)
case actors.Version2:
return make2(store)
case actors.Version3:
return make3(store)
case actors.Version4:
return make4(store)
case actors.Version5:
return make5(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.PaymentChannelActorCodeID, nil
case actors.Version2:
return builtin2.PaymentChannelActorCodeID, nil
case actors.Version3:
return builtin3.PaymentChannelActorCodeID, nil
case actors.Version4:
return builtin4.PaymentChannelActorCodeID, nil
case actors.Version5:
return builtin5.PaymentChannelActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
// State is an abstract version of payment channel state that works across
// versions
type State interface {
@ -88,6 +142,8 @@ type State interface {
// Iterate lane states
ForEachLaneState(cb func(idx uint64, dl LaneState) error) error
GetState() interface{}
}
// LaneState is an abstract copy of the state of a single lane
@ -114,7 +170,7 @@ func DecodeSignedVoucher(s string) (*SignedVoucher, error) {
return &sv, nil
}
var Methods = builtin4.MethodsPaych
var Methods = builtin5.MethodsPaych
func Message(version actors.Version, from address.Address) MessageBuilder {
switch version {
@ -131,6 +187,9 @@ func Message(version actors.Version, from address.Address) MessageBuilder {
case actors.Version4:
return message4{from}
case actors.Version5:
return message5{from}
default:
panic(fmt.Sprintf("unsupported actors version: %d", version))
}

View File

@ -24,6 +24,12 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make{{.v}}(store adt.Store) (State, error) {
out := state{{.v}}{store: store}
out.State = paych{{.v}}.State{}
return &out, nil
}
type state{{.v}} struct {
paych{{.v}}.State
store adt.Store
@ -74,6 +80,10 @@ func (s *state{{.v}}) LaneCount() (uint64, error) {
return lsamt.Length(), nil
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}
// Iterate lane states
func (s *state{{.v}}) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
// Get the lane state from the chain

View File

@ -24,6 +24,12 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make0(store adt.Store) (State, error) {
out := state0{store: store}
out.State = paych0.State{}
return &out, nil
}
type state0 struct {
paych0.State
store adt.Store
@ -74,6 +80,10 @@ func (s *state0) LaneCount() (uint64, error) {
return lsamt.Length(), nil
}
func (s *state0) GetState() interface{} {
return &s.State
}
// Iterate lane states
func (s *state0) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
// Get the lane state from the chain

Some files were not shown because too many files have changed in this diff Show More