Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

v1.0: Maintain sysvar balances for consistent market cap.#9937

Merged
mvines merged 4 commits into
solana-labs:v1.0from
ryoqun:sysvar-balance-for-capitalization-v1.0
May 8, 2020
Merged

v1.0: Maintain sysvar balances for consistent market cap.#9937
mvines merged 4 commits into
solana-labs:v1.0from
ryoqun:sysvar-balance-for-capitalization-v1.0

Conversation

@ryoqun
Copy link
Copy Markdown
Contributor

@ryoqun ryoqun commented May 8, 2020

manual back-port of #9936 with gating logics for the v1.0.x / mainnet-beta


pub fn include_owner_in_hash(slot: Slot) -> bool {
// Account hashing updated to include owner activates at this slot on the mainnet-beta
slot >= 11_000_000
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad... follow-up to #9920, yeah piggybacking on this pr..

11_000_000 is too close to tds tigger timing (*). I think this violates the purpose of OperatingMode::Preview... ;)

let's again move later to some round number of weekday. Or I'm caring too much?

$ cal
      May 2020        
Su Mo Tu We Th Fr Sa  
                1  2  
 3  4  5  6  7  8  9  
10 11 12 13 14 15 16  
17 18 19 20 21 22 23  
24 25 26 27 28 29 30  
31                    

$ pry
[5] pry(main)> Time.now + ((11_000_000 - 9834692) / 2.5) # mainnet beta
=> 2020-05-14 05:40:42 +0900
[7] pry(main)> Time.now + ((14_000_000 - 12953124) / 2.5) # tds
=> 2020-05-13 16:31:21 +0900
[6] pry(main)> Time.now + ((12_000_000 - 9834692) / 2.5) # another weekend around the world...
=> 2020-05-18 20:47:29 +0900
[8] pry(main)> Time.now + ((12_500_000 - 9834692) / 2.5) # projected trigger time
=> 2020-05-21 04:21:46 +0900

@ryoqun ryoqun changed the title Sysvar balance for capitalization v1.0 v1.0: Maintain sysvar balances for consistent market cap. May 8, 2020
@ryoqun ryoqun requested a review from mvines May 8, 2020 12:07
Comment thread runtime/src/bank/mod.rs

pub const MAX_LEADER_SCHEDULE_STAKES: Epoch = 5;

const SYSVAR_BALANCE_ACTIVATION_EPOCH: Epoch = 25;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's land this first than account.owner hashing considering significace:

$ pry
[2] pry(main)> Time.now + ((432000 - 336972) / 2.5) + 4 * 3600 * 24
=> 2020-05-13 07:32:39 +0900
$ solana  --url http://api.mainnet-beta.solana.com epoch-info

Slot: 9840972
Epoch: 22
Epoch Slot Range: [9504000..9936000)
Epoch Completed Percent: 78.003%
Epoch Completed Slots: 336972/432000 (95028 remaining)
Epoch Completed Time: 1day 13h 26m 28s/2days (10h 33m 31s remaining)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just now, mainnet-beta went into new sysvar behavior:

$ solana --url http://api.mainnet-beta.solana.com epoch-info

Slot: 10800429
Epoch: 25
Epoch slot range: [10800000..11232000)
Epoch completed percent: 0.099%
Epoch completed slots: 429/432000 (431571 remaining)
Epoch completed time: 2m 51s/2days (1day 23h 57m 8s remaining)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed we now fixed the capitalization security hole.

$ solana-ledger-tool --version
solana-ledger-tool 1.0.23 [channel=on-ryoqun-fork commit=e26840cb09465352067aa037b2eee7591091529b]

