Skip to content
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

Implement generational storage with SELFDESTRUCT tests #84

Merged
merged 8 commits into from Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -14,3 +14,7 @@
/*.wasm
/target/
etc/state-migration-test/target/

node_modules/
artifacts/
cache
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Expand Up @@ -59,6 +59,8 @@ rjson = { version = "0.3.1", default-features = false }

[dev-dependencies]
bstr = "0.2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
hex = { version = "0.4.3", default-features = false }
near-sdk = { git = "https://github.com/near/near-sdk-rs", rev = "9d99077c6acfde68c06845f2a1eb2b5ed7983401" }
near-sdk-sim = { git = "https://github.com/near/near-sdk-rs", rev = "9d99077c6acfde68c06845f2a1eb2b5ed7983401" }
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Expand Up @@ -17,6 +17,9 @@ target/wasm32-unknown-unknown/release/aurora_engine.wasm: Cargo.toml Cargo.lock
RUSTFLAGS='-C link-arg=-s' $(CARGO) build --target wasm32-unknown-unknown --release --no-default-features --features=$(FEATURES) -Z avoid-dev-deps
ls -l target/wasm32-unknown-unknown/release/aurora_engine.wasm

etc/eth-contracts/artifacts/contracts/StateTest.sol/StateTest.json: $(shell find etc/eth-contracts/contracts -name "*.sol") etc/eth-contracts/package.json
cd etc/eth-contracts && yarn && yarn build

debug: debug.wasm

debug.wasm: target/wasm32-unknown-unknown/debug/aurora_engine.wasm
Expand All @@ -25,7 +28,7 @@ debug.wasm: target/wasm32-unknown-unknown/debug/aurora_engine.wasm
target/wasm32-unknown-unknown/debug/aurora_engine.wasm: Cargo.toml Cargo.lock $(wildcard src/*.rs)
$(CARGO) build --target wasm32-unknown-unknown --no-default-features --features=$(FEATURES) -Z avoid-dev-deps

test-build:
test-build: etc/eth-contracts/artifacts/contracts/StateTest.sol/StateTest.json
RUSTFLAGS='-C link-arg=-s' $(CARGO) build --target wasm32-unknown-unknown --release --no-default-features --features=contract,integration-test -Z avoid-dev-deps
ln -sf target/wasm32-unknown-unknown/release/aurora_engine.wasm release.wasm
ls -l target/wasm32-unknown-unknown/release/aurora_engine.wasm
Expand Down
1 change: 1 addition & 0 deletions etc/eth-contracts/.eslintignore
@@ -0,0 +1 @@
node_modules/
52 changes: 52 additions & 0 deletions etc/eth-contracts/.eslintrc
@@ -0,0 +1,52 @@
{
"extends" : [
"standard",
"plugin:promise/recommended"
],
"plugins": [
"promise"
],
"env": {
"browser" : true,
"node": true,
"mocha": true,
"jest": true
},
"globals" : {
"artifacts": false,
"contract": false,
"assert": false,
"web3": false
},
"rules": {

// Strict mode
"strict": [2, "global"],

// Code style
"indent": [2, 4],
"quotes": [2, "single"],
"semi": ["error", "always"],
"space-before-function-paren": ["error", "always"],
"no-use-before-define": 0,
"no-unused-expressions": "off",
"eqeqeq": [2, "smart"],
"dot-notation": [2, {"allowKeywords": true, "allowPattern": ""}],
"no-redeclare": [2, {"builtinGlobals": true}],
"no-trailing-spaces": [2, { "skipBlankLines": true }],
"eol-last": 1,
"comma-spacing": [2, {"before": false, "after": true}],
"camelcase": [2, {"properties": "always"}],
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
"comma-dangle": [1, "always-multiline"],
"no-dupe-args": 2,
"no-dupe-keys": 2,
"no-debugger": 0,
"no-undef": 2,
"object-curly-spacing": [2, "always"],
"max-len": [2, 200, 2],
"generator-star-spacing": ["error", "before"],
"promise/avoid-new": 0,
"promise/always-return": 0
}
}
1 change: 1 addition & 0 deletions etc/eth-contracts/.soliumignore
@@ -0,0 +1 @@
node_modules
23 changes: 23 additions & 0 deletions etc/eth-contracts/.soliumrc.json
@@ -0,0 +1,23 @@
{
"extends": "solium:all",
"plugins": ["security"],
"rules": {
"mixedcase": "off",
"error-reason": "off",
"indentation": ["error", 4],
"lbrace": "off",
"linebreak-style": ["error", "unix"],
"max-len": ["error", 139],
"no-constant": ["error"],
"no-empty-blocks": "off",
"quotes": ["error", "double"],
"uppercase": "off",
"visibility-first": "error",
"arg-overflow": ["error", 5],
"function-order": "off",

"security/enforce-explicit-visibility": ["error"],
"security/no-block-members": ["off"],
"security/no-inline-assembly": ["warning"]
}
}
26 changes: 26 additions & 0 deletions etc/eth-contracts/contracts/StateTest.sol
@@ -0,0 +1,26 @@
pragma solidity ^0.8.0;

contract SelfDestruct {
uint256 public counter;

constructor() public {
}

function increase() public {
counter += 1;
}

function finish() public {
selfdestruct(payable(msg.sender));
}
}

contract SelfDestructFactory {
constructor() public {
}

function deploy() public returns(address) {
address addr = address(new SelfDestruct{salt: bytes32(uint256(0x1234))}());
return addr;
}
}
17 changes: 17 additions & 0 deletions etc/eth-contracts/hardhat.config.js
@@ -0,0 +1,17 @@
require('@nomiclabs/hardhat-ethers');
require('solidity-coverage');

/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: {
version: '0.8.3',
settings: {
optimizer: {
enabled: true,
runs: 1000,
},
},
},
};
36 changes: 36 additions & 0 deletions etc/eth-contracts/package.json
@@ -0,0 +1,36 @@
{
"name": "evm-erc20-token",
"version": "0.1.0",
"description": "ERC20 token implementation on EVM mapped from Native NEP-141",
"dependencies": {
"@openzeppelin/contracts": "^4.1.0"
},
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.1",
"chai": "^4.3.3",
"eslint": "^6.3.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"eth-gas-reporter": "^0.2.11",
"ethers": "^5.0.31",
"hardhat": "^2.1.1",
"rainbow-bridge-lib": "^2.0.0",
"solc": "0.8.3",
"solidity-coverage": "^0.7.16",
"solium": "^1.2.5"
},
"scripts": {
"build": "hardhat compile",
"test": "hardhat test",
"coverage": "hardhat coverage",
"lint:js": "eslint .",
"lint:js:fix": "eslint . --fix",
"lint:sol": "solium -d .",
"lint:sol:fix": "solium -d . --fix",
"lint": "yarn lint:js && yarn lint:sol",
"lint:fix": "yarn lint:js:fix && yarn lint:sol:fix"
}
}