Skip to content

Commit fd62df9

Browse files
giunataletbruyellealbttx
authored
feat: add x/photon module (#57)
This PR adds the `x/photon` module to the main branch, which implements the corresponding ADR (separate PR #34) Closes #44 --------- Co-authored-by: Thomas Bruyelle <[email protected]> Co-authored-by: Albert Le Batteux <[email protected]>
1 parent f7d541e commit fd62df9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+5849
-181
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414

1515
### STATE BREAKING
1616

17+
## v2.0.0
18+
19+
*Release date*
20+
21+
### FEATURES
22+
23+
- Add the photon module and use photon as the only fee denom [#57](https://github.com/atomone-hub/atomone/pull/57)
24+
1725
## v1.0.0
1826

1927
*Sep 26th, 2024*

Makefile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,13 @@ docker-build-hermes:
216216

217217
docker-build-all: docker-build-debug docker-build-hermes
218218

219-
.PHONY: docker-build-debug docker-build-hermes docker-build-all
219+
mockgen_cmd=$(rundep) github.com/golang/mock/mockgen
220+
221+
mocks-gen:
222+
$(mockgen_cmd) -source=x/gov/testutil/expected_keepers.go -package testutil -destination x/gov/testutil/expected_keepers_mocks.go
223+
$(mockgen_cmd) -source=x/photon/types/expected_keepers.go -package testutil -destination x/photon/testutil/expected_keepers_mocks.go
224+
225+
.PHONY: docker-build-debug docker-build-hermes docker-build-all mocks-gen
220226

221227
###############################################################################
222228
### Linting ###
@@ -261,14 +267,16 @@ update-swagger-docs: proto-swagger-gen
261267

262268
start-localnet-ci: build
263269
rm -rf ~/.atomoned-liveness
264-
./build/atomoned init liveness --chain-id liveness --home ~/.atomoned-liveness
270+
./build/atomoned init liveness --default-denom uatone --chain-id liveness --home ~/.atomoned-liveness
265271
./build/atomoned config chain-id liveness --home ~/.atomoned-liveness
266272
./build/atomoned config keyring-backend test --home ~/.atomoned-liveness
267273
./build/atomoned keys add val --home ~/.atomoned-liveness
268-
./build/atomoned genesis add-genesis-account val 10000000000000000000000000stake --home ~/.atomoned-liveness --keyring-backend test
269-
./build/atomoned genesis gentx val 1000000000stake --home ~/.atomoned-liveness --chain-id liveness
274+
./build/atomoned genesis add-genesis-account val 1000000000000uatone --home ~/.atomoned-liveness --keyring-backend test
275+
./build/atomoned keys add user --home ~/.atomoned-liveness
276+
./build/atomoned genesis add-genesis-account user 1000000000uatone --home ~/.atomoned-liveness --keyring-backend test
277+
./build/atomoned genesis gentx val 1000000000uatone --home ~/.atomoned-liveness --chain-id liveness
270278
./build/atomoned genesis collect-gentxs --home ~/.atomoned-liveness
271-
sed -i.bak'' 's/minimum-gas-prices = ""/minimum-gas-prices = "0uatone"/' ~/.atomoned-liveness/config/app.toml
279+
sed -i.bak 's#^minimum-gas-prices = .*#minimum-gas-prices = "0.001uatone,0.001uphoton"#g' ~/.atomoned-liveness/config/app.toml
272280
./build/atomoned start --home ~/.atomoned-liveness --x-crisis-skip-assert-invariants
273281

274282
.PHONY: start-localnet-ci

UPGRADING.md

Lines changed: 305 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
# Upgrading AtomOne
22

3-
This guide provides instructions for upgrading to specific versions of AtomOne.
3+
This guide provides instructions for upgrading AtomOne from v1.x to v2.x.
4+
5+
This document describes the steps for validators and full node operators, to
6+
upgrade successfully for the AtomOne v2 release.
7+
8+
For more details on the release, please see the [release notes][v2].
9+
10+
**Validators** will have to change their configuration to allow the PHOTON
11+
denom (`uphoton`) for the fees, **before** the upgrade, see [Validator config
12+
change](#validator-config-change).
13+
14+
**Relayer Operators** will also need to update their configuration to use the
15+
PHOTON denom for the fees, but this time **after** the upgrade, see [Relayer
16+
config change](#relayer-config-change) section.
17+
18+
## Release Binary
19+
20+
Please use the correct release binary: `v2.0.0`.
421

522
## Go version bump
623

@@ -18,3 +35,290 @@ AtomOne. For example, to run `make build` :
1835
```
1936
$ GOROOT=$(go1.22.10 env GOROOT) PATH=$GOROOT/bin:$PATH make build
2037
```
38+
39+
## Instructions
40+
41+
- [Upgrading AtomOne](#upgrading-atomeone)
42+
- [Release Binary](#release-binary)
43+
- [Go version bump](#go-version-dump)
44+
- [Instructions](#instructions)
45+
- [On-chain governance proposal attains consensus](#on-chain-governance-proposal-attains-consensus)
46+
- [Upgrade date](#upgrade-date)
47+
- [Preparing for the upgrade](#preparing-for-the-upgrade)
48+
- [System requirements](#system-requirements)
49+
- [Backups](#backups)
50+
- [Testing](#testing)
51+
- [Current runtime](#current-runtime)
52+
- [Target runtime](#target-runtime)
53+
- [Upgrade steps](#upgrade-steps)
54+
- [Validator config change](#validator-config-change)
55+
- [Relayer config change](#relayer-config-change)
56+
- [Method I: Manual Upgrade](#method-i-manual-upgrade)
57+
- [Method II: Upgrade using Cosmovisor](#method-ii-upgrade-using-cosmovisor)
58+
- [Manually preparing the binary](#manually-preparing-the-binary)
59+
- [Preparation](#preparation)
60+
- [Auto-Downloading the AtomOne binary](#auto-downloading-the-gaia-binary)
61+
- [Expected upgrade result](#expected-upgrade-result)
62+
- [Upgrade duration](#upgrade-duration)
63+
- [Rollback plan](#rollback-plan)
64+
- [Communications](#communications)
65+
- [Risks](#risks)
66+
67+
## On-chain governance proposal attains consensus
68+
69+
Once a software upgrade governance proposal is submitted to the Cosmos Hub,
70+
both a reference to this proposal and an `UPGRADE_HEIGHT` are added to the
71+
[release notes][v2].
72+
If and when this proposal reaches consensus, the upgrade height will be used to
73+
halt the "old" chain binaries. You can check the proposal on one of the block
74+
explorers or using the `atomoned` CLI tool.
75+
Neither core developers nor core funding entities control the governance.
76+
77+
## Upgrade date
78+
79+
The date/time of the upgrade is subject to change as blocks are not generated
80+
at a constant interval. You can stay up-to-date by checking the estimated
81+
estimated time until the block is produced one of the block explorers (e.g.
82+
https://www.mintscan.io/atomone/blocks/`UPGRADE_HEIGHT`).
83+
84+
## Preparing for the upgrade
85+
86+
### System requirements
87+
88+
### Backups
89+
90+
Prior to the upgrade, validators are encouraged to take a full data snapshot.
91+
Snapshotting depends heavily on infrastructure, but generally this can be done
92+
by backing up the `.atomone` directory.
93+
If you use Cosmovisor to upgrade, by default, Cosmovisor will backup your data
94+
upon upgrade. See below [upgrade using cosmovisor](#method-ii-upgrade-using-cosmovisor)
95+
section.
96+
97+
It is critically important for validator operators to back-up the
98+
`.atomone/data/priv_validator_state.json` file after stopping the atomoned
99+
process. This file is updated every block as your validator participates in
100+
consensus rounds. It is a critical file needed to prevent double-signing, in
101+
case the upgrade fails and the previous chain needs to be restarted.
102+
103+
### Current runtime
104+
105+
The AtomOne mainnet network, `atomone-1`, is currently running [AtomOne
106+
v1.0.0][v1]. We anticipate that operators who are running on v1.0.0, will be
107+
able to upgrade successfully. Validators are expected to ensure that their
108+
systems are up to date and capable of performing the upgrade. This includes
109+
running the correct binary and if building from source, building with the
110+
appropriate `go` version.
111+
112+
### Target runtime
113+
114+
The AtomOne mainnet network, `atomone-1`, will run **[AtomOne v2.0.0][v2]**.
115+
Operators _**MUST**_ use this version post-upgrade to remain connected to the
116+
network. The new version requires `go v1.21` to build successfully.
117+
118+
## Upgrade steps
119+
120+
There are 2 major ways to upgrade a node:
121+
122+
- Manual upgrade
123+
- Upgrade using [Cosmovisor](https://pkg.go.dev/cosmossdk.io/tools/cosmovisor)
124+
- Either by manually preparing the new binary
125+
- Or by using the auto-download functionality (this is not yet recommended)
126+
127+
If you prefer to use Cosmovisor to upgrade, some preparation work is needed
128+
before upgrade.
129+
130+
### Validator config change
131+
132+
**AtomOne v2.0.0** introduces `photon` as the only fee token, so it requires a
133+
modification of the validator configuration, namely the `minimum-gas-prices`
134+
which must contain the `uphoton` denom in addition to the `uatone` denom (so
135+
both denom). This setting is located in the `$ATOMONE_HOME/config/app.toml`
136+
file.
137+
138+
For example, considering this existing setting:
139+
```toml
140+
minimum-gas-prices = "0.001uatone"
141+
```
142+
Before upgrading, the setting should be changed to:
143+
```toml
144+
minimum-gas-prices = "0.001uatone,0.001uphoton"
145+
```
146+
147+
For validators that have `authz` transactions submitted periodically, the tx
148+
fee denom would need to be updated as well.
149+
150+
### Relayer config change
151+
152+
Similarly to the validator config change, any running relayers would have to
153+
change the gas price denom for the AtomOne chain, from `uatone` to `uphoton`.
154+
155+
For Hermes relayers, this setting is located in the `~/.hermes/config.toml`
156+
file.
157+
158+
For example, considerng the existing setting:
159+
```toml
160+
[[ chain ]]
161+
id = 'atomone-1'
162+
(...)
163+
gas_price = { price = 0.001, denom = 'uatone' }
164+
```
165+
Once the chain is upgraded, the setting should be changed to:
166+
```toml
167+
[[ chain ]]
168+
id = 'atomone-1'
169+
(...)
170+
gas_price = { price = 0.001, denom = 'uphoton' }
171+
```
172+
173+
Note that unlike the validator config change which still accepts `uatone` for
174+
fees, this change should be done **after** the upgrade because it is restricted
175+
to `uphoton` which has no supply before the upgrade.
176+
177+
### Method I: Manual Upgrade
178+
179+
Make sure **AtomOne v1.0.0** is installed by either downloading a [compatible
180+
binary][v1], or building from source. Check the required version to build this
181+
binary in the `Makefile`.
182+
183+
Run AtomOne v1.0.0 till upgrade height, the node will panic:
184+
185+
```shell
186+
ERR UPGRADE "v2" NEEDED at height: <UPGRADE_HEIGHT>: upgrade to v2 and applying upgrade "v2" at height:<UPGRADE_HEIGHT>
187+
```
188+
189+
Stop the node, and switch the binary to **AtomOne v2.0.0** and re-start by
190+
`atomone start`.
191+
192+
It may take several minutes to a few hours until validators with a total sum
193+
voting power > 2/3 to complete their node upgrades. After that, the chain can
194+
continue to produce blocks.
195+
196+
### Method II: Upgrade using Cosmovisor
197+
198+
#### Manually preparing the binary
199+
200+
##### Preparation
201+
202+
- Install the latest version of Cosmovisor (`1.5.0`):
203+
204+
```shell
205+
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest
206+
cosmovisor version
207+
# cosmovisor version: v1.5.0
208+
```
209+
210+
- Create a `cosmovisor` folder inside `$ATOMONE_HOME` and move AtomOne `v1.0.0`
211+
into `$ATOMONE_HOME/cosmovisor/genesis/bin`:
212+
213+
```shell
214+
mkdir -p $ATOMONE_HOME/cosmovisor/genesis/bin
215+
cp $(which atomoned) $ATOMONE_HOME/cosmovisor/genesis/bin
216+
```
217+
218+
- Build AtomOne `v2.0.0`, and move atomoned `v2.0.0` to
219+
`$ATOMONE_HOME/cosmovisor/upgrades/v2/bin`
220+
221+
```shell
222+
mkdir -p $ATOMONE_HOME/cosmovisor/upgrades/v2/bin
223+
cp $(which atomoned) $ATOMONE_HOME/cosmovisor/upgrades/v2/bin
224+
```
225+
226+
At this moment, you should have the following structure:
227+
228+
```shell
229+
.
230+
├── current -> genesis or upgrades/<name>
231+
├── genesis
232+
│ └── bin
233+
│ └── atomoned # old: v1.0.0
234+
└── upgrades
235+
└── v2
236+
└── bin
237+
└── atomoned # new: v2.0.0
238+
```
239+
240+
- Export the environmental variables:
241+
242+
```shell
243+
export DAEMON_NAME=atomoned
244+
# please change to your own gaia home dir
245+
# please note `DAEMON_HOME` has to be absolute path
246+
export DAEMON_HOME=$ATOMONE_HOME
247+
export DAEMON_RESTART_AFTER_UPGRADE=true
248+
```
249+
250+
- Start the node:
251+
252+
```shell
253+
cosmovisor run start --x-crisis-skip-assert-invariants --home $DAEMON_HOME
254+
```
255+
256+
Skipping the invariant checks can be used to decreases the upgrade time
257+
significantly, but it is done at the expense of verifying state validity and
258+
must be done cautiously.
259+
260+
#### Auto-Downloading the AtomOne binary
261+
262+
**This method is not recommended!**
263+
264+
## Expected upgrade result
265+
266+
When the upgrade block height is reached, AtomOne will panic and stop:
267+
268+
This may take a few minutes to a few hours.
269+
After upgrade, the chain will continue to produce blocks when validators with a
270+
total sum voting power > 2/3 complete their node upgrades.
271+
272+
## Upgrade duration
273+
274+
The upgrade may take a few minutes to several hours to complete because
275+
atomone-1 participants operate globally with differing operating hours and it
276+
may take some time for operators to upgrade their binaries and connect to the
277+
network.
278+
279+
## Rollback plan
280+
281+
During the network upgrade, core Cosmos teams will be keeping an ever vigilant
282+
eye and communicating with operators on the status of their upgrades. During
283+
this time, the core teams will listen to operator needs to determine if the
284+
upgrade is experiencing unintended challenges. In the event of unexpected
285+
challenges, the core teams, after conferring with operators and attaining
286+
social consensus, may choose to declare that the upgrade will be skipped.
287+
288+
Steps to skip this upgrade proposal are simply to resume the `atomone-1`
289+
network with the (downgraded) v1.0.0 binary using the following command:
290+
291+
```shell
292+
atomoned start --unsafe-skip-upgrade <UPGRADE_HEIGHT>
293+
```
294+
295+
Note: There is no particular need to restore a state snapshot prior to the
296+
upgrade height, unless specifically directed by core Cosmos teams.
297+
298+
Important: A social consensus decision to skip the upgrade will be based solely
299+
on technical merits, thereby respecting and maintaining the decentralized
300+
governance process of the upgrade proposal's successful YES vote.
301+
302+
## Communications
303+
304+
Operators are encouraged to join the `#validate-private` channel
305+
of the AtomOne (unofficial) Discord. This channel is the primary communication
306+
tool for operators to ask questions, report upgrade status, report technical
307+
issues, and to build social consensus should the need arise. This channel is
308+
restricted to known operators and requires verification beforehand. Requests to
309+
join the `#validator-private` channel can be sent to the `#support` channel.
310+
311+
## Risks
312+
313+
As a validator performing the upgrade procedure on your consensus nodes carries
314+
a heightened risk of double-signing and being slashed. The most important piece
315+
of this procedure is verifying your software version and genesis file hash
316+
before starting your validator and signing.
317+
318+
The riskiest thing a validator can do is discover that they made a mistake and
319+
repeat the upgrade procedure again during the network startup. If you discover
320+
a mistake in the process, the best thing to do is wait for the network to start
321+
before correcting it.
322+
323+
[v1]: https://github.com/atomone-hub/atomone/releases/tag/v1.0.0
324+
[v2]: https://github.com/atomone-hub/atomone/releases/tag/v2.0.0

0 commit comments

Comments
 (0)