Skip to content

Commit

Permalink
Merge pull request #159 from ElrondNetwork/eei-checks-24
Browse files Browse the repository at this point in the history
Bypass EEI checks, by default.
  • Loading branch information
andreibancioiu authored Nov 28, 2022
2 parents 9710ea3 + a639306 commit d1c11f7
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 243 deletions.
3 changes: 3 additions & 0 deletions erdpy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
## [Unreleased]
- TBD

## [2.1.0]
- [Bypass EEI checks, by default](https://github.com/ElrondNetwork/elrond-sdk-erdpy/pull/159)

## [2.0.4]
- Fix resolving latest release of Github repositories

Expand Down
10 changes: 6 additions & 4 deletions erdpy/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ optional arguments:
False)
--wasm-name WASM_NAME for rust projects, optionally specify the name of the wasm bytecode output file
--wasm-suffix WASM_SUFFIX for rust projects, optionally specify the suffix of the wasm bytecode output file
--skip-eei-checks skip EEI compatibility checks (default: False)
--ignore-eei-checks ignore EEI compatibility errors (default: False)
--eei-checks run EEI compatibility checks (default: False)
--skip-eei-checks deprecated flag
--ignore-eei-checks deprecated flag
```
### Contract.Clean
Expand Down Expand Up @@ -430,8 +431,9 @@ optional arguments:
output file
--wasm-suffix WASM_SUFFIX for rust projects, optionally specify the suffix of the wasm bytecode
output file
--skip-eei-checks skip EEI compatibility checks (default: False)
--ignore-eei-checks ignore EEI compatibility errors (default: False)
--eei-checks run EEI compatibility checks (default: False)
--skip-eei-checks deprecated flag
--ignore-eei-checks deprecated flag
```
## Group **Transactions**
Expand Down
2 changes: 1 addition & 1 deletion erdpy/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0.4"
__version__ = "2.1.0"
13 changes: 9 additions & 4 deletions erdpy/cli_contracts.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import logging
import os
from typing import Any, Dict, List

from pathlib import Path
from typing import Any, Dict, List

from erdpy import cli_shared, errors, projects, utils
from erdpy.accounts import Account, Address, LedgerAccount
Expand Down Expand Up @@ -144,8 +143,11 @@ def _add_build_options_args(sub: Any):
help="for rust projects, optionally specify the name of the wasm bytecode output file")
sub.add_argument("--wasm-suffix", type=str,
help="for rust projects, optionally specify the suffix of the wasm bytecode output file")
sub.add_argument("--skip-eei-checks", action="store_true", default=False, help="skip EEI compatibility checks (default: %(default)s)")
sub.add_argument("--ignore-eei-checks", action="store_true", default=False, help="ignore EEI compatibility errors (default: %(default)s)")

sub.add_argument("--eei-checks", action="store_true", default=False, help="run EEI compatibility checks (default: %(default)s)")
# Flags are kept in order to avoid breaking changes, for the moment - we might completely remove them in the future.
sub.add_argument("--skip-eei-checks", action="store_true", default=True, help="deprecated flag")
sub.add_argument("--ignore-eei-checks", action="store_true", default=True, help="deprecated flag")


def _add_recursive_arg(sub: Any):
Expand Down Expand Up @@ -230,7 +232,10 @@ def _prepare_build_options(args: Any) -> Dict[str, Any]:
"wasm-symbols": args.wasm_symbols,
"wasm-name": args.wasm_name,
"wasm-suffix": args.wasm_suffix,
"eei-checks": args.eei_checks,
# TODO: Remove this, in the future
"skip-eei-checks": args.skip_eei_checks,
# TODO: Remove this, in the future
"ignore-eei-checks": args.ignore_eei_checks
}

Expand Down
5 changes: 0 additions & 5 deletions erdpy/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ def __init__(self, directory: str):
super().__init__(f"Directory is not a supported project: {directory}")


class NotSupportedProjectFeature(KnownError):
def __init__(self):
super().__init__(f"Project feature not yet supported.")


class PlatformNotSupported(KnownError):
def __init__(self, action_or_item: str, platform: str):
super().__init__(f"[{action_or_item}] is not supported on platform [{platform}].")
Expand Down
13 changes: 3 additions & 10 deletions erdpy/projects/eei_checks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from typing import List

from erdpy import utils
from erdpy.errors import NotSupportedProjectFeature
from erdpy.projects.eei_activation import ActivationEpochsInfo
from erdpy.projects.eei_registry import EEIRegistry
from erdpy.projects.interfaces import IProject
Expand Down Expand Up @@ -29,19 +29,12 @@ def check_compatibility(project: IProject):
compatible_with_mainnet = _check_imports_compatibility(imports, activation_info_on_mainnet)
compatible_with_devnet = _check_imports_compatibility(imports, activation_info_on_devnet)

if _should_ignore_checks(project):
return

if not compatible_with_mainnet or not compatible_with_devnet:
raise NotSupportedProjectFeature()
logger.warn("Some features used by the project are not yet completely supported.")


def _should_skip_checks(project: IProject):
return project.get_option("skip-eei-checks") is True


def _should_ignore_checks(project: IProject):
return project.get_option("ignore-eei-checks") is True
return not project.get_option("eei-checks")


def _check_imports_compatibility(imports: List[str], activation_info: ActivationEpochsInfo) -> bool:
Expand Down
222 changes: 4 additions & 218 deletions erdpy/projects/eei_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,225 +7,10 @@
class EEIRegistry:
def __init__(self, activation_info: ActivationEpochsInfo) -> None:
self.activation_info = activation_info

storageAPICostOptimizationEnableEpoch = FeatureFlag("StorageAPICostOptimizationEnableEpoch")

self.flags = [
storageAPICostOptimizationEnableEpoch
]

self.flags: List[FeatureFlag] = []
self.functions: List[EEIFunction] = [
# big int
EEIFunction("bigIntNew", None, []),
EEIFunction("bigIntUnsignedByteLength", None, []),
EEIFunction("bigIntSignedByteLength", None, []),
EEIFunction("bigIntGetUnsignedBytes", None, []),
EEIFunction("bigIntGetSignedBytes", None, []),
EEIFunction("bigIntSetUnsignedBytes", None, []),
EEIFunction("bigIntSetSignedBytes", None, []),
EEIFunction("bigIntIsInt64", None, []),
EEIFunction("bigIntGetInt64", None, []),
EEIFunction("bigIntSetInt64", None, []),
EEIFunction("bigIntAdd", None, []),
EEIFunction("bigIntSub", None, []),
EEIFunction("bigIntMul", None, []),
EEIFunction("bigIntTDiv", None, []),
EEIFunction("bigIntTMod", None, []),
EEIFunction("bigIntEDiv", None, []),
EEIFunction("bigIntEMod", None, []),
EEIFunction("bigIntPow", None, []),
EEIFunction("bigIntLog2", None, []),
EEIFunction("bigIntSqrt", None, []),
EEIFunction("bigIntAbs", None, []),
EEIFunction("bigIntNeg", None, []),
EEIFunction("bigIntSign", None, []),
EEIFunction("bigIntCmp", None, []),
EEIFunction("bigIntNot", None, []),
EEIFunction("bigIntAnd", None, []),
EEIFunction("bigIntOr", None, []),
EEIFunction("bigIntXor", None, []),
EEIFunction("bigIntShr", None, []),
EEIFunction("bigIntShl", None, []),
EEIFunction("bigIntFinishUnsigned", None, []),
EEIFunction("bigIntFinishSigned", None, []),
EEIFunction("bigIntStorageStoreUnsigned", None, []),
EEIFunction("bigIntStorageLoadUnsigned", None, []),
EEIFunction("bigIntGetUnsignedArgument", None, []),
EEIFunction("bigIntGetSignedArgument", None, []),
EEIFunction("bigIntGetCallValue", None, []),
EEIFunction("bigIntGetESDTCallValue", None, []),
EEIFunction("bigIntGetESDTCallValueByIndex", None, []),
EEIFunction("bigIntGetESDTExternalBalance", None, []),
EEIFunction("bigIntGetExternalBalance", None, []),

# small int
EEIFunction("smallIntGetUnsignedArgument", None, []),
EEIFunction("smallIntGetSignedArgument", None, []),
EEIFunction("smallIntFinishUnsigned", None, []),
EEIFunction("smallIntFinishSigned", None, []),
EEIFunction("smallIntStorageStoreUnsigned", None, []),
EEIFunction("smallIntStorageStoreSigned", None, []),
EEIFunction("smallIntStorageLoadUnsigned", None, []),
EEIFunction("smallIntStorageLoadSigned", None, []),
EEIFunction("int64getArgument", None, []),
EEIFunction("int64storageStore", None, []),
EEIFunction("int64storageLoad", None, []),
EEIFunction("int64finish", None, []),

# buffers
EEIFunction("mBufferNew", None, []),
EEIFunction("mBufferNewFromBytes", None, []),
EEIFunction("mBufferGetLength", None, []),
EEIFunction("mBufferGetBytes", None, []),
EEIFunction("mBufferGetByteSlice", None, []),
EEIFunction("mBufferCopyByteSlice", None, []),
EEIFunction("mBufferEq", None, []),
EEIFunction("mBufferSetBytes", None, []),
EEIFunction("mBufferSetByteSlice", storageAPICostOptimizationEnableEpoch, []),
EEIFunction("mBufferAppend", None, []),
EEIFunction("mBufferAppendBytes", None, []),
EEIFunction("mBufferToBigIntUnsigned", None, []),
EEIFunction("mBufferToBigIntSigned", None, []),
EEIFunction("mBufferFromBigIntUnsigned", None, []),
EEIFunction("mBufferFromBigIntSigned", None, []),
EEIFunction("mBufferStorageStore", None, []),
EEIFunction("mBufferStorageLoad", None, []),
EEIFunction("mBufferStorageLoadFromAddress", storageAPICostOptimizationEnableEpoch, []),
EEIFunction("mBufferGetArgument", None, []),
EEIFunction("mBufferFinish", None, []),
EEIFunction("mBufferSetRandom", None, []),

# eei core
EEIFunction("getSCAddress", None, []),
EEIFunction("getOwnerAddress", None, []),
EEIFunction("getShardOfAddress", None, []),
EEIFunction("isSmartContract", None, []),
EEIFunction("getExternalBalance", None, []),
EEIFunction("getBlockHash", None, []),
EEIFunction("transferValue", None, []),
EEIFunction("transferESDTExecute", None, []),
EEIFunction("transferESDTNFTExecute", None, []),
EEIFunction("multiTransferESDTNFTExecute", None, []),
EEIFunction("transferValueExecute", None, []),
EEIFunction("getArgumentLength", None, []),
EEIFunction("getArgument", None, []),
EEIFunction("getFunction", None, []),
EEIFunction("getNumArguments", None, []),
EEIFunction("storageStore", None, []),
EEIFunction("storageLoadLength", None, []),
EEIFunction("storageLoad", None, []),
EEIFunction("storageLoadFromAddress", None, []),
EEIFunction("getCaller", None, []),
EEIFunction("checkNoPayment", None, []),
EEIFunction("getCallValue", None, []),
EEIFunction("getESDTValue", None, []),
EEIFunction("getESDTTokenName", None, []),
EEIFunction("getESDTTokenNonce", None, []),
EEIFunction("getESDTTokenType", None, []),
EEIFunction("getCallValueTokenName", None, []),
EEIFunction("getESDTValueByIndex", None, []),
EEIFunction("getESDTTokenNameByIndex", None, []),
EEIFunction("getESDTTokenNonceByIndex", None, []),
EEIFunction("getESDTTokenTypeByIndex", None, []),
EEIFunction("getCallValueTokenNameByIndex", None, []),
EEIFunction("getNumESDTTransfers", None, []),
EEIFunction("getCurrentESDTNFTNonce", None, []),
EEIFunction("writeLog", None, ["deprecated"]),
EEIFunction("writeEventLog", None, []),
EEIFunction("finish", None, []),
EEIFunction("signalError", None, []),
EEIFunction("getGasLeft", None, []),
EEIFunction("getESDTBalance", None, []),
EEIFunction("getESDTNFTNameLength", None, []),
EEIFunction("getESDTNFTAttributeLength", None, []),
EEIFunction("getESDTNFTURILength", None, []),
EEIFunction("getESDTTokenData", None, []),
EEIFunction("getESDTLocalRoles", storageAPICostOptimizationEnableEpoch, []),
EEIFunction("validateTokenIdentifier", storageAPICostOptimizationEnableEpoch, []),
EEIFunction("executeOnDestContext", None, []),
EEIFunction("executeOnDestContextByCaller", None, []),
EEIFunction("executeOnSameContext", None, []),
EEIFunction("executeReadOnly", None, []),
EEIFunction("createContract", None, []),
EEIFunction("deployFromSourceContract", None, []),
EEIFunction("upgradeContract", None, []),
EEIFunction("upgradeFromSourceContract", None, []),
EEIFunction("asyncCall", None, []),
EEIFunction("getNumReturnData", None, []),
EEIFunction("getReturnDataSize", None, []),
EEIFunction("getReturnData", None, []),
EEIFunction("cleanReturnData", storageAPICostOptimizationEnableEpoch, []),
EEIFunction("deleteFromReturnData", storageAPICostOptimizationEnableEpoch, []),
EEIFunction("setStorageLock", None, []),
EEIFunction("getStorageLock", None, []),
EEIFunction("isStorageLocked", None, []),
EEIFunction("clearStorageLock", None, []),
EEIFunction("getBlockTimestamp", None, []),
EEIFunction("getBlockNonce", None, []),
EEIFunction("getBlockRound", None, []),
EEIFunction("getBlockEpoch", None, []),
EEIFunction("getBlockRandomSeed", None, []),
EEIFunction("getStateRootHash", None, []),
EEIFunction("getPrevBlockTimestamp", None, []),
EEIFunction("getPrevBlockNonce", None, []),
EEIFunction("getPrevBlockRound", None, []),
EEIFunction("getPrevBlockEpoch", None, []),
EEIFunction("getPrevBlockRandomSeed", None, []),
EEIFunction("getOriginalTxHash", None, []),

# eei core (managed)
EEIFunction("managedSCAddress", None, []),
EEIFunction("managedOwnerAddress", None, []),
EEIFunction("managedCaller", None, []),
EEIFunction("managedSignalError", None, []),
EEIFunction("managedWriteLog", None, []),
EEIFunction("managedMultiTransferESDTNFTExecute", None, []),
EEIFunction("managedTransferValueExecute", None, []),
EEIFunction("managedExecuteOnDestContext", None, []),
EEIFunction("managedExecuteOnDestContextByCaller", None, []),
EEIFunction("managedExecuteOnSameContext", None, []),
EEIFunction("managedExecuteReadOnly", None, []),
EEIFunction("managedCreateContract", None, []),
EEIFunction("managedDeployFromSourceContract", None, []),
EEIFunction("managedUpgradeContract", None, []),
EEIFunction("managedUpgradeFromSourceContract", None, []),
EEIFunction("managedAsyncCall", None, []),
EEIFunction("managedGetMultiESDTCallValue", None, []),
EEIFunction("managedGetESDTBalance", None, []),
EEIFunction("managedGetESDTTokenData", None, []),
EEIFunction("managedGetReturnData", None, []),
EEIFunction("managedGetPrevBlockRandomSeed", None, []),
EEIFunction("managedGetBlockRandomSeed", None, []),
EEIFunction("managedGetStateRootHash", None, []),
EEIFunction("managedGetOriginalTxHash", None, []),

# crypto
EEIFunction("sha256", None, []),
EEIFunction("managedSha256", storageAPICostOptimizationEnableEpoch, []),
EEIFunction("keccak256", None, []),
EEIFunction("managedKeccak256", storageAPICostOptimizationEnableEpoch, []),
EEIFunction("ripemd160", None, []),
EEIFunction("verifyBLS", None, []),
EEIFunction("verifyEd25519", None, []),
EEIFunction("verifySecp256k1", None, []),
EEIFunction("verifyCustomSecp256k1", None, []),
EEIFunction("encodeSecp256k1DerSignature", None, []),
EEIFunction("addEC", None, []),
EEIFunction("doubleEC", None, []),
EEIFunction("isOnCurveEC", None, []),
EEIFunction("scalarBaseMultEC", None, []),
EEIFunction("scalarMultEC", None, []),
EEIFunction("marshalEC", None, []),
EEIFunction("unmarshalEC", None, []),
EEIFunction("marshalCompressedEC", None, []),
EEIFunction("unmarshalCompressedEC", None, []),
EEIFunction("generateKeyEC", None, []),
EEIFunction("createEC", None, []),
EEIFunction("getCurveLengthEC", None, []),
EEIFunction("getPrivKeyByteLengthEC", None, []),
EEIFunction("ellipticCurveGetValues", None, [])
# e.g. EEIFunction("foobar", FeatureFlag("fooFeature"), []),
]

self.functions_dict = {function.name: function for function in self.functions}

def sync_flags(self):
Expand All @@ -235,7 +20,8 @@ def sync_flags(self):
def is_function_active(self, function_name: str) -> Union[bool, None]:
function = self.functions_dict.get(function_name, None)
if function is None:
return False
# If function is not found in this registry, assume it is <active> on all known networks.
return True
if function.activated_by is None:
return True
return function.activated_by.is_active
Expand Down
1 change: 1 addition & 0 deletions erdpy/projects/project_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def _do_after_build_custom(self) -> List[Path]:
@final
def _do_after_build_core(self):
wabt.generate_artifacts(self)
# TODO: Remove this, in the future
eei_checks.check_compatibility(self)

def _copy_to_output(self, source: Path, destination: Union[str, None] = None) -> Path:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
with open("README.md", "r") as fh:
long_description = "https://github.com/ElrondNetwork/elrond-sdk-erdpy"

VERSION = "2.0.4"
VERSION = "2.1.0"

try:
with open('./erdpy/_version.py', 'wt') as versionfile:
Expand Down

0 comments on commit d1c11f7

Please sign in to comment.