Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate types from specs-actors #1

Merged
merged 2 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
version: 2.1
orbs:
go: gotest/tools@0.0.9
codecov: codecov/codecov@1.0.2

executors:
golang:
docker:
- image: circleci/golang:1.13
resource_class: small

commands:
install-deps:
steps:
- go/install-ssh
- go/install: {package: git}
prepare:
parameters:
linux:
default: true
description: is a linux build environment?
type: boolean
steps:
- checkout
- when:
condition: << parameters.linux >>
steps:
- run: sudo apt-get update
build-all:

jobs:
mod-tidy-check:
executor: golang
steps:
- install-deps
- prepare
- go/mod-download
- go/mod-tidy-check

build-all:
executor: golang
steps:
- install-deps
- prepare
- go/mod-download
- run:
command: make build
- store_artifacts:
path: go-state-types
- store_artifacts:
path: go-state-types

check-gen:
executor: golang
steps:
- install-deps
- prepare
- go/mod-download
- run:
name: "Install goimports"
command: |
cd / && go get golang.org/x/tools/cmd/goimports
- run:
name: "Ensure we don't need to run 'make gen'"
command: |
make gen && git diff --exit-code

test-all:
executor: golang
steps:
- install-deps
- prepare
- go/mod-download
- run:
command: |
make test-coverage
mkdir -p /tmp/artifacts
mv coverage.out /tmp/artifacts/coverage.out
- codecov/upload:
file: /tmp/artifacts/coverage.out
- store_artifacts:
path: go-state-types

lint: &lint
description: |
Run golangci-lint.
parameters:
executor:
type: executor
default: golang
golangci-lint-version:
type: string
default: 1.23.1
concurrency:
type: string
default: '2'
description: |
Concurrency used to run linters. Defaults to 2 because NumCPU is not
aware of container CPU limits.
args:
type: string
default: ''
description: |
Arguments to pass to golangci-lint
executor: << parameters.executor >>
steps:
- install-deps
- prepare
- run:
command: make build
- go/install-golangci-lint:
gobin: $HOME/.local/bin
version: << parameters.golangci-lint-version >>
- run:
name: Lint
command: |
$HOME/.local/bin/golangci-lint run -v --skip-dirs-use-default=false\
--concurrency << parameters.concurrency >> << parameters.args >>

lint-all:
<<: *lint

workflows:
version: 2.1
ci:
jobs:
- lint-all
- mod-tidy-check
- build-all
- test-all
- check-gen
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
GO_BIN ?= go
GOLINT ?= golangci-lint

all: build lint test tidy
.PHONY: all

build:
$(GO_BIN) build ./...
.PHONY: build

test:
$(GO_BIN) test ./...
.PHONY: test

test-coverage:
$(GO_BIN) test -coverprofile=coverage.out ./...
.PHONY: test-coverage

tidy:
$(GO_BIN) mod tidy
.PHONY: tidy

gen:
$(GO_BIN) run ./gen/gen.go
.PHONY: gen

lint:
$(GOLINT) run ./...
.PHONY: lint

38 changes: 38 additions & 0 deletions abi/actor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package abi

import "strconv"

// A sequential number assigned to an actor when created by the InitActor.
// This ID is embedded in ID-type addresses.
type ActorID uint64

func (e ActorID) String() string {
return strconv.FormatInt(int64(e), 10)
}

// MethodNum is an integer that represents a particular method
// in an actor's function table. These numbers are used to compress
// invocation of actor code, and to decouple human language concerns
// about method names from the ability to uniquely refer to a particular
// method.
//
// Consider MethodNum numbers to be similar in concerns as for
// offsets in function tables (in programming languages), and for
// tags in ProtocolBuffer fields. Tags in ProtocolBuffers recommend
// assigning a unique tag to a field and never reusing that tag.
// If a field is no longer used, the field name may change but should
// still remain defined in the code to ensure the tag number is not
// reused accidentally. The same should apply to the MethodNum
// associated with methods in Filecoin VM Actors.
type MethodNum uint64

func (e MethodNum) String() string {
return strconv.FormatInt(int64(e), 10)
}

// Multiaddrs is a byte array representing a Libp2p MultiAddress
type Multiaddrs = []byte

// PeerID is a byte array representing a Libp2p PeerID
type PeerID = []byte
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure of these last two. I'd slightly prefer we dropped them and used []byte directly. They both appear in miner info state, and hence in constructor params (which are also accessed by power actor).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning to merge as is but we can reevaluate later today.


165 changes: 165 additions & 0 deletions abi/cbor_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading