lotus/lotus-soup/rfwp/html_chain_state.go
Anton Evangelatov 097d82535d
upgrade lotus-soup (drand, lotus, stop/resume drand) (#249)
* wip

* commit with fewer error messages

* reduce headlag from 3 to 1

* fixes for params

* add composition for local:docker

* revert drand-halt plan

* initial monitor of miner power and chain epochs

* revert params to be same as filecoin mainnet

* increase timeout for drand resuming from 30sec to 120sec.

* increase log level

* upgrade lotus to v0.6.1

* upgrade drand to v1.1.1

* increase prepare node timeout from 1 min to 3 min

* upgrade drand to master. increase timeouts for prepare drand node

* nil the stmgr.ForksAtHeight map

* modify starting/stopping of drand within testplan

* increase drand outage to 45min. so that we miss windows

* upgrade proof parameters in docker images

* revert in-complete changes

* use correct runtime debug image
2020-09-16 12:51:23 +02:00

67 lines
1.4 KiB
Go

package rfwp
import (
"context"
"fmt"
"os"
"github.com/filecoin-project/oni/lotus-soup/testkit"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/cli"
tstats "github.com/filecoin-project/lotus/tools/stats"
"github.com/ipfs/go-cid"
)
func FetchChainState(t *testkit.TestEnvironment, m *testkit.LotusMiner) error {
height := 0
headlag := 3
ctx := context.Background()
api := m.FullApi
tipsetsCh, err := tstats.GetTips(ctx, m.FullApi, abi.ChainEpoch(height), headlag)
if err != nil {
return err
}
for tipset := range tipsetsCh {
err := func() error {
filename := fmt.Sprintf("%s%cchain-state-%d.html", t.TestOutputsPath, os.PathSeparator, tipset.Height())
file, err := os.Create(filename)
defer file.Close()
if err != nil {
return err
}
stout, err := api.StateCompute(ctx, tipset.Height(), nil, tipset.Key())
if err != nil {
return err
}
codeCache := map[address.Address]cid.Cid{}
getCode := func(addr address.Address) (cid.Cid, error) {
if c, found := codeCache[addr]; found {
return c, nil
}
c, err := api.StateGetActor(ctx, addr, tipset.Key())
if err != nil {
return cid.Cid{}, err
}
codeCache[addr] = c.Code
return c.Code, nil
}
return cli.ComputeStateHTMLTempl(file, tipset, stout, getCode)
}()
if err != nil {
return err
}
}
return nil
}