From d37a4fdb10355cbd44b20ecefbbdd9a5556d651e Mon Sep 17 00:00:00 2001 From: Margarita Skomorokh Date: Fri, 6 Sep 2024 09:40:53 +0200 Subject: [PATCH 1/4] Docs wardend commands (#783) * started drafting the wardend commands guide * finished the node commands guide, added links, edited run a local chain * fixed a broken link * added the --node flag * coderabbit * coderabbit * deleted the wardend version command * deleted a wrong note in run-a-local-chain * minor fixes * more fixes * more fixes * more fixes * more fixes * more fixes * added a link to the binary --- .../build-an-app/test/run-a-local-chain.md | 17 +- .../docs/operate-a-node/introduction.md | 4 +- .../docs/operate-a-node/node-commands.md | 146 ++++++++++++++++++ 3 files changed, 163 insertions(+), 4 deletions(-) create mode 100644 docs/developer-docs/docs/operate-a-node/node-commands.md diff --git a/docs/developer-docs/docs/build-an-app/test/run-a-local-chain.md b/docs/developer-docs/docs/build-an-app/test/run-a-local-chain.md index fc2e0be48..fc957704f 100644 --- a/docs/developer-docs/docs/build-an-app/test/run-a-local-chain.md +++ b/docs/developer-docs/docs/build-an-app/test/run-a-local-chain.md @@ -8,9 +8,20 @@ sidebar_position: 1 This guide explains how to run a local chain for development and testing purposes. +There are three ways to run a node: + +- **Option 1: Run a `just` script** +It's the simplest way to run a local chain. Initiate a `just` script that builds the chain binary and then creates, configures, and runs a new chain. + +- **Option 2: Use a devnet snapshot** +You can use a devnet snapshot with prebuilt node settings. + +- **Option 3. Configure manually** +We recommend this option if you wish to run a node with custom settings and learn the basics of interacting with a node. + ## Prerequisites -Before you start, complete following prerequisites: +Before you start, complete the following prerequisites: - [Install Go](https://golang.org/doc/install) 1.22.3 or later. - Install [just](https://just.systems/man/en/chapter_4.html). @@ -111,6 +122,8 @@ You can check the settings of your node in the genesis file: `$HOME/.warden/conf ## Option 3. Configure manually +We recommend this option if you wish to run a node with custom settings and learn the basics of interacting with a node. + ### 1. Clone the repository Clone the Warden Protocol repository and navigate to the root directory: @@ -335,7 +348,7 @@ The output should contain status information about your node: ``` :::tip -You can use other `wardend` commands to interact with the node. Just run `wardend` to see a list of available commands. +To learn more about `wardend` commands for interacting with the node, see [Node commands](/operate-a-node/node-commands). ::: :::tip diff --git a/docs/developer-docs/docs/operate-a-node/introduction.md b/docs/developer-docs/docs/operate-a-node/introduction.md index 708d9df10..c537e983b 100644 --- a/docs/developer-docs/docs/operate-a-node/introduction.md +++ b/docs/developer-docs/docs/operate-a-node/introduction.md @@ -20,9 +20,9 @@ This section explains how to run a node and become a validator. These are the basic steps to get started: -- Download the [wardend binary](https://github.com/warden-protocol/wardenprotocol/releases) or run it in a container and [join Buenavista](buenavista-testnet/join-buenavista). +- Download the [wardend binary](https://github.com/warden-protocol/wardenprotocol/releases) or run it in a container and [join Buenavista](buenavista-testnet/join-buenavista). - To become a validator, follow this guide: [Create a validator](create-a-validator). -- To interact with a node, use the [Node API](node-api-reference). +- To interact with a node, use the [Node API](node-api-reference) and [node commands](node-commands). :::tip We recommend using [Cosmovisor](https://docs.archway.io/validators/running-a-node/cosmovisor) – a utility for managing binary versions of Cosmos SDK-based chains. Its primary function is to enable binary upgrades without manual intervention. diff --git a/docs/developer-docs/docs/operate-a-node/node-commands.md b/docs/developer-docs/docs/operate-a-node/node-commands.md new file mode 100644 index 000000000..0660dd5b7 --- /dev/null +++ b/docs/developer-docs/docs/operate-a-node/node-commands.md @@ -0,0 +1,146 @@ +--- +sidebar_position: 7 +--- + +# Node commands + +## Overview + +**Node commands** are commands for interacting with a node through the command line. In this article, you'll find a brief overview of commands for interacting with the Warden node, `wardend`. + +These commands allow you to do the following: + +- Query the node +- Initiate transactions +- Manage your key +- Edit the genesis file +- and much more + +## Prerequisites + +To interact with the node, you need to install the [Warden binary](https://github.com/warden-protocol/wardenprotocol/releases), `wardend`. + +## Execute `wardend` commands + +To execute a node command, just run `wardend`, followed by the command. Include the `--node` flag with the node endpoint. + +For example, to check the node status, run the example below, using the preferred endpoint. + +```bash +wardend status --node https://rpc.buenavista.wardenprotocol.org:443 +``` + +:::tip +You can exclude the `--node` flag if you're running a chain on the same machine at moment when you're executing `wardend` commands. If not specified, `--node` defaults to the localhost. +::: + +## Get a list of commands + +To get a full list of available `wardend` commands and flags, run `wardend` with the `--help` flag: + +```bash +wardend --help --node https://rpc.buenavista.wardenprotocol.org:443 +``` + +## Get details of a command + +To learn more about a command, run `wardend`, followed by the command name and the `--help` flag. + +For example, you can execute this to learn more about querying the node with the `query` command: + +```bash +wardend query --help --node https://rpc.buenavista.wardenprotocol.org:443 +``` + +In the output, you'll see a list of available subcommands and flags. You can query subcommands the same way. + +## Examples + +This section contains useful examples of `wardend` commands. You'll learn how to query the node, manage keys, and initiate transactions. However, note that there are many more commands available. + +### `query`: Query the node + +To get a full list of commands for querying a node, run this: + +```bash +wardend query --help --node https://rpc.buenavista.wardenprotocol.org:443 +``` + +For example, the `warden` command allows you to query the [Warden](/learn/warden-protocol-modules/x-warden) module. + +Here are some of the available `wardend query warden` subcommands with examples: + +- `keychains`: This command returns a list of your [Keychains](/learn/glossary#keychain). + + ```bash + wardend query warden keychains --node https://rpc.buenavista.wardenprotocol.org:443 + ``` + +- `spaces`: This command returns a list of your [Spaces](/learn/glossary#space). + + ```bash + wardend query warden spaces --node https://rpc.buenavista.wardenprotocol.org:443 + ``` + +### `keys`: Manage keys + +To get a full list of commands for managing your keys, run this: + +```bash +wardend keys --help --node https://rpc.buenavista.wardenprotocol.org:443 +``` + +Here are some examples of `wardend keys` commands: + +- `list`: This command returns a list of your keys. + + ```bash + wardend keys list --node https://rpc.buenavista.wardenprotocol.org:443 + ``` + +- `add`: This command adds a key – you executed it when setting up your node. It requires specifying an arbitrary key name. + + ```bash + wardend keys add my-key-name --node https://rpc.buenavista.wardenprotocol.org:443 + ``` + +- `delete`: This command deletes a key, identified by its name. + + ```bash + wardend keys delete my-key-name --node https://rpc.buenavista.wardenprotocol.org:443 + ``` + +- `add-keychain-writer`: This command adds a new [Keychain Writer](/learn/glossary#keychain-writer). It requires specifying an arbitrary Keychain Writer name. + + ```bash + wardend keys add my-keychain-writer-name --node https://rpc.buenavista.wardenprotocol.org:443 + ``` + +### `tx`: Initiate transactions + +To get a full list of commands for initiating transactions, run this: + +```bash +wardend tx --help --node https://rpc.buenavista.wardenprotocol.org:443 +``` + +For example, the `warden` command allows you to initiate [Warden](/learn/warden-protocol-modules/x-warden) transactions. Here are some of the available `wardend tx warden` subcommands with examples: + +- `new-keychain`: This command creates a new [Keychain](/learn/glossary#keychain). It requires specifying an arbitrary Keychain description, your key name, and the chain ID. + + ```bash + wardend tx warden new-keychain \ + --description 'my-description' \ + --from my-key-name \ + --chain-id my-chain-id \ + --node https://rpc.buenavista.wardenprotocol.org:443 + ``` + +- `new-space`: This command creates a new [Space](/learn/glossary#space). It requires specifying your key name and the chain ID. + + ```bash + wardend tx warden new-space \ + --from my-key-name \ + --chain-id my-chain-id \ + --node https://rpc.buenavista.wardenprotocol.org:443 + ``` \ No newline at end of file From adbcd1d7db3983a3b992d2c95fcd8023f2af4b4f Mon Sep 17 00:00:00 2001 From: Aliasgar Merchant <44069404+alijnmerchant21@users.noreply.github.com> Date: Fri, 6 Sep 2024 09:51:46 +0200 Subject: [PATCH 2/4] Build an oapp (#790) * Add a guide to create, deploy, and interact with a simple Hello World smart contract on the Warden chain * Remove quick start. Once we have capability to add a new smart contract with single command; let us bring it back then * Remove under construction tag * Remove API reference from docs Will be added later * Remove front-end reference till we have said capabilities * Remove test so it can be moved under run a node section * Update hierarchy * Move to folder * Add build with warenjs Contains basic understanding + features * Add categorization * Add spaces Explains space and actions related to it * A detailed tutorial on how spaceward works * fixed broken links * quick fixes * fixed a broken link * fixed the Intro and WardenJS docs * fixed the prerequisites part * fixed a broken link * coderabbit * coderabbit * a minor fix --------- Co-authored-by: Margarita Skomorokh --- .../build-a-custom-smart-contract.md | 218 +++++++++++++++++- .../build-the-frontend/_category_.json | 11 - .../build-the-frontend/quick-start.md | 7 - .../build-the-frontend/wardenjs-functions.md | 14 -- .../build-the-frontend/wardenui-components.md | 13 -- .../docs/build-an-app/build-with-wardenjs.md | 13 +- .../docs/build-an-app/examples-of-oapps.md | 2 +- .../docs/build-an-app/introduction.md | 24 +- .../docs/build-an-app/quick-start.md | 21 -- .../smart-contract-api-reference.md | 13 -- .../docs/build-an-app/useful-links.md | 2 +- docs/developer-docs/docusaurus.config.ts | 29 +-- 12 files changed, 229 insertions(+), 138 deletions(-) delete mode 100644 docs/developer-docs/docs/build-an-app/build-the-frontend/_category_.json delete mode 100644 docs/developer-docs/docs/build-an-app/build-the-frontend/quick-start.md delete mode 100644 docs/developer-docs/docs/build-an-app/build-the-frontend/wardenjs-functions.md delete mode 100644 docs/developer-docs/docs/build-an-app/build-the-frontend/wardenui-components.md delete mode 100644 docs/developer-docs/docs/build-an-app/quick-start.md delete mode 100644 docs/developer-docs/docs/build-an-app/smart-contract-api-reference.md diff --git a/docs/developer-docs/docs/build-an-app/build-a-custom-smart-contract.md b/docs/developer-docs/docs/build-an-app/build-a-custom-smart-contract.md index ca0039db2..bef478c4c 100644 --- a/docs/developer-docs/docs/build-an-app/build-a-custom-smart-contract.md +++ b/docs/developer-docs/docs/build-an-app/build-a-custom-smart-contract.md @@ -1,13 +1,221 @@ --- -sidebar_position: 5 +sidebar_position: 2 --- # Build a custom smart contract -*Coming soon* +## Overview - \ No newline at end of file +Before you start, complete the following prerequisites: + +- Install Rust by running the following: + + ```bash + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + ``` + +- Set up the CosmWasm development environment: + + - [CosmWasm](https://book.cosmwasm.com/setting-up-env.html): The CosmWasm binary and its dependencies. + + - [cargo-generate](https://cargo-generate.github.io/cargo-generate/installation.html): A tool to help you get up and running quickly with a new Rust project by leveraging a pre-existing git repository as a template. + + - [wasm-opt](https://docs.rs/wasm-opt/latest/wasm_opt/index.html): A tool for optimizing the compiled WebAssembly (Wasm) code. + + To install these tools, run the following commands: + + ```bash + rustup target add wasm32-unknown-unknown + cargo install cargo-generate --features vendored-openssl + brew install binaryen + ``` + +- [Run a local chain](test/run-a-local-chain) and make sure you have `wardend` correctly installed. You can stop the chain for now if you wish. + + The next steps require your local account name, or key name, which is referenced as `my-key-name` in the provided command-line examples. You can check the list of available keys by executing this command (while the node is running): + + ```bash + wardend keys list + ``` + :::tip + In development genesis files, you'll typically find an account named shulgin that is preconfigured and ready for use. + ::: + +## 1. Create a new CosmWasm project + +Create a new CosmWasm project by running the following: + +```bash +cargo generate --git https://github.com/CosmWasm/cw-template.git --name hello-world +cd hello-world +``` + +## 2. Modify the contract code + +1. Open `src/contract.rs` and replace its contents with this code: + + ```rust + use cosmwasm_std::{ + entry_point, to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, + }; + use cw2::set_contract_version; + + use crate::error::ContractError; + use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; + + const CONTRACT_NAME: &str = "crates.io:hello-world"; + const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); + + #[entry_point] + pub fn instantiate( + deps: DepsMut, + _env: Env, + info: MessageInfo, + _msg: InstantiateMsg, + ) -> Result { + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; + Ok(Response::new().add_attribute("method", "instantiate") + .add_attribute("owner", info.sender)) + } + + #[entry_point] + pub fn execute( + _deps: DepsMut, + _env: Env, + info: MessageInfo, + msg: ExecuteMsg, + ) -> Result { + match msg { + ExecuteMsg::SayHello {} => Ok(Response::new() + .add_attribute("method", "say_hello") + .add_attribute("sender", info.sender)), + } + } + + #[entry_point] + pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + match msg { + QueryMsg::GetGreeting {} => to_binary(&"Hello, World!"), + } + } + ``` + +2. Open `src/msg.rs` and replace its contents with this code: + + ```rust + use cosmwasm_schema::{cw_serde, QueryResponses}; + + #[cw_serde] + pub struct InstantiateMsg {} + + #[cw_serde] + pub enum ExecuteMsg { + SayHello {}, + } + + #[cw_serde] + #[derive(QueryResponses)] + pub enum QueryMsg { + #[returns(String)] + GetGreeting {}, + } + ``` + +## 4. Compile the contract + +To compile the contract, run the following: + +```bash +cargo wasm +``` + +The contract should be compiled without any errors. + +## 5. Optimize the compiled Wasm code + +Now you need to optimize your compiled Wasm code: + +```bash +wasm-opt -Os -o target/wasm32-unknown-unknown/release/hello_world.wasm / +target/wasm32-unknown-unknown/release/hello_world.wasm +``` + +## 6. Run the chain + +If your local chain isn't running, start it: + +```bash +wardend start +``` + +## 7. Store the contract on-chain + +To store your contract on the Warden chain, run the command below. Replace `my-key-name` with your key name (typically `shulgin`). + + ```bash + wardend tx wasm store target/wasm32-unknown-unknown/release/hello_world.wasm / + --from my-key-name --gas auto --gas-adjustment 1.3 --gas-prices 0.1uward -y + ``` + + The transaction should be successful without any errors. + +## 8. Get the code ID + +Get the code ID, which identifies your Wasm code: + +```bash +wardend query wasm list-code +``` + +Note down `code_id` from the output. + +## 9. Instantiate the contract + +You can instantiate the contract by using the command below. + +Before you proceed, should replace replace `1` with the actual code ID you retrieved in previous step and replace `my-key-name` with your key name. Also note that you can either define an admin or pass `--no-admin` to make it immutable, like in this example. + +```bash +wardend tx wasm instantiate 1 '{}' --from my-key-name / +--label "Hello World" --gas auto --gas-adjustment 1.3 / +--gas-prices 0.1uward --no-admin -y +``` + +## 10. Get the contract address + +To get the contract address, run the following command. Replace `1` with the actual code ID: + +```bash +wardend query wasm list-contract-by-code 1 +``` + +Note down the contract address. + +## 11. Execute the contract + +Use the command below to exectute your contract. Replace `my-contract-address` with your contract address and `my-key-name` with your key name. + +```bash +wardend tx wasm execute my-contract-address '{"say_hello":{}}' / +--from my-key-name --gas auto --gas-adjustment 1.3 --gas-prices 0.1uward -y +``` + +## Result + +Now your contract is ready! + +You can query it with the following command. Replace `my-contract-address` with your contract address. + +```bash +wardend query wasm contract-state smart my-contract-address '{"get_greeting":{}}' +``` + +In the output, you should see `data: Hello, World!` + +If you encounter any issues, please reach out to us via [Discord](https://discord.com/invite/warden) or [Twitter](https://twitter.com/wardenprotocol). + +Happy Coding! 🚀 \ No newline at end of file diff --git a/docs/developer-docs/docs/build-an-app/build-the-frontend/_category_.json b/docs/developer-docs/docs/build-an-app/build-the-frontend/_category_.json deleted file mode 100644 index 07df568e0..000000000 --- a/docs/developer-docs/docs/build-an-app/build-the-frontend/_category_.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "position": 8, - "label": "Build the frontend", - "collapsible": true, - "collapsed": true, - "link": { - "type": "generated-index", - "title": "Build the frontend" - }, - "customProps": {} -} \ No newline at end of file diff --git a/docs/developer-docs/docs/build-an-app/build-the-frontend/quick-start.md b/docs/developer-docs/docs/build-an-app/build-the-frontend/quick-start.md deleted file mode 100644 index 550591b31..000000000 --- a/docs/developer-docs/docs/build-an-app/build-the-frontend/quick-start.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -sidebar_position: 1 ---- - -# Quick start - -*Coming soon* \ No newline at end of file diff --git a/docs/developer-docs/docs/build-an-app/build-the-frontend/wardenjs-functions.md b/docs/developer-docs/docs/build-an-app/build-the-frontend/wardenjs-functions.md deleted file mode 100644 index 6c630c8e7..000000000 --- a/docs/developer-docs/docs/build-an-app/build-the-frontend/wardenjs-functions.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -sidebar_position: 3 ---- - -# WardenJS functions - -*Coming soon* - - \ No newline at end of file diff --git a/docs/developer-docs/docs/build-an-app/build-the-frontend/wardenui-components.md b/docs/developer-docs/docs/build-an-app/build-the-frontend/wardenui-components.md deleted file mode 100644 index 357a69cf9..000000000 --- a/docs/developer-docs/docs/build-an-app/build-the-frontend/wardenui-components.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -sidebar_position: 2 ---- - -# WardenUI components - -*Coming soon* - - \ No newline at end of file diff --git a/docs/developer-docs/docs/build-an-app/build-with-wardenjs.md b/docs/developer-docs/docs/build-an-app/build-with-wardenjs.md index 70d870126..42bdf5b67 100644 --- a/docs/developer-docs/docs/build-an-app/build-with-wardenjs.md +++ b/docs/developer-docs/docs/build-an-app/build-with-wardenjs.md @@ -1,16 +1,9 @@ --- -sidebar_position: 4 +sidebar_position: 3 --- # Build with WardenJS -*Coming soon* +**WardenJS** is a tool helping you to build the frontend part of your application. It makes it easy to compose and broadcast messages, with all of the proto and amino encoding handled for you. - \ No newline at end of file +You can find basic WardenJS documentation here: [WardenJS](https://www.npmjs.com/package/@wardenprotocol/wardenjs) \ No newline at end of file diff --git a/docs/developer-docs/docs/build-an-app/examples-of-oapps.md b/docs/developer-docs/docs/build-an-app/examples-of-oapps.md index 4e748ae8e..fd435b19c 100644 --- a/docs/developer-docs/docs/build-an-app/examples-of-oapps.md +++ b/docs/developer-docs/docs/build-an-app/examples-of-oapps.md @@ -1,5 +1,5 @@ --- -sidebar_position: 2 +sidebar_position: 4 --- # Examples of OApps diff --git a/docs/developer-docs/docs/build-an-app/introduction.md b/docs/developer-docs/docs/build-an-app/introduction.md index 48e40b230..ef80736a0 100644 --- a/docs/developer-docs/docs/build-an-app/introduction.md +++ b/docs/developer-docs/docs/build-an-app/introduction.md @@ -8,22 +8,18 @@ sidebar_position: 1 **Omnichain Applications** (**OApps**) are a powerful evolution of traditional smart contracts. They allow signing transactions at any chain, while traditional smart contract applications only target users of a single chain. -An example of an OApp is [SpaceWard](https://help.wardenprotocol.org) – our application functioning as the front-end interface for Warden. For a full list of available OApps, see [Examples of OApps](examples-of-oapps). +An example of an OApp is [SpaceWard](https://help.wardenprotocol.org) – our application functioning as the front-end interface for Warden. -This section explains how to build the backend and frontend of an OApp. Here you'll also find guides for running a [node](/learn/glossary#warden-protocol-node) and a [Keychain](/learn/glossary#keychain) in the test mode. +## Section overview -## Get started +- [Build a custom smart contract](build-a-custom-smart-contract) +Get started with OApps and build a basic **Omnichain Contract**, which is the main part of any Omnichain Application. -The main part of any Omnichain Application is an **Omnichain Contract**: a smart contract that allows signing transactions and messages at any destination chain. For this reason, OApp development starts with building a custom Omnichain Contract with [CosmWasm](https://cosmwasm.com). +- [Build with WardenJS](build-with-wardenjs) +Here you'll find information on WardenJS – a tool used for building the frontend part of your application. Stay tuned in for more frontend guides. -To learn more, check our list of CosmWasm resources in the [Useful links](useful-links) section. +- [Useful links](useful-links) +To learn more about building smart contracts, check our list of CosmWasm resources and developer guides. -*Please note that this section is under construction. More information is coming soon.* - - \ No newline at end of file +- [Examples of OApps](examples-of-oapps) +Here you can find a full list of available OApps. \ No newline at end of file diff --git a/docs/developer-docs/docs/build-an-app/quick-start.md b/docs/developer-docs/docs/build-an-app/quick-start.md deleted file mode 100644 index 44215ce87..000000000 --- a/docs/developer-docs/docs/build-an-app/quick-start.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -sidebar_position: 3 ---- - -# Quick start - -*This section is under construction.* - -*To get started, you can check our list of CosmWasm resources in the [Useful links](useful-links) section.* - - \ No newline at end of file diff --git a/docs/developer-docs/docs/build-an-app/smart-contract-api-reference.md b/docs/developer-docs/docs/build-an-app/smart-contract-api-reference.md deleted file mode 100644 index c14f7da71..000000000 --- a/docs/developer-docs/docs/build-an-app/smart-contract-api-reference.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -sidebar_position: 6 ---- - -# Smart contract API reference - -*Coming soon* - - \ No newline at end of file diff --git a/docs/developer-docs/docs/build-an-app/useful-links.md b/docs/developer-docs/docs/build-an-app/useful-links.md index 22aa55be3..fb4227dd4 100644 --- a/docs/developer-docs/docs/build-an-app/useful-links.md +++ b/docs/developer-docs/docs/build-an-app/useful-links.md @@ -1,5 +1,5 @@ --- -sidebar_position: 7 +sidebar_position: 3 --- # Useful links diff --git a/docs/developer-docs/docusaurus.config.ts b/docs/developer-docs/docusaurus.config.ts index 87adf687f..212027650 100644 --- a/docs/developer-docs/docusaurus.config.ts +++ b/docs/developer-docs/docusaurus.config.ts @@ -81,7 +81,7 @@ const config: Config = { { type: "docSidebar", sidebarId: "buildApp", - label: "Build an App", + label: "Build an app", position: "left", }, { @@ -102,33 +102,6 @@ const config: Config = { label: "Tokens", position: "left", }, - { - type: "dropdown", - label: "Tools", - position: "left", - items: [ - { - type: "doc", - label: "Smart contract API", - docId: "build-an-app/smart-contract-api-reference", - }, - { - type: "doc", - label: "WardenJS", - docId: "build-an-app/build-the-frontend/wardenjs-functions", - }, - { - type: "doc", - label: "Keychain SDK", - docId: "build-a-keychain/sdk/keychain-sdk", - }, - { - type: "doc", - label: "Node API", - docId: "operate-a-node/node-api-reference", - }, - ], - }, { href: "https://discord.com/invite/warden", label: "Discord", From 94dc86d3fb49dce9eaa493a062603f8a4bb1fd4f Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Fri, 6 Sep 2024 10:02:17 +0000 Subject: [PATCH 3/4] fix: warden.Dockerfile to reduce vulnerabilities The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-DEBIAN12-EXPAT-7855502 - https://snyk.io/vuln/SNYK-DEBIAN12-EXPAT-7855503 - https://snyk.io/vuln/SNYK-DEBIAN12-EXPAT-7855507 - https://snyk.io/vuln/SNYK-DEBIAN12-CURL-7575306 - https://snyk.io/vuln/SNYK-DEBIAN12-CURL-7575306 --- warden.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/warden.Dockerfile b/warden.Dockerfile index 2658dee33..cf83a316d 100644 --- a/warden.Dockerfile +++ b/warden.Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22.5 +FROM golang:1.22.7 # Install dependencies RUN apt-get update && \ From 5a8598655586ca55ccd2b233115777ce0fe7b769 Mon Sep 17 00:00:00 2001 From: backsapc Date: Fri, 6 Sep 2024 15:18:16 +0500 Subject: [PATCH 4/4] Avoid Action pruning if params are zero (#798) --- warden/x/act/keeper/abci.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/warden/x/act/keeper/abci.go b/warden/x/act/keeper/abci.go index fdd1846c8..006b4ac5d 100644 --- a/warden/x/act/keeper/abci.go +++ b/warden/x/act/keeper/abci.go @@ -3,6 +3,7 @@ package keeper import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" + "time" ) func (k Keeper) EndBlocker(ctx context.Context) error { @@ -10,17 +11,36 @@ func (k Keeper) EndBlocker(ctx context.Context) error { blockHeight := sdkCtx.BlockHeight() params := k.GetParams(ctx) + if params.MaxPendingTime > 0 && params.MaxCompletedTime > 0 { + if err := k.pruneActions( + ctx, + blockHeight, + params.PruneCheckBlockFrequency, + params.MaxPendingTime, + params.MaxCompletedTime); err != nil { + return err + } + } + + return nil +} + +func (k Keeper) pruneActions( + ctx context.Context, + blockHeight int64, + pruneCheckBlockFrequency int64, + maxPendingTime, maxCompletedTime time.Duration) error { latestPruneHeight, err := k.ActionKeeper.GetLatestPruneHeight(ctx) if err != nil { return err } - if (blockHeight - latestPruneHeight) < params.PruneCheckBlockFrequency { + if (blockHeight - latestPruneHeight) < pruneCheckBlockFrequency { return nil } blockTime := k.getBlockTime(ctx) - expiredActions, err := k.ActionKeeper.ExpiredActions(ctx, blockTime, params.MaxPendingTime, params.MaxCompletedTime) + expiredActions, err := k.ActionKeeper.ExpiredActions(ctx, blockTime, maxPendingTime, maxCompletedTime) if err != nil { return err }