Skip to content

Commit

Permalink
Merge pull request #38 from tronprotocol/feature/add_freeze_unfreeze
Browse files Browse the repository at this point in the history
Feature/add freeze unfreeze
  • Loading branch information
Lredhdx authored Apr 16, 2021
2 parents fbf12e5 + f4aefd4 commit 44338cd
Show file tree
Hide file tree
Showing 22 changed files with 160 additions and 420 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include(EthPolicy)
eth_policy()

# project name and version should be set after cmake_policy CMP0048
set(PROJECT_VERSION "0.5.16")
set(PROJECT_VERSION "0.5.17")
project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX)

include(TestBigEndian)
Expand Down
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 0.5.17 (2020-03-17)

Bugfixes:
* Type Checker: Disallow overriding of private functions.

### 0.5.16 (2020-01-02)

Bugfixes:
Expand Down
4 changes: 4 additions & 0 deletions docs/bugs_by_version.json
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,10 @@
"bugs": [],
"released": "2020-01-02"
},
"0.5.17": {
"bugs": [],
"released": "2020-03-17"
},
"0.5.2": {
"bugs": [
"SignedArrayStorageCopy",
Expand Down
22 changes: 7 additions & 15 deletions libevmasm/GasMeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,27 +187,19 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _
gas += GasCosts::expByteGas(m_evmVersion) * 32;
break;
case Instruction::BALANCE:
case Instruction::REWARDBALANCE:
case Instruction::TOKENBALANCE:
case Instruction::ISCONTRACT:
case Instruction::ISSRCANDIDATE:
gas = GasCosts::balanceGas(m_evmVersion);
break;
case Instruction::NATIVESTAKE:
gas = runGas(Instruction::NATIVESTAKE);
case Instruction::NATIVEFREEZE:
gas = runGas(Instruction::NATIVEFREEZE);
break;
case Instruction::NATIVEUNSTAKE:
gas = runGas(Instruction::NATIVEUNSTAKE);
break;
case Instruction::NATIVEWITHDRAWREWARD:
gas = runGas(Instruction::NATIVEWITHDRAWREWARD);
break;
case Instruction::TOKENISSUE:
gas = runGas(Instruction::TOKENISSUE);
case Instruction::NATIVEUNFREEZE:
gas = runGas(Instruction::NATIVEUNFREEZE);
break;
case Instruction::NATIVEFREEZEEXPIRETIME:
gas = runGas(Instruction::NATIVEFREEZEEXPIRETIME);
break;
case Instruction::UPDATEASSET:
gas = runGas(Instruction::UPDATEASSET);
break;
case Instruction::CHAINID:
gas = runGas(Instruction::CHAINID);
break;
Expand Down
29 changes: 7 additions & 22 deletions libevmasm/Instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,12 @@ std::map<std::string, Instruction> const dev::eth::c_instructions =
{ "KECCAK256", Instruction::KECCAK256 },
{ "ADDRESS", Instruction::ADDRESS },
{ "BALANCE", Instruction::BALANCE },
{ "REWARDBALANCE", Instruction::REWARDBALANCE },
{ "TOKENBALANCE", Instruction::TOKENBALANCE },
{ "ISCONTRACT", Instruction::ISCONTRACT },
{ "ISSRCANDIDATE", Instruction::ISSRCANDIDATE },
{ "ORIGIN", Instruction::ORIGIN },
// { "NATIVEFREEZE", Instruction::NATIVEFREEZE },
// { "NATIVEUNFREEZE", Instruction::NATIVEUNFREEZE },
// { "NATIVEVOTE", Instruction::NATIVEVOTE },
{ "NATIVESTAKE", Instruction::NATIVESTAKE },
{ "NATIVEUNSTAKE", Instruction::NATIVEUNSTAKE },
{ "NATIVEWITHDRAWREWARD", Instruction::NATIVEWITHDRAWREWARD },
{ "TOKENISSUE", Instruction::TOKENISSUE },
{ "UPDATEASSET", Instruction::UPDATEASSET },
{ "NATIVEFREEZE", Instruction::NATIVEFREEZE },
{ "NATIVEUNFREEZE", Instruction::NATIVEUNFREEZE },
{ "NATIVEFREEZEEXPIRETIME", Instruction::NATIVEFREEZEEXPIRETIME },
{ "CALLER", Instruction::CALLER },
{ "CALLVALUE", Instruction::CALLVALUE },
{ "CALLTOKENVALUE", Instruction::CALLTOKENVALUE },
Expand Down Expand Up @@ -222,23 +215,15 @@ static std::map<Instruction, InstructionInfo> const c_instructionInfo =
{ Instruction::KECCAK256, { "KECCAK256", 0, 2, 1, true, Tier::Special } },
{ Instruction::ADDRESS, { "ADDRESS", 0, 0, 1, false, Tier::Base } },
{ Instruction::BALANCE, { "BALANCE", 0, 1, 1, false, Tier::Balance } },
{ Instruction::REWARDBALANCE, { "REWARDBALANCE", 0, 1, 1, false, Tier::Balance } },
{ Instruction::TOKENBALANCE, { "TOKENBALANCE", 0, 2, 1, false, Tier::Balance } },
{ Instruction::TOKENBALANCE, { "TOKENBALANCE", 0, 2, 1, false, Tier::Balance } },
{ Instruction::ISCONTRACT, { "ISCONTRACT", 0, 1, 1, false, Tier::Balance } },
{ Instruction::ISSRCANDIDATE, { "ISSRCANDIDATE", 0, 1, 1, false, Tier::Balance } },
{ Instruction::ORIGIN, { "ORIGIN", 0, 0, 1, false, Tier::Base } },
// todo freeze unfreeze vote
// { Instruction::NATIVEFREEZE, { "NATIVEFREEZE", 0, 4, 1, true, Tier::Ext } },
// { Instruction::NATIVEUNFREEZE, { "NATIVEUNFREEZE", 0, 2, 1, true, Tier::Ext } },
// { Instruction::NATIVEVOTE, { "NATIVEVOTE", 0, 4, 1, true, Tier::Ext } },
{ Instruction::NATIVESTAKE, { "NATIVESTAKE", 0, 2, 1, true, Tier::Ext } },
{ Instruction::NATIVEUNSTAKE, { "NATIVEUNSTAKE", 0, 0, 1, true, Tier::Ext } },
{ Instruction::NATIVEWITHDRAWREWARD, { "NATIVEWITHDRAWREWARD", 0, 0, 1, true, Tier::Ext } },
{ Instruction::NATIVEFREEZE, { "NATIVEFREEZE", 0, 3, 1, true, Tier::Ext } },
{ Instruction::NATIVEUNFREEZE, { "NATIVEUNFREEZE", 0, 2, 1, true, Tier::Ext } },
{ Instruction::NATIVEFREEZEEXPIRETIME, { "NATIVEFREEZEEXPIRETIME", 0, 2, 1, true, Tier::Ext } },
{ Instruction::CALLER, { "CALLER", 0, 0, 1, false, Tier::Base } },
{ Instruction::CALLVALUE, { "CALLVALUE", 0, 0, 1, false, Tier::Base } },
{ Instruction::CALLTOKENVALUE, { "CALLTOKENVALUE", 0, 0, 1, false, Tier::Base } },
{ Instruction::TOKENISSUE, { "TOKENISSUE", 0, 4, 1, true, Tier::High } },
{ Instruction::UPDATEASSET, { "UPDATEASSET", 0, 3, 1, true, Tier::High } },
{ Instruction::CALLTOKENID, { "CALLTOKENID", 0, 0, 1, false, Tier::Base } },
{ Instruction::CALLDATALOAD,{ "CALLDATALOAD", 0, 1, 1, false, Tier::VeryLow } },
{ Instruction::CALLDATASIZE,{ "CALLDATASIZE", 0, 0, 1, false, Tier::Base } },
Expand Down
14 changes: 3 additions & 11 deletions libevmasm/Instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,9 @@ enum class Instruction: uint8_t
CALLTOKENVALUE,
CALLTOKENID,
ISCONTRACT,
NATIVESTAKE,
NATIVEUNSTAKE,
NATIVEWITHDRAWREWARD,
REWARDBALANCE,
ISSRCANDIDATE,
TOKENISSUE,
UPDATEASSET,
// todo freeze unfreeze vote
// NATIVEFREEZE,
// NATIVEUNFREEZE,
// NATIVEVOTE,
NATIVEFREEZE,
NATIVEUNFREEZE,
NATIVEFREEZEEXPIRETIME,

CREATE = 0xf0, ///< create a new account with associated code
CALL, ///< message-call into an account
Expand Down
34 changes: 9 additions & 25 deletions libevmasm/SemanticInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,11 @@ bool SemanticInformation::isDeterministic(AssemblyItem const& _item)
case Instruction::PC:
case Instruction::MSIZE: // depends on previous writes and reads, not only on content
case Instruction::BALANCE: // depends on previous calls
case Instruction::REWARDBALANCE:
case Instruction::TOKENBALANCE:
case Instruction::ISCONTRACT:
case Instruction::ISSRCANDIDATE:
// case Instruction::NATIVEFREEZE:
// case Instruction::NATIVEUNFREEZE:
// case Instruction::NATIVEVOTE:
// case Instruction::NATIVESTAKE:
case Instruction::NATIVEUNSTAKE:
case Instruction::NATIVESTAKE:
case Instruction::NATIVEWITHDRAWREWARD:
case Instruction::TOKENISSUE:
case Instruction::UPDATEASSET:
case Instruction::NATIVEFREEZE:
case Instruction::NATIVEUNFREEZE:
case Instruction::NATIVEFREEZEEXPIRETIME:
case Instruction::SELFBALANCE: // depends on previous calls
case Instruction::EXTCODESIZE:
case Instruction::EXTCODEHASH:
Expand All @@ -209,10 +201,8 @@ bool SemanticInformation::movable(Instruction _instruction)
{
case Instruction::KECCAK256:
case Instruction::BALANCE:
case Instruction::REWARDBALANCE:
case Instruction::TOKENBALANCE:
case Instruction::ISCONTRACT:
case Instruction::ISSRCANDIDATE:
case Instruction::SELFBALANCE:
case Instruction::EXTCODESIZE:
case Instruction::EXTCODEHASH:
Expand Down Expand Up @@ -289,15 +279,11 @@ bool SemanticInformation::invalidInPureFunctions(Instruction _instruction)
case Instruction::ADDRESS:
case Instruction::SELFBALANCE:
case Instruction::BALANCE:
case Instruction::REWARDBALANCE:
case Instruction::TOKENBALANCE:
case Instruction::ISCONTRACT:
case Instruction::ISSRCANDIDATE:
case Instruction::NATIVESTAKE:
case Instruction::NATIVEUNSTAKE:
case Instruction::NATIVEWITHDRAWREWARD:
case Instruction::TOKENISSUE:
case Instruction::UPDATEASSET:
case Instruction::NATIVEFREEZE:
case Instruction::NATIVEUNFREEZE:
case Instruction::NATIVEFREEZEEXPIRETIME:
case Instruction::ORIGIN:
case Instruction::CALLER:
case Instruction::CALLVALUE:
Expand Down Expand Up @@ -342,11 +328,9 @@ bool SemanticInformation::invalidInViewFunctions(Instruction _instruction)
case Instruction::DELEGATECALL:
case Instruction::CREATE2:
case Instruction::SELFDESTRUCT:
case Instruction::NATIVESTAKE:
case Instruction::NATIVEUNSTAKE:
case Instruction::NATIVEWITHDRAWREWARD:
case Instruction::TOKENISSUE:
case Instruction::UPDATEASSET:
case Instruction::NATIVEFREEZE:
case Instruction::NATIVEUNFREEZE:
case Instruction::NATIVEFREEZEEXPIRETIME:
return true;
default:
break;
Expand Down
3 changes: 3 additions & 0 deletions libsolidity/analysis/ContractLevelChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ void ContractLevelChecker::checkFunctionOverride(FunctionDefinition const& _func
stateMutabilityToString(_function.stateMutability()) +
"\"."
);
if (_super.visibility() == Declaration::Visibility::Private)
overrideError(_function, _super, "Private functions cannot be overridden.");

}

void ContractLevelChecker::overrideError(FunctionDefinition const& function, FunctionDefinition const& super, string message)
Expand Down
Loading

0 comments on commit 44338cd

Please sign in to comment.