seal: Rework contracts API (#6573)

* Transition getter functions to not use scratch buffer

* Remove scratch buffer from ext_get_storage

* Remove scratch buffer from ext_call

* Remove scratch buffer from ext_instantiate

* Add ext_input and remove scratch buffer

* Rework error handling (changes RPC exposed data)

* ext_return passes a flags field instead of a return code
	* Flags is only for seal and not for the caller
	* flags: u32 replaced status_code: u8 in RPC exposed type
* API functions use a unified error type (ReturnCode)
* ext_transfer now traps on error to be consistent with call and instantiate

* Remove the no longer used `Dispatched` event

* Updated inline documentation

* Prevent skipping of copying the output for getter API

* Return gas_consumed from the RPC contracts call interface

* Updated COMPLEXTITY.md

* Rename ext_gas_price to ext_weight_to_fee

* Align comments with spaces

* Removed no longer used `ExecError`

* Remove possible panic in `from_typed_value`

* Use a struct as associated data for SpecialTrap::Return

* Fix nits in COMPLEXITY.md

* Renamed SpecialTrap to TrapReason

* Fix test

* Finish renaming special_trap -> trap_reason

* Remove no longer used get_runtime_storage

* fixup! Remove no longer used get_runtime_storage

* Removed tabs for comment aligment
This commit is contained in:
Alexander Theißen
2020-07-09 15:07:02 +02:00
committed by GitHub
parent a4427f3635
commit 25de5b5c78
26 changed files with 1116 additions and 1256 deletions
+6 -5
View File
@@ -17,6 +17,7 @@
use crate::{
BalanceOf, ContractAddressFor, ContractInfo, ContractInfoOf, GenesisConfig, Module,
RawAliveContractInfo, RawEvent, Trait, TrieId, Schedule, TrieIdGenerator, gas::Gas,
Error,
};
use assert_matches::assert_matches;
use hex_literal::*;
@@ -478,7 +479,7 @@ fn run_out_of_gas() {
67_500_000,
vec![],
),
"ran out of gas during contract execution"
Error::<Test>::OutOfGas,
);
});
}
@@ -1169,7 +1170,7 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage:
DJANGO,
0,
GAS_LIMIT,
vec![],
set_rent_code_hash.as_ref().to_vec(),
)
};
@@ -1294,7 +1295,7 @@ fn storage_max_value_limit() {
Origin::signed(ALICE),
BOB,
0,
GAS_LIMIT,
GAS_LIMIT * 2, // we are copying a huge buffer
Encode::encode(&self::MaxValueSize::get()),
));
@@ -1594,8 +1595,8 @@ fn crypto_hashes() {
0,
GAS_LIMIT,
params,
).unwrap();
assert_eq!(result.status, 0);
).0.unwrap();
assert!(result.is_success());
let expected = hash_fn(input.as_ref());
assert_eq!(&result.data[..*expected_size], &*expected);
}