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

Add entitlement for locked account creator #423

Merged
merged 2 commits into from
Apr 24, 2024

Conversation

joshuahannan
Copy link
Member

Adds an entitlement to the LockedTokens contract for adding account information to the LockedTokenAdmin resource
Need to confirm if this will require a custom migration or not
Also updates the README and flow.json to use correct import addresses

@joshuahannan joshuahannan changed the base branch from master to stable-cadence April 24, 2024 14:56
}

// account creators store this resource in their account
// in order to be able to register accounts who have locked tokens
access(all) resource LockedAccountCreator: LockedAccountCreatorPublic, AddAccount {

access(self) var addAccountCapability: Capability<&TokenAdminCollection>?
access(self) var addAccountCapability: Capability<auth(LockedTokens.AccountCreator) &TokenAdminCollection>?
Copy link
Member Author

Choose a reason for hiding this comment

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

This will be migrated by default, correct? We don't need a custom migration for this?

Copy link
Contributor

@sisyphusSmiling sisyphusSmiling Apr 24, 2024

Choose a reason for hiding this comment

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

I believe so since the prior capability was on the resource, but I'd want to double check with @turbolent

Copy link
Member

Choose a reason for hiding this comment

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

Please try migrating the contract and see if the entitlement is inferred to be required now. From what I can see, it should and no custom migration should be required (if someone had a &TokenAdminCollection before, they now need auth(LockedTokens.AccountCreator) to keep using it the same way)

@@ -661,14 +661,16 @@ access(all) contract LockedTokens {
}
}

access(all) entitlement AccountCreator
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
access(all) entitlement AccountCreator
access(all) entitlement AccountCreator

Copy link
Contributor

@sisyphusSmiling sisyphusSmiling left a comment

Choose a reason for hiding this comment

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

Approving to unblock as I think this should migrate just fine. But might be worth a sanity check from someone more familiar with migration patterns

@joshuahannan joshuahannan merged commit 272832a into stable-cadence Apr 24, 2024
2 checks passed
@joshuahannan joshuahannan deleted the add-entitlement branch April 24, 2024 16:43
joshuahannan added a commit that referenced this pull request Jun 12, 2024
* update to view functions for stable cadence

