Skip to content

Commit

Permalink
fix v1api not in effect and update calibnet (#4471)
Browse files Browse the repository at this point in the history
* fix v1api not in effect

* updata calibnet
  • Loading branch information
simlecode authored Jun 19, 2021
1 parent 50e1a44 commit e63892f
Show file tree
Hide file tree
Showing 9 changed files with 475 additions and 90 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ gen:
gofmt -s -l -w ./app/client/client_gen.go
goimports -l -w ./app/client/client_gen.go


gen-asset:
go-bindata -pkg=asset -o ./fixtures/asset/asset.go ./fixtures/_assets/car/ ./fixtures/_assets/proof-params/ ./fixtures/_assets/arch-diagram.monopic
4 changes: 2 additions & 2 deletions app/client/v0api/full.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ type IChainInfoStruct struct {
StateNetworkVersion func(p0 context.Context, p1 types.TipSetKey) (network.Version, error) `perm:"read"`
StateSearchMsg func(p0 context.Context, p1 cid.Cid) (*apitypes.MsgLookup, error) `perm:"read"`
StateSearchMsgLimited func(p0 context.Context, p1 cid.Cid, p2 abi.ChainEpoch) (*apitypes.MsgLookup, error) `perm:"read"`
StateWaitMsg func(p0 context.Context, p1 cid.Cid, p2 uint64, p3 abi.ChainEpoch) (*apitypes.MsgLookup, error) `perm:"read"`
StateWaitMsgLimited func(p0 context.Context, p1 cid.Cid, p2 uint64, p3 abi.ChainEpoch, p4 abi.ChainEpoch) (*apitypes.MsgLookup, error) `perm:"read"`
StateWaitMsg func(p0 context.Context, p1 cid.Cid, p2 uint64) (*apitypes.MsgLookup, error) `perm:"read"`
StateWaitMsgLimited func(p0 context.Context, p1 cid.Cid, p2 uint64, p3 abi.ChainEpoch) (*apitypes.MsgLookup, error) `perm:"read"`
StateGetReceipt func(p0 context.Context, p1 cid.Cid, p2 types.TipSetKey) (*types.MessageReceipt, error) `perm:"read"`
VerifyEntry func(p0 *types.BeaconEntry, p1 *types.BeaconEntry, p2 abi.ChainEpoch) bool `perm:"read"`
}
Expand Down
5 changes: 3 additions & 2 deletions app/node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package node

import (
"context"
"github.com/filecoin-project/venus/pkg/jwtauth"
"time"

"github.com/filecoin-project/venus/pkg/jwtauth"

"github.com/filecoin-project/venus/app/submodule/multisig"

"github.com/filecoin-project/go-state-types/abi"
Expand Down Expand Up @@ -337,8 +338,8 @@ func (b *Builder) build(ctx context.Context) (*Node, error) {
if err != nil {
return nil, errors.Wrap(err, "add service failed ")
}
nd.jsonRPCService = apiBuilder.Build("v0")
nd.jsonRPCServiceV1 = apiBuilder.Build("v1")
nd.jsonRPCService = apiBuilder.Build("v0")
return nd, nil
}

Expand Down
12 changes: 7 additions & 5 deletions app/node/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,19 @@ func (builder *RPCBuilder) Build(version string) *jsonrpc.RPCServer {
for _, apiStruct := range builder.v0APIStruct {
funcrule.PermissionProxy(apiStruct, &fullNodeV0)
}
for _, nameSpace := range builder.namespace {
server.Register(nameSpace, &fullNodeV0)
}
case "v1":
for _, apiStruct := range builder.v1APIStruct {
funcrule.PermissionProxy(apiStruct, &fullNode)
}
for _, nameSpace := range builder.namespace {
server.Register(nameSpace, &fullNode)
}
default:

panic("invalid version: " + version)
}

for _, nameSpace := range builder.namespace {
server.Register(nameSpace, &fullNode)
server.Register(nameSpace, &fullNodeV0)
}
return server
}
2 changes: 1 addition & 1 deletion extern/filecoin-ffi
Submodule filecoin-ffi updated 2 files
+27 −27 rust/Cargo.lock
+1 −1 version.go
Binary file modified fixtures/_assets/car/calibnet.car
Binary file not shown.
386 changes: 317 additions & 69 deletions fixtures/asset/asset.go

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions fixtures/networks/calibration.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ func Calibration() *NetworkConf {
return &NetworkConf{
Bootstrap: config.BootstrapConfig{
Addresses: []string{
"/dns4/bootstrap-0.calibration.fildev.network/tcp/1347/p2p/12D3KooWRLZAseMo9h7fRD6ojn6YYDXHsBSavX5YmjBZ9ngtAEec",
"/dns4/bootstrap-1.calibration.fildev.network/tcp/1347/p2p/12D3KooWJFtDXgZEQMEkjJPSrbfdvh2xfjVKrXeNFG1t8ioJXAzv",
"/dns4/bootstrap-2.calibration.fildev.network/tcp/1347/p2p/12D3KooWP1uB9Lo7yCA3S17TD4Y5wStP5Nk7Vqh53m8GsFjkyujD",
"/dns4/bootstrap-3.calibration.fildev.network/tcp/1347/p2p/12D3KooWLrPM4WPK1YRGPCUwndWcDX8GCYgms3DiuofUmxwvhMCn",
"/dns4/bootstrap-0.calibration.fildev.network/tcp/1347/p2p/12D3KooWJkikQQkxS58spo76BYzFt4fotaT5NpV2zngvrqm4u5ow",
"/dns4/bootstrap-1.calibration.fildev.network/tcp/1347/p2p/12D3KooWLce5FDHR4EX4CrYavphA5xS3uDsX6aoowXh5tzDUxJav",
"/dns4/bootstrap-2.calibration.fildev.network/tcp/1347/p2p/12D3KooWA9hFfQG9GjP6bHeuQQbMD3FDtZLdW1NayxKXUT26PQZu",
"/dns4/bootstrap-3.calibration.fildev.network/tcp/1347/p2p/12D3KooWMHDi3LVTFG8Szqogt7RkNXvonbQYqSazxBx41A5aeuVz",
},
MinPeerThreshold: 0,
Period: "30s",
Expand All @@ -37,16 +37,16 @@ func Calibration() *NetworkConf {
UpgradeTapeHeight: 60,
UpgradeLiftoffHeight: -5,
UpgradeKumquatHeight: 90,
UpgradeCalicoHeight: 100,
UpgradeCalicoHeight: 120,
UpgradePersianHeight: 100 + (120 * 1),
UpgradeOrangeHeight: 300,
UpgradeTrustHeight: 600,
UpgradeNorwegianHeight: 114000,
UpgradeTurboHeight: 193789,
UpgradeHyperdriveHeight: 321519, // 2021-06-11T14:30:00Z
UpgradeTrustHeight: 330,
UpgradeNorwegianHeight: 360,
UpgradeTurboHeight: 390,
UpgradeHyperdriveHeight: 420,

BreezeGasTampingDuration: 120,
UpgradeClausHeight: 250,
UpgradeClausHeight: 270,
},
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1},
AddressNetwork: address.Testnet,
Expand Down
133 changes: 133 additions & 0 deletions tools/client/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package main

import (
"context"
"fmt"
"net/http"
"net/url"
"runtime/debug"

"github.com/filecoin-project/go-jsonrpc"
"github.com/ipfs/go-cid"
"github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr/net"

"github.com/filecoin-project/venus/app/client"
"github.com/filecoin-project/venus/app/client/v0api"
"github.com/filecoin-project/venus/pkg/constants"
"github.com/filecoin-project/venus/pkg/types"
)

const Filecoin = "Filecoin"

func main() {
defer func() {
if r := recover(); r != nil {
fmt.Println(r)
fmt.Println(string(debug.Stack()))
}
}()

ctx := context.Background()

addrBase := "/ip4/127.0.0.1/tcp/3453"
addr, err := dialArgs(addrBase, "v0")
checkErr(err)
addr2, err := dialArgs(addrBase, "v1")
checkErr(err)

handler := http.Header{}
var cliV0 v0api.FullNodeStruct
var cliV1 client.FullNodeStruct

closeV0, err := jsonrpc.NewClient(ctx, addr, Filecoin, &cliV0, handler)
checkErr(err)
defer closeV0()

closeV1, err := jsonrpc.NewClient(ctx, addr2, Filecoin, &cliV1, handler)
checkErr(err)
defer closeV1()

v, err := cliV0.Version(ctx)
checkErr(err)
fmt.Println("Version", v)

head, err := cliV0.ChainHead(ctx)
checkErr(err)
fmt.Println(head)

var checkOver bool
var i int
for ; !checkOver; i++ {
fullBlock, err := cliV0.GetFullBlock(ctx, head.Blocks()[0].Cid())
checkErr(err)
fmt.Println("GetFullBlock ", fullBlock.Header)

for _, m := range fullBlock.BLSMessages {
checkOver = true
msgLookup, err := cliV0.StateWaitMsg(ctx, m.Cid(), constants.DefaultConfidence)
checkErr(err)
fmt.Println("StateWaitMsg ", msgLookup)

msgLookup, err = cliV0.StateSearchMsg(ctx, m.Cid())
checkErr(err)
fmt.Println("StateSearchMsg ", msgLookup)

receipt, err := cliV0.StateGetReceipt(ctx, m.Cid(), types.TipSetKey{})
checkErr(err)
fmt.Println("StateGetReceipt ", receipt)

break
}

for _, m := range fullBlock.BLSMessages {
checkOver = true
msgLookup, err := cliV1.StateWaitMsg(ctx, m.Cid(), constants.DefaultConfidence, constants.LookbackNoLimit, true)
checkErr(err)
fmt.Println("StateWaitMsg ", msgLookup)

msgLookup, err = cliV1.StateSearchMsg(ctx, types.TipSetKey{}, m.Cid(), constants.LookbackNoLimit, true)
checkErr(err)
fmt.Println("StateSearchMsg ", msgLookup)

break
}

pt, err := cliV0.ChainGetTipSet(ctx, head.Parents())
checkErr(err)
fmt.Println("parent ", pt, "height ", pt.Height())
head = pt
}

}

func checkErr(err error) {
if err != nil {
panic(err)
}
}

// eg. "bafy2bzaceb2ff6egw54sjcarqvl22mkitmr7q5rmlinza6nnhk6p44t5eee24"
func toCid(cidStr string) cid.Cid { // nolint
cid, err := cid.Decode(cidStr)
checkErr(err)
return cid
}

func dialArgs(addr string, version string) (string, error) {
ma, err := multiaddr.NewMultiaddr(addr)
if err == nil {
_, addr, err := manet.DialArgs(ma)
if err != nil {
return "", err
}

return "ws://" + addr + "/rpc/" + version, nil
}

_, err = url.Parse(addr)
if err != nil {
return "", err
}
return addr + "/rpc/" + version, nil
}

0 comments on commit e63892f

Please sign in to comment.