Skip to content

Commit

Permalink
Merge branch 'main' into jord/doc-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanschalm committed Sep 21, 2024
2 parents abfe646 + 4a00801 commit bcbb8db
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 27 deletions.
31 changes: 31 additions & 0 deletions docs/networks/node-ops/node-operation/monitoring-nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,37 @@ The following are some important metrics produced by the node.
| consensus_hotstuff_cur_view | Current view of the HotStuff consensus algorith; Consensus/Collection only; should increase at a constant rate. |
| consensus_hotstuff_timeout_seconds | How long it takes to timeout failed rounds; Consensus/Collection only; values consistently larger than 5s are abnormal. |

### Machine Account

Collection and consensus nodes use a machine account that must be kept funded. See [here](../../staking/11-machine-account.md) for details.

Nodes check their machine account's configuration and funding and produce metrics.

| Metric Name | Description |
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| machine_account_balance | The current balance (FLOW) |
| machine_account_recommended_min_balance | The recommended minimum balance (FLOW) |
| machine_account_is_misconfigured | 0 if the node is configured correctly; 1 if the node is misconfigured |

To be notified when your node's machine account needs to be refilled or has a configuration error, you can set up alerts.

When the machine account balance needs to be refilled:
```
machine_account_balance < machine_account_recommended_min_balance
```

When the machine account has a configuration error:
```
machine_account_is_misconfigured > 0
```

The metrics include the account address of the machine account (`acct_address` label) for convenience:
```
# HELP machine_account_balance the last observed balance of this node's machine account, in units of FLOW
# TYPE machine_account_balance gauge
machine_account_balance{acct_address="7b16b57ae0a3c6aa"} 9.99464935
```

## Monitoring a Flow node using Metrika Monitoring

Metrika has developed the Flow node monitoring service and is the recommended way of monitoring a Flow node.
Expand Down
2 changes: 1 addition & 1 deletion docs/networks/staking/11-machine-account.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ however more may be required under certain circumstances and network conditions.
<Callout type="info">

Because some transactions sent by the Machine Account are system critical, we recommend maintaining
a balance sufficient to accommodate worst-case transaction submission numbers at all times.
a balance sufficient to accommodate worst-case transaction submission numbers at all times. **See [here](./../node-ops/node-operation/monitoring-nodes.md#machine-account) for how to monitor.**

</Callout>

Expand Down
2 changes: 0 additions & 2 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
const sidebars = {
overview: [{ type: 'autogenerated', dirName: 'overview' }],
networks: [
'networks/index',
{
Expand Down Expand Up @@ -120,7 +119,6 @@ const sidebars = {
],
build: [{ type: 'autogenerated', dirName: 'build' }],
evm: [{ type: 'autogenerated', dirName: 'evm' }],
tutorials: [{ type: 'autogenerated', dirName: 'tutorials' }],
tools: [{ type: 'autogenerated', dirName: 'tools' }],
ecosystem: [{ type: 'autogenerated', dirName: 'ecosystem' }],
};
Expand Down
80 changes: 56 additions & 24 deletions src/components/addNetworkButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,67 @@ import {
ButtonLink,
} from '@site/src/ui/design-system/src/lib/Components/Button/index';

export const AddNetworkButton = () => {
const targetChainIds = [747, 646, 545]; // Your target chain IDs
const targetChains = [
{
id: 747,
name: 'EVM on Flow',
rpcUrls: ['https://mainnet.evm.nodes.onflow.org'],
blockExplorerUrls: ['https://evm.flowscan.io/'],
},
{
id: 545,
name: 'EVM on Flow Testnet',
rpcUrls: ['https://testnet.evm.nodes.onflow.org'],
blockExplorerUrls: ['https://evm-testnet.flowscan.io/'],
},
];

export const AddNetworkButton = (): JSX.Element => {
const [isNetworkAdded, setIsNetworkAdded] = useState<boolean>(false);
const [chainId, setChainId] = useState<string>(''); // Flow Testnet
const [chainId, setChainId] = useState<number>(0); // Flow Testnet

const getChainId = async () => {
const getChainId = async (): Promise<void> => {
if (!window?.ethereum) return;
const chainId = await window?.ethereum.request({ method: 'eth_chainId' });
setChainId(parseInt(chainId, 16)); // Convert chainId from hex to decimal
};

useEffect(() => {
getChainId();
getChainId().catch((e) => {
console.error(e);
});
}, []);

const hasEthereum = window?.ethereum !== undefined;

useEffect(() => {
if (targetChainIds.includes(chainId)) {
if (targetChains.map(({ id }) => id).includes(chainId)) {
setIsNetworkAdded(true);
} else {
setIsNetworkAdded(false);
}
}, [chainId]);

const addFlowNetwork = async () => {
const addFlowNetwork = async ({
id,
name,
rpcUrls,
blockExplorerUrls,
}: {
id: number;
name: string;
rpcUrls: string[];
blockExplorerUrls: string[];
}): Promise<void> => {
try {
// Define your network details here
await window?.ethereum?.request({
method: 'wallet_addEthereumChain',
params: [
{
chainId: '0x2eb', // 747 in hexadecimal
chainName: 'EVM on Flow',
rpcUrls: ['https://mainnet.evm.nodes.onflow.org'],
chainId: id.toString(16), // '0x2eb', // 747 in hexadecimal
chainName: name,
rpcUrls,
iconUrls: [
'https://assets-global.website-files.com/5f734f4dbd95382f4fdfa0ea/65b016be9b9cf0a402a67a38_ico-flow-crescendo.png',
],
Expand All @@ -47,7 +73,7 @@ export const AddNetworkButton = () => {
symbol: 'FLOW',
decimals: 18,
},
blockExplorerUrls: ['https://evm.flowscan.io/'],
blockExplorerUrls,
},
],
});
Expand All @@ -58,20 +84,26 @@ export const AddNetworkButton = () => {

// eslint-disable-next-line @typescript-eslint/no-misused-promises
return hasEthereum ? (
<Button
className="my-5 "
disabled={isNetworkAdded}
variant="secondary"
onClick={() => addFlowNetwork()}
>
{isNetworkAdded ? 'Flow Network Added!' : 'Add Flow Network'}
</Button>
<div className="flex gap-2 my-5">
{targetChains.map((chain) => (
<Button
key={chain.id}
disabled={isNetworkAdded}
variant="secondary"
onClick={() => {
addFlowNetwork(chain).catch((e) => {
console.error(e);
});
}}
>
{isNetworkAdded
? `${chain.name} Network Added!`
: `Add ${chain.name} Network`}
</Button>
))}
</div>
) : (
<ButtonLink
className="my-5"
variant="primary"
href="https://metamask.io/download/"
>
<ButtonLink variant="primary" href="https://metamask.io/download/">
Install MetaMask
</ButtonLink>
);
Expand Down

0 comments on commit bcbb8db

Please sign in to comment.