Make contract a separate runtime module (#345)

* decl_module and extract runtime mod

* Invert dependency staking←→contract

* Remove CodeOf

* Remove StorageOf and move double_map

* Comment staking test

* Clean

* Add gas_price and gas_limit

* Commit.

* Renames

* Params

* WIP

* Rename transfer to call

* WIP

* Rebuild binaries.

* WIP

* Backport ctro changes

* Call wiring

* Commit overlay.

* Rename merge → commit, into_state → ..._change_set

* WIP

* Contract creation routines

* Set code of the created account.

* Fix the ID of `create` Call

* Fix most of the warning.

* Add the simplest test in the contract crate

* Transfers work!

* Add contract_create test.

* Clean

* Add top-level create test

* Clean a bit.

* Pass gas_limit and data via create.

* Introduce OnAccountKill callback in staking

* Hook up OnAccountKill

* Comments

* Pay for gas.

* Refund unused gas in call

* Tests for zero call and zero endownment.

* Add todo about rewriting docs

* Pay for gas in create transactions

* Fix refunds

* Clean unrelevant comments

* fixup! Fix refunds

* fixup! Clean unrelevant comments

* Move DetermineContractAddress to contract

Also restore account removal test

* fixup! Clean unrelevant comments

* Inline effect_transfer, remove effect_create

Remove account_db!

* Use own new_test_ext.

* Don't account for liability

* Add some docs

* Move contract_fee into contract module

* Take GasMeter in vm::execute

* Use GasMeter throughout contract module for meter

* gas module refactoring

* Clean

* Add base call fee

* note about gas price should be taken from storage

* Add base fee for create

* Rename send → call

* Clean

* Take fee expressed in dots in gas

* Add Checked{Add,Sub,Mul,Div} to SimpleArithmetic

* Make Gas generic

* Store {call,create}_base_fee in storage

* Clean

* Rename buy_gas

* Store gas_price in the storage

* Remove unneeded comment.

* Bail out if contract already has code.

* Todos

* Refund even if top-level contract fails.

* Fix error msg

* Fix caller issue

* Extract tests module

* Add max_depth var in storage

* Remove left over gas_left

* Refactor exec

* Add test oog test.

* set_free_balance_creating

* Docs and comments.

* Update storage roots because of ContractFee move

* Rebuild binaries.

* Simplify vm code.

* Wrapping.

* Refactor a bit.

* Typo

* UpdateBalanceOutcome enum

* Style grumbles.

* Rebuild binaries.

* Always consume the given amount of gas.

* [skip ci] endownment → endowment

* Rename `AccountId` generic in on_account_kill

* Fix Cargo.lock

* Refine docs for gas meter.

* [skip ci] Add comments for gas module

* Directly assign to `return_data` at declaration

* Use slices instead of vecs to pass the input data

* Add todo about passing return data without copy

* Use checked_add instead of add with overflow

* Use return_data directly.

* Rebuild binaries.

* Rebuild binaries.
This commit is contained in:
Sergey Pepyakin
2018-07-29 16:55:55 +03:00
committed by Gav Wood
parent 5b6dde07dc
commit 8c527f2999
34 changed files with 2124 additions and 957 deletions
+3 -4
View File
@@ -205,7 +205,6 @@ mod tests {
existential_deposit: 0,
transfer_fee: 0,
creation_fee: 0,
contract_fee: 0,
reclaim_rebate: 0,
early_era_slash: 0,
session_reward: 0,
@@ -248,7 +247,7 @@ mod tests {
construct_block(
1,
[69u8; 32].into(),
hex!("786071057714fdd6ea4595eecd4a0f327908d65f462ff5bca0f700fafce588c9").into(),
hex!("b97d52254fc967bb94bed485de6a738e9fad05decfda3453711677b8becf6d0a").into(),
vec![BareExtrinsic {
signed: alice(),
index: 0,
@@ -261,7 +260,7 @@ mod tests {
construct_block(
2,
block1().1,
hex!("a7f1259cc6b2fa758542f2996e737f8f0de9dec3a9d32641da348178f48b9fc2").into(),
hex!("a1f018d2faa339f72f5ee29050b4670d971e2e271cc06c41ee9cbe1f4c6feec9").into(),
vec![
BareExtrinsic {
signed: bob(),
@@ -281,7 +280,7 @@ mod tests {
construct_block(
1,
[69u8; 32].into(),
hex!("d95fc2cf4541b97ed2cd381fe7a486af8aebad9ed0480c30e9cca184bb207e95").into(),
hex!("41d07010f49aa29b2c9aca542cbaa6f59aafd3dda53cdf711c51ddb7d386912e").into(),
vec![BareExtrinsic {
signed: alice(),
index: 0,