Skip to content

Commit

Permalink
a few more governance actions left and the contract is done
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroProofs committed May 7, 2024
1 parent abc0e7f commit d2fd4ea
Show file tree
Hide file tree
Showing 6 changed files with 341 additions and 202 deletions.
6 changes: 3 additions & 3 deletions aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ requirements = []
source = "github"

[etags]
"aiken-lang/fuzz@main" = [{ secs_since_epoch = 1715114053, nanos_since_epoch = 34164000 }, "d7aadd4a9b25589bd6d5e3bbedcd809cdf97fe3eddb365cf89cd6ac6bc829643"]
"aiken-lang/sparse-merkle-tree@main" = [{ secs_since_epoch = 1715114053, nanos_since_epoch = 286332000 }, "c2269ba7d11b13b8ed2f3cd383b1dbfc525bead047d83e9ccbcca169d71e70d6"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715114052, nanos_since_epoch = 761271000 }, "5ee55dc5ccf269bb493f4cacb32096f0191a6adb2ef39d62a1f79b8c5a8fcc7f"]
"aiken-lang/fuzz@main" = [{ secs_since_epoch = 1715121260, nanos_since_epoch = 605714000 }, "d7aadd4a9b25589bd6d5e3bbedcd809cdf97fe3eddb365cf89cd6ac6bc829643"]
"aiken-lang/sparse-merkle-tree@main" = [{ secs_since_epoch = 1715121260, nanos_since_epoch = 796341000 }, "c2269ba7d11b13b8ed2f3cd383b1dbfc525bead047d83e9ccbcca169d71e70d6"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1715121260, nanos_since_epoch = 420128000 }, "5ee55dc5ccf269bb493f4cacb32096f0191a6adb2ef39d62a1f79b8c5a8fcc7f"]
15 changes: 15 additions & 0 deletions lib/fortuna/parameters.ak
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,20 @@ pub const initial_payout = 5000000000
/// Padding for integer division. Went with 4 bit padding for ease
pub const padding = 16

// New Params for V2

pub const latest_merkle_root =
#"f0eb964a37dea6f59de5d19896f82233f13031a2799027b666f7f5796ee5cd09"

pub const voting_days = 7

/// Minimum supply threshold for the upgrade contract vote to be successful
/// In thousandth percentage i.e. 250 = 25%
pub const supply_threshold = 250

/// Minimum yes votes over no votes for the upgrade contract vote to be successful
pub const vote_threshold = 666

/// Minimum number of miners to vote for the upgrade contract vote to be successful
/// Must be within a epoch time frame i.e. epoch_number
pub const miner_threshold = 850
29 changes: 27 additions & 2 deletions lib/fortunav2.ak
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use aiken/transaction.{Transaction} as tx
use aiken/transaction/credential.{Inline, ScriptCredential}
use aiken/transaction/value
use fortuna.{master_token_name}
use fortuna/parameters.{latest_merkle_root}
use fortuna/parameters.{latest_merkle_root, voting_days}
use fortuna/types.{State, Statev2}
use fortuna/utils.{get_inline_datum, integer_to_bytes, list_at}
use hardfork/hftypes.{HardFork, NftForkAction}
Expand Down Expand Up @@ -92,4 +92,29 @@ pub fn genesis_v2(tx, own_policy, fortuna_v1_hash: Data, fork_script_hash: Data)
|> builtin.equals_data(expected_value),
}
}
/// Voting and governance functions

// Voting and governance functions

pub fn voting_period() -> Int {
1000 * 60 * 60 * 24 * voting_days
}

/// Flips the bits of a hash
pub fn flip_hash(hash: ByteArray) -> ByteArray {
do_flip_hash(hash, #[], bytearray.length(hash))
}

fn do_flip_hash(hash: ByteArray, new_hash: ByteArray, index: Int) -> ByteArray {
if index == 0 {
new_hash
} else {
do_flip_hash(
hash,
hash
|> builtin.index_bytearray(index - 1)
|> builtin.subtract_integer(255, _)
|> builtin.cons_bytearray(new_hash),
index - 1,
)
}
}
2 changes: 0 additions & 2 deletions lib/hardfork/params.ak
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ pub const miner_lock_state_token = "miner_lock_state"
pub const lock_state_token = "lock_state"

pub const hard_fork_state_token = "hfs"

pub const hard_fork_merkle_root = ""

0 comments on commit d2fd4ea

Please sign in to comment.