Skip to content

Commit

Permalink
imp(all): Minor improvements and updated README (#44)
Browse files Browse the repository at this point in the history
* improve test

* improve readme and add update makefile command

* add changelog entry

* update makefile
  • Loading branch information
MalteHerrmann authored Aug 9, 2024
1 parent 16ccacb commit a000f23
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 65 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

### Improvements

- (all) [#44](https://github.com/evmos/proposer/pull/44) Minor improvements and updated README.
- (command) [#40](https://github.com/evmos/proposer/pull/40) Improve handling of Commonwealth info.
- (block) [#39](https://github.com/evmos/proposer/pull/39) Round upgrade height to nearest 500.
- (llm) [#38](https://github.com/evmos/proposer/pull/38) Enable using GPT-4o.
Expand Down
39 changes: 24 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@ lint:
test:
cargo test

# on CI the keyring and OpenAI key are not set up so we're skipping those tests
test-remote:
cargo test --features remote

update:
cargo update

build:
cargo build --locked

install:
cargo install --path . --locked

.PHONY: format lint test test-remote update build install
76 changes: 69 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,78 @@ This repository contains a helper to aid in generating the contents of Software
- [x] Creating the CLI command to submit the proposal
- [ ] Creating a Notion page that contains the proposal text as well as the CLI command

## Usage

**NOTE:** Because the Commonwealth integration is not yet implemented (an API key is already requested)
it is not possible to run all of this in one go.

It is rather required, to first _generate the proposal_, which creates a Markdown file with the proposal description,
that need to be posted on Commonwealth for mainnet upgrades.

```yaml
$ ./proposer generate-proposal -h

Usage: proposer generate-proposal [OPTIONS]

Options:
-m, --model <MODEL> The LLM model to use for summarizing the release notes [default: gpt4o] [possible values: gpt4o]
-h, --help Print help
```

As a second step, it is required to _generate the shell command_ to submit the proposal.
It is written to a `.sh` file in your current working directory.

```yaml
$ ./proposer generate-command -h

Usage: proposer generate-command [OPTIONS]

Options:
-c, --config <CONFIG> The path to the configuration file
-h, --help Print help
```


## Requirements

- **Rust** and **Cargo**

You will need to have a somewhat recent version of the Rust toolchain installed.

- **OpenAI API Key**

The tool is using OpenAI's LLMs to generate a summary of the changes in the release(s).
To use this feature, ensure that you run the binary in an environment where `OPENAI_API_KEY` is set.

- **Configured `.evmosd` Home**

To generate a shell command that can be instantly used,
the tool is checking `$HOME/.evmosd` for the configured keyring.
This keyring is then used to get the list of available keys.
It is checked, which of those keys hold a balance on the selected network (mainnet/testnet)
and lets the user select the one to execute the command with if there are multiple.
To use this feature, ensure that you have your `$HOME/.evmosd` configuration set
so that the configured keyring holds your mainnet or testnet keys.

## Installation

The tool can be built or installed using Rust's `cargo` utility.
The tool can be built or installed locally using Rust's `cargo` utility.
Clone the desired version of the repository locally:

- `cargo install`
- `cargo build`
```
git clone https://github.com/evmos/proposer.git --depth latest
cd proposer
```

## Usage
To install the binary, run:

```
make install
```

The following main commands can be used when calling the binary:
If you do not wish for the binary to be installed in your `$PATH`,
run the build command which creates the binary inside of the `target` directory:

1. `./proposer generate-proposal`: Updates the description template with the information for the desired upgrade.
2. `./proposer generate-command`: Creates the CLI command to submit the software upgrade proposal.
```
make build
```
57 changes: 14 additions & 43 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,49 +111,20 @@ mod tests {
std::fs::write(&helper.proposal_file_name, description)
.expect("Unable to write proposal to file");

match prepare_command(&helper, &client_config, "dev0").await {
Ok(command) => {
// Remove description file
std::fs::remove_file(&helper.proposal_file_name)
.expect("failed to remove description file after test");

let mut expected_command =
"evmosd tx gov submit-legacy-proposal software-upgrade v14.0.0 \\\n".to_owned();
expected_command.push_str("--title \"Evmos Testnet v14.0.0 Upgrade\" \\\n");
expected_command
.push_str(format!("--upgrade-height {} \\\n", helper.upgrade_height).as_str());
expected_command.push_str("--description \"This is a test proposal.\" \\\n");
expected_command.push_str("--keyring-backend test \\\n");
expected_command.push_str("--from dev0 \\\n");
expected_command.push_str("--fees 10000000000atevmos \\\n");
expected_command.push_str("--gas auto \\\n");
expected_command.push_str("--chain-id evmos_9000-4 \\\n");
expected_command.push_str(
format!(
"--home {} \\\n",
helper
.evmosd_home
.as_os_str()
.to_str()
.expect("failed to get home directory as str")
)
.as_str(),
);
expected_command.push_str("--node https://tm.evmos-testnet.lava.build:443 \\\n");
expected_command.push_str(concat!(r#"--upgrade-info '{"binaries":{"darwin/amd64":"https://github.com/evmos/evmos/releases/download/v14.0.0/evmos_14.0.0_Darwin_amd64.tar.gz?checksum=35202b28c856d289778010a90fdd6c49c49a451a8d7f60a13b0612d0cd70e178","darwin/arm64":"https://github.com/evmos/evmos/releases/download/v14.0.0/evmos_14.0.0_Darwin_arm64.tar.gz?checksum=541d4bac1513c84278c8d6b39c86aca109cc1ecc17652df56e57488ffbafd2d5","linux/amd64":"https://github.com/evmos/evmos/releases/download/v14.0.0/evmos_14.0.0_Linux_amd64.tar.gz?checksum=427c2c4a37f3e8cf6833388240fcda152a5372d4c5132ca2e3861a7085d35cd0","linux/arm64":"https://github.com/evmos/evmos/releases/download/v14.0.0/evmos_14.0.0_Linux_arm64.tar.gz?checksum=a84279d66b6b0ecd87b85243529d88598995eeb124bc16bb8190a7bf022825fb"}}'"#, " \\\n"));
expected_command.push_str("-b sync");
assert_eq!(
command, expected_command,
"expected different proposal command"
);
}
Err(e) => {
// Remove description file
std::fs::remove_file(&helper.proposal_file_name)
.expect("failed to remove description file after test");
assert!(false, "unexpected error while preparing command: {}", e);
}
}
// Parse the description and prepare exported command
let command = prepare_command(&helper, &client_config, "dev0")
.await
.expect("failed to prepare command");

// Remove description file
std::fs::remove_file(&helper.proposal_file_name)
.expect("failed to remove description file after test");

assert_eq!(
command,
include_str!("testdata/example_command.sh"),
"expected different proposal command"
);
}

#[test]
Expand Down
13 changes: 13 additions & 0 deletions src/testdata/example_command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
evmosd tx gov submit-legacy-proposal software-upgrade v14.0.0 \
--title "Evmos Testnet v14.0.0 Upgrade" \
--upgrade-height 60 \
--description "This is a test proposal." \
--keyring-backend test \
--from dev0 \
--fees 10000000000atevmos \
--gas auto \
--chain-id evmos_9000-4 \
--home ./.evmosd \
--node https://tm.evmos-testnet.lava.build:443 \
--upgrade-info '{"binaries":{"darwin/amd64":"https://github.com/evmos/evmos/releases/download/v14.0.0/evmos_14.0.0_Darwin_amd64.tar.gz?checksum=35202b28c856d289778010a90fdd6c49c49a451a8d7f60a13b0612d0cd70e178","darwin/arm64":"https://github.com/evmos/evmos/releases/download/v14.0.0/evmos_14.0.0_Darwin_arm64.tar.gz?checksum=541d4bac1513c84278c8d6b39c86aca109cc1ecc17652df56e57488ffbafd2d5","linux/amd64":"https://github.com/evmos/evmos/releases/download/v14.0.0/evmos_14.0.0_Linux_amd64.tar.gz?checksum=427c2c4a37f3e8cf6833388240fcda152a5372d4c5132ca2e3861a7085d35cd0","linux/arm64":"https://github.com/evmos/evmos/releases/download/v14.0.0/evmos_14.0.0_Linux_arm64.tar.gz?checksum=a84279d66b6b0ecd87b85243529d88598995eeb124bc16bb8190a7bf022825fb"}}' \
-b sync

0 comments on commit a000f23

Please sign in to comment.