Skip to content

Commit

Permalink
Load IPC-actors bundle and spawn IPC gateway actor in genesis (fileco…
Browse files Browse the repository at this point in the history
…in-project#71)

* Test and fix eth_FeeHistory

* Add test for eth_getStorageAt

* Add test for eth_call

* Change EthBlock.Extradata type to EthBytes

* fix: EthAPI: Drop hack in GetStorageAt

* Eth JSON-RPC: implement web3_clientVersion

* fix lint

* add genesis for ipc gateway

* Remove debug logging

* chore: cli

Standarize cli/code functions similar to: filecoin-project#9317

- cctx.NArg() instead of cctx.Args().xxx
- Add check for args and print help on functions that did not have it

* fix: rpcenc: Don't hang when source dies

* make docsgen-cli

make docsgen-cli

* fix: EthAPI: Handle EthCall return correctly

* feat: vm: Assert empty object CID when dumping state

* Update codeql to v2

* Enable code ql for release branches

* less strict ArgsCheck

Less strict ArgsCheck

* feat: wdpost: Emit more detailed errors

* Fix panic in EthGetCode

* Update codeql to v2

* Enable code ql for release branches

* Add actors to circ-supply

- Consider funds to EAM as locked
- Add evm, placeholder and ethaccount to circ supply

* devnets starts with nv17

* Use new kit.DisableEthRPC method in test

* make gen

* init git submodules in build-docker CI

* Remove old Snapcraft and AppDir folders

* Always include checked in files in docker context

The .dockerignore file is symlinked to the .gitignore file, and checked
in files should not be removed from our docker context otherwise they
result in dirty git state when we build our images.

* Check git state in Dockerfile to catch .dockerignore bugs

* make jen

- Add builtin.EthereumAddressManagerActorAddr to builtin.go.template and make jen
- Rename to EthereumAddressManagerActorAddr to match pattern of other actors (CronActorAddr/etc)

* chore: all: bump go-libipfs to replace go-block-format

Includes changes from:
- ipfs/go-block-format#37
- ipfs/boxo#58

* init git submodules in build-docker CI

* Remove old Snapcraft and AppDir folders

* Always include checked in files in docker context

The .dockerignore file is symlinked to the .gitignore file, and checked
in files should not be removed from our docker context otherwise they
result in dirty git state when we build our images.

* Check git state in Dockerfile to catch .dockerignore bugs

* Fix lint errors

* Skip some rpc conformance tests

* make gen

* Changed skip message

* fix: don't replace the method in EthSendRawTransaction (filecoin-project#10129)

This will just cause signature validation to fail.

* Remove stm: #integration comment

* Fix comment

* fix: devnets: default to starting from nv17

* Refactor to ensure conformance test can run in circleci

* go fmt

* Standardize path variable

* Update to go-state-types v0.10.0-alpha-11

* chore: node: migrate go-bitswap to go-libipfs/bitswap

This was migrated in ipfs/boxo#63.

* simplify transaction hash db queries, prevent fd leaks

* Refactor: Unify EthTx to FilecoinMessage methods v2 (filecoin-project#10095)

* Refactor: Unify EthTx to FilecoinMessage methods

* Filecoin messages can again be converted to Eth Txs

* All BLS messages should calculated tx hash with unsigned message

* Refactor newEthTxReceipt

* fill in from and to for non-eth transactions

* Hoist nil check out of newEthTxFromMessageLookup

---------

Co-authored-by: Aayush <arajasek94@gmail.com>
Co-authored-by: Raúl Kripalani <raul@protocol.ai>

* Populate transaction hash database if the database has not been set up before

* rpc: Switch eth_subscribe to reverse calls

* gateway: eth_subscribe support

* itests: Fix TestEthSubscribeLogs

* ethtypes: Serialize EthFilterID/EthSubscriptionID correctly

* eth rpc: Params are optional in eth_subscribe

* fix: cli: add ArgsUsage

fix: cli: add ArgsUsage

* make libp2p user agent overridable

* move UserAgentOption upwards

* Eth JSON-RPC: from in eth_getTransactionByHash is not correctly populated filecoin-project#1614

* Move assigning `from` address to the API level

* Improve the error message

* Add test for EthGetTransactionByHash

* fix: should not serve non v0 api in v1

* Fix: typo

Fix: typo

* Fix: typos

Fix: typos

* Fix: typo

Fix: typo

* Fix: typo

Fix: typo

* Fix: typo

Fix: typo

* Fix: typos

Fix: typos

* Fix: typos

Fix: typos

* test: fevm: add in tests for deploying, destroying contracts, recursive calls, sending value (filecoin-project#10082)

adds the following tests to itests/fevm_test.go:
 - recursive tests
 - delegate call tests
 - delegate call recursive tests
 - revert tests
 - destruct tests
 - contract deploy address tests
 - send value to contracts
 - gas limit on value transfer tests
 - sending value to destroyed contracts
adds the test to itests/fevm_address_test.go:
 - deploy contract and confirm address is different second deploy

* merge

* tests that use create2 and destroy to validate evm state

* wip: ipc_gateway in genesis

* deps: Update go-jsonrpc to v0.2.1

* Test: assert all fields returned from EthGetTransactionByHash have expected values

Related to  filecoin-project#10151 (comment)

* Fix merge conflicts

* Allow f4 address to send to all address types if ID address exists on chain

* fix: extend LOTUS_CHAIN_BADGERSTORE_DISABLE_FSYNC to the markset

Without doing this walking a badger markset on a non-nvme knocks the
node hopelessly out of sync during a compaction.

* review fixes

* gateway: Support all EthModule methods

* node builder: Use gateway eth module in lite mode

* feat: ethrpc: Support filtering by address in subscribe

* itests: Fix TestEthFilterAPIDisabledViaConfig

* Check decoding params for new methods

* Review fixes

* feat: evm: align events implementation with FIP-0049 and FIP-0054. (filecoin-project#10152)

- Event keys are now t1, t2, t3, t4 for topics; and d for data.
- ref-fvm no longer stores events in the blockstore for us. It just
  returns events to the client, who is now responsible for handling
  them as it wishes / according to its configuration.
- Add a flag to VMOpts to have the events AMT be written in the blockstore.
- Add a flag to the ChainStore to advertise to the rest of the system
  if the ChainStore is storing events.
- Enable that flag if the EthRPC is enabled (can also add an explicit
  configuration flag if wanted).

* cli: fix extend cmd to get the right sector number

* todo: rebase master to include release/v1.20.0

* feat: compute a better gas limit for recursive external contract calls

* make gen

* fix: ethtypes: Correct 'no uncles' hash in NewEthBlock

* LOTUS_FEVM_ENABLEETHRPC: Fix env variable name in error

* fix: ethtypes: Correct 'no transactions' hash in NewEthBlock

* fix: null rounds: pass correct timestamp to the FVM.

* itest: fix FEVM tests for upstream changes

* itest: fix: test comment

* itest: fix remaining fevm failures

* improve evm error handling in itests (filecoin-project#10161)

* use WithValue language for test

* clean up test for recursive delegate call count. improved readability (filecoin-project#10195)

* chain: explicitly check that gasLimit is above zero

* add bundle git tag from pack.sh into builtin_actors_gen

* fix: worker: add all task type flag

Add all flag for the `lotus-worker tasks enable/disable` cmd

* Update cmd/lotus-worker/tasks.go

Co-authored-by: Łukasz Magiera <magik6k@users.noreply.github.com>

* Update cmd/lotus-worker/tasks.go

Co-authored-by: Łukasz Magiera <magik6k@users.noreply.github.com>

* Update cmd/lotus-worker/tasks.go

Co-authored-by: Łukasz Magiera <magik6k@users.noreply.github.com>

* make docsgen-cli

make docsgen-cli

* retry make docsgen-cli

retry make docsgen-cli with the new usage

* remove bundle-gen from make gen - not actually useful today anyway

* fvm: chore: update FVM

This:

1. Updates the builtin actors bundle (for actors v10).
2. Updates the event entry type to include the codec.
3. Removes the cbor encoding and zero trimming from event data.

I've chose to:

1. _Not_ add codec handling to the event filtering system for now.
2. _Skip_ events with unexpected codecs.

We don't actually _allow_ these events in the FVM right now, and it
simplifies the implementation.

However, I _am_ recording the codecs in the database so we don't have to
migrate it later.

* Option to set-seal-delay seconds

Add the option to set-seal-delay in seconds

* make docsgen-cli

make docsgen-cli

* Error if backup file exists

Error out if backup file already exists

* fix: ethrpc: Don't send sub notifs in array

* Update eth_subscribe itests to work with correct responses

* test: build: ignore git tags in embedded metadata

* fix: build: use actual v9 bundles for butterfly

* fix: ethrpc: emit correct bloom filters (filecoin-project#10194)

* skip problematic test vectors.

* feat: actors: Add bytecode getter

* itests: Test EVM bytecode getters, check bytecode hash

* ethrpc: Add missing fields to EthTx

* Update cli/backup.go

Co-authored-by: Łukasz Magiera <magik6k@users.noreply.github.com>

* feat: eth cli: Strip out empty spaces around contract bytes

* fix: chain: make sure the head is empty, not the code

* bump test vectors.

* remove test vectors bleeding edge job.

We no longer need it because specs-actors is deprecated.
v7 vectors have been merged to master.

* fix: Don't call WalletExport in msg signing flows

* updates butterflynet reset artifacts

* bootstrap node multiaddr
* new genesis file

these files are necessary for others to build lotus and join the new butterflynet, reset on February 08, 2023

* fix: gas: update ffi & correct the message inclusion cost in nv18 (filecoin-project#10228)

Co-authored-by: Raúl Kripalani <raul@protocol.ai>

* refactor: use EthHash for event topics

This ensures they're always 32 bytes and padded, as required.

* fix: eth: strict event parsing

We now enforce the following rules:

1. No duplicate topics or data.
2. Topics must have 32 byte keys.
3. Topics may not be skipped. (e.g., no t1 & t3 without a t2).
4. Raw codecs.

We _don't_ require that topics/data be emitted in any specific order.

We _skip_ events with unknown keys. We _drop_ events that violate the
above rules.

* Apply suggestions from code review

Co-authored-by: raulk <raul@protocol.ai>

* fix: eth: log on unexpected events

We can remove these later as we add more event types, but this will aid
in debugging.

* fix: make gen

* fix config.yml

* implement itest and handle optional params

* fix typo

* fix: stmgr: make the tipset and height agree when estimating gas (filecoin-project#10216)

* fix: stmgr: make the tipset and height agree when estimating gas

Specifically re-execute all messages in the current tipset, tacking the new
message onto the end. That way, the epoch is the epoch of the current tipset.

We could try to "make" a fake block and use that, but that's unlikely to
work well.

* fix: stmgr: only apply tipset messages for CallWithGas

* fix: itest: window post dispute

* eth_feeHistory: parse block param correctly.

* add todo

* Update to FFI v1.20.0-rc1

* fix bad test.

* improve TODO.

* Update to go-state-types v0.10.0-rc2

* disable adding git tags to bundle metadata

* Update actors to v10.0.0-rc.1

* eth: FIP-0055: implement final version of transitory delegated signature. (filecoin-project#10239)

* make lint happy and re-generate devgen.car

* setup ipc gateway in genesis and assign initial balance

* override with ipc-actors type to load ipc bundle automatically

* set balance of reward actor according to network name and minor fix

* linter fixes

* make linter happy :)

* deploy ipc subnet actor

* fix config.yml

---------

Co-authored-by: Ian Davis <nospam@iandavis.com>
Co-authored-by: Aayush <arajasek94@gmail.com>
Co-authored-by: ychiao <ychiaoli18@users.noreply.github.com>
Co-authored-by: cryptoAtwill <willes.lau@protocol.ai>
Co-authored-by: Phi <orjan.roren@gmail.com>
Co-authored-by: Łukasz Magiera <magik6k@gmail.com>
Co-authored-by: Geoff Stuart <geoff.vball@gmail.com>
Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com>
Co-authored-by: Geoff Stuart <geoffrey.stuart@protocol.ai>
Co-authored-by: Łukasz Magiera <magik6k@users.noreply.github.com>
Co-authored-by: Jennifer Wang <jiayingw703@gmail.com>
Co-authored-by: Ian Davis <jungziege@gmail.com>
Co-authored-by: Jorropo <jorropo.pgm@gmail.com>
Co-authored-by: Steven Allen <steven@stebalien.com>
Co-authored-by: Raúl Kripalani <raul@protocol.ai>
Co-authored-by: Richard Guan <richard.guan@protocol.ai>
Co-authored-by: Maciej Witowski <maciej.witowski@protocol.ai>
Co-authored-by: omahs <73983677+omahs@users.noreply.github.com>
Co-authored-by: snissn <snissn@gmail.com>
Co-authored-by: Peter Rabbitson <ribasushi@protocol.ai>
Co-authored-by: 0x5459 <0x5459@protonmail.com>
Co-authored-by: Travis Person <travisperson@users.noreply.github.com>
Co-authored-by: Anton Evangelatov <anton.evangelatov@gmail.com>
Co-authored-by: ognots <ognots@protonmail.com>
  • Loading branch information
25 people committed Feb 16, 2023
1 parent 8d114e2 commit 262595b
Show file tree
Hide file tree
Showing 49 changed files with 627 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -617,4 +617,4 @@ workflows:
name: mir-consensus-tests
suite: consensus
go-test-flags: "-tags=spacenet -timeout 60m -run TestMirConsensus"
target: "./itests/mir_test.go"
target: "./itests/mir_test.go"
4 changes: 4 additions & 0 deletions api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"time"

"github.com/consensus-shipyard/go-ipc-types/subnetactor"
"github.com/google/uuid"
"github.com/ipfs/go-cid"
blocks "github.com/ipfs/go-libipfs/blocks"
Expand Down Expand Up @@ -858,6 +859,9 @@ type FullNode interface {

RaftState(ctx context.Context) (*RaftStateData, error) //perm:read
RaftLeader(ctx context.Context) (peer.ID, error) //perm:read

// IPC-specific methods
IpcAddSubnetActor(ctx context.Context, wallet address.Address, params subnetactor.ConstructParams) (address.Address, error) //perm:write
}

// reverse interface to the client, called after EthSubscribe
Expand Down
7 changes: 4 additions & 3 deletions api/cbor_gen.go

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

3 changes: 3 additions & 0 deletions api/docgen/docgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"time"
"unicode"

"github.com/consensus-shipyard/go-ipc-types/subnetactor"
"github.com/google/uuid"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-graphsync"
Expand Down Expand Up @@ -401,6 +402,8 @@ func init() {
FromBlock: pstring("2301220"),
Address: []ethtypes.EthAddress{ethaddr},
})

addExample(subnetactor.ConsensusType(0))
}

func GetAPIType(name, pkg string) (i interface{}, t reflect.Type, permStruct []reflect.Type) {
Expand Down
34 changes: 26 additions & 8 deletions api/mocks/mock_full.go

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

32 changes: 24 additions & 8 deletions api/proxy_gen.go

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

10 changes: 6 additions & 4 deletions api/v0api/proxy_gen.go

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

18 changes: 10 additions & 8 deletions api/v0api/v0mocks/mock_full.go

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

Binary file added build/actors/ipc-actors.car
Binary file not shown.
57 changes: 54 additions & 3 deletions build/builtin_actors.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import (
//go:embed actors/*.tar.zst
var embeddedBuiltinActorReleases embed.FS

const IPCCarPath = "actors/ipc-actors.car"

//go:embed actors/ipc-actors.car
var ipcActorsFs embed.FS

func init() {
if BundleOverrides == nil {
BundleOverrides = make(map[actorstypes.Version]string)
Expand Down Expand Up @@ -61,9 +66,30 @@ func loadManifests(netw string) error {
var newMetadata []*BuiltinActorsMetadata
// First, prefer overrides.
for av, path := range BundleOverrides {
root, actorCids, err := readBundleManifestFromFile(path)
if err != nil {
return err
var (
root cid.Cid
actorCids map[string]cid.Cid
err error
)
// if the version bundle is to be overridden by the ipc-actors bundle
if IsIPCActorOverride(path) {
fi, err := ipcActorsFs.Open(IPCCarPath)
if err != nil {
return xerrors.Errorf("couldn't open ipc-actors.car: %w", err)
}

root, actorCids, err = readBundleManifest(fi)
if err != nil {
return err
}
fi.Close() //nolint

} else {
// else we use a path override
root, actorCids, err = readBundleManifestFromFile(path)
if err != nil {
return err
}
}
newMetadata = append(newMetadata, &BuiltinActorsMetadata{
Network: netw,
Expand Down Expand Up @@ -264,3 +290,28 @@ func GetEmbeddedBuiltinActorsBundle(version actorstypes.Version) ([]byte, bool)
return car, true
}
}

// GetIPCActorsBundle gets the specific bundle including ipc actors from the embedded car file.
func GetIPCActorsBundle(ctx context.Context, bs blockstore.Blockstore) (cid.Cid, error) {
f, err := ipcActorsFs.Open(IPCCarPath)
if err != nil {
return cid.Undef, xerrors.Errorf("error opening ipc-actors bundle: %w", err)
}
defer f.Close() //nolint

hdr, err := car.LoadCar(ctx, bs, f)
if err != nil {
return cid.Undef, xerrors.Errorf("error loading builtin actors bundle: %w", err)
}

if len(hdr.Roots) != 1 {
return cid.Undef, xerrors.Errorf("expected one root when loading actors bundle, got %d", len(hdr.Roots))
}
return hdr.Roots[0], nil
}

// IsIPCActorOverride checks if the override should point to the ipc-actors or
// some other generic path.
func IsIPCActorOverride(path string) bool {
return path == "ipc-actors"
}
Binary file modified build/openrpc/full.json.gz
Binary file not shown.
Binary file modified build/openrpc/gateway.json.gz
Binary file not shown.
Binary file modified build/openrpc/miner.json.gz
Binary file not shown.
Binary file modified build/openrpc/worker.json.gz
Binary file not shown.
4 changes: 3 additions & 1 deletion build/params_spacenet.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import (
)

var NetworkBundle = "devnet"
var BundleOverrides map[actorstypes.Version]string
var BundleOverrides = map[actorstypes.Version]string{
actorstypes.Version10: "ipc-actors",
}
var ActorDebugging = false

// FIXME: The following will be used to address this issue:
Expand Down
Binary file added builtin-actors-devnet.car
Binary file not shown.
14 changes: 12 additions & 2 deletions chain/gen/genesis/f02_reward.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package genesis
import (
"context"

ipctypes "github.com/consensus-shipyard/go-ipc-types/sdk"
cbor "github.com/ipfs/go-ipld-cbor"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-state-types/abi"
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/manifest"
Expand All @@ -18,7 +20,7 @@ import (
"github.com/filecoin-project/lotus/chain/types"
)

func SetupRewardActor(ctx context.Context, bs bstore.Blockstore, qaPower big.Int, av actorstypes.Version) (*types.Actor, error) {
func SetupRewardActor(ctx context.Context, bs bstore.Blockstore, qaPower big.Int, av actorstypes.Version, networkName string) (*types.Actor, error) {
cst := cbor.NewCborStore(bs)
rst, err := reward.MakeState(adt.WrapStore(ctx, cst), av, qaPower)
if err != nil {
Expand All @@ -35,9 +37,17 @@ func SetupRewardActor(ctx context.Context, bs bstore.Blockstore, qaPower big.Int
return nil, xerrors.Errorf("failed to get reward actor code ID for actors version %d", av)
}

// For IPC and spacenet, rewards are handled by the IPC gateway in subnets,
// let's not allocate any initial balance into the reward actor if this is not
// the rootnet.
balance := abi.NewTokenAmount(0)
if networkName == ipctypes.RootSubnet.String() {
balance = types.BigInt{Int: build.InitialRewardBalance}
}

act := &types.Actor{
Code: actcid,
Balance: types.BigInt{Int: build.InitialRewardBalance},
Balance: balance,
Head: statecid,
}

Expand Down
Loading

0 comments on commit 262595b

Please sign in to comment.