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

refactor: authorizations table #2114

Closed
wants to merge 24 commits into from
Closed

Conversation

kingpinXD
Copy link
Contributor

@kingpinXD kingpinXD commented May 3, 2024

Description

  • Adds an authorization table
  • Separate MsgUpdateZRC20 into MsgPauseZRC20 and MsgUnPauseZRC20
  • Separate MsgUpdateCrosschainFlags into MsgEnableCCTXFlags MsgDisableCCTXFlags and MsgUpdateGasPriceIncreaseFlags
  • Policy requirements for new messages
  • MsgPauseZRC20 : PolicyType_groupEmergency
  • MsgUnPauseZRC20 PolicyType_groupOperational
  • MsgUpdateGasPriceIncreaseFlags : PolicyType_groupOperational
  • MsgEnableCCTXFlags : PolicyType_groupOperational
  • MsgDisableCCTXFlags : PolicyType_groupEmergency

Closes:#2107

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Include instructions and any relevant details so others can reproduce.

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Checklist:

  • I have added unit tests that prove my fix feature works

Copy link

codecov bot commented May 3, 2024

Codecov Report

Attention: Patch coverage is 86.58537% with 44 lines in your changes are missing coverage. Please review.

Project coverage is 72.40%. Comparing base (dd4ca91) to head (45442b5).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2114      +/-   ##
===========================================
+ Coverage    72.34%   72.40%   +0.05%     
===========================================
  Files          250      257       +7     
  Lines        14046    14214     +168     
===========================================
+ Hits         10162    10291     +129     
- Misses        3423     3459      +36     
- Partials       461      464       +3     
Files Coverage Δ
pkg/authorizations/authorizations.go 100.00% <100.00%> (ø)
x/authority/keeper/policies.go 100.00% <100.00%> (ø)
x/crosschain/keeper/msg_server_abort_stuck_cctx.go 100.00% <100.00%> (ø)
...rosschain/keeper/msg_server_add_to_intx_tracker.go 94.73% <100.00%> (+0.45%) ⬆️
...osschain/keeper/msg_server_add_to_outtx_tracker.go 89.33% <100.00%> (+0.44%) ⬆️
.../crosschain/keeper/msg_server_migrate_tss_funds.go 84.12% <100.00%> (+0.12%) ⬆️
.../crosschain/keeper/msg_server_refund_aborted_tx.go 100.00% <100.00%> (ø)
...sschain/keeper/msg_server_remove_out_tx_tracker.go 100.00% <100.00%> (ø)
...ain/keeper/msg_server_update_rate_limiter_flags.go 100.00% <100.00%> (ø)
x/crosschain/keeper/msg_server_update_tss.go 100.00% <100.00%> (ø)
... and 26 more

... and 1 file with indirect coverage changes

@kingpinXD kingpinXD changed the title Authorizations table refacore: authorizations table May 10, 2024
@kingpinXD kingpinXD changed the title refacore: authorizations table refactor: authorizations table May 10, 2024
@kingpinXD kingpinXD marked this pull request as ready for review May 10, 2024 16:01
Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

Not complete review but giving some comments already

pkg/authorizations/authorizations.go Outdated Show resolved Hide resolved
pkg/authorizations/authorizations.go Outdated Show resolved Hide resolved
pkg/authorizations/authorizations.go Outdated Show resolved Hide resolved
testutil/keeper/authority.go Show resolved Hide resolved
x/crosschain/keeper/msg_server_add_to_outtx_tracker.go Outdated Show resolved Hide resolved
x/authority/keeper/policies.go Outdated Show resolved Hide resolved
x/fungible/keeper/msg_server_unpause_zrc20.go Outdated Show resolved Hide resolved
@lumtis lumtis linked an issue May 13, 2024 that may be closed by this pull request
@kingpinXD kingpinXD requested a review from lumtis May 13, 2024 19:16
Copy link
Contributor

@skosito skosito 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, just some comments to consider before merging

changelog.md Outdated Show resolved Hide resolved
pkg/authorizations/authorizations.go Outdated Show resolved Hide resolved
pkg/authorizations/authorizations.go Outdated Show resolved Hide resolved
testutil/sample/authority.go Show resolved Hide resolved
proto/zetachain/zetacore/authority/policies.proto Outdated Show resolved Hide resolved
x/observer/keeper/msg_server_disable_cctx_flags.go Outdated Show resolved Hide resolved
x/observer/keeper/msg_server_update_observer.go Outdated Show resolved Hide resolved
return false
}

var OperationalPolicyMessageList = []string{
Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking about defining a type PolicyTable containing a list [url,policy] tuples with crud methods, so it can be easily update, even if we add a new policy type and can be used once we persist the table in the state


var OperationalPolicyMessageList = []string{
// Crosschain admin messages
sdk.MsgTypeURL(&crosschaintypes.MsgRefundAbortedCCTX{}),
Copy link
Member

Choose a reason for hiding this comment

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

Can be made less verbose defining an alias

msgURL := sdk.MsgTypeURL

"github.com/zeta-chain/zetacore/pkg/authorizations"
authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"
)

Copy link
Member

Choose a reason for hiding this comment

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

We can add assertion with all messages in the tests

@@ -0,0 +1,59 @@
package types
Copy link
Member

Choose a reason for hiding this comment

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

The test for this file use the pause message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants