diff --git a/chain/store/store.go b/chain/store/store.go index e7a269602..2ca09dfe9 100644 --- a/chain/store/store.go +++ b/chain/store/store.go @@ -733,11 +733,25 @@ func (cs *ChainStore) AddToTipSetTracker(b *types.BlockHeader) error { } } } + // This function is called 5 times per epoch on average + // It is also called with tipsets that are done with initial validation + // so they cannot be from the future. + // We are guaranteed not to use tipsets older than 900 epochs (fork limit) + // This means that we ideally want to keep only most recent 900 epochs in here + // Golang's map iteration starts at a random point in a map. + // With 5 tries per epoch, and 900 entries to keep, on average we will have + // ~136 garbage entires in the `cs.tipsets` map. (solve for 1-(1-x/(900+x))^5 == 0.5) + // Seems good enough to me + + for height := range cs.tipsets { + if height < b.Height-build.Finality { + delete(cs.tipsets, height) + } + break + } cs.tipsets[b.Height] = append(tss, b.Cid()) - // TODO: do we want to look for slashable submissions here? might as well... - return nil } diff --git a/node/impl/full/wallet.go b/node/impl/full/wallet.go index 05a7a5768..80ae65576 100644 --- a/node/impl/full/wallet.go +++ b/node/impl/full/wallet.go @@ -56,7 +56,7 @@ func (a *WalletAPI) WalletSignMessage(ctx context.Context, k address.Address, ms return nil, xerrors.Errorf("serializing message: %w", err) } - sig, err := a.WalletAPI.WalletSign(ctx, k, mb.Cid().Bytes(), api.MsgMeta{ + sig, err := a.WalletAPI.WalletSign(ctx, keyAddr, mb.Cid().Bytes(), api.MsgMeta{ Type: api.MTChainMsg, Extra: mb.RawData(), })