$ solana-ledger-tool --ledger 7Np4/ capitalization
[2020-05-13T14:58:52.451659928Z INFO  solana_ledger::blockstore] Maximum open file descriptors: 65000
[2020-05-13T14:58:52.451757437Z INFO  solana_ledger::blockstore] Opening database at "/home/ryoqun/work/solana/solana/7Np4/rocksdb"
[2020-05-13T14:58:52.496282617Z INFO  solana_ledger::blockstore] "/home/ryoqun/work/solana/solana/7Np4/rocksdb" open took 44ms
[2020-05-13T14:58:52.496396355Z INFO  solana_ledger::bank_forks_utils] Initializing snapshot path: "/home/ryoqun/work/solana/solana/7Np4/snapshot"
[2020-05-13T14:58:52.510939661Z INFO  solana_ledger::bank_forks_utils] Loading snapshot package: "/home/ryoqun/work/solana/solana/7Np4/snapshot-10800485-D7hNsgoVP78JhCcYaLnNxmcjdmFGsVV972LPHws2F8sW.tar.bz2"
[2020-05-13T15:00:44.248861917Z INFO  solana_ledger::snapshot_utils] snapshot untar took 111.7s
[2020-05-13T15:00:44.249240456Z INFO  solana_ledger::snapshot_utils] snapshot version: 1.1.0
[2020-05-13T15:00:44.249389877Z INFO  solana_ledger::snapshot_utils] Loading bank from "/home/ryoqun/work/solana/solana/7Np4/snapshot/.tmp7V6HdT/snapshots/10800485/10800485"
[2020-05-13T15:00:44.349281802Z INFO  solana_ledger::snapshot_utils] Rebuilding accounts...
[2020-05-13T15:03:59.756305474Z INFO  solana_ledger::snapshot_utils] Rebuilding status cache...
[2020-05-13T15:04:00.177954788Z INFO  solana_ledger::snapshot_utils] Loaded bank for slot: 10800485
[2020-05-13T15:04:00.179688287Z INFO  solana_runtime::accounts_db] total_stores: 2500, newest_slot: 10800485, oldest_slot: 0, max_slot: 0 (num=5), min_slot: 4352296 (num=1)
[2020-05-13T15:04:00.179824349Z INFO  solana_metrics::metrics] metrics disabled: SOLANA_METRICS_CONFIG: environment variable not found
[2020-05-13T15:04:00.180175764Z INFO  solana_metrics::metrics] datapoint: accounts_db-stores total_count=2500i
[2020-05-13T15:04:01.017741218Z INFO  solana_runtime::accounts_db] scan took 309us merge took 55us accumulate took 157us
[2020-05-13T15:04:01.017911287Z INFO  solana_runtime::bank] bank frozen: 10800485 hash: HHQZF2VqbKfhWrWqySVPHZfkqQAB1sHA7LHG35Fv9duN accounts_delta: DrbroEkyrFtMTwyp1xEWfXnpAdYurwXMiSqBvz2gZab signature_count: 2 last_blockhash: DdmF1iG8ERFS4YGKUowDxmemqSFAd8VUS8uTYEoguLw8 capitalization: 499996966416753973
[2020-05-13T15:04:01.018237665Z INFO  solana_runtime::bank] accounts hash slot: 10800485 stats: BankHashStats { num_removed_accounts: 10, num_added_accounts: 0, num_lamports_stored: 1340866471525, total_data_len: 165103, num_executable_accounts: 0 }
[2020-05-13T15:04:01.018317962Z INFO  solana_ledger::snapshot_utils] bank rebuild from snapshot took 196.8s
[2020-05-13T15:04:01.027419913Z INFO  solana_ledger::blockstore_processor] processing ledger from root slot 10800485...
[2020-05-13T15:04:02.474804690Z INFO  solana_ledger::blockstore_processor] ledger processed in 1445ms. 90 MB allocated. 1 fork at 10800485, with 1 frozen bank
Capitalization: 499996966.416753973 SOL

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2020

Codecov Report

Merging #9937 into v1.0 will increase coverage by 0.0%.
The diff coverage is 98.4%.

@@          Coverage Diff          @@
##            v1.0   #9937   +/-   ##
=====================================
  Coverage   80.1%   80.1%           
=====================================
  Files        271     271           
  Lines      60043   60089   +46     
=====================================
+ Hits       48115   48163   +48     
+ Misses     11928   11926    -2     

Copy link
Copy Markdown
Contributor

@mvines mvines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks

@mvines mvines merged commit a7b0fcc into solana-labs:v1.0 May 8, 2020
@ryoqun ryoqun added the security Pull requests that address a security vulnerability label May 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

security Pull requests that address a security vulnerability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants