Merge pull request #1505 from filecoin-project/fix/pond-tskeys

pond: Use tipestKeys for state calls
This commit is contained in:
Łukasz Magiera 2020-04-03 01:17:01 +02:00 committed by GitHub
commit d060dda0c5
5 changed files with 30 additions and 30 deletions

View File

@ -192,7 +192,7 @@ func (h handlers) handle(ctx context.Context, req request, w func(func(io.Writer
for i := 0; i < handler.nParams; i++ { for i := 0; i < handler.nParams; i++ {
rp := reflect.New(handler.paramReceivers[i]) rp := reflect.New(handler.paramReceivers[i])
if err := json.NewDecoder(bytes.NewReader(req.Params[i].data)).Decode(rp.Interface()); err != nil { if err := json.NewDecoder(bytes.NewReader(req.Params[i].data)).Decode(rp.Interface()); err != nil {
rpcError(w, &req, rpcParseError, xerrors.Errorf("unmarshaling params for '%s': %w", handler.handlerFunc, err)) rpcError(w, &req, rpcParseError, xerrors.Errorf("unmarshaling params for '%s' (param: %T): %w", req.Method, rp.Interface(), err))
stats.Record(ctx, metrics.RPCRequestError.M(1)) stats.Record(ctx, metrics.RPCRequestError.M(1))
return return
} }

View File

@ -50,11 +50,11 @@ class Address extends React.Component {
try { try {
balance = await this.props.client.call('Filecoin.WalletBalance', [this.props.addr]) balance = await this.props.client.call('Filecoin.WalletBalance', [this.props.addr])
actor = await this.props.client.call('Filecoin.StateGetActor', [this.props.addr, this.props.ts || null]) actor = await this.props.client.call('Filecoin.StateGetActor', [this.props.addr, (this.props.ts || {}).Cids])
actorInfo = await this.actorInfo(actor) actorInfo = await this.actorInfo(actor)
if(this.props.miner) { if(this.props.miner) {
minerInfo = await this.props.client.call('Filecoin.StateMinerPower', [this.props.addr, this.props.ts || null]) minerInfo = await this.props.client.call('Filecoin.StateMinerPower', [this.props.addr, (this.props.ts || {}).Cids])
} }
if(this.props.nonce) { if(this.props.nonce) {
nonce = await this.props.client.call('Filecoin.MpoolGetNonce', [this.props.addr]) nonce = await this.props.client.call('Filecoin.MpoolGetNonce', [this.props.addr])
@ -82,7 +82,7 @@ class Address extends React.Component {
let info = <span>({mh.digest.toString()}{method})</span> let info = <span>({mh.digest.toString()}{method})</span>
switch(mh.digest.toString()) { switch(mh.digest.toString()) {
case 'paych': case 'paych':
const actstate = await this.props.client.call('Filecoin.StateReadState', [actor, this.props.ts || null]) const actstate = await this.props.client.call('Filecoin.StateReadState', [actor, (this.props.ts || {}).Cids])
info = <span>({mh.digest.toString()}{method} to <Address nobalance={true} client={this.props.client} addr={actstate.State.To} mountWindow={this.props.mountWindow}/>)</span> info = <span>({mh.digest.toString()}{method} to <Address nobalance={true} client={this.props.client} addr={actstate.State.To} mountWindow={this.props.mountWindow}/>)</span>
} }

View File

@ -12,7 +12,7 @@ export class BlockLinks extends React.Component {
block = this.props.blocks[k] block = this.props.blocks[k]
} }
return <span><BlockLink key={c + '-' + k} block={block} conn={this.props.conn} cid={c} mountWindow={this.props.mountWindow}/> </span> return <span key={c + '-' + k}><BlockLink block={block} conn={this.props.conn} cid={c} mountWindow={this.props.mountWindow}/> </span>
}) })
} }
} }

View File

@ -45,7 +45,7 @@ class FullNode extends React.Component {
return this.props.client.call('Filecoin.PaychVoucherList', [paych]) return this.props.client.call('Filecoin.PaychVoucherList', [paych])
})) }))
let mpoolPending = (await this.props.client.call('Filecoin.MpoolPending', [tipset])).length let mpoolPending = (await this.props.client.call('Filecoin.MpoolPending', [tipset.Cids])).length
this.setState(() => ({ this.setState(() => ({
id: id, id: id,
@ -64,13 +64,13 @@ class FullNode extends React.Component {
} }
async newSecpAddr() { async newSecpAddr() {
const t = "secp256k1" const t = 1
await this.props.client.call("Filecoin.WalletNew", [t]) await this.props.client.call("Filecoin.WalletNew", [t])
this.loadInfo() this.loadInfo()
} }
async newBLSAddr() { async newBLSAddr() {
const t = "bls" const t = 2
await this.props.client.call("Filecoin.WalletNew", [t]) await this.props.client.call("Filecoin.WalletNew", [t])
this.loadInfo() this.loadInfo()
} }

View File

@ -22,7 +22,7 @@ class State extends React.Component {
async componentDidMount() { async componentDidMount() {
const tipset = this.props.tipset || await this.props.client.call("Filecoin.ChainHead", []) const tipset = this.props.tipset || await this.props.client.call("Filecoin.ChainHead", [])
const actstate = await this.props.client.call('Filecoin.StateReadState', [this.props.actor, tipset]) const actstate = await this.props.client.call('Filecoin.StateReadState', [this.props.actor, tipset.Cids])
const c = new CID(this.props.actor.Code['/']) const c = new CID(this.props.actor.Code['/'])
const mh = multihash.decode(c.multihash) const mh = multihash.decode(c.multihash)
@ -37,7 +37,7 @@ class State extends React.Component {
const Stelem = this.byCode[this.state.code] const Stelem = this.byCode[this.state.code]
state = <Stelem addr={this.props.addr} actor={this.props.actor} client={this.props.client} mountWindow={this.props.mountWindow} tipset={this.props.tipset}/> state = <Stelem addr={this.props.addr} actor={this.props.actor} client={this.props.client} mountWindow={this.props.mountWindow} tipset={this.props.tipset}/>
} else { } else {
state = <div>{Object.keys(this.state.State).map(k => <div key={k}>{k}: <span>{JSON.stringify(this.state.State[k])}</span></div>)}</div> state = <div>{Object.keys(this.state.State || {}).map(k => <div key={k}>{k}: <span>{JSON.stringify(this.state.State[k])}</span></div>)}</div>
} }
const content = <div className="State"> const content = <div className="State">
@ -60,7 +60,7 @@ class InitState extends React.Component {
async componentDidMount() { async componentDidMount() {
const tipset = await this.props.client.call("Filecoin.ChainHead", []) // TODO: from props const tipset = await this.props.client.call("Filecoin.ChainHead", []) // TODO: from props
const actors = await this.props.client.call("Filecoin.StateListActors", [tipset]) const actors = await this.props.client.call("Filecoin.StateListActors", [tipset.Cids])
this.setState({actors: actors}) this.setState({actors: actors})
} }
@ -79,8 +79,8 @@ class PowerState extends React.Component {
async componentDidMount() { async componentDidMount() {
const tipset = await this.props.client.call("Filecoin.ChainHead", []) // TODO: from props const tipset = await this.props.client.call("Filecoin.ChainHead", []) // TODO: from props
const actors = await this.props.client.call("Filecoin.StateListMiners", [tipset]) const actors = await this.props.client.call("Filecoin.StateListMiners", [tipset.Cids])
const state = await this.props.client.call('Filecoin.StateReadState', [this.props.actor, tipset]) const state = await this.props.client.call('Filecoin.StateReadState', [this.props.actor, tipset.Cids])
this.setState({actors, state}) this.setState({actors, state})
} }
@ -105,9 +105,9 @@ class MarketState extends React.Component {
async componentDidMount() { async componentDidMount() {
const tipset = await this.props.client.call("Filecoin.ChainHead", []) // TODO: from props const tipset = await this.props.client.call("Filecoin.ChainHead", []) // TODO: from props
const participants = await this.props.client.call("Filecoin.StateMarketParticipants", [tipset]) const participants = await this.props.client.call("Filecoin.StateMarketParticipants", [tipset.Cids])
const deals = await this.props.client.call("Filecoin.StateMarketDeals", [tipset]) const deals = await this.props.client.call("Filecoin.StateMarketDeals", [tipset.Cids])
const state = await this.props.client.call('Filecoin.StateReadState', [this.props.actor, tipset]) const state = await this.props.client.call('Filecoin.StateReadState', [this.props.actor, tipset.Cids])
this.setState({participants, deals, nextDeal: state.State.NextDealID}) this.setState({participants, deals, nextDeal: state.State.NextDealID})
} }
@ -128,15 +128,15 @@ class MarketState extends React.Component {
<div>---</div> <div>---</div>
<div>Deals ({this.state.nextDeal} Total):</div> <div>Deals ({this.state.nextDeal} Total):</div>
<table> <table>
<tr><td>id</td><td>Active</td><td>Client</td><td>Provider</td><td>Size</td><td>Price</td><td>Duration</td></tr> <tr><td>id</td><td>Started</td><td>Client</td><td>Provider</td><td>Size</td><td>Price</td><td>Duration</td></tr>
{Object.keys(this.state.deals).map(d => <tr> {Object.keys(this.state.deals).map(d => <tr>
<td>{d}</td> <td>{d}</td>
<td>{this.state.deals[d].ActivationEpoch || "No"}</td> <td>{this.state.deals[d].State.SectorStartEpoch || "No"}</td>
<td><Address short={true} addr={this.state.deals[d].Deal.Proposal.Client} client={this.props.client} mountWindow={this.props.mountWindow}/></td> <td><Address short={true} addr={this.state.deals[d].Proposal.Client} client={this.props.client} mountWindow={this.props.mountWindow}/></td>
<td><Address short={true} addr={this.state.deals[d].Deal.Proposal.Provider} client={this.props.client} mountWindow={this.props.mountWindow}/></td> <td><Address short={true} addr={this.state.deals[d].Proposal.Provider} client={this.props.client} mountWindow={this.props.mountWindow}/></td>
<td>{this.state.deals[d].Deal.Proposal.PieceSize}B</td> <td>{this.state.deals[d].Proposal.PieceSize}B</td>
<td>{this.state.deals[d].Deal.Proposal.StoragePricePerEpoch*this.state.deals[d].Deal.Proposal.Duration}</td> <td>{this.state.deals[d].Proposal.StoragePricePerEpoch*(this.state.deals[d].Proposal.EndEpoch-this.state.deals[d].Proposal.StartEpoch)}</td>
<td>{this.state.deals[d].Deal.Proposal.Duration}</td> <td>{this.state.deals[d].Proposal.EndEpoch-this.state.deals[d].Proposal.StartEpoch}</td>
</tr>)} </tr>)}
</table> </table>
</div> </div>
@ -153,17 +153,17 @@ class MinerState extends React.Component {
async componentDidMount() { async componentDidMount() {
const tipset = await this.props.client.call("Filecoin.ChainHead", []) // TODO: from props const tipset = await this.props.client.call("Filecoin.ChainHead", []) // TODO: from props
const state = await this.props.client.call('Filecoin.StateReadState', [this.props.actor, tipset]) const state = await this.props.client.call('Filecoin.StateReadState', [this.props.actor, tipset.Cids])
const sectorSize = await this.props.client.call("Filecoin.StateMinerSectorSize", [this.props.addr, tipset]) const sectorSize = await this.props.client.call("Filecoin.StateMinerSectorSize", [this.props.addr, tipset.Cids])
const worker = await this.props.client.call("Filecoin.StateMinerWorker", [this.props.addr, tipset]) const worker = await this.props.client.call("Filecoin.StateMinerWorker", [this.props.addr, tipset.Cids])
const tpow = await this.props.client.call("Filecoin.StateMinerPower", [this.props.addr, tipset]) const tpow = await this.props.client.call("Filecoin.StateMinerPower", [this.props.addr, tipset.Cids])
const networkPower = tpow.TotalPower const networkPower = tpow.TotalPower
let sectors = {} let sectors = {}
const sset = await this.props.client.call("Filecoin.StateMinerSectors", [this.props.addr, tipset]) || [] const sset = await this.props.client.call("Filecoin.StateMinerSectors", [this.props.addr, tipset.Cids]) || []
const pset = await this.props.client.call("Filecoin.StateMinerProvingSet", [this.props.addr, tipset]) || [] const pset = await this.props.client.call("Filecoin.StateMinerProvingSet", [this.props.addr, tipset.Cids]) || []
sset.forEach(s => sectors[s.SectorID] = {...s, sectorSet: true}) sset.forEach(s => sectors[s.SectorID] = {...s, sectorSet: true})
pset.forEach(s => sectors[s.SectorID] = {...(sectors[s.SectorID] || s), provingSet: true}) pset.forEach(s => sectors[s.SectorID] = {...(sectors[s.SectorID] || s), provingSet: true})
@ -181,7 +181,7 @@ class MinerState extends React.Component {
return <div> return <div>
<div>Worker: <Address addr={this.state.worker} client={this.props.client} mountWindow={this.props.mountWindow}/></div> <div>Worker: <Address addr={this.state.worker} client={this.props.client} mountWindow={this.props.mountWindow}/></div>
<div>Sector Size: <b>{this.state.sectorSize/1024}</b> KiB</div> <div>Sector Size: <b>{this.state.sectorSize/1024}</b> KiB</div>
<div>Power: <b>{state.Power}</b> (<b>{state.Power/this.state.networkPower*100}</b>%)</div> <div>Power: <b>todoPower</b> (<b>{1/this.state.networkPower*100}</b>%)</div>
<div>Election Period Start: <b>{state.ElectionPeriodStart}</b></div> <div>Election Period Start: <b>{state.ElectionPeriodStart}</b></div>
<div>Slashed: <b>{state.SlashedAt === 0 ? "NO" : state.SlashedAt}</b></div> <div>Slashed: <b>{state.SlashedAt === 0 ? "NO" : state.SlashedAt}</b></div>
<div> <div>