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

Find min witnessed level has problem when witness list of free main chain unit and last stable unit are different #96

Closed
gaoxiangxyz opened this issue May 23, 2018 · 3 comments

Comments

@gaoxiangxyz
Copy link

gaoxiangxyz commented May 23, 2018

Below is code in "updateStableMcFlag" function of main_chain.js to find min witnessed level.
If free main chain unit and last stable unit has different witness list, for example, there is one witness different. From free main chain unit to unit whose level large than witnessed_level of free main chain unit along main chain, there may be only 6 witnesses are in witness list of last stable unit.

conn.query("SELECT witnessed_level FROM units WHERE is_free=1 AND is_on_main_chain=1", function(wl_rows)
{
    if (wl_rows.length !== 1)
        throw Error("not a single mc wl");
    // this is the level when we colect 7 witnesses if walking up the MC from its end
    var mc_end_witnessed_level = wl_rows[0].witnessed_level;
    conn.query(
    // among these 7 witnesses, find min wl
    "SELECT MIN(witnessed_level) AS min_mc_wl FROM units LEFT JOIN unit_authors USING(unit) \n\
    WHERE is_on_main_chain=1 AND level>=? AND address IN(?)", // _left_ join enforces the best query plan in sqlite
    [mc_end_witnessed_level, arrWitnesses],
    function(min_wl_rows){
    if (min_wl_rows.length !== 1)
        throw Error("not a single min mc wl");
    var min_mc_wl = min_wl_rows[0].min_mc_wl;
...
@tonyofbyteball
Copy link
Member

witness list of free main chain is irrelevant, we use witness list of last stable unit.

@gaoxiangxyz
Copy link
Author

The mc_end_witnessed_level is the witness level of free main chain unit and it is relevant to witness list of free main chain unit.

@tonyofbyteball
Copy link
Member

Your concern was right, the issue is fixed by this PR #145.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants