farming info

This commit is contained in:
Yostra 2021-02-02 23:29:16 -05:00 committed by Gene Hoffman
parent 4415abb63d
commit a0a80949af
13 changed files with 163 additions and 65 deletions

View File

@ -3,35 +3,42 @@ import { useSelector } from 'react-redux';
import { Trans } from '@lingui/macro'; import { Trans } from '@lingui/macro';
import { Table, Card, FormatBytes } from '@chia/core'; import { Table, Card, FormatBytes } from '@chia/core';
import { Typography } from '@material-ui/core'; import { Typography } from '@material-ui/core';
import moment from 'moment';
import type { Row } from '../core/components/Table/Table'; import type { Row } from '../core/components/Table/Table';
import usePlots from '../../hooks/usePlots'; import usePlots from '../../hooks/usePlots';
import { RootState } from '../../modules/rootReducer'; import { RootState } from '../../modules/rootReducer';
const cols = [ const cols = [
{
field(row: Row) {
return row.signage_point_index;
},
title: <Trans id="FarmFullNodeConnections.height">Signage Point Index</Trans>,
},
{ {
field(row: Row) { field(row: Row) {
return row.challenge_hash; return row.challenge_hash;
}, },
title: <Trans id="FarmFullNodeConnections.date">Challenge Hash</Trans>, title: <Trans id="FarmFullNodeConnections.challenge">Challenge</Trans>,
}, },
{ {
field(row: Row) { field(row: Row) {
return row.plot_identifier; return `${row.passed_filter} / ${row.total_plots}`;
}, },
title: <Trans id="FarmFullNodeConnections.time">Plot ID</Trans>, title: <Trans id="FarmFullNodeConnections.passed_filter">Plots Passed Filter</Trans>,
},
{
field(row: Row) {
return row.proofs;
},
title: <Trans id="FarmFullNodeConnections.proofs_found">Proofs Found</Trans>,
},
{
field(row: Row) {
return moment(row.timestamp * 1000).format('lll');
},
title: <Trans id="FarmFullNodeConnections.date">Date</Trans>,
}, },
]; ];
export default function FarmLastAttemptedProof() { export default function FarmLastAttemptedProof() {
const { size } = usePlots(); const { size } = usePlots();
const lastAttemtedProof = useSelector((state: RootState) => state.farming_state.farmer.last_attempted_proofs ?? []); const lastAttemtedProof = useSelector((state: RootState) => state.farming_state.farmer.last_farming_info ?? []);
const reducedLastAttemtedProof = lastAttemtedProof.slice(0, 5); const reducedLastAttemtedProof = lastAttemtedProof.slice(0, 5);
const isEmpty = !reducedLastAttemtedProof.length; const isEmpty = !reducedLastAttemtedProof.length;

File diff suppressed because one or more lines are too long

View File

@ -883,21 +883,25 @@ msgstr "Total Size of Plots"
msgid "FarmFullNodeConnections.actions" msgid "FarmFullNodeConnections.actions"
msgstr "Actions" msgstr "Actions"
#: src/components/farm/FarmLastAttemptedProof.tsx:12
msgid "FarmFullNodeConnections.challenge"
msgstr "Challenge"
#: src/components/farm/FarmFullNodeConnections.tsx:66 #: src/components/farm/FarmFullNodeConnections.tsx:66
msgid "FarmFullNodeConnections.connectionStatus" msgid "FarmFullNodeConnections.connectionStatus"
msgstr "Connection Status:" msgstr "Connection Status:"
#: src/components/farm/FarmLastAttemptedProof.tsx:18 #: src/components/farm/FarmLastAttemptedProof.tsx:36
msgid "FarmFullNodeConnections.date" msgid "FarmFullNodeConnections.date"
msgstr "Challenge Hash" msgstr "Date"
#: src/components/farm/FarmFullNodeConnections.tsx:58 #: src/components/farm/FarmFullNodeConnections.tsx:58
msgid "FarmFullNodeConnections.description" msgid "FarmFullNodeConnections.description"
msgstr "The full node that your farmer is connected to is below. <0>Learn more</0>" msgstr "The full node that your farmer is connected to is below. <0>Learn more</0>"
#: src/components/farm/FarmLastAttemptedProof.tsx:12 #: src/components/farm/FarmLastAttemptedProof.tsx:12
msgid "FarmFullNodeConnections.height" #~ msgid "FarmFullNodeConnections.height"
msgstr "Signage Point Index" #~ msgstr "Signage Point Index"
#: src/components/farm/FarmFullNodeConnections.tsx:24 #: src/components/farm/FarmFullNodeConnections.tsx:24
msgid "FarmFullNodeConnections.hostName" msgid "FarmFullNodeConnections.hostName"
@ -907,13 +911,25 @@ msgstr "Host Name"
msgid "FarmFullNodeConnections.nodeId" msgid "FarmFullNodeConnections.nodeId"
msgstr "Node ID" msgstr "Node ID"
#: src/components/farm/FarmLastAttemptedProof.tsx:24
msgid "FarmFullNodeConnections.passed_filter"
msgstr "Plots Passed Filter"
#: src/components/farm/FarmFullNodeConnections.tsx:30 #: src/components/farm/FarmFullNodeConnections.tsx:30
msgid "FarmFullNodeConnections.port" msgid "FarmFullNodeConnections.port"
msgstr "Port" msgstr "Port"
#: src/components/farm/FarmLastAttemptedProof.tsx:30
msgid "FarmFullNodeConnections.proofs_found"
msgstr "Proofs Found"
#: src/components/farm/FarmLastAttemptedProof.tsx:18
msgid "FarmFullNodeConnections.signage_point"
msgstr "Signage Point"
#: src/components/farm/FarmLastAttemptedProof.tsx:24 #: src/components/farm/FarmLastAttemptedProof.tsx:24
msgid "FarmFullNodeConnections.time" #~ msgid "FarmFullNodeConnections.time"
msgstr "Plot ID" #~ msgstr "Plot ID"
#: src/components/farm/FarmFullNodeConnections.tsx:56 #: src/components/farm/FarmFullNodeConnections.tsx:56
msgid "FarmFullNodeConnections.title" msgid "FarmFullNodeConnections.title"
@ -923,19 +939,19 @@ msgstr "Your Full Node Connection"
msgid "FarmFullNodeConnections.upDown" msgid "FarmFullNodeConnections.upDown"
msgstr "MiB Up/Down" msgstr "MiB Up/Down"
#: src/components/farm/FarmLastAttemptedProof.tsx:38 #: src/components/farm/FarmLastAttemptedProof.tsx:50
msgid "FarmLastAttemptedProof.emptyDescription" msgid "FarmLastAttemptedProof.emptyDescription"
msgstr "None of your plots have passed the plot filter yet." msgstr "None of your plots have passed the plot filter yet."
#: src/components/farm/FarmLastAttemptedProof.tsx:44 #: src/components/farm/FarmLastAttemptedProof.tsx:56
msgid "FarmLastAttemptedProof.emptySubDescription" msgid "FarmLastAttemptedProof.emptySubDescription"
msgstr "But you are currently farming <0/>" msgstr "But you are currently farming <0/>"
#: src/components/farm/FarmLastAttemptedProof.tsx:32 #: src/components/farm/FarmLastAttemptedProof.tsx:44
msgid "FarmLastAttemptedProof.title" msgid "FarmLastAttemptedProof.title"
msgstr "Last Attempted Proof" msgstr "Last Attempted Proof"
#: src/components/farm/FarmLastAttemptedProof.tsx:34 #: src/components/farm/FarmLastAttemptedProof.tsx:46
msgid "FarmLastAttemptedProof.tooltip" msgid "FarmLastAttemptedProof.tooltip"
msgstr "This table shows you the last time your farm attempted to win a block challenge." msgstr "This table shows you the last time your farm attempted to win a block challenge."

File diff suppressed because one or more lines are too long

View File

@ -883,11 +883,15 @@ msgstr "Celková veľkosť polí"
msgid "FarmFullNodeConnections.actions" msgid "FarmFullNodeConnections.actions"
msgstr "Akcie" msgstr "Akcie"
#: src/components/farm/FarmLastAttemptedProof.tsx:12
msgid "FarmFullNodeConnections.challenge"
msgstr ""
#: src/components/farm/FarmFullNodeConnections.tsx:66 #: src/components/farm/FarmFullNodeConnections.tsx:66
msgid "FarmFullNodeConnections.connectionStatus" msgid "FarmFullNodeConnections.connectionStatus"
msgstr "Stav pripojenia" msgstr "Stav pripojenia"
#: src/components/farm/FarmLastAttemptedProof.tsx:18 #: src/components/farm/FarmLastAttemptedProof.tsx:36
msgid "FarmFullNodeConnections.date" msgid "FarmFullNodeConnections.date"
msgstr "Dátum" msgstr "Dátum"
@ -896,8 +900,8 @@ msgid "FarmFullNodeConnections.description"
msgstr "Kombajn je služba bežiaca na stroji, kde sú skutočne uložené polia. Nižšie si pozrite svoju sieť prepojených kombajnov. Viac informácií" msgstr "Kombajn je služba bežiaca na stroji, kde sú skutočne uložené polia. Nižšie si pozrite svoju sieť prepojených kombajnov. Viac informácií"
#: src/components/farm/FarmLastAttemptedProof.tsx:12 #: src/components/farm/FarmLastAttemptedProof.tsx:12
msgid "FarmFullNodeConnections.height" #~ msgid "FarmFullNodeConnections.height"
msgstr "Pozícia" #~ msgstr "Pozícia"
#: src/components/farm/FarmFullNodeConnections.tsx:24 #: src/components/farm/FarmFullNodeConnections.tsx:24
msgid "FarmFullNodeConnections.hostName" msgid "FarmFullNodeConnections.hostName"
@ -907,13 +911,25 @@ msgstr ""
msgid "FarmFullNodeConnections.nodeId" msgid "FarmFullNodeConnections.nodeId"
msgstr "" msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:24
msgid "FarmFullNodeConnections.passed_filter"
msgstr ""
#: src/components/farm/FarmFullNodeConnections.tsx:30 #: src/components/farm/FarmFullNodeConnections.tsx:30
msgid "FarmFullNodeConnections.port" msgid "FarmFullNodeConnections.port"
msgstr "Port" msgstr "Port"
#: src/components/farm/FarmLastAttemptedProof.tsx:30
msgid "FarmFullNodeConnections.proofs_found"
msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:18
msgid "FarmFullNodeConnections.signage_point"
msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:24 #: src/components/farm/FarmLastAttemptedProof.tsx:24
msgid "FarmFullNodeConnections.time" #~ msgid "FarmFullNodeConnections.time"
msgstr "Čas" #~ msgstr "Čas"
#: src/components/farm/FarmFullNodeConnections.tsx:56 #: src/components/farm/FarmFullNodeConnections.tsx:56
msgid "FarmFullNodeConnections.title" msgid "FarmFullNodeConnections.title"
@ -923,19 +939,19 @@ msgstr "Vaše pripojenie k sieti"
msgid "FarmFullNodeConnections.upDown" msgid "FarmFullNodeConnections.upDown"
msgstr "Odoslané/Stiahnuté" msgstr "Odoslané/Stiahnuté"
#: src/components/farm/FarmLastAttemptedProof.tsx:38 #: src/components/farm/FarmLastAttemptedProof.tsx:50
msgid "FarmLastAttemptedProof.emptyDescription" msgid "FarmLastAttemptedProof.emptyDescription"
msgstr "" msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:44 #: src/components/farm/FarmLastAttemptedProof.tsx:56
msgid "FarmLastAttemptedProof.emptySubDescription" msgid "FarmLastAttemptedProof.emptySubDescription"
msgstr "" msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:32 #: src/components/farm/FarmLastAttemptedProof.tsx:44
msgid "FarmLastAttemptedProof.title" msgid "FarmLastAttemptedProof.title"
msgstr "Posledný pokus o dôkaz" msgstr "Posledný pokus o dôkaz"
#: src/components/farm/FarmLastAttemptedProof.tsx:34 #: src/components/farm/FarmLastAttemptedProof.tsx:46
msgid "FarmLastAttemptedProof.tooltip" msgid "FarmLastAttemptedProof.tooltip"
msgstr "" msgstr ""

File diff suppressed because one or more lines are too long

View File

@ -883,11 +883,15 @@ msgstr ""
msgid "FarmFullNodeConnections.actions" msgid "FarmFullNodeConnections.actions"
msgstr "" msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:12
msgid "FarmFullNodeConnections.challenge"
msgstr ""
#: src/components/farm/FarmFullNodeConnections.tsx:66 #: src/components/farm/FarmFullNodeConnections.tsx:66
msgid "FarmFullNodeConnections.connectionStatus" msgid "FarmFullNodeConnections.connectionStatus"
msgstr "" msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:18 #: src/components/farm/FarmLastAttemptedProof.tsx:36
msgid "FarmFullNodeConnections.date" msgid "FarmFullNodeConnections.date"
msgstr "" msgstr ""
@ -896,8 +900,8 @@ msgid "FarmFullNodeConnections.description"
msgstr "" msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:12 #: src/components/farm/FarmLastAttemptedProof.tsx:12
msgid "FarmFullNodeConnections.height" #~ msgid "FarmFullNodeConnections.height"
msgstr "" #~ msgstr ""
#: src/components/farm/FarmFullNodeConnections.tsx:24 #: src/components/farm/FarmFullNodeConnections.tsx:24
msgid "FarmFullNodeConnections.hostName" msgid "FarmFullNodeConnections.hostName"
@ -907,14 +911,26 @@ msgstr ""
msgid "FarmFullNodeConnections.nodeId" msgid "FarmFullNodeConnections.nodeId"
msgstr "" msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:24
msgid "FarmFullNodeConnections.passed_filter"
msgstr ""
#: src/components/farm/FarmFullNodeConnections.tsx:30 #: src/components/farm/FarmFullNodeConnections.tsx:30
msgid "FarmFullNodeConnections.port" msgid "FarmFullNodeConnections.port"
msgstr "" msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:24 #: src/components/farm/FarmLastAttemptedProof.tsx:30
msgid "FarmFullNodeConnections.time" msgid "FarmFullNodeConnections.proofs_found"
msgstr "" msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:18
msgid "FarmFullNodeConnections.signage_point"
msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:24
#~ msgid "FarmFullNodeConnections.time"
#~ msgstr ""
#: src/components/farm/FarmFullNodeConnections.tsx:56 #: src/components/farm/FarmFullNodeConnections.tsx:56
msgid "FarmFullNodeConnections.title" msgid "FarmFullNodeConnections.title"
msgstr "" msgstr ""
@ -923,19 +939,19 @@ msgstr ""
msgid "FarmFullNodeConnections.upDown" msgid "FarmFullNodeConnections.upDown"
msgstr "" msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:38 #: src/components/farm/FarmLastAttemptedProof.tsx:50
msgid "FarmLastAttemptedProof.emptyDescription" msgid "FarmLastAttemptedProof.emptyDescription"
msgstr "" msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:44 #: src/components/farm/FarmLastAttemptedProof.tsx:56
msgid "FarmLastAttemptedProof.emptySubDescription" msgid "FarmLastAttemptedProof.emptySubDescription"
msgstr "" msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:32 #: src/components/farm/FarmLastAttemptedProof.tsx:44
msgid "FarmLastAttemptedProof.title" msgid "FarmLastAttemptedProof.title"
msgstr "" msgstr ""
#: src/components/farm/FarmLastAttemptedProof.tsx:34 #: src/components/farm/FarmLastAttemptedProof.tsx:46
msgid "FarmLastAttemptedProof.tooltip" msgid "FarmLastAttemptedProof.tooltip"
msgstr "" msgstr ""

View File

@ -1,6 +1,6 @@
import { service_farmer, service_harvester } from '../util/service_names'; import { service_farmer, service_harvester } from '../util/service_names';
import type Plot from '../types/Plot'; import type Plot from '../types/Plot';
import type Challenge from '../types/Challenge'; import type FarmingInfo from '../types/FarmingInfo';
import type SignagePoint from '../types/SignagePoint'; import type SignagePoint from '../types/SignagePoint';
import type ProofsOfSpace from '../types/ProofsOfSpace'; import type ProofsOfSpace from '../types/ProofsOfSpace';
@ -12,7 +12,7 @@ type SignagePointAndProofsOfSpace = {
type FarmingState = { type FarmingState = {
farmer: { farmer: {
signage_points: SignagePointAndProofsOfSpace[]; signage_points: SignagePointAndProofsOfSpace[];
last_attempted_proofs: Challenge[]; last_farming_info: FarmingInfo[];
connections: { connections: {
bytes_read: number; bytes_read: number;
bytes_written: number; bytes_written: number;
@ -39,7 +39,7 @@ type FarmingState = {
const initialState: FarmingState = { const initialState: FarmingState = {
farmer: { farmer: {
signage_points: [], signage_points: [],
last_attempted_proofs: [], last_farming_info: [],
connections: [], connections: [],
open_connection_error: '', open_connection_error: '',
}, },
@ -65,17 +65,16 @@ export default function farmingReducer(
const { command } = message; const { command } = message;
// Farmer API // Farmer API
if (command === 'proof') { if (command === 'new_farming_info') {
const last_attempted_proofs = [ const last_farming_info = [
data.proof, data.farming_info,
...state.farmer.last_attempted_proofs, ...state.farmer.last_farming_info,
]; ];
return { return {
...state, ...state,
farmer: { farmer: {
...state.farmer, ...state.farmer,
last_attempted_proofs, last_farming_info,
}, },
}; };
} }

View File

@ -0,0 +1,10 @@
type FarmingInfo = {
challenge_hash: string;
signage_point: string;
timestamp: number;
passed_filter: number;
proofs: number;
total_plots: number;
};
export default FarmingInfo;

View File

@ -264,3 +264,19 @@ class FarmerAPI:
msg = Message("request_signatures", request) msg = Message("request_signatures", request)
await self.farmer.server.send_to_specific([msg], node_id) await self.farmer.server.send_to_specific([msg], node_id)
@api_request
async def farming_info(self, request: farmer_protocol.FarmingInfo):
self.farmer.state_changed(
"new_farming_info",
{
"farming_info": {
"challenge_hash": request.challenge_hash,
"signage_point": request.sp_hash,
"passed_filter": request.passed,
"proofs": request.proofs,
"total_plots": request.total_plots,
"timestamp": request.timestamp,
}
},
)

View File

@ -14,12 +14,13 @@ from src.consensus.pot_iterations import (
from src.harvester.harvester import Harvester from src.harvester.harvester import Harvester
from src.plotting.plot_tools import PlotInfo from src.plotting.plot_tools import PlotInfo
from src.protocols import harvester_protocol from src.protocols import harvester_protocol
from src.protocols.farmer_protocol import FarmingInfo
from src.server.outbound_message import Message from src.server.outbound_message import Message
from src.server.ws_connection import WSChiaConnection from src.server.ws_connection import WSChiaConnection
from src.types.proof_of_space import ProofOfSpace from src.types.proof_of_space import ProofOfSpace
from src.types.sized_bytes import bytes32 from src.types.sized_bytes import bytes32
from src.util.api_decorators import api_request, peer_required from src.util.api_decorators import api_request, peer_required
from src.util.ints import uint8, uint64 from src.util.ints import uint8, uint64, uint32
class HarvesterAPI: class HarvesterAPI:
@ -164,16 +165,20 @@ class HarvesterAPI:
return all_responses return all_responses
awaitables = [] awaitables = []
passed = 0
total = 0
for try_plot_filename, try_plot_info in self.harvester.provers.items(): for try_plot_filename, try_plot_info in self.harvester.provers.items():
if try_plot_filename.exists(): if try_plot_filename.exists():
# Passes the plot filter (does not check sp filter yet though, since we have not reached sp) # Passes the plot filter (does not check sp filter yet though, since we have not reached sp)
# This is being executed at the beginning of the slot # This is being executed at the beginning of the slot
total += 1
if ProofOfSpace.passes_plot_filter( if ProofOfSpace.passes_plot_filter(
self.harvester.constants, self.harvester.constants,
try_plot_info.prover.get_id(), try_plot_info.prover.get_id(),
new_challenge.challenge_hash, new_challenge.challenge_hash,
new_challenge.sp_hash, new_challenge.sp_hash,
): ):
passed += 1
awaitables.append(lookup_challenge(try_plot_filename, try_plot_info)) awaitables.append(lookup_challenge(try_plot_filename, try_plot_info))
# Concurrently executes all lookups on disk, to take advantage of multiple disk parallelism # Concurrently executes all lookups on disk, to take advantage of multiple disk parallelism
@ -183,6 +188,18 @@ class HarvesterAPI:
total_proofs_found += 1 total_proofs_found += 1
msg = Message("new_proof_of_space", response) msg = Message("new_proof_of_space", response)
await peer.send_message(msg) await peer.send_message(msg)
now = uint64(int(time.time()))
farming_info = FarmingInfo(
new_challenge.challenge_hash,
new_challenge.sp_hash,
now,
uint32(passed),
uint32(total_proofs_found),
uint32(total),
)
pass_msg = Message("farming_info", farming_info)
await peer.send_message(pass_msg)
self.harvester.log.info( self.harvester.log.info(
f"{len(awaitables)} plots were eligible for farming {new_challenge.challenge_hash.hex()[:10]}..." f"{len(awaitables)} plots were eligible for farming {new_challenge.challenge_hash.hex()[:10]}..."
f" Found {total_proofs_found} proofs. Time: {time.time() - start:.5f} s. " f" Found {total_proofs_found} proofs. Time: {time.time() - start:.5f} s. "

View File

@ -6,7 +6,7 @@ from src.types.proof_of_space import ProofOfSpace
from src.types.sized_bytes import bytes32 from src.types.sized_bytes import bytes32
from src.types.pool_target import PoolTarget from src.types.pool_target import PoolTarget
from src.util.cbor_message import cbor_message from src.util.cbor_message import cbor_message
from src.util.ints import uint64, uint8 from src.util.ints import uint64, uint8, uint32
""" """
Protocol between farmer and full node. Protocol between farmer and full node.
@ -47,6 +47,17 @@ class RequestSignedValues:
foliage_block_hash: bytes32 foliage_block_hash: bytes32
@dataclass(frozen=True)
@cbor_message
class FarmingInfo:
challenge_hash: bytes32
sp_hash: bytes32
timestamp: uint64
passed: uint32
proofs: uint32
total_plots: uint32
@dataclass(frozen=True) @dataclass(frozen=True)
@cbor_message @cbor_message
class SignedValues: class SignedValues:

View File

@ -1,7 +1,6 @@
from typing import Callable, Dict, List from typing import Callable, Dict, List
from src.farmer.farmer import Farmer from src.farmer.farmer import Farmer
from src.protocols.farmer_protocol import DeclareProofOfSpace
from src.util.byte_types import hexstr_to_bytes from src.util.byte_types import hexstr_to_bytes
from src.util.ws_message import create_payload from src.util.ws_message import create_payload
@ -30,20 +29,11 @@ class FarmerRpcApi:
string=False, string=False,
) )
] ]
elif change == "proof": elif change == "new_farming_info":
proof: DeclareProofOfSpace = change_data["proof"]
data = {
"proof": {
"challenge_hash": proof.challenge_hash,
"reward_chain_sp": proof.reward_chain_sp,
"plot_identifier": proof.proof_of_space.plot_public_key,
"signage_point_index": proof.signage_point_index,
}
}
return [ return [
create_payload( create_payload(
"proof", "new_farming_info",
data, change_data,
self.service_name, self.service_name,
"wallet_ui", "wallet_ui",
string=False, string=False,