Skip to content

Commit

Permalink
- release 2.0.3: fix hardfork proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
elonmusk committed Oct 24, 2021
1 parent ce4ddad commit 499978c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {
}

group 'org.unichain'
version '2.0.2'
version '2.0.3'

apply plugin: 'java'
apply plugin: 'com.google.protobuf'
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/unichain/core/config/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class ChainConstant {
public static final long MAX_FUTURE_TRANSFER_UNW_TIME_RANGE_UPPER_BOUND = 30*31536000000L;//30 years

public static final long MAX_FUTURE_TRANSFER_TIME_RANGE_TOKEN = 10*31536000000L;//10 years
public static final long MAX_FUTURE_TRANSFER_TIME_RANGE_TOKEN_UPPER_BOUND = 30*31536000000L;//10 years
public static final long MAX_FUTURE_TRANSFER_TIME_RANGE_TOKEN_UPPER_BOUND = 30*31536000000L;//30 years

public static final long MAX_TOKEN_AGE = 50*31536000000L;//50 years
public static final long DEFAULT_TOKEN_AGE = 20*31536000000L;//20 years
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ public boolean validBlock(BlockCapsule block) throws P2pException {
}
}

//@todo review: is it solid or snapshot version ?
public int getRunningBlockVersion(){
return dbManager.getDynamicPropertiesStore().getHardForkVersion();
}
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/org/unichain/core/services/ProposalService.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,10 @@ public static void validator(Manager manager, long code, long value) throws Cont

case HARD_FORK: {
logger.info("validating hardfork proposal --> {}", value);
Assert.isTrue(value >= 2 && value <= Integer.MAX_VALUE, "hardfork version should greater than version 1 and not greater than MAX_INTEGER :" + Integer.MAX_VALUE);
Assert.isTrue(Parameter.BLOCK_VERSION_SUPPORTED.contains(value), "hardfork version not supported by software :" + value);
Assert.isTrue(value > manager.getDynamicPropertiesStore().getHardForkVersion(), "hardfork version must be greater than current version");
int valueInt = Long.valueOf(value).intValue();
Assert.isTrue(valueInt >= 2 && valueInt <= Integer.MAX_VALUE, "hardfork version should greater than version 1 and not greater than MAX_INTEGER :" + Integer.MAX_VALUE);
Assert.isTrue(Parameter.BLOCK_VERSION_SUPPORTED.contains(valueInt), "hardfork version not supported by software :" + valueInt);
Assert.isTrue(valueInt > manager.getDynamicPropertiesStore().getHardForkVersion(), "hardfork version must be greater than current version: " + manager.getDynamicPropertiesStore().getHardForkVersion());
break;
}
case MAX_FUTURE_TRANSFER_TIME_RANGE_UNW: {
Expand Down Expand Up @@ -452,6 +453,11 @@ public static boolean process(Manager manager, ProposalCapsule proposalCapsule)
manager.getDynamicPropertiesStore().saveWitness55PayPerBlock(entry.getValue());
break;
}
/**
* @note:
* - if some hard fork proposals created/approved in the same maintain time, they will be processed sequentially
* - the last proposal will win.
*/
case HARD_FORK: {
logger.info("saving hardfork proposal --> {}", entry.getValue());
manager.getDynamicPropertiesStore().saveHardForkVersion(entry.getValue());
Expand Down

0 comments on commit 499978c

Please sign in to comment.