Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stakenet 6 #183

Merged
merged 44 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3fb832a
Fix airdrop state compatibility for stakenet
mappum Aug 7, 2023
11805be
Add checkpoint rewinding
mappum Aug 7, 2023
3c4813f
Don't prune on stakenet
mappum Aug 7, 2023
d5eecb6
Rewind checkpoints on stakenet
mappum Aug 7, 2023
ccf22e8
Only prune in testnet
mappum Aug 7, 2023
612f39f
v6.0.0
mappum Aug 8, 2023
ba2dede
Add stakenet.toml network config
mappum Aug 8, 2023
890960e
Implement upgrade height config option
mappum Aug 8, 2023
46d7288
Fix warnings
mappum Aug 8, 2023
a0973e6
Remove testnet default feature
mappum Aug 8, 2023
1a391ed
Allow NOMIC_LEGACY_REV with NOMIC_LEGACY_VERSION in build script (REV…
mappum Aug 8, 2023
6111a84
Pass correct args to stakenet legacy binary
mappum Aug 8, 2023
bbf128d
Add pull after checkout in build script
mappum Aug 8, 2023
83d23cb
Enable orga compat feature
mappum Aug 8, 2023
2d475fb
Add first seed and statesync bootstrap address
mappum Aug 8, 2023
608b02e
Add airdrop2 call
cwlittle Aug 8, 2023
419f593
Remove dust outputs in rewind
mappum Aug 9, 2023
2822889
Fix warning
mappum Aug 9, 2023
67217fb
Update legacy version for stakenet
mappum Aug 9, 2023
06fe6b2
Fix incentives allocation
keppel Aug 9, 2023
5466a34
Clear input signatures in rewind
mappum Aug 10, 2023
264b76c
Clear signed_txs and signed_inputs in bitcoin checkpoint rewinding
mappum Aug 10, 2023
27d09f5
Fix stakenet airdrop test
mappum Aug 10, 2023
0d16f48
Add rewind test
mappum Aug 10, 2023
ba7a368
Only show IBC balance on testnet
mappum Aug 9, 2023
4c29a62
Fix state compatibility issues
keppel Aug 11, 2023
dc248bc
Compare withdraw value to dust_value
cwlittle Aug 11, 2023
57b3b6a
Upgrade orga dependency
mappum Aug 11, 2023
9e06f18
Increase bitcoin fee rate to 10 sats/byte
mappum Aug 11, 2023
5b534a2
Fix build script for tag revs
mappum Aug 11, 2023
ed92c46
Fix relay_deposit implementation when 'testnet' feature is disabled
mappum Aug 11, 2023
25eaa4d
Fix CLI deposit relayer address
mappum Aug 14, 2023
871858a
Add double statesync rpc in stakenet network config
mappum Aug 14, 2023
775c6f0
Update testnet incentive snapshot for testnet height 6777820
mappum Aug 14, 2023
807048e
Re-enable confirmation depth check in deposit relay
mappum Aug 15, 2023
15b2ba8
Add height bound check test for bitcoin deposit relay
mappum Aug 15, 2023
98481d7
Set bitcoin min_confirmations to 3
mappum Aug 15, 2023
7ca9c29
Fix signer key network
mappum Aug 15, 2023
996a5fd
Increase legacy_version for stakenet to 3.0.2
mappum Aug 15, 2023
1d0b355
Select network in build script based on feature flags
mappum Aug 15, 2023
00e0fee
Add upgrade height for stakenet
mappum Aug 15, 2023
b640be0
Fix warnings
mappum Aug 15, 2023
0aa5d69
Remove outdated airdrop tests
mappum Aug 15, 2023
2c8022f
Fix tests for different feature sets
mappum Aug 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,14 +1,14 @@
[package]
name = "nomic"
version = "5.2.0"
version = "6.0.0"
authors = [ "The Nomic Team <hello@nomic.io>" ]
edition = "2021"
default-run = "nomic"

[dependencies]
bitcoin = { version = "0.29.2", features = ["serde", "rand"] }
bitcoind = { version = "0.27.0", features = ["22_0"], optional = true }
orga = { git = "https://github.com/nomic-io/orga.git", rev = "028725159d614e28e5cc8f642a7d7e19e7a97afe", features = ["merk-verify"] }
orga = { git = "https://github.com/nomic-io/orga.git", rev = "860052c382b01fa5d5c4b4d954da4aa129adacb9", features = ["merk-verify", "compat"] }
thiserror = "1.0.30"
ed = { git = "https://github.com/nomic-io/ed", rev = "9c0e206ffdb59dacb90f083e004e8080713e6ad8" }
clap = { version = "3.2.16", features = ["derive"], optional = true }
Expand Down Expand Up @@ -58,7 +58,7 @@ toml = { version = "0.7.2", features = ["parse"] }
semver = "1.0.18"

[features]
default = ["full", "feat-ibc", "testnet", "legacy-bin"]
default = ["full", "feat-ibc", "legacy-bin"]
full = ["bitcoind", "bitcoincore-rpc-async", "clap", "tokio", "orga/merk-full", "orga/abci", "orga/state-sync", "csv", "warp", "rand", "reqwest", "tendermint-rpc", "home"]
feat-ibc = ["orga/feat-ibc"]
testnet = []
Expand Down
21 changes: 13 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ fn main() {
let version = std::env::var("NOMIC_LEGACY_VERSION");
let rev = std::env::var("NOMIC_LEGACY_REV");

if version.is_ok() && rev.is_ok() {
panic!("Cannot specify both NOMIC_LEGACY_VERSION and NOMIC_LEGACY_REV");
}

let rev = if let Ok(rev) = rev {
rev
} else {
let mut version_req_str = if let Ok(version_req_str) = version {
version_req_str
} else {
let toml = if branch_name == "main" {
todo!()
} else {
#[cfg(feature = "testnet")]
let toml = {
println!("cargo:rerun-if-changed=networks/testnet.toml");
include_str!("networks/testnet.toml")
};
#[cfg(not(feature = "testnet"))]
let toml = {
println!("cargo:rerun-if-changed=networks/stakenet.toml");
include_str!("networks/stakenet.toml")
};
let config: toml::Value = toml::from_str(toml).unwrap();
config
.as_table()
Expand Down Expand Up @@ -80,8 +80,13 @@ fn main() {
let shell = std::env::var("SHELL").unwrap_or("/bin/bash".to_string());
println!("Using shell: {}", shell);

#[cfg(feature = "testnet")]
let default_features = "full,feat-ibc,testnet";
#[cfg(not(feature = "testnet"))]
let default_features = "full";

let cargo_features =
std::env::var("NOMIC_LEGACY_FEATURES").unwrap_or("full,feat-ibc,testnet".to_string());
std::env::var("NOMIC_LEGACY_FEATURES").unwrap_or(default_features.to_string());

let res = std::process::Command::new(shell)
.env_clear()
Expand Down
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if [ ! -f "$NOMIC_LEGACY_PATH" ]; then
git checkout main
git pull
git checkout $NOMIC_LEGACY_REV
git fetch

rustc --version
echo "Building with features: $CARGO_FEATURES"
Expand Down
39 changes: 39 additions & 0 deletions networks/stakenet.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
state_sync_rpc = [
"http://161.35.51.124:26667",
"http://161.35.51.124:26667"
]
tendermint_flags = [
"--p2p.seeds",
"""
238120dfe716082754048057c1fdc3d6f09609b5@161.35.51.124:26656
""",
]

upgrade_height = 9357000
legacy_version = "3.0.2"

genesis = """
{
"genesis_time": "2022-07-04T00:00:00Z",
"chain_id": "nomic-stakenet-3",
"initial_height": "0",
"consensus_params": {
"block": {
"max_bytes": "22020096",
"max_gas": "-1",
"time_iota_ms": "1000"
},
"evidence": {
"max_age_num_blocks": "100000",
"max_age_duration": "172800000000000",
"max_bytes": "1048576"
},
"validator": {
"pub_key_types": ["ed25519"]
},
"version": {}
},
"validators": [],
"app_hash": ""
}
"""
6 changes: 3 additions & 3 deletions rest/Cargo.lock

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

141 changes: 5 additions & 136 deletions src/airdrop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct Airdrop {
x: u8,
#[cfg(not(feature = "testnet"))]
#[orga(version(V0))]
#[state(prefix(2))]
#[state(prefix(0, 2))]
accounts: Map<Address, Account>,
#[cfg(not(feature = "testnet"))]
#[orga(version(V1))]
Expand Down Expand Up @@ -202,25 +202,9 @@ impl Airdrop {
) -> Result<(u64, u64)> {
let mut acct = self.accounts.entry(addr)?.or_insert_default()?;

#[cfg(feature = "testnet")]
{
acct.airdrop2.claimable = unom;

Ok((0, 0))
}
acct.airdrop2.claimable = unom;

#[cfg(not(feature = "testnet"))]
{
acct.airdrop2.claimable = unom;
assert!(testnet_completions <= 3);
acct.testnet_participation.locked = unom / 12 * (3 - testnet_completions);
acct.testnet_participation.claimable = unom / 12 * testnet_completions;

Ok((
acct.testnet_participation.locked,
acct.testnet_participation.claimable,
))
}
Ok((0, 0))
}

#[cfg(feature = "full")]
Expand Down Expand Up @@ -327,7 +311,7 @@ pub struct Account {
#[orga(version(V0))]
pub claimable: Amount,

#[orga(version(V1))]
#[orga(version(V1, V2))]
pub airdrop1: Part,
#[orga(version(V1))]
pub btc_deposit: Part,
Expand Down Expand Up @@ -460,10 +444,7 @@ mod test {

#[cfg(not(feature = "testnet"))]
fn amount_airdropped(acct: &Account) -> u64 {
acct.btc_deposit.locked
+ acct.btc_withdraw.locked
+ acct.ibc_transfer.locked
+ acct.testnet_participation.claimable
acct.airdrop2.claimable
}

#[cfg(feature = "testnet")]
Expand Down Expand Up @@ -534,116 +515,4 @@ nomic10005vr6w230rer02rgwsvmhh0vdpk9hvxkv8zs,1,1,1,1,1,1,1,1,1,1,true,true,true"

assert_approx_eq(airdrop2_total, expected);
}

#[cfg(not(feature = "testnet"))]
#[test]
fn airdrop_allocation_multiple_uneven() {
let mut airdrop = Airdrop::default();
let csv = "address,evmos_9000-1_staked,evmos_9000-1_count,kaiyo-1_staked,kaiyo-1_count,cosmoshub-4_staked,cosmoshub-4_count,juno-1_staked,juno-1_count,osmosis-1_staked,osmosis-1_count,btc_deposit_claimed,btc_withdraw_claimed,ibc_transfer_claimed
nomic100000aeu2lh0jrrnmn2npc88typ25u7t3aa64x,1,1,1,1,1,1,1,1,1,1,true,true,true
nomic10005vr6w230rer02rgwsvmhh0vdpk9hvxkv8zs,1,1,1,1,1,1,1,1,1,1,false,false,false".as_bytes();

airdrop.init_from_airdrop2_csv(csv).unwrap();

let account = airdrop
.get_mut(Address::from_str("nomic100000aeu2lh0jrrnmn2npc88typ25u7t3aa64x").unwrap())
.unwrap()
.unwrap();
let airdrop2_total = amount_airdropped(&*account);
let expected: u64 = (Amount::from(AIRDROP_II_TOTAL) / Amount::from(2))
.result()
.unwrap()
.amount()
.unwrap()
.into();
assert_approx_eq(airdrop2_total, expected);

let account = airdrop
.get_mut(Address::from_str("nomic10005vr6w230rer02rgwsvmhh0vdpk9hvxkv8zs").unwrap())
.unwrap()
.unwrap();
let airdrop2_total = amount_airdropped(&*account);
let expected: u64 = (Amount::from(AIRDROP_II_TOTAL) / Amount::from(16) * Amount::from(6))
.result()
.unwrap()
.amount()
.unwrap()
.into();

assert_approx_eq(airdrop2_total, expected);
}

#[cfg(not(feature = "testnet"))]
#[test]
fn airdrop_allocation_multiple_one_claim() {
let mut airdrop = Airdrop::default();
let csv = "address,evmos_9000-1_staked,evmos_9000-1_count,kaiyo-1_staked,kaiyo-1_count,cosmoshub-4_staked,cosmoshub-4_count,juno-1_staked,juno-1_count,osmosis-1_staked,osmosis-1_count,btc_deposit_claimed,btc_withdraw_claimed,ibc_transfer_claimed
nomic100000aeu2lh0jrrnmn2npc88typ25u7t3aa64x,1,1,1,1,1,1,1,1,1,1,true,true,true
nomic10005vr6w230rer02rgwsvmhh0vdpk9hvxkv8zs,1,1,1,1,1,1,1,1,1,1,true,false,false".as_bytes();

airdrop.init_from_airdrop2_csv(csv).unwrap();

let account = airdrop
.get_mut(Address::from_str("nomic100000aeu2lh0jrrnmn2npc88typ25u7t3aa64x").unwrap())
.unwrap()
.unwrap();
let airdrop2_total = amount_airdropped(&*account);
let expected: u64 = (Amount::from(AIRDROP_II_TOTAL) / Amount::from(2))
.result()
.unwrap()
.amount()
.unwrap()
.into();
assert_approx_eq(airdrop2_total, expected);

let account = airdrop
.get_mut(Address::from_str("nomic10005vr6w230rer02rgwsvmhh0vdpk9hvxkv8zs").unwrap())
.unwrap()
.unwrap();
let airdrop2_total = amount_airdropped(&*account);
let expected: u64 = (Amount::from(AIRDROP_II_TOTAL) / Amount::from(24) * Amount::from(10))
.result()
.unwrap()
.amount()
.unwrap()
.into();
assert_approx_eq(airdrop2_total, expected);
}

#[cfg(not(feature = "testnet"))]
#[test]
fn airdrop_allocation_multiple_two_claim() {
let mut airdrop = Airdrop::default();
let csv = "address,evmos_9000-1_staked,evmos_9000-1_count,kaiyo-1_staked,kaiyo-1_count,cosmoshub-4_staked,cosmoshub-4_count,juno-1_staked,juno-1_count,osmosis-1_staked,osmosis-1_count,btc_deposit_claimed,btc_withdraw_claimed,ibc_transfer_claimed
nomic100000aeu2lh0jrrnmn2npc88typ25u7t3aa64x,1,1,1,1,1,1,1,1,1,1,true,true,true
nomic10005vr6w230rer02rgwsvmhh0vdpk9hvxkv8zs,1,1,1,1,1,1,1,1,1,1,true,true,false".as_bytes();

airdrop.init_from_airdrop2_csv(csv).unwrap();

let account = airdrop
.get_mut(Address::from_str("nomic100000aeu2lh0jrrnmn2npc88typ25u7t3aa64x").unwrap())
.unwrap()
.unwrap();
let airdrop_total_1 = amount_airdropped(&*account);
let expected: u64 = (Amount::from(AIRDROP_II_TOTAL) / Amount::from(2))
.result()
.unwrap()
.amount()
.unwrap()
.into();
assert_approx_eq(airdrop_total_1, expected);

let account = airdrop
.get_mut(Address::from_str("nomic10005vr6w230rer02rgwsvmhh0vdpk9hvxkv8zs").unwrap())
.unwrap()
.unwrap();
let airdrop_total_2 = amount_airdropped(&*account);
let expected: u64 = (Amount::from(AIRDROP_II_TOTAL) / Amount::from(24) * Amount::from(11))
.result()
.unwrap()
.amount()
.unwrap()
.into();
assert_approx_eq(airdrop_total_2, expected);
}
}
Loading
Loading