Skip to content

Commit

Permalink
Merge pull request #279 from nomic-io/testnet-7.1
Browse files Browse the repository at this point in the history
Testnet 7.1 staging
  • Loading branch information
mappum authored Feb 15, 2024
2 parents 67a7050 + 06ebd7f commit 4743a33
Show file tree
Hide file tree
Showing 20 changed files with 1,514 additions and 180 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
toolchain: nightly-2023-05-08
override: true
- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo
Expand All @@ -51,7 +51,7 @@ jobs:
toolchain: nightly-2023-05-08
override: true
- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo
Expand All @@ -76,7 +76,7 @@ jobs:
toolchain: nightly-2023-05-08
override: true
- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo
Expand Down Expand Up @@ -137,7 +137,7 @@ jobs:
override: true
- name: Cache
id: cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo
Expand Down Expand Up @@ -192,7 +192,7 @@ jobs:
components: clippy
override: true
- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "nomic"
version = "7.0.0"
version = "7.1.0"
authors = ["The Turbofish Team <[email protected]>"]
edition = "2021"
default-run = "nomic"

[dependencies]
bitcoin = { version = "0.29.2", features = ["serde", "rand"] }
orga = { git = "https://github.com/nomic-io/orga.git", rev = "38682a1eafc9c3566aa5de4601a1aff06eb79c4f", features = [
orga = { git = "https://github.com/nomic-io/orga.git", rev = "bd9b07a96c21669bf0de52640ad81eaf8d7f0aae", features = [
"merk-verify",
] }
thiserror = "1.0.30"
Expand Down Expand Up @@ -66,7 +66,7 @@ toml = { version = "0.7.2", features = ["parse"] }
semver = "1.0.18"

[features]
default = ["full", "feat-ibc", "legacy-bin"]
default = ["full", "feat-ibc", "testnet"]
full = [
"bitcoincore-rpc-async",
"clap",
Expand Down
16 changes: 8 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ fn main() {
include_str!("networks/stakenet.toml")
};
let config: toml::Value = toml::from_str(toml).unwrap();
config
.as_table()
.unwrap()
.get("legacy_version")
.unwrap()
.as_str()
.unwrap()
.to_string()
if let Some(legacy_version) = config.as_table().unwrap().get("legacy_version") {
legacy_version.as_str().unwrap().to_string()
} else {
println!("No legacy_version set in network config");
println!("cargo:rustc-env=NOMIC_LEGACY_BUILD_PATH=/dev/null");
println!("cargo:rustc-env=NOMIC_LEGACY_BUILD_VERSION=");
return;
}
};
if version_req_str.chars().next().unwrap().is_numeric() {
version_req_str = format!("={}", version_req_str);
Expand Down
40 changes: 22 additions & 18 deletions networks/testnet.toml
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
state_sync_rpc = [
"http://147.182.171.216:26667",
"http://147.182.171.216:26677",
"https://rpc.nomic-testnet.basementnodes.ca"
]
tendermint_flags = [
"--p2p.seeds",
"""
tendermint_flags = ["--p2p.seeds", """
[email protected]:26656,\
""",
]
btc_relayer = [
"https://relayer.nomic-testnet.mappum.io:8443"
]

legacy_version = "6.4"
"""]
btc_relayer = ["https://relayer.nomic-testnet.mappum.io:8443"]

genesis = """
{
"genesis_time": "2022-10-05T00:00:00Z",
"chain_id": "nomic-testnet-4d",
"initial_height": "0",
"app_hash": "",
"chain_id": "nomic-testnet-5",
"consensus_params": {
"block": {
"max_bytes": "22020096",
"max_gas": "-1",
"time_iota_ms": "1000"
},
"evidence": {
"max_age_num_blocks": "100000",
"max_age_duration": "172800000000000",
"max_age_num_blocks": "100000",
"max_bytes": "1048576"
},
"validator": {
"pub_key_types": ["ed25519"]
"pub_key_types": [
"ed25519"
]
},
"version": {}
},
"validators": [],
"app_hash": ""
"genesis_time": "2024-02-14T19:53:11.939148Z",
"initial_height": "0",
"validators": [
{
"address": "044AD55B10017D73B72269396305A71B82CD1216",
"name": "",
"power": "10",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "orlC75T55Qe9hgqGZzkPMIOeTn7kvsA2+/d2gZWHL2g="
}
}
]
}
"""
53 changes: 44 additions & 9 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ const STRATEGIC_RESERVE_ADDRESS: &str = "nomic1d5n325zrf4elfu0heqd59gna5j6xyunhe
const VALIDATOR_BOOTSTRAP_ADDRESS: &str = "nomic1fd9mxxt84lw3jdcsmjh6jy8m6luafhqd8dcqeq";

const IBC_FEE_USATS: u64 = 1_000_000;
const DECLARE_FEE_USATS: u64 = 100_000_000;
const CALL_FEE_USATS: u64 = 100_000_000;

#[orga(version = 4)]
#[orga(version = 5)]
pub struct InnerApp {
#[call]
pub accounts: Accounts<Nom>,
Expand All @@ -93,7 +93,7 @@ pub struct InnerApp {
#[call]
pub ibc: Ibc,
#[cfg(not(feature = "testnet"))]
#[orga(version(V4))]
#[orga(version(V4, V5))]
#[call]
pub ibc: Ibc,

Expand All @@ -105,13 +105,13 @@ pub struct InnerApp {
#[cfg(feature = "testnet")]
pub cosmos: Cosmos,
#[cfg(not(feature = "testnet"))]
#[orga(version(V4))]
#[orga(version(V4, V5))]
pub cosmos: Cosmos,
}

#[orga]
impl InnerApp {
pub const CONSENSUS_VERSION: u8 = 10;
pub const CONSENSUS_VERSION: u8 = 11;

#[cfg(feature = "full")]
fn configure_faucets(&mut self) -> Result<()> {
Expand Down Expand Up @@ -328,16 +328,21 @@ impl InnerApp {

#[call]
pub fn declare_with_nbtc(&mut self, declaration: Declaration) -> Result<()> {
self.deduct_nbtc_fee(DECLARE_FEE_USATS.into())?;
self.deduct_nbtc_fee(CALL_FEE_USATS.into())?;
let signer = self.signer()?;
self.staking.declare(signer, declaration, 0.into())
}

#[call]
pub fn pay_nbtc_fee(&mut self) -> Result<()> {
self.deduct_nbtc_fee(CALL_FEE_USATS.into())
}

fn deduct_nbtc_fee(&mut self, amount: Amount) -> Result<()> {
disable_fee();
let signer = self.signer()?;
self.bitcoin.accounts.withdraw(signer, amount)?.burn();

let fee = self.bitcoin.accounts.withdraw(signer, amount)?;
self.bitcoin.give_rewards(fee)?;
Ok(())
}

Expand Down Expand Up @@ -424,6 +429,18 @@ mod abci {
.current_version
.insert((), vec![Self::CONSENSUS_VERSION].try_into().unwrap())?;

#[cfg(feature = "testnet")]
{
self.upgrade.activation_delay_seconds = 20 * 60;

include_str!("../testnet_addresses.csv")
.lines()
.try_for_each(|line| {
let address = line.parse().unwrap();
self.accounts.deposit(address, Coin::mint(10_000_000_000))
})?;
}

Ok(())
}
}
Expand Down Expand Up @@ -923,12 +940,30 @@ impl ConvertSdkTx for InnerApp {
crate::bitcoin::adapter::Adapter::new(recovery_addr.script_pubkey());

let funding_amt = MIN_FEE;
let payer = build_call!(self.accounts.take_as_funding(funding_amt.into()));
let payer = build_call!(self.pay_nbtc_fee());
let paid = build_call!(self.bitcoin.set_recovery_script(script.clone()));

Ok(PaidCall { payer, paid })
}

"nomic/PayToFeePool" => {
let msg = msg
.value
.as_object()
.ok_or_else(|| Error::App("Invalid message value".to_string()))?;

let amount: u64 = msg["amount"]
.as_str()
.ok_or_else(|| Error::App("Invalid amount".to_string()))?
.parse()
.map_err(|e: std::num::ParseIntError| Error::App(e.to_string()))?;

let payer = build_call!(self.bitcoin.transfer_to_fee_pool(amount.into()));
let paid = build_call!(self.app_noop());

Ok(PaidCall { payer, paid })
}

_ => Err(Error::App("Unsupported message type".into())),
}
}
Expand Down
29 changes: 28 additions & 1 deletion src/app/migrations.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::incentives::Incentives;

use super::{InnerAppV0, InnerAppV1, InnerAppV2, InnerAppV3, InnerAppV4};
use super::{InnerAppV0, InnerAppV1, InnerAppV2, InnerAppV3, InnerAppV4, InnerAppV5};
use orga::{
coins::Take,
ibc::Ibc,
Expand Down Expand Up @@ -87,3 +87,30 @@ impl MigrateFrom<InnerAppV3> for InnerAppV4 {
})
}
}

impl MigrateFrom<InnerAppV4> for InnerAppV5 {
fn migrate_from(other: InnerAppV4) -> Result<Self> {
#[cfg(not(feature = "testnet"))]
{
todo!()
}

Ok(Self {
accounts: other.accounts,
staking: other.staking,
airdrop: other.airdrop,
community_pool: other.community_pool,
incentive_pool: other.incentive_pool,
staking_rewards: other.staking_rewards,
dev_rewards: other.dev_rewards,
community_pool_rewards: other.community_pool_rewards,
incentive_pool_rewards: other.incentive_pool_rewards,
bitcoin: other.bitcoin,
reward_timer: other.reward_timer,
upgrade: other.upgrade,
incentives: other.incentives,
ibc: other.ibc,
cosmos: other.cosmos,
})
}
}
Loading

0 comments on commit 4743a33

Please sign in to comment.