AstarNetwork / astar-frame

Core frame modules for Astar & Shiden network.
Other
58 stars 38 forks source link

Fix for incorrect era when compounding #51

Closed Dinonard closed 2 years ago

Dinonard commented 2 years ago

Pull Request Summary

Reproduced and fixed issue where incorrect contract era stake is overwritten.

Check list

This pull request makes the following changes:

codespool commented 2 years ago

@Dinonard I got the logic in, but I'm having trouble with the contract type and converting it to Vec<u8>, mainly because I couldn't find a method to get it in raw format from iter_prefix_from. (if I used the storage_map_final_key from ledger like you suggested, it complained there are encodeLike traits missing on SmartContract type, and if I added that trait, then the runtime build failed - i figured we don't want to touch runtime code for this)

I tried to use SmartContract type as key for BTreeMap so I don't have to convert, but that got me an overflow issue from the scale codec.

In the end I used I used PrefixIterator::last_raw_key but that got me into ownership issues.

I know there's probably a super simple solution, but I spent a good part of last night trying to find it, so any advice is welcome 🙏

codespool commented 2 years ago

@Dinonard thanks for the comments! Since this is resolved from another PR, I'll just fix them for the sake of learning and close the PR.

akru commented 2 years ago

@Dinonard should we close this PR?