Skip to content

fix(toolkit): set witness flag for fork accounts#122

Open
Federico2014 wants to merge 2 commits into
tronprotocol:developfrom
Federico2014:account-iswitness-fix
Open

fix(toolkit): set witness flag for fork accounts#122
Federico2014 wants to merge 2 commits into
tronprotocol:developfrom
Federico2014:account-iswitness-fix

Conversation

@Federico2014
Copy link
Copy Markdown
Contributor

What does this PR do?

This PR fixes toolkit db fork witness account initialization.

  • Mark witness accounts in account store with isWitness=true when processing witnesses in DbFork
  • When ALLOW_MULTI_SIGN == 1, initialize default witness permissions for witness accounts that do not already have witnessPermission
  • Preserve existing witnessPermission if it is already configured, instead of overwriting it
  • Reuse a shared account-loading path for both witness and account updates in DbFork
  • Add regression tests for:
    • witness flag persistence
    • default witness permission initialization under multi-sign
    • keeping pre-existing witness permission unchanged

Why are these changes required?

Before this change, db fork updated the witness store but did not fully initialize the corresponding witness account state in account store.

This caused two problems:

  • witness accounts created through db fork could miss the isWitness flag
  • under multi-sign, witness accounts could miss default witnessPermission, which makes the forked database inconsistent with runtime witness-account initialization logic

This PR makes db fork produce witness account data that is compatible with multi-sign behavior while remaining safe for accounts that already have customized witness permissions.

This PR has been tested by:

  • Unit Tests
    • ./gradlew :toolkit:test --tests org.tron.plugins.DbForkTest
  • Manual Testing

Follow up

  • None

Extra details

  • ALLOW_MULTI_SIGN and ACTIVE_DEFAULT_OPERATIONS are read from the dynamic properties store
  • Default witness permission is only added when multi-sign is enabled and the account does not already have witnessPermission

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.

1 participant