Function X Technology Updates — May 2024

Function X Foundation
Function X
Published in
3 min readMay 15, 2024

In 2023 and before, the Function X Team has conducted extensive custom development on f(x)Core mainnet. A large part of these developments on f(x)Core is based on the Cosmos ecosystem, and significant improvements have also been made to the Cosmos SDK to meet the specific needs of the Function X team. The practical aspects of these developments will be highlighted in this summary.

Additionally, the team is continuously making improvements in the original Cosmos SDK and its other aspects, and the team has also innovated a transaction matching system combined with the Cosmos chain for the MarginX project. Validators on f(x)Core no longer only produce blocks and secure the chain but they also provide the transaction matching service, serving as a high I/O transaction extension (subnet) for the network. This theoretically allows for unlimited transaction throughput expansion, making up for the lack of throughput in swap (AMM) and similar DEX on f(x)Core.

The Function X Team will continue to improve and contribute to the Cosmos ecosystem, and will soon launch a series of new features such as Omnichain, which will be detailed in the technical updates over the coming months.

This summary will only provide an overview of the work that the team has achieved. For more details please refer to the team’s GitHub.

Improvements to Cosmos Python SDK

Based on feedback from f(x)Wallet users and the community, the following optimizations and secondary developments were made to the Cosmos-SDK.

  1. Wallet Features
    - Support for mnemonic phrases and private key imports
    - Support for custom address prefixes
    - Support for `eth_secp256k1` and `secp256k1` private key types
  2. Connecting to Nodes:
    - Cosmos gRPC
    - Tendermint json-rpc/websocket
  3. Protobuf API Support
    - Cosmos-sdk v0.46.x (all versions)
    - f(x)Core (all versions)
    - Ethermint (all versions)

Project name: fx-py-sdk

Repository: https://github.com/FunctionX/fx-py-sdk

Is it open source: Yes

Supported Cosmos version: v0.46.x

Purpose: The Swiss Army knife to power Python based client solutions

Usage examples:

Related articles on Medium: https://medium.com/lava-network/tutorial-how-to-cosmos-pt-3-sending-a-signed-tx-on-cosmos-hub-using-cosmjs-bd273381440d

Contract Monitoring

Project name: Contract Monitor

Repository: https://github.com/FunctionX/contract-monitor

Is it open source: Yes

Purpose: A general solution for smart contract monitoring that enables direct querying of on-chain smart contracts or data from subgraphs

Prerequisites: Familiarity with Prometheus/ Alertmanager

Methodology

  1. By setting the contract address and ABI in the configuration file, then specifying the calling contract’s method name and parameters, and finally setting alert/monitoring rules based on the contract’s return values. The configuration file’s format is as follows:
{
"name": "PIP_ETH",
"contract_name": "OSM",
"address": "0x430a901cCBB48F0363E9cf0756a19ff1F549Ab90",
"network": "testchain",
"abi_path": "./abis/testchain/OSM.json",
"functions": [
{
"fun_name": "peek",
"from": "0xe196908c3641A02A4E60651427cc8A3E061b4D29",
"input": [],
"output": [
{
"serial_number": 0,
"metric_name": "PEEK",
"metric_help": "ETH-A price value",
"alert_rules": {
"alert": "makerdao ilk ETH-A price more than 5%",
"expr": "(abs(PIP_ETH_PEEK - (PIP_ETH_PEEK offset 60m)))/1e+18 > ((PIP_ETH_PEEK offset 60m) * 0.05) / 1e+18",
"for": "0m",
"labels": {
"severity": "warning"
},
"annotations": {
"description": "makerdao ilk ETH-A price more than 5% :{{$value}}"
}
}
}
]
}
]
}

2. In the configuration file, set the subgraph table and field name that
needs to be monitored. The configuration format is as follows:

{
"table": "systemStates",
"metric": [
{
"name": "systemStates_totalDebt",
"type": "gauge",
"help": "Total debt issued (token.debt))",
"labels": {
"source": "vat_debt"
},
"field": "totalDebt",
"alert_rules": {
"alert": " systemStates totalDebt change",
"expr": "abs(systemStates_totalDebt-(systemStates_totalDebt offset 2m)) > systemStates_totalDebt * 0.05",
"for": "0m",
"annotations": {
"description": "systemStates totalDebt(vat_debt) have changed in two minutes change more than 5%,change data {{$value}}"
}
}
}
]
}

Next

Thank you for reading the first part of Function X tech update and stay tuned for the next one!

If you’d like to know more about Function X and stay up-to-date with us, check out any of the links below.

Website | Twitter | Forum | Telegram Announcements | Telegram Group | Discord | Github

--

--