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 PoP of staking private key for node registration #425

Closed
wants to merge 141 commits into from
Closed
Show file tree
Hide file tree
Changes from 135 commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
d7330c3
update to view functions for stable cadence
joshuahannan Nov 2, 2022
bebb19d
Update to newest Stable Cadence Preview (#371)
dsainati1 Jul 5, 2023
a9e9e5d
remove casting and fix conflicts
joshuahannan Jul 10, 2023
253f985
integrate ft and nft stable cadence changes, use access, view, and en…
joshuahannan Jul 18, 2023
d5d3fc2
use v2 ft and nft
joshuahannan Jul 18, 2023
58bfcfb
use string for nft import
joshuahannan Jul 18, 2023
d9d2614
update token deps
joshuahannan Jul 18, 2023
9b8c764
update token deps
joshuahannan Jul 18, 2023
5044e1d
update nft dependecy
joshuahannan Jul 18, 2023
07c8c7b
update nft dep
joshuahannan Jul 18, 2023
99f47a0
update ft dep
joshuahannan Jul 18, 2023
aa0d30b
add more view
joshuahannan Jul 19, 2023
69e65bd
update FlowToken contract getter to explicitly use metadata views
joshuahannan Jul 19, 2023
a94c565
implement new standard methods
joshuahannan Jul 19, 2023
90cd889
update nft dependency
joshuahannan Jul 19, 2023
8217b15
update ft dep
joshuahannan Jul 19, 2023
7a4a112
fix FungibleToken.Vault types and imports
joshuahannan Jul 19, 2023
dc499b4
remove view from copy
joshuahannan Jul 19, 2023
3e0bd42
add correct vault type
joshuahannan Jul 19, 2023
e642b90
remove views and update balances
joshuahannan Jul 19, 2023
9f786d5
use vault interface type
joshuahannan Jul 19, 2023
a3ad792
remove restricted types
joshuahannan Jul 26, 2023
0bd0969
remove AnyStruct
joshuahannan Jul 26, 2023
40fdc45
remove type restrictions
joshuahannan Jul 26, 2023
bceaf1d
fix view modifiers in epoch contracts
joshuahannan Jul 27, 2023
d6f1c62
remove view for dkgCompleted
joshuahannan Jul 27, 2023
00f3f53
remove non-view methods from pre-conditions
joshuahannan Jul 27, 2023
d258883
use setter methods in QC
joshuahannan Jul 27, 2023
334b5ef
remove pub from QC
joshuahannan Jul 27, 2023
088c4f1
add fun keyword
joshuahannan Jul 27, 2023
186f352
use setters for fields and use getBalance
joshuahannan Jul 27, 2023
eaf04f6
use view keyword
joshuahannan Jul 27, 2023
4a593e6
remove restricted types from flow epoch
joshuahannan Jul 27, 2023
f82c0bd
use setters in FlowEpoch
joshuahannan Jul 27, 2023
1e42943
correct metadata types
joshuahannan Jul 27, 2023
b6eea49
use UInt64 in NodeVersionBeacon
joshuahannan Jul 27, 2023
234488b
dont use restricted types in locked tokens and staking collection
joshuahannan Jul 27, 2023
32ee36b
make LockedTokens compatible with FungibleToken
joshuahannan Jul 28, 2023
3e7e66c
use entitlement for manager
joshuahannan Jul 28, 2023
81673c1
correct entitlement syntax
joshuahannan Jul 28, 2023
3366647
fix entitlement issues with locked tokens
joshuahannan Jul 28, 2023
ae14189
fix entitlement issues with staking collection
joshuahannan Jul 28, 2023
98e669c
fix entitlement return types
joshuahannan Jul 28, 2023
d03de9a
add withdrawable to machine account functions
joshuahannan Jul 28, 2023
20bc88d
replace addresses and fix transactions and scripts
joshuahannan Aug 2, 2023
f00e74c
fixes to epoch tests
joshuahannan Aug 8, 2023
8a95802
update to latest token standards and update locked tokens transactions
joshuahannan Aug 22, 2023
90028cb
Update contracts
SupunS Sep 8, 2023
5624221
Update more contracts
SupunS Sep 11, 2023
a146eb7
Update contracts
SupunS Sep 11, 2023
47c7323
Update contarcts and transactions
SupunS Sep 12, 2023
7f6a9cf
go mod tidy
SupunS Sep 12, 2023
006692d
Update flow-sdk
SupunS Sep 12, 2023
20bf827
Update more contracts
SupunS Sep 12, 2023
f90b7db
Update ft/nft deps
SupunS Sep 13, 2023
3e4a8d7
Generate assets
SupunS Sep 13, 2023
148f186
Update more cadence codes
SupunS Sep 13, 2023
5287d71
Update staking collection
SupunS Sep 13, 2023
82e83fc
Update go mods
SupunS Sep 13, 2023
6e65aab
Fix typo
SupunS Sep 14, 2023
071589b
Replace get()+borrow() with borrow()
SupunS Sep 14, 2023
8bf41b7
Refactor code
SupunS Sep 14, 2023
36b3a40
Update go-sdk and flow-nft versions
SupunS Sep 15, 2023
a14bfc3
Fix publish_voter transaction
SupunS Sep 18, 2023
1a47522
Update to Cadence v1.0.0-preview.1
SupunS Sep 21, 2023
7f0ae3d
Apply suggestions from code review
SupunS Sep 21, 2023
222d143
Refactor code
SupunS Sep 22, 2023
889e103
fix and improve syntax
turbolent Sep 22, 2023
0e44d6d
use optional chaining and nil-coaelescing instead of force-unwrapping
turbolent Sep 22, 2023
2ba8ec1
Update get_total_balance.cdc
SupunS Sep 26, 2023
5d361b6
Merge remote-tracking branch 'origin/master' into stable-cadence
joshuahannan Nov 21, 2023
b41a334
make sure epoch contracts work with capability controllers and entitl…
joshuahannan Nov 22, 2023
f8dfacb
update dependencies and add public burn tokens method
joshuahannan Dec 4, 2023
69a42be
fix go.mod conflict from merge from master
joshuahannan Dec 11, 2023
e45ba2b
remove view from getRandomSourceHistoryPage and use account.storage
joshuahannan Dec 11, 2023
37cbe45
remove custom destructors and fix entitlement usage
joshuahannan Dec 12, 2023
965521c
merge from master and update dependencies
joshuahannan Jan 2, 2024
5f2af20
get all go tests passing for cadence 1.0
joshuahannan Jan 2, 2024
93317bc
make ci
joshuahannan Jan 2, 2024
6eb32e7
make ci
joshuahannan Jan 2, 2024
b29775f
update random source transactions
joshuahannan Jan 2, 2024
1c546c6
update cli version for CI
joshuahannan Jan 2, 2024
cb90b89
update go version
joshuahannan Jan 3, 2024
c0c5250
Update Cadence version (#406)
SupunS Jan 23, 2024
77b4a62
update Withdrawable and createEmptyVault
joshuahannan Jan 23, 2024
1036e08
merge from origin
joshuahannan Jan 23, 2024
8d58eb4
update createEmpty in staking
joshuahannan Jan 24, 2024
7204ba8
use Burner and update dependencies
joshuahannan Jan 25, 2024
9289bdc
update to SDK v1.0.0-M1
turbolent Jan 25, 2024
1a178d6
update NFT contracts, remove replace statements
turbolent Jan 25, 2024
edbd26e
update to Cadence v1.0.0-M3
turbolent Jan 25, 2024
df76aaf
update to Cadence v1.0.0-M3 and SDK v1.0.0-M1
turbolent Jan 25, 2024
b7a9513
remove getBalance, add isAvailableToWithdraw
joshuahannan Jan 25, 2024
e3aada3
update ft and nft deps
joshuahannan Feb 1, 2024
1984b08
merge from master
joshuahannan Feb 1, 2024
5f44be4
update emulator dependencies and get tests passing
joshuahannan Feb 1, 2024
80dacce
use FungibleToken.Balance instead of FlowToken.Vault
joshuahannan Feb 1, 2024
89c4b73
use correct public path types
joshuahannan Feb 5, 2024
e489275
update imports
joshuahannan Feb 6, 2024
7af9d5b
go mod tidy
joshuahannan Feb 6, 2024
b75941c
add fungible token switchboard
joshuahannan Feb 6, 2024
928bf99
fix switchboard
joshuahannan Feb 6, 2024
098fbb0
update error messages for ledger transactions
joshuahannan Feb 7, 2024
439755c
add updated manifests with new account, FT, and NFT transactions and …
joshuahannan Feb 9, 2024
b403661
update account transactions to use simple arguments
joshuahannan Feb 12, 2024
7d800d5
update manifest to include both styles of token transfer transactions:
joshuahannan Feb 13, 2024
46d7685
update emulator dependency
joshuahannan Feb 13, 2024
439c5aa
use string args for NFT contracts
joshuahannan Feb 14, 2024
f5053a4
update collection machine account transactions to not use keylist entry
joshuahannan Feb 15, 2024
a7b73af
Update contract getter methods to use env (#410)
joshuahannan Feb 27, 2024
fda9bc2
get address replacement working in tests and add event emission restr…
joshuahannan Feb 27, 2024
d81e0c3
update to latest emulator, cadence, and token standards versions
joshuahannan Mar 5, 2024
6f9e0a9
Update README
joshuahannan Mar 7, 2024
bcf77ee
Don't copy dictionary in getEpochMetadata (#413)
janezpodhostnik Mar 22, 2024
4352c32
update NFT contracts
joshuahannan Mar 26, 2024
10241ff
update ft dependency
joshuahannan Mar 27, 2024
f410947
update token standard dependencies
joshuahannan Apr 2, 2024
9004857
make ci
joshuahannan Apr 2, 2024
77f7eae
fix algorithm typo and test names
joshuahannan Apr 8, 2024
826099b
update nft transactions
joshuahannan Apr 9, 2024
d40b890
fix typos in transactions
joshuahannan Apr 15, 2024
486ea68
update nft dependencies
joshuahannan Apr 15, 2024
1b20b4d
update RandomBeaconHistory to Cadence 1.0
joshuahannan Apr 16, 2024
272832a
Add entitlement for locked account creator (#423)
joshuahannan Apr 24, 2024
50821c3
update ft dependencies
joshuahannan Apr 24, 2024
93d97ed
remove optional chaining in FlowStakingCollection
joshuahannan Apr 24, 2024
0fc367f
remove optional chaining
joshuahannan Apr 24, 2024
e696a8e
update nft imports and remove unnecessary Burner import from FlowToken
joshuahannan Apr 29, 2024
b0461a7
add pop for node registration
May 6, 2024
af808a6
update dependencies
joshuahannan May 7, 2024
63b1dba
merge stable-cadence branch
May 8, 2024
6234d8b
merge master branch
Sep 19, 2024
dc121f1
fix cli name
Sep 19, 2024
0bf8e03
fix merging errors
Sep 19, 2024
0341eca
update assets
Sep 20, 2024
cf66e1d
Update contracts/FlowIDTableStaking.cdc
tarakby Sep 26, 2024
4c10f40
remove PoP wrongly added to Create Account tx
Oct 9, 2024
8472e21
add POP changes to a new branch
joshuahannan Oct 17, 2024
b4f3a13
merge josh/proof-of-possesion
Oct 18, 2024
fec1699
add missing changes from merge
Oct 18, 2024
a5be481
minor comment update
tarakby Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions contracts/FlowIDTableStaking.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ access(all) contract FlowIDTableStaking {
access(all) var networkingKey: String
access(all) var stakingKey: String

/// TODO: Proof of Possession (PoP) of the staking private key

/// The total tokens that only this node currently has staked, not including delegators
/// This value must always be above the minimum requirement to stay staked or accept delegators
access(mapping Identity) var tokensStaked: @FlowToken.Vault
Expand Down Expand Up @@ -160,6 +158,7 @@ access(all) contract FlowIDTableStaking {
networkingAddress: String,
networkingKey: String,
stakingKey: String,
stakingKeyPoP: String,
tokensCommitted: @{FungibleToken.Vault}
) {
pre {
Expand All @@ -180,13 +179,17 @@ access(all) contract FlowIDTableStaking {
signatureAlgorithm: SignatureAlgorithm.BLS_BLS12_381
)

// Verify the proof of possesion of the private staking key
assert(
stakeKey.verifyPoP(stakingKeyPoP.decodeHex()),
message: "Invalid Proof of Possesion for staking key"
tarakby marked this conversation as resolved.
Show resolved Hide resolved
)

let netKey = PublicKey(
publicKey: networkingKey.decodeHex(),
signatureAlgorithm: SignatureAlgorithm.ECDSA_P256
)

// TODO: Verify the provided Proof of Possession of the staking private key

self.id = id
self.role = role
self.networkingAddress = networkingAddress
Expand Down Expand Up @@ -1554,6 +1557,7 @@ access(all) contract FlowIDTableStaking {
networkingAddress: String,
networkingKey: String,
stakingKey: String,
stakingKeyPoP: String,
tokensCommitted: @{FungibleToken.Vault}): @NodeStaker
{
assert (
Expand All @@ -1566,6 +1570,7 @@ access(all) contract FlowIDTableStaking {
networkingAddress: networkingAddress,
networkingKey: networkingKey,
stakingKey: stakingKey,
stakingKeyPoP: stakingKeyPoP,
tokensCommitted: <-FlowToken.createEmptyVault(vaultType: Type<@FlowToken.Vault>()))

let minimum = self.minimumStakeRequired[role]!
Expand Down
2 changes: 2 additions & 0 deletions contracts/FlowStakingCollection.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ access(all) contract FlowStakingCollection {
networkingAddress: String,
networkingKey: String,
stakingKey: String,
stakingKeyPoP: String,
amount: UFix64,
payer: auth(BorrowValue) &Account
): auth(Storage, Capabilities, Contracts, Keys, Inbox) &Account? {
Expand All @@ -433,6 +434,7 @@ access(all) contract FlowStakingCollection {
networkingAddress: networkingAddress,
networkingKey: networkingKey,
stakingKey: stakingKey,
stakingKeyPoP: stakingKeyPoP,
tokensCommitted: <-tokens
)

Expand Down
8 changes: 4 additions & 4 deletions contracts/LockedTokens.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ access(all) contract LockedTokens {

/// Registers a new node operator with the Flow Staking contract
/// and commits an initial amount of locked tokens to stake
access(account) fun registerNode(nodeInfo: StakingProxy.NodeInfo, amount: UFix64) {
access(account) fun registerNode(nodeInfo: StakingProxy.NodeInfo, stakingKeyPoP: String, amount: UFix64) {
if let nodeStaker <- self.nodeStaker <- nil {
let stakingInfo = FlowIDTableStaking.NodeInfo(nodeID: nodeStaker.id)

Expand All @@ -210,7 +210,7 @@ access(all) contract LockedTokens {

let tokens <- vaultRef.withdraw(amount: amount)

let nodeStaker <- self.nodeStaker <- FlowIDTableStaking.addNodeRecord(id: nodeInfo.id, role: nodeInfo.role, networkingAddress: nodeInfo.networkingAddress, networkingKey: nodeInfo.networkingKey, stakingKey: nodeInfo.stakingKey, tokensCommitted: <-tokens)
let nodeStaker <- self.nodeStaker <- FlowIDTableStaking.addNodeRecord(id: nodeInfo.id, role: nodeInfo.role, networkingAddress: nodeInfo.networkingAddress, networkingKey: nodeInfo.networkingKey, stakingKey: nodeInfo.stakingKey, stakingKeyPoP: stakingKeyPoP, tokensCommitted: <-tokens)

destroy nodeStaker

Expand Down Expand Up @@ -378,9 +378,9 @@ access(all) contract LockedTokens {

/// The user calls this function if they want to register as a node operator
/// They have to provide all the info for their node
access(TokenOperations) fun createNodeStaker(nodeInfo: StakingProxy.NodeInfo, amount: UFix64) {
access(TokenOperations) fun createNodeStaker(nodeInfo: StakingProxy.NodeInfo, stakingKeyPoP: String, amount: UFix64) {

self.borrowTokenManager().registerNode(nodeInfo: nodeInfo, amount: amount)
self.borrowTokenManager().registerNode(nodeInfo: nodeInfo, stakingKeyPoP: stakingKeyPoP, amount: amount)

// Create a new staker proxy that can be accessed in transactions
self.nodeStakerProxy = LockedNodeStakerProxy(tokenManager: self.tokenManager)
Expand Down
1 change: 1 addition & 0 deletions contracts/testContracts/TestFlowIDTableStaking.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ access(all) contract FlowIDTableStaking {
networkingAddress: String,
networkingKey: String,
stakingKey: String,
stakingKeyPoP: String,
tokensCommitted: @{FungibleToken.Vault}
): @NodeStaker {
destroy tokensCommitted
Expand Down
24 changes: 12 additions & 12 deletions lib/go/contracts/internal/assets/assets.go

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion lib/go/templates/cmd/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ func generateManifest(env templates.Environment) *manifest {
}

sampleStakingKey := cadenceValue{
cadence.String("9e9ae0d645fd5fd9050792e0b0daa82cc1686d9133afa0f81a784b375c42ae48567d1545e7a9e1965f2c1a32f73cf8575ebb7a967f6e4d104d2df78eb8be409135d12da0499b8a00771f642c1b9c49397f22b440439f036c3bdee82f5309dab3"),
cadence.String("8dec36ed8a91e3e5d737b06434d94a8a561c7889495d6c7081cd5e123a42124415b9391c9b9aa165c2f71994bf9607cb0ea262ad162fec74146d1ebc482a33b9dad203d16a83bbfda89b3f6e1cd1d8fb2e704a162d259a0ac9f26bc8635d74f6"),
}

sampleStakingKeyPoP := cadenceValue{
cadence.String("828a68a2be392804044d85888100462702a422901da3269fb6512defabad07250aad24f232671e4ac8ae531f54e062fc"),
}

sampleNullOptional := cadenceValue{
Expand Down Expand Up @@ -167,6 +171,12 @@ func generateManifest(env templates.Environment) *manifest {
Label: "Raw Value for Hash Algorithm Enum",
SampleValues: []cadenceValue{sampleHashAlgoEnumRawValue},
},
{
Type: "String",
Name: "stakingKeyPoP",
Label: "Staking Key PoP",
SampleValues: []cadenceValue{sampleStakingKeyPoP},
},
{
Type: "UFix64",
Name: "weight",
Expand Down Expand Up @@ -474,6 +484,12 @@ func generateManifest(env templates.Environment) *manifest {
Label: "Staking Key",
SampleValues: []cadenceValue{sampleStakingKey},
},
{
Type: "String",
Name: "stakingKeyPoP",
Label: "Staking Key PoP",
SampleValues: []cadenceValue{sampleStakingKeyPoP},
},
{
Type: "UFix64",
Name: "amount",
Expand Down
Loading
Loading