-
Notifications
You must be signed in to change notification settings - Fork 27
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
WIP: Staking contract #453
Closed
Closed
Changes from 14 commits
Commits
Show all changes
501 commits
Select commit
Hold shift + click to select a range
55ad8a7
Fixup
geoff-vball 57256e9
require init end callable by owner
cam-schultz 7616bb5
revamp delegation events
cam-schultz 0a4ae92
fix e2e
cam-schultz 68c9eaa
store starting validator weight
cam-schultz d63a131
Update contracts/staking/NativeTokenStakingManager.sol
cam-schultz 24b9c61
Merge pull request #504 from ava-labs/delegation-poc
cam-schultz 0834d6c
Merge branch 'staking-contract' into delegation-track-uptime
cam-schultz 666f5d7
Merge pull request #520 from ava-labs/delegation-track-uptime
cam-schultz 27e2063
Merge branch 'staking-contract' into delegation-id
cam-schultz e9db526
update mapping descriptions
cam-schultz aed4ed7
delegationID w/keccak; remove unnecessary check
cam-schultz de9845f
expand delegation comments
cam-schultz 9930e65
Merge pull request #528 from ava-labs/delegation-id
cam-schultz b8f8f60
Update contracts/staking/interfaces/IPoSValidatorManager.sol
geoff-vball 99a12a5
Update contracts/staking/interfaces/IPoSValidatorManager.sol
geoff-vball 1e2489d
Merge pull request #530 from ava-labs/delegation-comments
geoff-vball 01b6bab
Merge branch 'staking-contract' into churn-tracker
geoff-vball 1c170e6
Fix test
geoff-vball fc99b2c
Add tests
geoff-vball c197215
Merge remote-tracking branch 'origin/staking-contract' into unlock-stake
feuGeneA fc51cdc
lint
geoff-vball 03b96a1
rename to validatormanager
ba44522
lint
geoff-vball 50ce587
validatormanager bindings
1ea4bfc
natspec style review comment
feuGeneA daa99b8
Move total weight tracking to ValidatorManager
geoff-vball b256857
Remove pendingEndValidationMessages
geoff-vball c5ccd92
Remove pendingRegisterDelegatorMessages
geoff-vball d54c724
Remove pendingEndDelegatorMessages
geoff-vball c785809
add unit tests
feuGeneA 1ef6e2d
unlock starting weight, not weight w/ delegations
feuGeneA bae1c68
update abi bindings
feuGeneA 6decd64
expect ERC20.transfer for stake unlock
feuGeneA fa3931d
expect native receive() for unlocked stake
feuGeneA 9b9d856
Fix tests
geoff-vball eb140eb
Merge pull request #527 from ava-labs/unlock-stake
feuGeneA e87babf
Merge branch 'staking-contract' into unify-resend-methods
geoff-vball 91fac1b
Merge branch 'staking-contract' into churn-tracker
geoff-vball a8af00f
parameterize values init
ea5a403
save validator requirements
612b626
unit tests passing
299d3a4
add initializer tests
0dd5b6c
invalid validator requirements
8be8b5e
unlock stake at delegation end
feuGeneA 310fbca
Merge pull request #539 from ava-labs/unlock-stake-for-delegators
feuGeneA c6c290d
`IERC20Mintable`, not `IERC20`
feuGeneA 318c277
issue ERC20 staking rewards (native rewards TBD)
feuGeneA 1763ca2
Update contracts/staking/PoSValidatorManager.sol
geoff-vball cd497d7
Merge branch 'staking-contract' into churn-tracker
geoff-vball c6dd4b3
Remove churn tracker start time
geoff-vball f52c04a
Churn tracker to ValidatorManager
geoff-vball f45cce7
mint(addr,amount): respect _MAX_MINT
feuGeneA 57a519e
incorporate uptime in rewards
feuGeneA 538ea24
Fixup churn tracker
geoff-vball c4ec69c
Fix tests
geoff-vball 1fc2700
Fix comment
geoff-vball 4281078
Fixups
geoff-vball 62c73d2
Merge branch 'staking-contract' into unify-resend-methods
geoff-vball 06ef037
Add comment
geoff-vball f26ecbe
increment validator rewards, not overwrite them
feuGeneA f5d460a
rename back to staking and lint
794e29d
Merge remote-tracking branch 'origin/staking-contract' into min-stake…
35bb886
bindings
e336fc7
add cap to maximum stake multiplier
a34ab4f
allow 0 maximum stake multiplier
437d61e
update e2e tests
16e04fc
zero min staking duration
4b61e03
handle initial validator end
4a35b8c
initial validator draft
f502ea7
change in initialize
d3b8ccc
remove owner as part of validator struct
de7ab80
draft with initialValidatorSet, removing owner from ValidatorManager,…
006de7e
Merge pull request #536 from ava-labs/unify-resend-methods
geoff-vball 0d815a0
fix checks for initial validator set
e367998
Merge branch 'staking-contract' into churn-tracker
geoff-vball 2be8305
remove enumerable set use
e0ca117
fix up delegation fees and add unit tests
b86ec1a
change types for parameterized valuse
731c77f
Merge remote-tracking branch 'origin/staking-contract' into min-stake…
d704a40
add max for minimum delegation fee
eb844c5
add max check for min delegation fee
6c697c3
bindings
6b1670b
Merge branch 'min-stake-duration' into initial-validators-ending
9fa3ec2
fix merge
06e650e
pr fixes
b906016
e2e tests fixing
0fa897d
Review fixes
geoff-vball 95b20fa
min stake duration not passing
1836583
Fix unit tests
geoff-vball ceff4ed
Fix e2e tests
geoff-vball 2eb6d02
Add comment
geoff-vball 6372e82
min stake duration fix
iansuvak 4894609
add public getValidator function and fix e2e test
99976c1
Merge pull request #550 from ava-labs/min-stake-duration-block
72a6417
add utils and fix lint
65cf972
Fix e2e tests
geoff-vball bb8b32c
Merge pull request #544 from ava-labs/min-stake-duration
94cc0d8
Merge branch 'staking-contract' into churn-tracker
geoff-vball 0542c82
Fix most unit tests
geoff-vball 07dd6f2
Merge remote-tracking branch 'origin/staking-contract' into initial-v…
2c1a1b1
unit tests compile but need initial validator set
1dcb74c
bindings
b7f2677
bug fixes
ba9024c
Fix most unit tests
geoff-vball 58d5803
Fix all unit tests
geoff-vball 22a0a8c
Fix e2e tests
geoff-vball 0c67133
Review fixes
geoff-vball d103844
Review fixes
geoff-vball 91bef5d
Merge pull request #511 from ava-labs/churn-tracker
fd0aa94
Merge branch 'staking-contract' into staking-rewards
geoff-vball 6ba67b6
Fixup
geoff-vball 56304eb
Fix tests
geoff-vball 08d95b8
Fix rewards calculator
geoff-vball 6fbb9ad
WIP but not working at all yet
iansuvak f2c13d5
Fixups
geoff-vball 267d92e
Fixups
geoff-vball dabde59
Fixups
geoff-vball d480b4c
Fixups
geoff-vball 2ecf2bf
lint
geoff-vball e29827c
Native staking rewards
feuGeneA 38be7d9
update initial validator set verification to take into account extra …
2806198
Update contracts/staking/ValidatorMessages.sol
05cb8d7
pack subnet conversion message
db1867d
gets through signing step but fails the subnetconversion hash check
iansuvak c382766
Merge remote-tracking branch 'origin/initial-validators-ending' into …
iansuvak dcadbf1
poa validator manager test passes
iansuvak 9766b4e
replace manual encoding with BigEndian Put methods
iansuvak be54336
add validationID verification
iansuvak 8096301
minor cleanup
iansuvak 695aaff
move subnetConversion functions to helpers in utils
iansuvak 57256e0
mock initialize validator set
19aa136
Merge remote-tracking branch 'origin/staking-contract' into initial-v…
5551db9
lint fixes
dac8d50
Update other tests and go mod tidy
iansuvak ffb7151
Merge remote-tracking branch 'origin/initial-validators-ending' into …
iansuvak 19f4998
lint
iansuvak 4fb66c9
update test to fix churn tracking
410fef4
Update contracts/staking/interfaces/IValidatorManager.sol
766ebdf
Update contracts/staking/ValidatorManager.sol
05e2cfd
fix comment
f03a1f1
make weight configurable for poa
iansuvak 38aa2a2
Merge remote-tracking branch 'origin/initial-validators-ending' into …
iansuvak 2fd7783
fix churn
iansuvak f1dcd6b
fix initialized validator set after migration
7e6cbd5
poa->pos testing fix
iansuvak 29259c5
Merge pull request #552 from ava-labs/gstuart/native-staking-rewards
geoff-vball a247eeb
pre-increment fix
iansuvak 436290b
Merge pull request #553 from ava-labs/initial-validators-ending-e2e
iansuvak 15d9fbd
Account for validation ending before delegation
geoff-vball 44d8097
Updates and fixes
geoff-vball 9abff90
Move weight update to validatormanager
geoff-vball d0ba99e
Move weight update to validatormanager
geoff-vball 2faa0af
Simplify churn tracking
geoff-vball eed92e4
Simplify churn tracking
geoff-vball 9019085
Remove unneccessary comment
geoff-vball 2109a68
Add comments
geoff-vball 0eb93c6
rename newWeight and oldWeight
geoff-vball 69242fd
Merge branch 'validation-ends-first' into staking-rewards
geoff-vball 8d2969a
Update contracts/staking/PoSValidatorManager.sol
geoff-vball b465fba
Update contracts/staking/PoSValidatorManager.sol
geoff-vball c215b3c
Update contracts/staking/PoSValidatorManager.sol
geoff-vball d9ae361
fix comment
geoff-vball fbeb9c5
Update contracts/staking/ValidatorMessages.sol
cam-schultz fb872a7
fix comment
geoff-vball b943edc
Update contracts/staking/interfaces/IValidatorManager.sol
cam-schultz 8e25aa2
review fixes
geoff-vball 9bbfde2
review fixes
geoff-vball 7d96776
Merge branch 'validation-ends-first' into staking-rewards
geoff-vball be8d434
lint
geoff-vball bda2341
Merge branch 'validation-ends-first' into staking-rewards
geoff-vball ebe122e
lint
geoff-vball 32d2b9e
minor feedback
cam-schultz 260b8a1
remove subnetConversionData validity checks
cam-schultz 75b4b38
Merge branch 'initial-validators-ending' of github.com:ava-labs/telep…
cam-schultz 90e33ad
build fix
cam-schultz 6623df0
fix packing
cam-schultz 0896ba3
Merge pull request #547 from ava-labs/initial-validators-ending
cam-schultz ff7163e
Merge branch 'staking-contract' into validation-ends-first
geoff-vball 8a791c1
Merge branch 'staking-contract' into staking-rewards
geoff-vball 56fae8b
rename staking folder to validatorManager
iansuvak fcaf32c
remove staking abi-bindings
iansuvak 44807c9
update imports
iansuvak 13e210b
Review fixes
geoff-vball 061c125
Review fixes
geoff-vball 3716819
rename more files
iansuvak 19e28b3
Fix unit tests
geoff-vball d5e5e26
Function for withdrawing delegation fees
geoff-vball 622e6a8
validatorManager -> validator-manager
iansuvak a7998b8
Merge remote-tracking branch 'origin/staking-rewards' into staking-re…
iansuvak c9b1556
Hook up native minter precompile to PoS tests
geoff-vball bc7ddc7
wait for success in AddNativeMinterAdmin
iansuvak 9e80079
lint
iansuvak 491ae79
Merge branch 'staking-rewards' into staking-rename
iansuvak 015d92e
Review fixes
geoff-vball daad525
Check for owner when initializing validator completion
geoff-vball 3286116
Small fix
geoff-vball 6b1e9c0
Small fix
geoff-vball db44dab
Emit rewards and fees on delegator exit
geoff-vball 49636c1
manual packing:
iansuvak b4ea1b3
rename more references
iansuvak 71230b9
Merge remote-tracking branch 'origin/staking-rewards' into staking-re…
iansuvak 099bf13
add test
geoff-vball 2b9ff69
use constant for pchain blockchain id
c1de7d3
Merge pull request #534 from ava-labs/staking-rewards
geoff-vball 22bd94a
Merge remote-tracking branch 'origin/staking-contract' into p-chain-id
b8d58ee
bindings
f01daad
Merge remote-tracking branch 'origin/staking-contract' into staking-r…
iansuvak 4b2e326
Merge pull request #563 from ava-labs/staking-rename
iansuvak 6c4b0f7
fix uptime get blockchain ID
0c7b3eb
Merge branch 'staking-contract' into iv-packing
iansuvak f03a6c8
Merge remote-tracking branch 'origin/staking-contract' into p-chain-id
ef2425c
Merge pull request #562 from ava-labs/p-chain-id
fd20c84
pass unit tests but exceed max contract size
iansuvak bc4de86
make all other pack functions use abi.encodePacked
iansuvak 627f47b
Merge remote-tracking branch 'origin/staking-contract' into iv-packing
iansuvak 1aa83fe
Small fixes
geoff-vball 59a98b1
Fix e2e
geoff-vball ed15d98
Fix unit tests
geoff-vball 5048225
review feedback
iansuvak 9683e9c
Fix bug where validator exits while delegation is still pending added
geoff-vball 4149155
Merge pull request #564 from ava-labs/iv-packing
iansuvak a2e817a
Merge branch 'staking-contract' into gstuart/fixups
geoff-vball e6e1629
validator manager custom errors
cam-schultz c8ee395
remove error decls from interface
cam-schultz bafc103
pos manager custom errors
cam-schultz e7ac131
update abi
cam-schultz 329d1e7
Merge branch 'staking-contract' into custom-errors
cam-schultz 059aee3
Update contracts/validator-manager/PoSValidatorManager.sol
cam-schultz 6a80d63
comment type
cam-schultz 556c147
Fix bug where delegator can't exit after validation has ended
geoff-vball 4b00073
cleanup
geoff-vball 396bf4c
Fix delegator end time
geoff-vball b61841d
consistent types
cam-schultz 315ee62
update bindings
cam-schultz 69cf948
reference custom errors directly
cam-schultz 1793727
validator messages custom errors
cam-schultz 64700da
Fixups
geoff-vball d0b3724
fix comment
geoff-vball 5d1be58
Add check
geoff-vball d9b18da
pre-increment
michaelkaplan13 0eaeea8
Fix abi bindings
michaelkaplan13 d7367d6
Remove Delegator.endedAt
geoff-vball f73d2d0
format + lint
cam-schultz c54321c
Merge pull request #566 from ava-labs/custom-errors
cam-schultz 9a17f4c
Merge branch 'staking-contract' into gstuart/fixups
geoff-vball 8c27c5a
update vdr manager readme
cam-schultz f3a6194
clarification
cam-schultz 09e69d7
Merge pull request #565 from ava-labs/gstuart/fixups
geoff-vball 855eb00
Merge pull request #567 from ava-labs/update-readme
cam-schultz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// (c) 2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
// SPDX-License-Identifier: Ecosystem | ||
|
||
pragma solidity 0.8.25; | ||
|
||
import {INativeTokenStakingManager} from "./interfaces/INativeTokenStakingManager.sol"; | ||
import {Address} from "@openzeppelin/[email protected]/utils/Address.sol"; | ||
import {StakingManager} from "./StakingManager.sol"; | ||
|
||
contract NativeTokenStakingManager is StakingManager, INativeTokenStakingManager { | ||
using Address for address payable; | ||
/** | ||
* @notice Begins the validator registration process. Locks the provided native asset in the contract as the stake. | ||
* @param nodeID The node ID of the validator being registered. | ||
* @param registrationExpiry The time at which the reigistration is no longer valid on the P-Chain. | ||
* @param signature The raw bytes of the Ed25519 signature over the concatenated bytes of | ||
* [subnetID]+[nodeID]+[blsPublicKey]+[weight]+[balance]+[expiry]. This signature must correspond to the Ed25519 | ||
* public key that is used for the nodeID. This approach prevents NodeIDs from being unwillingly added to Subnets. | ||
* balance is the minimum initial $nAVAX balance that must be attached to the validator serialized as a uint64. | ||
* The signature field will be validated by the P-Chain. Implementations may choose to validate that the signature | ||
* field is well-formed but it is not required. | ||
*/ | ||
|
||
function initializeValidatorRegistration( | ||
bytes32 nodeID, | ||
uint64 registrationExpiry, | ||
bytes memory signature | ||
) external payable onlyWhenInitialStakeProvided returns (bytes32) { | ||
return _initializeValidatorRegistration(nodeID, msg.value, registrationExpiry, signature); | ||
} | ||
|
||
function _lock(uint256 value) internal virtual override returns (uint256) { | ||
return value; | ||
} | ||
|
||
function _unlock(uint256 value, address to) internal virtual override { | ||
payable(to).sendValue(value); | ||
} | ||
Check warning Code scanning / Slither Dead-code
NativeTokenStakingManager._unlock(uint256,address) (contracts/staking/NativeTokenStakingManager.sol#38-40) is never used and should be removed
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) Confirm with a lawyer, but I think this should be
UNLICENSED
per Solidity conventions for non-OSS licenses (notUNLICENSE
without theD
). There are specific license identifiers for SPDX.