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

feat: add node power #592

Merged
merged 10 commits into from
Feb 3, 2023
Merged

feat: add node power #592

merged 10 commits into from
Feb 3, 2023

Conversation

DylanVerstraete
Copy link
Contributor

No description provided.

@DylanVerstraete DylanVerstraete marked this pull request as ready for review January 26, 2023 13:35

## Decision

Node Power State and Power targer were added to `pallet-tfgrid` to orchestrate the Farmerbot taking actions to do power management.
Copy link
Contributor

Choose a reason for hiding this comment

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

targer -> target

@@ -0,0 +1,30 @@
# 3. Third party service contract
Copy link
Contributor

Choose a reason for hiding this comment

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

4 . Node power ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

woops

Copy link
Contributor

@renauter renauter left a comment

Choose a reason for hiding this comment

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

Nice job!!
Meanwhile I have just some doubts on some points

twin_id == farm.twin_id,
Error::<T>::UnauthorizedToChangePowerTarget
);

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we check if node has active contract/deployment on it in case of state is Up and farmer ask to shut it Down?

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed. The question is what do we do with those contracts then? Cancel them or throw an error... I like the idea of throwing an error so that we don't cancel them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The farmerbot should be doing this check, it doesn't really matter to check it here in my opinion.

The way I see it is that a farmer always has to opportunity to physically shut down his node thus having the same possibility on chain without consequences is also an option. Also, we don't want to drag pallet-smart-contract as a dependency in this tfgrid pallet.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's also true.

Copy link
Contributor

@brandonpille brandonpille left a comment

Choose a reason for hiding this comment

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

Looks good. Some small remarks.


let power_state = match power_state {
Power::Up => PowerState::Up,
Power::Down => PowerState::Down(system::Pallet::<T>::block_number()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need the block number? Does ZOS need it? Don't we know it from the event?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We save the blocknumber on this powerstate for the minting to check later

twin_id == farm.twin_id,
Error::<T>::UnauthorizedToChangePowerTarget
);

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed. The question is what do we do with those contracts then? Cancel them or throw an error... I like the idea of throwing an error so that we don't cancel them.

@DylanVerstraete DylanVerstraete changed the title feat: add node power state and calls to modify feat: add node power Jan 27, 2023
@DylanVerstraete DylanVerstraete merged commit 861db03 into development Feb 3, 2023
@DylanVerstraete DylanVerstraete deleted the development_node_power branch February 3, 2023 08:27
DylanVerstraete added a commit that referenced this pull request Apr 12, 2023
* feat: rework documentation (#571)

* doc: service consumer contract flow (#567)

* fix: farming policies map ids (#591)

* chore: reset runtime migrations

* feat: delete twin is not allowed (#586)

* fix: typos (#595)

* fix: locked balances (#590)

* feat: allow twin to connect to a relay (#570)

* chore: bump to version 2.3.0-rc1 (specVersion: 124)

* feat: add node power (#592)

* chore: update ADR docs

* chore: bump to version 2.3.0-rc2 (specVersion: 125)

* chore: rework logging pallet smart contract

* fix: allow numbers in relay addresses

* chore: bump to version 2.3.0-rc3 (specVersion: 125)

* fix: migration V15 for devnet #598

* chore: bump to version 2.3.0-rc4 (specVersion: 127)

* chore: restore V15 migration

* chore: update dev chain spec

* fix: soften serial number validation (#603)

* chore: set max length of serial number to 128 bytes

* chore: align tft bridge dependency

* chore: update default dev chainspec

* chore: revert default dev bridge validators chainspec

* Drop unused structopt dependency

This also removes some unused child dependencies

Signed-off-by: Lee Smet <lee.smet@hotmail.com>

* Set the substrate node default chart image to ghcr.io

* fix: rework balances migrations

* chore: refactor

* feat: also remove contract and lock if twin is deleted

* chore: add writes

* chore: resolve comment

* chore: fix ci

* chore: resolve pr comments

* chore: add log

* Update build_test.yaml to use the new runner (#617)

* chore: remove serial valdiation (#616)

* chore: bump to version 2.3.0-rc6 (specVersion: 129)

* chore: rework chart #620

* fix: discount calculation handle variable billing frequency (#626)

* fix: migrations for v2.3.0 (#627)

* chore: bump to version 2.3.0-rc7 (specVersion: 130)

* fix: soften node city/country validation

* chore: bump to version 2.3.0-rc8 (specVersion: 131)

* chore: update cargo lock

* chore: bump version to 2.3.0

---------

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
Co-authored-by: Erwan Renaut <73958772+renauter@users.noreply.github.com>
Co-authored-by: omahs <73983677+omahs@users.noreply.github.com>
Co-authored-by: Lee Smet <lee.smet@hotmail.com>
Co-authored-by: Rob Van Mieghem <robvanmieghem@gmail.com>
Co-authored-by: Brandon <brandon@threefold.tech>
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

Successfully merging this pull request may close these issues.

4 participants