* Update to newest Stable Cadence Preview (#371)

* update to view functions for stable cadence

* remove unreachable code

* update templates to Stable Cadence

* update to Stable Cadence preview 4

* update for stable cadence

* fix parse error

---------

Co-authored-by: Josh Hannan <[email protected]>
Co-authored-by: Bastian Müller <[email protected]>

* remove casting and fix conflicts

* integrate ft and nft stable cadence changes, use access, view, and entitlements

* use v2 ft and nft

* use string for nft import

* update token deps

* update token deps

* update nft dependecy

* update nft dep

* update ft dep

* add more view

* update FlowToken contract getter to explicitly use metadata views

* implement new standard methods

* update nft dependency

* update ft dep

* fix FungibleToken.Vault types and imports

* remove view from copy

* add correct vault type

* remove views and update balances

* use vault interface type

* remove restricted types

* remove AnyStruct

* remove type restrictions

* fix view modifiers in epoch contracts

* remove view for dkgCompleted

* remove non-view methods from pre-conditions

* use setter methods in QC

* remove pub from QC

* add fun keyword

* use setters for fields and use getBalance

* use view keyword

* remove restricted types from flow epoch

* use setters in FlowEpoch

* correct metadata types

* use UInt64 in NodeVersionBeacon

* dont use restricted types in locked tokens and staking collection

* make LockedTokens compatible with FungibleToken

* use entitlement for manager

* correct entitlement syntax

* fix entitlement issues with locked tokens

* fix entitlement issues with staking collection

* fix entitlement return types

* add withdrawable to machine account functions

* replace addresses and fix transactions and scripts

* fixes to epoch tests

* update to latest token standards and update locked tokens transactions

* Update contracts

* Update more contracts

* Update contracts

* Update contarcts and transactions

* go mod tidy

* Update flow-sdk

* Update more contracts

* Update ft/nft deps

* Generate assets

* Update more cadence codes

* Update staking collection

* Update go mods

* Fix typo

* Replace get()+borrow() with borrow()

* Refactor code

* Update go-sdk and flow-nft versions

* Fix publish_voter transaction

* Update to Cadence v1.0.0-preview.1

* Apply suggestions from code review

Co-authored-by: Bastian Müller <[email protected]>

* Refactor code

* fix and improve syntax

* use optional chaining and nil-coaelescing instead of force-unwrapping

* Update get_total_balance.cdc

* make sure epoch contracts work with capability controllers and entitlements

* update dependencies and add public burn tokens method

* remove view from getRandomSourceHistoryPage and use account.storage

* remove custom destructors and fix entitlement usage

* get all go tests passing for cadence 1.0

* make ci

* make ci

* update random source transactions

* update cli version for CI

* update go version

* Update Cadence version (#406)

* update Withdrawable and createEmptyVault

* update createEmpty in staking

* use Burner and update dependencies

* update to SDK v1.0.0-M1

* update NFT contracts, remove replace statements

* update to Cadence v1.0.0-M3

* update to Cadence v1.0.0-M3 and SDK v1.0.0-M1

* remove getBalance, add isAvailableToWithdraw

* update ft and nft deps

* update emulator dependencies and get tests passing

* use FungibleToken.Balance instead of FlowToken.Vault

* use correct public path types

* update imports

* go mod tidy

* add fungible token switchboard

* fix switchboard

* update error messages for ledger transactions

* add updated manifests with new account, FT, and NFT transactions and removed locked token staking txs

* update account transactions to use simple arguments

* update manifest to include both styles of token transfer transactions:

* update emulator dependency

* use string args for NFT contracts

* update collection machine account transactions to not use keylist entry

* Update contract getter methods to use env (#410)

* update import addresses to better format and use env

* update deps

* update go mod

* re-add lockedaccountinfo

* update ft and nft dependencies

* get address replacement working in tests and add event emission restrictions for FlowToken

* update to latest emulator, cadence, and token standards versions

* Update README

* Don't copy dictionary in getEpochMetadata (#413)

* Don't copy dictionary in getEpochMetadata

* update NFT contracts

* update ft dependency

* update token standard dependencies

* make ci

* fix algorithm typo and test names

* update nft transactions

* fix typos in transactions

* update nft dependencies

* Add entitlement for locked account creator (#423)

* update deps, add entitlement for locked account creator

* make ci

* update ft dependencies

* remove optional chaining in FlowStakingCollection

* remove optional chaining

* update nft imports and remove unnecessary Burner import from FlowToken

* update dependencies

* Improve random distribution (#428)

* better use of  revertible random with correct types

* improve random distribution

* address PR comments and add entitlements to LockedTokens.TokenManager

* remove UseTokens entitlement

* use view more and update nft deps

* make ci

* add view modifiers

* update dependencies

---------

Co-authored-by: Daniel Sainati <[email protected]>
Co-authored-by: Bastian Müller <[email protected]>
Co-authored-by: Supun Setunga <[email protected]>
Co-authored-by: Bastian Müller <[email protected]>
Co-authored-by: Janez Podhostnik <[email protected]>
Co-authored-by: Tarak Ben Youssef <[email protected]>
kc1116 pushed a commit that referenced this pull request Jun 20, 2024
* update deps, add entitlement for locked account creator

* make ci
jordanschalm added a commit that referenced this pull request Feb 18, 2025
This commit squashes the `feature/efm-recovery` branch and merges it to master. For more granular detail on the change, see #465.

## Included PRs
- #440
- #441
- #464
- #471


* update to view functions for stable cadence

* Update to newest Stable Cadence Preview (#371)

* update to view functions for stable cadence

* remove unreachable code

* update templates to Stable Cadence

* update to Stable Cadence preview 4

* update for stable cadence

* fix parse error

---------

Co-authored-by: Josh Hannan <[email protected]>
Co-authored-by: Bastian Müller <[email protected]>

* remove casting and fix conflicts

* integrate ft and nft stable cadence changes, use access, view, and entitlements

* use v2 ft and nft

* use string for nft import

* update token deps

* update token deps

* update nft dependecy

* update nft dep

* update ft dep

* add more view

* update FlowToken contract getter to explicitly use metadata views

* implement new standard methods

* update nft dependency

* update ft dep

* fix FungibleToken.Vault types and imports

* remove view from copy

* add correct vault type

* remove views and update balances

* use vault interface type

* remove restricted types

* remove AnyStruct

* remove type restrictions

* fix view modifiers in epoch contracts

* use setter methods in QC

* remove pub from QC

* remove restricted types from flow epoch

* use setters in FlowEpoch

* correct metadata types

* use UInt64 in NodeVersionBeacon

* replace addresses and fix transactions and scripts

* fixes to epoch tests

* update to latest token standards and update locked tokens transactions

* Update contracts

* Update more contracts

* Update contracts

* Update contarcts and transactions

* go mod tidy

* Update flow-sdk

* Update more contracts

* Update ft/nft deps

* Generate assets

* Update more cadence codes

* Fix typo

* Replace get()+borrow() with borrow()

* Refactor code

* Update go-sdk and flow-nft versions

* Fix publish_voter transaction

* Update to Cadence v1.0.0-preview.1

* Apply suggestions from code review

Co-authored-by: Bastian Müller <[email protected]>

* Refactor code

* fix and improve syntax

* use optional chaining and nil-coaelescing instead of force-unwrapping

* Update get_total_balance.cdc

* make sure epoch contracts work with capability controllers and entitlements

* update dependencies and add public burn tokens method

* remove view from getRandomSourceHistoryPage and use account.storage

* remove custom destructors and fix entitlement usage

* get all go tests passing for cadence 1.0

* make ci

* make ci

* update cli version for CI

* update go version

* update Withdrawable and createEmptyVault

* Update Cadence version (#406)

* update createEmpty in staking

* use Burner and update dependencies

* update to SDK v1.0.0-M1

* update NFT contracts, remove replace statements

* update to Cadence v1.0.0-M3

* update to Cadence v1.0.0-M3 and SDK v1.0.0-M1

* remove getBalance, add isAvailableToWithdraw

* update ft and nft deps

* update emulator dependencies and get tests passing

* use FungibleToken.Balance instead of FlowToken.Vault

* use correct public path types

* update imports

* go mod tidy

* add fungible token switchboard

* fix switchboard

* update error messages for ledger transactions

* add updated manifests with new account, FT, and NFT transactions and removed locked token staking txs

* update account transactions to use simple arguments

* update manifest to include both styles of token transfer transactions:

* use string args for NFT contracts

* update collection machine account transactions to not use keylist entry

* Update contract getter methods to use env (#410)

* update import addresses to better format and use env

* update deps

* update go mod

* re-add lockedaccountinfo

* update ft and nft dependencies

* get address replacement working in tests and add event emission restrictions for FlowToken

* update to latest emulator, cadence, and token standards versions

* Update README

* Don't copy dictionary in getEpochMetadata (#413)

* Don't copy dictionary in getEpochMetadata

* update NFT contracts

* update ft dependency

* update token standard dependencies

* make ci

* fix algorithm typo and test names

* update nft transactions

* update FlowEpoch contract

- add epoch recover event and struct
- store recovery epoch metadata in storage, emit event in heartbeat
- add ClusterQCVoteData struct to FlowClusterQC contract
- add recover epoch transaction

* generate assets

* happy path tests

* Update flow_epoch_test.go

* upgrade changes to be compliant with cadence 1.0

- add service event verification to tests
- update test helpers
- add node weight sanity check

* generate assets

* happy path tests

* remove unused stakingEndView param

* cant use timing config in epoch recover

- target duration and end time must be provided in governance transaction

* add epoch counter comment

* move save epoch metadata to ending of recover func add comment

* Update FlowEpoch.cdc

* Update contracts/epochs/FlowEpoch.cdc

Co-authored-by: Alexander Hentschel <[email protected]>

* Update contracts/epochs/FlowEpoch.cdc

Co-authored-by: Alexander Hentschel <[email protected]>

* update assets

* Apply suggestions from code review

Co-authored-by: Jordan Schalm <[email protected]>
Co-authored-by: Bastian Müller <[email protected]>

* reuse old var names

* remove RecoverEpochMetadata

* use named parameters

* use separate var for long lines, remove casts

* generate assets

* use common.AddressLocation

* add separate funcs recover new epoch and recover current epoch

* - dont generate a new random source when overwriting the epoch metadata
- generate random source in contract - update qcVoterData to match protocol struct - fix tests

* fix typos in transactions

* update nft dependencies

* Add entitlement for locked account creator (#423)

* update deps, add entitlement for locked account creator

* make ci

* update ft dependencies

* update nft imports and remove unnecessary Burner import from FlowToken

* update dependencies

* address PR comments and add entitlements to LockedTokens.TokenManager

* remove UseTokens entitlement

* use view more and update nft deps

* make ci

* merge master

* update assets

* merge master

* update changes from master

* update changes from master

* Update random_beacon_history_test.cdc

* fix whitespace

* Update ci.yml

* update assets

* update test helpers

* reference event from parent scope

* use aggregatedSignature

* Update contracts/epochs/FlowClusterQC.cdc

Co-authored-by: Jordan Schalm <[email protected]>

* Apply suggestions from code review

Co-authored-by: Jordan Schalm <[email protected]>

* Sync `feature/efm-recovery` with `master` (#437)

* Remove feature branch

* Add a new script that checks if payer has balance to pay for tx (#435)

* Add a new script that checks if payer has balance to pay for tx

* Rewrite check_if_payer_has_sufficient_balance to return struct

* Update contract to cadence 1

* create custom minted account

* payer executes tx and pays for it

* fix tx signers

* refactor test

---------

Co-authored-by: Chase Fleming <[email protected]>
Co-authored-by: Illia <[email protected]>

* make generate

* tidy

* document TestEpochRecover

* remove unused dkg qc txs

* add sanity check to ensure we receive vote data for each cluster

* ensure curEpochCounter = startEpochCounter+1

* check counter and epoch metadata after second recover transaction

* provide recovery epoch counter in recover epoch transaction

* Update contracts/epochs/FlowEpoch.cdc

Co-authored-by: Jordan Schalm <[email protected]>

* Update contracts/epochs/FlowEpoch.cdc

Co-authored-by: Jordan Schalm <[email protected]>

* add new line

* Update flow_epoch_test.go

* remove state changes from prechecks func add new func stop epoch components

* use access self on admin commands

* Revert "EpochRecover service event and transaction"

* Add node ID to index mapping to DKG data model (#441)

* define ResultSubmission struct

* annotate required changes

* setup test framework

* add preliminary new fields to EpochCommit

* add submission tracker sketch

* ResultSubmission tests

* ResultSubmission docs

* addSubmission method

* add tx todos

* add init test, validation on ResultSubmission init

* test comments

* basic SubmissionTracker tests

* update other contract methods to use SubmissionTracker

* add dummy values for EpochCommit event

* add docs

* add exceedsThreshold test

* update FlowEpoch to compile

* update transactions

* improve representation for "empty submissions"

* add test for empty submission

* test empty submission exceeds threshold

* fix go test: send submission

* wip

* remove '

* incredibly, the tests are passing

* note where tests still need updating

* consistent terminology: empty submission

* resolve some todos

- make funs view
- improve docs
- remove commented-out code

* fix empty submission dkg tests

* fix epoch tests

* rename publish admin script

was called "publish participant" but was actually publishing admin

* store as much as possible in EpochMetadata

* build static files

* make more functions view

* fix test

* rename isValidNilSubmission

since it is specifically enforcing the named Invariant (1), and checking
both empty and non-empty submissions.

* update error messages

* go generate

* Apply suggestions from code review

Co-authored-by: Tarak Ben Youssef <[email protected]>
Co-authored-by: Joshua Hannan <[email protected]>

* 2nd pass over error messages

* fix empty whiteboard message test

* improve post whiteboard message test

* rm dupe test

* address remaining todos in tests

* add preconditions for dkg enabled

* fix message, generate

* add documentation for test helper functions

---------

Co-authored-by: Tarak Ben Youssef <[email protected]>
Co-authored-by: Joshua Hannan <[email protected]>

* EFM Recovery Service Event and Transaction (#440)

* efm recovery transaction

* use provided recovery epoch counter as the source of truth

* add proper line indentation

* update assets

* define ResultSubmission struct

* annotate required changes

* setup test framework

* add preliminary new fields to EpochCommit

* add submission tracker sketch

* Apply suggestions from code review

Co-authored-by: Alexander Hentschel <[email protected]>
Co-authored-by: Jordan Schalm <[email protected]>

* Apply suggestions from code review

Co-authored-by: Jordan Schalm <[email protected]>
Co-authored-by: Alexander Hentschel <[email protected]>

* adjust recover transaction logic

* move recoverEpochPreChecks call to emitEpochRecoverEvent

* fix broken sentence

* add comment describing unsafeAllowOverwrite

* use previous syntax for randomSource generation

* replace usage of numViewsInStakingAuction and numViewsInDKGPhase

- replace numViewsInStakingAuction with stakingEndView - startView
- don't accept numViewsInDKGPhase as a parameter read it from configurable epoch metadata

* add godoc for convertClusterQcsCdc

* add additional test cases

* ResultSubmission tests

* ResultSubmission docs

* addSubmission method

* add tx todos

* add init test, validation on ResultSubmission init

* test comments

* basic SubmissionTracker tests

* update other contract methods to use SubmissionTracker

* add dummy values for EpochCommit event

* add docs

* add exceedsThreshold test

* update FlowEpoch to compile

* update transactions

* improve representation for "empty submissions"

* add test for empty submission

* test empty submission exceeds threshold

* fix go test: send submission

* wip

* remove '

* incredibly, the tests are passing

* note where tests still need updating

* consistent terminology: empty submission

* resolve some todos

- make funs view
- improve docs
- remove commented-out code

* fix empty submission dkg tests

* fix epoch tests

* rename publish admin script

was called "publish participant" but was actually publishing admin

* store as much as possible in EpochMetadata

* build static files

* make more functions view

* fix test

* add dkgIdMapping

* rename isValidNilSubmission

since it is specifically enforcing the named Invariant (1), and checking
both empty and non-empty submissions.

* Updated epoch recovery tx to accept dkg group key as well as emitting correct EpochRecover service event

* update error messages

* go generate

* Apply suggestions from code review

Co-authored-by: Tarak Ben Youssef <[email protected]>
Co-authored-by: Joshua Hannan <[email protected]>

* 2nd pass over error messages

* fix empty whiteboard message test

* improve post whiteboard message test

* rm dupe test

* address remaining todos in tests

* fix whitespace

* Apply suggestions from code review

* Update contracts/epochs/FlowDKG.cdc

* random source generatation doc/postconditions

* recovery function docs

* recoverCurrentEpoch precondition

* recovery methods internal documentation

* add todos

* ClusterQCVoteData docs

* recover_epoch tx comments

* remove duplicated LN vote tag

* add todos

* make generate

* tweak godocs

* fixing and annotating tests

* all existing epoch recovery tests passing

* refactor happy path validation check test

* rm duplicate tests

* refactor overwrite validation tests

* clean up verifyEpochTotalRewardsPaid

* fix extra / in comments

* refactor success efm recovery tests

* rename and document rewards test case

* Apply suggestions from code review

Co-authored-by: Joshua Hannan <[email protected]>

* use stopEpochComponents

remove dupe code fragment

* comments

* validate epoch counter and phase in tests

* recoverCurrentEpoch: always start in stakign phase

* make generate

* totalRewards todos

* pass over remaining todos

* make generate

* update test

---------

Co-authored-by: Jordan Schalm <[email protected]>
Co-authored-by: Alexander Hentschel <[email protected]>
Co-authored-by: Yurii Oleksyshyn <[email protected]>
Co-authored-by: Tarak Ben Youssef <[email protected]>
Co-authored-by: Joshua Hannan <[email protected]>

* Add `ProtocolStateVersionUpgrade` service event (#464)

* add service event definition and doc

* move service event to version beacon

* add heartbeat/admin process for proto state version

accepting broken assets.go, will regenerate after cherry-pick is
complete

* add smoketest for setting protostate version

broken assets.go

* Apply suggestions from code review

* generate

broken assets.go

* update contract for cadence1

* update admin tx for cadence 1

* generate

* emit service event in governance transaction

Previously service events could only be emitted in the system chunk.
With onflow/flow-go#5828, we can directly emit
them in governance transactions.

* re-generate assets

* fix field reflection

* add context for where validation occurs and multiple emissions

* make generate

* Add special case for DKG threshold when n=2, matching flow-go (#471)

* Update FlowDKG.cdc

* spacing + generate

* fix test

* fix empty submission test

* Update contracts/epochs/FlowDKG.cdc

Co-authored-by: Tarak Ben Youssef <[email protected]>

* make generate

---------

Co-authored-by: Tarak Ben Youssef <[email protected]>

---------

Co-authored-by: Josh Hannan <[email protected]>
Co-authored-by: Daniel Sainati <[email protected]>
Co-authored-by: Bastian Müller <[email protected]>
Co-authored-by: Supun Setunga <[email protected]>
Co-authored-by: Bastian Müller <[email protected]>
Co-authored-by: Janez Podhostnik <[email protected]>
Co-authored-by: Khalil Claybon <[email protected]>
Co-authored-by: Alexander Hentschel <[email protected]>
Co-authored-by: Chase Fleming <[email protected]>
Co-authored-by: Illia <[email protected]>
Co-authored-by: Khalil Claybon <[email protected]>
Co-authored-by: Tarak Ben Youssef <[email protected]>
Co-authored-by: Yurii Oleksyshyn <[email protected]>
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.

3 participants