-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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(freezeV2): merge feature ‘stake 2.0’ into release v4.7.0 #4838
feat(freezeV2): merge feature ‘stake 2.0’ into release v4.7.0 #4838
Conversation
1. add UNFREEZE_DELAY_DAYS proposal 2. add new freeze/unfreeze actuator Closes #
1. add delegate resource contract 2. add undelegate resource contract 3. add test cases for delegate and undelegate resource
…ture/new_tvm_unfreeze
…e_2.0 feat(freezeV2): add three interfaces for the new stake model
…e_2.0 feat(freezeV2): add one interface for new stake model
…e_2.0 feat(freezeV2): add query api to get delegate max resource size
fix(freezeV2): sort frozenV2 list
…e_2.0 feat(freezeV2): Add bandwidth cost for delegating validation
…e_2.0 # Conflicts: # actuator/src/main/java/org/tron/core/utils/ProposalUtil.java # chainbase/src/main/java/org/tron/core/capsule/DelegatedResourceCapsule.java # chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java # common/src/main/java/org/tron/common/parameter/CommonParameter.java # framework/src/main/java/org/tron/core/config/args/Args.java
…e_2.0 # Conflicts: # actuator/src/main/java/org/tron/core/utils/ProposalUtil.java # chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java # common/src/main/java/org/tron/common/parameter/CommonParameter.java # framework/src/main/java/org/tron/core/Wallet.java # framework/src/main/java/org/tron/core/config/args/Args.java # framework/src/main/java/org/tron/core/consensus/ProposalService.java
fix(freezeV2): optimize stake2.0 code
…ze_delegate_index feat(freezeV2): optimize delegate index
fix(freezeV2): fix some problems
# Conflicts: # framework/src/main/java/org/tron/core/Wallet.java
FreezeBalanceV2Contract = 54; | ||
UnfreezeBalanceV2Contract = 55; | ||
WithdrawExpireUnfreezeContract = 56; | ||
DelegateResourceContract = 57; |
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.
DelegateResourceContract = 57; | |
DelegateResourceContract = 57; |
FreezeBalanceV2Contract = 54; | ||
UnfreezeBalanceV2Contract = 55; | ||
WithdrawExpireUnfreezeContract = 56; | ||
DelegateResourceContract = 57; |
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.
**
DelegateResourceContract = 57; | |
DelegateResourceContract = 57; |
**
MarketSellAssetContract = 52; | ||
MarketCancelOrderContract = 53; | ||
FreezeBalanceV2Contract = 54; | ||
UnfreezeBalanceV2Contract = 55; |
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.
UnfreezeBalanceV2Contract = 55; | |
UnfreezeBalanceV2Contract = 55; |
@@ -873,6 +880,13 @@ Contract and contract-related messages. | |||
ClearABIContract = 48; | |||
UpdateBrokerageContract = 49; | |||
ShieldedTransferContract = 51; | |||
MarketSellAssetContract = 52; | |||
MarketCancelOrderContract = 53; | |||
FreezeBalanceV2Contract = 54; |
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.
FreezeBalanceV2Contract = 54; | |
FreezeBalanceV2Contract = 54; |
@@ -873,6 +880,13 @@ Contract and contract-related messages. | |||
ClearABIContract = 48; | |||
UpdateBrokerageContract = 49; | |||
ShieldedTransferContract = 51; | |||
MarketSellAssetContract = 52; | |||
MarketCancelOrderContract = 53; | |||
FreezeBalanceV2Contract = 54; |
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.
@@ -671,7 +691,7 @@ public long getTotalEnergyLimitWithFixRatio(AccountCapsule creator, AccountCapsu | |||
long originEnergyLeft = 0; | |||
if (consumeUserResourcePercent < VMConstant.ONE_HUNDRED) { | |||
originEnergyLeft = rootRepository.getAccountLeftEnergyFromFreeze(creator); | |||
if (VMConfig.allowTvmFreeze()) { | |||
if (VMConfig.allowTvmFreeze() || VMConfig.allowTvmFreezeV2()) { |
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.
if (VMConfig.allowTvmFreeze() || VMConfig.allowTvmFreezeV2()) { | |
if (VMConfig.allowTvmFreeze() || VMConfig.allowTvmFreezeV2()) { |
if (VMConfig.allowTvmFreezeV2()) { | ||
long now = rootRepository.getHeadSlot(); | ||
EnergyProcessor energyProcessor = | ||
new EnergyProcessor( | ||
rootRepository.getDynamicPropertiesStore(), | ||
ChainBaseManager.getInstance().getAccountStore()); | ||
energyProcessor.updateUsage(account); | ||
account.setLatestConsumeTimeForEnergy(now); | ||
receipt.setCallerEnergyUsage(account.getEnergyUsage()); | ||
receipt.setCallerEnergyWindowSize(account.getWindowSize(Common.ResourceCode.ENERGY)); | ||
account.setEnergyUsage( | ||
energyProcessor.increase(account, Common.ResourceCode.ENERGY, | ||
account.getEnergyUsage(), min(leftFrozenEnergy, energyFromFeeLimit), now, now)); | ||
receipt.setCallerEnergyMergedUsage(account.getEnergyUsage()); | ||
rootRepository.updateAccount(account.createDbKey(), account); | ||
} |
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.
if (VMConfig.allowTvmFreezeV2()) { | |
long now = rootRepository.getHeadSlot(); | |
EnergyProcessor energyProcessor = | |
new EnergyProcessor( | |
rootRepository.getDynamicPropertiesStore(), | |
ChainBaseManager.getInstance().getAccountStore()); | |
energyProcessor.updateUsage(account); | |
account.setLatestConsumeTimeForEnergy(now); | |
receipt.setCallerEnergyUsage(account.getEnergyUsage()); | |
receipt.setCallerEnergyWindowSize(account.getWindowSize(Common.ResourceCode.ENERGY)); | |
account.setEnergyUsage( | |
energyProcessor.increase(account, Common.ResourceCode.ENERGY, | |
account.getEnergyUsage(), min(leftFrozenEnergy, energyFromFeeLimit), now, now)); | |
receipt.setCallerEnergyMergedUsage(account.getEnergyUsage()); | |
rootRepository.updateAccount(account.createDbKey(), account); | |
} | |
if (VMConfig.allowTvmFreezeV2()) { | |
long now = rootRepository.getHeadSlot(); | |
EnergyProcessor energyProcessor = | |
new EnergyProcessor( | |
rootRepository.getDynamicPropertiesStore(), | |
ChainBaseManager.getInstance().getAccountStore()); | |
energyProcessor.updateUsage(account); | |
account.setLatestConsumeTimeForEnergy(now); | |
receipt.setCallerEnergyUsage(account.getEnergyUsage()); | |
receipt.setCallerEnergyWindowSize(account.getWindowSize(Common.ResourceCode.ENERGY)); | |
account.setEnergyUsage( | |
energyProcessor.increase(account, Common.ResourceCode.ENERGY, | |
account.getEnergyUsage(), min(leftFrozenEnergy, energyFromFeeLimit), now, now)); | |
receipt.setCallerEnergyMergedUsage(account.getEnergyUsage()); | |
rootRepository.updateAccount(account.createDbKey(), account); | |
} |
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.
if (VMConfig.allowTvmFreezeV2()) { | ||
long now = rootRepository.getHeadSlot(); | ||
EnergyProcessor energyProcessor = | ||
new EnergyProcessor( | ||
rootRepository.getDynamicPropertiesStore(), | ||
ChainBaseManager.getInstance().getAccountStore()); | ||
energyProcessor.updateUsage(creator); | ||
creator.setLatestConsumeTimeForEnergy(now); | ||
receipt.setOriginEnergyUsage(creator.getEnergyUsage()); | ||
receipt.setOriginEnergyWindowSize(creator.getWindowSize(Common.ResourceCode.ENERGY)); | ||
creator.setEnergyUsage( | ||
energyProcessor.increase(creator, Common.ResourceCode.ENERGY, | ||
creator.getEnergyUsage(), creatorEnergyLimit, now, now)); | ||
receipt.setOriginEnergyMergedUsage(creator.getEnergyUsage()); | ||
rootRepository.updateAccount(creator.createDbKey(), creator); | ||
} |
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.
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.
**```
@@ -49,6 +52,8 @@ | |||
import org.tron.protos.Protocol.TransactionSign; | |||
import org.tron.protos.contract.SmartContractOuterClass.CreateSmartContract; | |||
import org.tron.protos.contract.SmartContractOuterClass.TriggerSmartContract; | |||
import org.tron.protos.Protocol.Transaction.Contract.ContractType; | |||
import org.tron.protos.contract.BalanceContract.DelegateResourceContract; |
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.
http://Common.ResourceCode.ENERGY
import org.tron.protos.contract.BalanceContract.DelegateResourceContract; | |
import org.tron.protos.contract.BalanceContract.DelegateResourceContract; |
@@ -0,0 +1,298 @@ | |||
package org.tron.core.vm.nativecontract; |
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.
actuator/src/main/java/org/tron/core/vm/nativecontract/UnfreezeBalanceV2Processor.java
What does this PR do?
Launch a new staking mechanism - stake2.0
Why are these changes required?
TIP:tronprotocol/tips#467
This PR has been tested by:
Follow up
Extra details