From 33322906265f8756a1cb8ea9b15fdadad8851492 Mon Sep 17 00:00:00 2001 From: Mike Greenberg Date: Fri, 10 Jul 2020 11:54:11 -0400 Subject: [PATCH] fix: Logic bug; Schema column update stateroot -> state_root --- cmd/lotus-chainwatch/storage.go | 12 ++++++------ cmd/lotus-chainwatch/sync.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/lotus-chainwatch/storage.go b/cmd/lotus-chainwatch/storage.go index c48435829..8a4215bd2 100644 --- a/cmd/lotus-chainwatch/storage.go +++ b/cmd/lotus-chainwatch/storage.go @@ -299,7 +299,7 @@ create table if not exists miner_info */ create table if not exists chain_power ( - stateroot text not null + state_root text not null constraint chain_power_pk primary key, baseline_power text not null @@ -311,11 +311,11 @@ create table if not exists chain_power create table if not exists miner_power ( miner_id text not null, - stateroot text not null, + state_root text not null, raw_bytes_power text not null, quality_adjusted_power text not null, constraint miner_power_pk - primary key (miner_id, stateroot) + primary key (miner_id, state_root) ); /* used to tell when a miners sectors (proven-not-yet-expired) changed if the miner_sectors_cid's are different a new sector was added or removed (terminated/expired) */ @@ -535,7 +535,7 @@ func (st *storage) storeChainPower(rewardTips map[types.TipSetKey]*rewardStateIn return xerrors.Errorf("prep chain_power temp: %w", err) } - stmt, err := tx.Prepare(`copy cp (stateroot, baseline_power) from STDIN`) + stmt, err := tx.Prepare(`copy cp (state_root, baseline_power) from STDIN`) if err != nil { return xerrors.Errorf("prepare tmp chain_power: %w", err) } @@ -545,7 +545,7 @@ func (st *storage) storeChainPower(rewardTips map[types.TipSetKey]*rewardStateIn rewardState.stateroot.String(), rewardState.baselinePower.String(), ); err != nil { - log.Errorw("failed to store chain power", "stateroot", rewardState.stateroot, "error", err) + log.Errorw("failed to store chain power", "state_root", rewardState.stateroot, "error", err) } } @@ -682,7 +682,7 @@ func (st *storage) storeMinerPower(minerTips map[types.TipSetKey][]*minerStateIn return xerrors.Errorf("prep miner_power temp: %w", err) } - stmt, err := tx.Prepare(`copy cp (miner_id, stateroot, raw_bytes_power, quality_adjusted_power) from STDIN`) + stmt, err := tx.Prepare(`copy mp (miner_id, state_root, raw_bytes_power, quality_adjusted_power) from STDIN`) if err != nil { return xerrors.Errorf("prepare tmp miner_power: %w", err) } diff --git a/cmd/lotus-chainwatch/sync.go b/cmd/lotus-chainwatch/sync.go index 4ba4ea33c..442fd9c0c 100644 --- a/cmd/lotus-chainwatch/sync.go +++ b/cmd/lotus-chainwatch/sync.go @@ -317,7 +317,7 @@ func syncHead(ctx context.Context, api api.FullNode, st *storage, headTs *types. for addr, m := range actors { for actor, c := range m { // reward actor - if actor.Code != builtin.RewardActorCodeID { + if actor.Code == builtin.RewardActorCodeID { rewardTips[c.tsKey] = &rewardStateInfo{ stateroot: c.stateroot, baselinePower: big.Zero(), @@ -326,7 +326,7 @@ func syncHead(ctx context.Context, api api.FullNode, st *storage, headTs *types. } // miner actors with head change events - if actor.Code != builtin.StorageMinerActorCodeID { + if actor.Code == builtin.StorageMinerActorCodeID { if _, found := headsSeen[actor.Head]; found { continue }