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

feat: draft implementation of NEP-366 (fork) #8385

Merged
merged 35 commits into from
Jan 19, 2023
Merged

feat: draft implementation of NEP-366 (fork) #8385

merged 35 commits into from
Jan 19, 2023

Conversation

jakmeier
Copy link
Contributor

@jakmeier jakmeier commented Jan 18, 2023

A fork of #7497

Nearcore code owners currently don't have permissions to change the
original PR, so we will add the necessary changes here before merging.

This is also merged with the current master.

Original authors that came up with the implementation and design:
@e-uleyskiy
@fadeevab

See also NEP-366

Egor Ulesykiy added 30 commits August 30, 2022 00:02
This is a draft implementation of NEP-366 (near/NEPs#366)

Not done yet:
* Need to implement DelegateAction for implicit accounts (nonce problem)
* Need new error codes for DelegateAction
* Implement Fees for DelegateAction
* Add tests
* Removed published_id
* Added sender_id to DelegateAction
* All things are verified when action is processing except verification
  of DelegateAction count in the transaction and verification wheher
  DelegateAction contains the nested ones
* Added block_hash, nonce, public_key fields to DelegateAction
* Gas is refunded to Transaction signer, deposit is refund to Receipt
  predecessor (because publisher_id has been removed)

Need to be done:
1. `block_hash` isn't verified because there is not access to Store from
   `runtime'
2. Need to apply recommendation to `action_array_serde`: https://near.zulipchat.com/#narrow/stream/295302-general/topic/recursive.20types.20in.20borsh-rs/near/305181116
3. Need to add unit tests
* Handle a nested DelegateAction while the parent one is deserialized
1. Charge the inner actions' `send_fee` on Relayer shard and prepaid the
   `send_fee` for Sender shard
2. Burn the inner actions' `send_fee` on Sender shard (when
   DelegateAction is processed)
The feature flag enables DelegateAction support
This test fails if "protocol_feature_delegate_action" is disabled.
Therefore another version of this test has been added which works on
stable build.
Cause: runtime::config_store::tests::test_json_unchanged fails

The following command created the snapshots:
`cargo insta test --accept -p near-primitives -- test_json_unchanged`
- Update PROTOCOL_VERSION
- Update ProtocolFeature::DelegateAction version number
@jakmeier jakmeier requested a review from a team as a code owner January 18, 2023 12:24
@jakmeier jakmeier requested review from mzhangmzz and mm-near and removed request for mzhangmzz January 18, 2023 12:24
Instead of relying on deserialization failing, remove the new action
completely from non-nightly code. This should give us more confidence
to merge this PR into nearcore.
@jakmeier
Copy link
Contributor Author

@mm-near I have added a ton of cfg here to eliminate essentially all the meta transaction code from our stable build.

While this can look a bit messy, I think it simplifies the PR a lot in terms of risks. Most code is now trivially ok to merge because it is only active in nightly. Ssuch as the todo!() in the rosetta rpc. I guess we just postpone the complexity of the actual code to the stabilization PR in the future. (sorry future you and me 😢 )

PTAL if there is anything left you want resolved before we merge this.

Copy link
Contributor

@mm-near mm-near left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - thanks !

BTW - there is a small compilation error when compiling with feature enabled (cargo build -p neard --features protocol_feature_nep366_delegate_action)

@jakmeier
Copy link
Contributor Author

BTW - there is a small compilation error when compiling with feature enabled (cargo build -p neard --features protocol_feature_nep366_delegate_action

Fixed, thanks!

@near-bulldozer near-bulldozer bot merged commit f4744fd into master Jan 19, 2023
@near-bulldozer near-bulldozer bot deleted the NEP-366 branch January 19, 2023 14:10
nikurt pushed a commit to nikurt/nearcore that referenced this pull request Jan 30, 2023
A fork of near#7497 

Nearcore code owners currently don't have permissions to change the
original PR, so we will add the necessary changes here before merging.

This is also merged with the current master.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants