-
Notifications
You must be signed in to change notification settings - Fork 6
anvil-polkadot: add impersonation #332
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
Conversation
...account RPC Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
...account test Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
| redundant-lifetimes = "warn" | ||
| rust-2018-idioms = "warn" | ||
| unused-must-use = "warn" | ||
| unexpected_cfgs = { level = "warn", check-cfg = ['cfg(substrate_runtime)'] } |
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.
needed to supress some warnings after overriding the host functions
|
From @alindima offline:
|
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.
LGTM overall
|
IIRC this could also be configured via CLI |
Good catch, the auto impersonation enabling can be done via CLI too. Will add support for this, thanks! |
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
…alse Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Also created the impersonation manager accounting for the `enable_auto_impersonate` anvil config flag. Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
...touched Cargo.tomls Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
cc @alindima
@AlexandruCihodaru given our discussion offline about the toml formatters, I added a .taplo.toml config file, same as the one used by taplo itself. I don't think it is a bad idea doing it at this point, since editors differ in how they treat identation so using same formatting will simplify reviews. Alternatively we can reuse same config as for polkadot-sdk, but I don't think it is important. I might be able to do it in a separate PR but I think it is a bit pointless to revert the changes (they aren't that many and also they are simple to review). Either way please lmk your thoughts. |
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
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.
Amazing job! ❤️
| // Assert on balances after first transfer. | ||
| let alith_final_balance = node.get_balance(alith_account.address(), latest_block).await; | ||
| let dest_final_balance = node.get_balance(dest_h160, latest_block).await; | ||
| let existential_deposit = U256::from_str_radix("100000000000000000000", 10).unwrap(); |
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: make this a constant in utils.rs because it could be useful in other tests
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.
and make it use the constant in substrate_runtime::currency::DOLLARS under the hood
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.
Created a u128 cost, and whenever needed as u256 I am converting it. Did it this way to avoid creating a static/lazylock (since a cost u256 creation requires calling non-const fn's like U256::from(..).unwrap(), which can not be done with consts): bcab3f9
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.
Good job!
.config/.taplo.toml
Outdated
| "target", | ||
| ] | ||
|
|
||
| [formatting] |
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.
do we have a CI step for checking this format? Because if we don't, it's not that useful. Not everyone uses a code editor that automatically uses taplo for formatting.
Also, where did we get this taplo format from? I am not a big fan of the rule which adds whitespace in order to align the = signs in dependency lists.
Overall I'm not really sure we need it at this point. Anyway, let's not bundle this in this PR, as it's unrelated and would be best to also ask the embedded EVM guys for feedback
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.
do we have a CI step for checking this format?
We should add one. I can work on this in some other PR, once a taplo config makes its way into the repo.
Because if we don't, it's not that useful. Not everyone uses a code editor that automatically uses taplo for formatting.
It is not a matter of automatically using taplo with the code editor, but to configure it (assuming our code editors allows it). I thought that our team should have taplo configured already given we also opened in the past PRs against polkadot-sdk.
Also, where did we get this taplo format from? I am not a big fan of the rule which adds whitespace in order to align the = signs in dependency lists.
It is the taplo config used by the taplo-cli repo. Changing a rule or the entire taplo config is straight forward (with the caveat that all tomls from anvil-polkadot should be formatted afterward). I am fine with most of the rules, only to have all of us use the same ones.
Overall I'm not really sure we need it at this point. Anyway, let's not bundle this in this PR, as it's unrelated and would be best to also ask the embedded EVM guys for feedback
Sure, we can ask. By then I'll revert my toml changes. I hoped we can align quickly behind some "battle tested" formatting, whichever that is and assumed people can comply easily with taplo formatting in their editors (given our previous polkadot-sdk practice), and preferences to be factored in incrementally. Will open a new PR on this subject, maybe with the formatting rules of polkadot-sdk (since we know them already).
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.
Revert here: 5d489e0
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.
Removed taplo config: 6162666.
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.
This could be useful, but we should request feedback on the other devs working on the repo (since it affects all of us) and make sure that it's enforced by CI (otherwise it's not that useful)
| // Assert on balances after first transfer. | ||
| let alith_final_balance = node.get_balance(alith_account.address(), latest_block).await; | ||
| let dest_final_balance = node.get_balance(dest_h160, latest_block).await; | ||
| let existential_deposit = U256::from_str_radix("100000000000000000000", 10).unwrap(); |
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.
and make it use the constant in substrate_runtime::currency::DOLLARS under the hood
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
|
Some unrelated tests are failing, will have to look into it too before merging. |
I think this will fix them: #338. I think we can merge it since it's unrelated and the fix is in review |
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Motivation
Closes #242 .
Solution