-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from filecoin-project/feat/f2-chain
chain: Use f2 code
- Loading branch information
Showing
38 changed files
with
5,060 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,22 +3,136 @@ orbs: | |
go: gotest/[email protected] | ||
|
||
|
||
commands: | ||
install-deps: | ||
steps: | ||
- go/install-ssh | ||
- go/install: {package: git} | ||
- go/install: {package: bzr} | ||
prepare: | ||
steps: | ||
- checkout | ||
- run: git submodule sync | ||
- run: git submodule update --init | ||
|
||
|
||
jobs: | ||
mod-tidy-check: | ||
executor: go/circleci-golang | ||
steps: | ||
- go/install-ssh | ||
- checkout | ||
- install-deps | ||
- prepare | ||
- go/mod-download | ||
- go/mod-tidy-check | ||
|
||
test: | ||
description: | | ||
Run tests with gotestsum. | ||
parameters: | ||
executor: | ||
type: executor | ||
default: go/circleci-golang | ||
go-test-flags: | ||
type: string | ||
default: "" | ||
description: Flags passed to go test. | ||
packages: | ||
type: string | ||
default: "./..." | ||
description: Import paths of packages to be tested. | ||
test-suite-name: | ||
type: string | ||
default: unit | ||
description: Test suite name to report to CircleCI. | ||
gotestsum-format: | ||
type: string | ||
default: short | ||
description: gotestsum format. https://github.com/gotestyourself/gotestsum#format | ||
coverage: | ||
type: string | ||
default: -coverprofile=coverage.txt | ||
description: Coverage flag. Set to the empty string to disable. | ||
codecov-upload: | ||
type: boolean | ||
default: false | ||
description: | | ||
Upload coverage report to https://codecov.io/. Requires the codecov API token to be | ||
set as an environment variable for private projects. | ||
executor: << parameters.executor >> | ||
steps: | ||
- install-deps | ||
- prepare | ||
- go/mod-download | ||
- run: make deps | ||
- go/install-gotestsum: | ||
gobin: $HOME/.local/bin | ||
- run: | ||
name: go test | ||
environment: | ||
GOTESTSUM_JUNITFILE: /tmp/test-reports/<< parameters.test-suite-name >>/junit.xml | ||
GOTESTSUM_FORMAT: << parameters.gotestsum-format >> | ||
command: | | ||
mkdir -p /tmp/test-reports/<< parameters.test-suite-name >> | ||
gotestsum -- \ | ||
<< parameters.coverage >> \ | ||
<< parameters.go-test-flags >> \ | ||
<< parameters.packages >> | ||
- store_test_results: | ||
path: /tmp/test-reports | ||
- when: | ||
condition: << parameters.codecov-upload >> | ||
steps: | ||
- go/install: {package: bash} | ||
- go/install: {package: curl} | ||
- run: | ||
shell: /bin/bash -eo pipefail | ||
command: | | ||
bash <(curl -s https://codecov.io/bash) | ||
lint: | ||
description: | | ||
Run golangci-lint. | ||
parameters: | ||
executor: | ||
type: executor | ||
default: go/circleci-golang | ||
golangci-lint-version: | ||
type: string | ||
default: 1.17.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 | ||
- go/mod-download | ||
- run: make deps | ||
- go/install-golangci-lint: | ||
gobin: $HOME/.local/bin | ||
version: << parameters.golangci-lint-version >> | ||
- run: | ||
name: Lint | ||
command: | | ||
golangci-lint run -v \ | ||
--concurrency << parameters.concurrency >> << parameters.args >> | ||
workflows: | ||
version: 2 | ||
ci: | ||
jobs: | ||
- go/lint: | ||
golangci-lint-version: 1.17.1 | ||
- go/test: | ||
executor: go/circleci-golang | ||
- lint | ||
- lint: | ||
args: "--no-config --exclude-use-default=false --disable-all --enable golint" | ||
- test: | ||
codecov-upload: true | ||
- mod-tidy-check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
lotus | ||
**/*.h | ||
**/*.a | ||
**/*.pc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
all: build | ||
|
||
blssigs: lib/bls-signatures/include/libbls_signatures.h | ||
|
||
lib/bls-signatures/include/libbls_signatures.h: lib/bls-signatures/bls-signatures ; | ||
./scripts/install-bls-signatures.sh | ||
|
||
deps: blssigs | ||
|
||
build: deps | ||
go build -o lotus ./cmd/lotus | ||
|
||
.PHONY: all build deps blssigs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package chain | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/filecoin-project/go-lotus/chain/address" | ||
|
||
"github.com/ipfs/go-cid" | ||
hamt "github.com/ipfs/go-hamt-ipld" | ||
cbor "github.com/ipfs/go-ipld-cbor" | ||
mh "github.com/multiformats/go-multihash" | ||
) | ||
|
||
func init() { | ||
cbor.RegisterCborType(InitActorState{}) | ||
cbor.RegisterCborType(AccountActorState{}) | ||
} | ||
|
||
var AccountActorCodeCid cid.Cid | ||
var StorageMarketActorCodeCid cid.Cid | ||
var StorageMinerCodeCid cid.Cid | ||
var MultisigActorCodeCid cid.Cid | ||
var InitActorCodeCid cid.Cid | ||
|
||
var InitActorAddress = mustIDAddress(0) | ||
var NetworkAddress = mustIDAddress(1) | ||
var StorageMarketAddress = mustIDAddress(2) | ||
|
||
func mustIDAddress(i uint64) address.Address { | ||
a, err := address.NewIDAddress(i) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return a | ||
} | ||
|
||
func init() { | ||
pref := cid.NewPrefixV1(cid.Raw, mh.ID) | ||
mustSum := func(s string) cid.Cid { | ||
c, err := pref.Sum([]byte(s)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return c | ||
} | ||
|
||
AccountActorCodeCid = mustSum("account") | ||
StorageMarketActorCodeCid = mustSum("smarket") | ||
StorageMinerCodeCid = mustSum("sminer") | ||
MultisigActorCodeCid = mustSum("multisig") | ||
InitActorCodeCid = mustSum("init") | ||
} | ||
|
||
type VMActor struct { | ||
} | ||
|
||
type InitActorState struct { | ||
AddressMap cid.Cid | ||
|
||
NextID uint64 | ||
} | ||
|
||
func (ias *InitActorState) AddActor(vmctx *VMContext, addr address.Address) (address.Address, error) { | ||
nid := ias.NextID | ||
ias.NextID++ | ||
|
||
amap, err := hamt.LoadNode(context.TODO(), vmctx.Ipld(), ias.AddressMap) | ||
if err != nil { | ||
return address.Undef, err | ||
} | ||
|
||
if err := amap.Set(context.TODO(), string(addr.Bytes()), nid); err != nil { | ||
return address.Undef, err | ||
} | ||
|
||
if err := amap.Flush(context.TODO()); err != nil { | ||
return address.Undef, err | ||
} | ||
|
||
ncid, err := vmctx.Ipld().Put(context.TODO(), amap) | ||
if err != nil { | ||
return address.Undef, err | ||
} | ||
ias.AddressMap = ncid | ||
|
||
return address.NewIDAddress(nid) | ||
} | ||
|
||
func (ias *InitActorState) Lookup(cst *hamt.CborIpldStore, addr address.Address) (address.Address, error) { | ||
amap, err := hamt.LoadNode(context.TODO(), cst, ias.AddressMap) | ||
if err != nil { | ||
return address.Undef, err | ||
} | ||
|
||
val, err := amap.Find(context.TODO(), string(addr.Bytes())) | ||
if err != nil { | ||
return address.Undef, err | ||
} | ||
|
||
ival, ok := val.(uint64) | ||
if !ok { | ||
return address.Undef, fmt.Errorf("invalid value in init actor state, expected uint64, got %T", val) | ||
} | ||
|
||
return address.NewIDAddress(ival) | ||
} | ||
|
||
type AccountActorState struct { | ||
Address address.Address | ||
} |
Oops, something went wrong.