-
Notifications
You must be signed in to change notification settings - Fork 10
Conversation
a4bac80
to
c4e86b6
Compare
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.
These tests are actual gold, @aakoshh. Thanks! This makes testing significantly easier than what we were doing pre-Fendermint ❤️
) -> TryCallResult<()> { | ||
let public_key = validator.public_key.0.serialize(); | ||
let addr = EthAddress::new_secp256k1(&public_key)?; | ||
let deposit = from_fvm::to_eth_tokens(&validator.power.0)?; |
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.
I like this from_fvm
and from_eth
conversion utils. I feel we should expose them as a crate and make them available to the ipc
repo. I feel we have a lot of redundant conversion functions here and there :)
//cc @cryptoAtwill, thoughts?
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.
They are exposed in the messages
crate, but some low level ones might be useful on their own for someone who doesn't want to deal with Fendermint message types.
28db305
to
de0549a
Compare
* fix lotus querying * query range * fix decoding * Revert typechain * log of parsing * fix order * more logs * more logs * more logs * disable change set * debug * more code * more code * more code * more logs * mint to gateway * debug code * working version with clean up * update comments * remove testing code * fix lint * adding topdown module * remove unused code * Test staking: Part 2 (#319) * TEST: Use EthAddress * TEST: Update closure * TEST: Generate join and leave * TEST: Separate configuration number for current and next * TEST: Take &mut self in StakingState * TEST: Test join * TEST: Test collateral and balance * TEST: Test stake command; fix check of has_joined * TEST: Test leave command; fix total collateral * TEST: Test checkpoint command; signature fails * TEST: Build checkpoint during command run * TEST: Higher default random size * TEST: Unit test for ABI encoding * TEST: Hash checkpoint as tuple * TEST: Try sending the signature with +27 recovery ID * TEST: Use non-masked ethereum address * TEST: Do not increment config when staking 0 * TEST: Tweak token amount generation so there aren't that many zeroes * TEST: Choose min_collateral so the last joiner activates * TEST: Bootstrap tests * TEST: Claim * TEST: Show error data in genesis * TEST: min_collateral > 0 * TEST: use local actors * TEST: Ranking * TEST: Subnet deactivation * TEST: Trying to debug the active validator set * TEST: See doesn't need bytes * TEST: Do not fail test if minimum collateral disagrees * TEST: Maybe we should fail * TEST: Assert active limit * TEST: Fix repeatability * TEST: Example of going over the limit of 2 active validators * TEST: Debugged the over-the-limit validators * TEST: Fix the active collateral sum * TEST: Quit testing if we hit the situation of differently ordered minimum collaterals * TEST: Check the hash of cross messages * TEST: Point at the integration testing branch of ABIs * TEST: Fix clippy * TEST: Update ABI git reference * FIX: Only take the /out * FIX: Install openssl in docker * TEST: Update Rust version in docker * FIX: Remove debug * FIX: 27 shift only needed by Solidity * TEST: Add unstake * FIX: SMT unit tests * FIX: Update RocksDB code * TEST: Use IPC actors dev * Update fendermint/vm/interpreter/src/fvm/state/ipc.rs Co-authored-by: Akosh Farkash <aakoshh@gmail.com> * update cargo * format code * log parent sync messages * sort staking change requests * sort in ascending order * fmt code --------- Co-authored-by: Akosh Farkash <aakoshh@gmail.com>
* migrate top down crate * top down crate * new ipc changes * export proxy mod * fix tests * update cargo * update convert * stashed * stashed * initial impl * update cargo * lint * update tests * execute top down * format code * fm-303: update ipc sdk deps * ipc-308: address review * ipc-308: add additional check for reorgs * ipc-308: revert additional reorg check and add todo * detect chain reorg * temp changes * update reorg * fix tests * fix review * move get finality * more logging * fix getting genesis epoch * update config * more logging * more logs * update cargo lock * update config * remove network name * more logs * update cargo * fix top down error * more logs * fix prev hash * revert toolchain * implicit execution * remove context * implicit execution * more logging * more logging * address review * Fix topdown (#321) * fix lotus querying * query range * fix decoding * Revert typechain * log of parsing * fix order * more logs * more logs * more logs * disable change set * debug * more code * more code * more code * more logs * mint to gateway * debug code * working version with clean up * update comments * remove testing code * fix lint * adding topdown module * remove unused code * Test staking: Part 2 (#319) * TEST: Use EthAddress * TEST: Update closure * TEST: Generate join and leave * TEST: Separate configuration number for current and next * TEST: Take &mut self in StakingState * TEST: Test join * TEST: Test collateral and balance * TEST: Test stake command; fix check of has_joined * TEST: Test leave command; fix total collateral * TEST: Test checkpoint command; signature fails * TEST: Build checkpoint during command run * TEST: Higher default random size * TEST: Unit test for ABI encoding * TEST: Hash checkpoint as tuple * TEST: Try sending the signature with +27 recovery ID * TEST: Use non-masked ethereum address * TEST: Do not increment config when staking 0 * TEST: Tweak token amount generation so there aren't that many zeroes * TEST: Choose min_collateral so the last joiner activates * TEST: Bootstrap tests * TEST: Claim * TEST: Show error data in genesis * TEST: min_collateral > 0 * TEST: use local actors * TEST: Ranking * TEST: Subnet deactivation * TEST: Trying to debug the active validator set * TEST: See doesn't need bytes * TEST: Do not fail test if minimum collateral disagrees * TEST: Maybe we should fail * TEST: Assert active limit * TEST: Fix repeatability * TEST: Example of going over the limit of 2 active validators * TEST: Debugged the over-the-limit validators * TEST: Fix the active collateral sum * TEST: Quit testing if we hit the situation of differently ordered minimum collaterals * TEST: Check the hash of cross messages * TEST: Point at the integration testing branch of ABIs * TEST: Fix clippy * TEST: Update ABI git reference * FIX: Only take the /out * FIX: Install openssl in docker * TEST: Update Rust version in docker * FIX: Remove debug * FIX: 27 shift only needed by Solidity * TEST: Add unstake * FIX: SMT unit tests * FIX: Update RocksDB code * TEST: Use IPC actors dev * Update fendermint/vm/interpreter/src/fvm/state/ipc.rs Co-authored-by: Akosh Farkash <aakoshh@gmail.com> * update cargo * format code * log parent sync messages * sort staking change requests * sort in ascending order * fmt code --------- Co-authored-by: Akosh Farkash <aakoshh@gmail.com> --------- Signed-off-by: Alfonso de la Rocha <adlrocha@tutamail.com> Co-authored-by: Alfonso de la Rocha <adlrocha@tutamail.com> Co-authored-by: Akosh Farkash <aakoshh@gmail.com>
Continuation of #299
join
andleave
commandunstake
in the contractjoin
stake
leave
unstake
checkpoint
Fixes:
Running
The tests can be executed as follows:
cargo test --release -p contract-test --test smt_staking
To run them on modified Solidity contracts, change the
Cargo.toml
file like so:And then run
make ipc-actors-abi
to recompile the ABI artifacts.Notes
Ranking
I cannot replicate the exact ordering of validators when multiple validators have the same collateral, which can lead to disagreements between Rust and Solidity about who exactly are the top N validators, when validator N and N+1 both have the same collateral.
I used a stable sorting mechanism hoping that it will work fairly: given a sorted list of validators, we update the collateral, and the move them up or down to their new place, leaving others in place.
However, in Solidity the priority queues are unstable. For example:
[1a, 2b, 2c, 3d, 3e, 3f]
, where the letter is the validator identity and the number is their collateral1a
1a
with the last element3f
, resulting in[3f, 2b, 2c, 3d, 3e, 1a]
. Then it removes the last element and makes the queue shorter. Finally it sinks the first element back into its place, resulting in[2b, 2c, 3f, 3d, 3e]
.3f
moved from being the last to the top of the "threes".1a
from the queue if it leaves, leaving the others in their relative order.If this situation arises, I stop testing the system further and start with a fresh state. I don't think it's worth trying to replicate this exact ordering mechanism.