EspressoSystems / HotShot

http://hotshot.docs.espressosys.com/
101 stars 25 forks source link

[Upgradability] - Avoid tracking the version in task states #3378

Open shenkeyao opened 1 week ago

shenkeyao commented 1 week ago

What is this task and why do we need to work on it?

[Pasting from @ss-es's comment on Zulip.]

we could probably avoid tracking the version as part of the task state. really, it should just be enough to just write the decided_upgrade_certificate Arc<RwLock<...>> as soon as we hit a decide on it. then any place that needs a version could calculate it dynamically like we do in types/src/message.rs by:

        let version = match upgrade_certificate {
            Some(ref cert) => {
                if view >= cert.data.new_version_first_view
                    && cert.data.new_version == Upgrade::VERSION
                {
                    Upgrade::VERSION
                } else if view >= cert.data.new_version_first_view
                    && cert.data.new_version != Upgrade::VERSION
                {
                    bail!("The network has upgraded to a new version that we do not support!");
                } else {
                    Base::VERSION
                }
            }
            None => Base::VERSION,
        };

(this should probably be its own method)

What work will need to be done to complete this task?

No response

Are there any other details to include?

No response

What are the acceptance criteria to close this issue?

We aren't rely on the version in task states.

Branch work will be merged to (if not the default branch)

No response