From 0b498d25f65903a7343e948e2276dbe275958c74 Mon Sep 17 00:00:00 2001 From: Mike Greenberg Date: Thu, 13 Aug 2020 22:59:30 -0400 Subject: [PATCH 1/3] fix(chainwatch): Actor code are human readable --- cmd/lotus-chainwatch/processor/common_actors.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/lotus-chainwatch/processor/common_actors.go b/cmd/lotus-chainwatch/processor/common_actors.go index 5264a48c8..698badcce 100644 --- a/cmd/lotus-chainwatch/processor/common_actors.go +++ b/cmd/lotus-chainwatch/processor/common_actors.go @@ -8,8 +8,6 @@ import ( "golang.org/x/sync/errgroup" "golang.org/x/xerrors" - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/lotus/chain/events/state" "github.com/filecoin-project/lotus/chain/types" @@ -17,6 +15,8 @@ import ( "github.com/filecoin-project/specs-actors/actors/builtin" _init "github.com/filecoin-project/specs-actors/actors/builtin/init" "github.com/filecoin-project/specs-actors/actors/util/adt" + "github.com/ipfs/go-cid" + "github.com/multiformats/go-multihash" typegen "github.com/whyrusleeping/cbor-gen" ) @@ -243,9 +243,13 @@ func (p *Processor) storeActorHeads(actors map[cid.Cid]ActorTips) error { } for code, actTips := range actors { + actorName := code.String() + if s, err := multihash.Decode(code.Hash()); err != nil { + actorName = string(s.Digest) + } for _, actorInfo := range actTips { for _, a := range actorInfo { - if _, err := stmt.Exec(a.addr.String(), code.String(), a.act.Head.String(), a.act.Nonce, a.act.Balance.String(), a.stateroot.String()); err != nil { + if _, err := stmt.Exec(a.addr.String(), actorName, a.act.Head.String(), a.act.Nonce, a.act.Balance.String(), a.stateroot.String()); err != nil { return err } } @@ -285,9 +289,13 @@ func (p *Processor) storeActorStates(actors map[cid.Cid]ActorTips) error { } for code, actTips := range actors { + actorName := code.String() + if s, err := multihash.Decode(code.Hash()); err != nil { + actorName = string(s.Digest) + } for _, actorInfo := range actTips { for _, a := range actorInfo { - if _, err := stmt.Exec(a.act.Head.String(), code.String(), a.state); err != nil { + if _, err := stmt.Exec(a.act.Head.String(), actorName, a.state); err != nil { return err } } From b37a39588e36a15e9e0cb0619b4bf2c647299aa9 Mon Sep 17 00:00:00 2001 From: Mike Greenberg Date: Mon, 17 Aug 2020 11:31:59 -0400 Subject: [PATCH 2/3] feat(chainwatch): Add full version to help/startup log via build param --- Makefile | 2 +- cmd/lotus-chainwatch/main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0ef3c2264..2383585b5 100644 --- a/Makefile +++ b/Makefile @@ -148,7 +148,7 @@ BINS+=lotus-fountain lotus-chainwatch: rm -f lotus-chainwatch - go build -o lotus-chainwatch ./cmd/lotus-chainwatch + go build $(GOFLAGS) -o lotus-chainwatch ./cmd/lotus-chainwatch .PHONY: lotus-chainwatch BINS+=lotus-chainwatch diff --git a/cmd/lotus-chainwatch/main.go b/cmd/lotus-chainwatch/main.go index bcea3193d..b230d9cae 100644 --- a/cmd/lotus-chainwatch/main.go +++ b/cmd/lotus-chainwatch/main.go @@ -14,7 +14,7 @@ func main() { if err := logging.SetLogLevel("*", "info"); err != nil { log.Fatal(err) } - log.Info("Starting chainwatch") + log.Info("Starting chainwatch", " v", build.UserVersion()) app := &cli.App{ Name: "lotus-chainwatch", From 80fef50b90d7c780d0cb7bef277da0e9c3ca80f9 Mon Sep 17 00:00:00 2001 From: Mike Greenberg Date: Mon, 17 Aug 2020 12:22:34 -0400 Subject: [PATCH 3/3] feat(chainwatch): Include detailed economic data per epoch --- cmd/lotus-chainwatch/syncer/sync.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/lotus-chainwatch/syncer/sync.go b/cmd/lotus-chainwatch/syncer/sync.go index 81cd9e269..5e559b42a 100644 --- a/cmd/lotus-chainwatch/syncer/sync.go +++ b/cmd/lotus-chainwatch/syncer/sync.go @@ -46,7 +46,11 @@ create table if not exists chain_economics ( parent_state_root text not null constraint chain_economics_pk primary key, - circulating_fil text not null + circulating_fil text not null, + vested_fil text not null, + mined_fil text not null, + burnt_fil text not null, + locked_fil text not null ); create table if not exists block_cids @@ -283,12 +287,16 @@ func (s *Syncer) storeCirculatingSupply(ctx context.Context, tipset *types.TipSe return err } - ceInsert := `insert into chain_economics (parent_state_root, circulating_fil) values ('%s', '%s');` + ceInsert := `insert into chain_economics (parent_state_root, circulating_fil, vested_fil, mined_fil, burnt_fil, locked_fil)` + + `values ('%s', '%s', '%s', '%s', '%s', '%s');` if _, err := s.db.Exec(fmt.Sprintf(ceInsert, tipset.ParentState().String(), - // TODO: Include all the details maybe? supply.FilCirculating.String(), + supply.FilVested.String(), + supply.FilMined.String(), + supply.FilBurnt.String(), + supply.FilLocked.String(), )); err != nil { return xerrors.Errorf("insert circulating supply for tipset (%s): %w", tipset.Key().String(), err) }