This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
refactor: Move run_transaction params into fields of a TxInput struct and make doc comments of its fields #10769
refactor: Move run_transaction params into fields of a TxInput struct and make doc comments of its fields #10769
Changes from 4 commits
8a6e644
6bf9c05
8e09d1a
1ad5e29
2333fbb
997d844
1a4e7cd
ad18fc9
cb81ff9
ac83684
ed5e667
b828e33
2e17bb3
4b98474
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need all the members to be
pub
? It is generally avoided so that the code is easier to change in the future. Maybe it could be a way to use theDefault
trait to avoid supplying all args all the time? It would also let you do fancy things like haveMyChainTxInput
types where e.g. thename
member is pre-set and you can have logic to ensure users don't misuse the api (say, use aForkSpec
that is invalid for the given chain spec name).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't figure out how to use the
Default
trait, but I've pushed an approach herein this commit 426a438, but unfortunately I can't work out how to overcome these errors
error: expected expression, found `}` --> evmbin/./src/info.rs:139:3 | 139 | } | ^ expected expression
error: expected expression, found
}
--> evmbin/./src/info.rs:146:3
|
146 | }
| ^ expected expression
error: expected expression, found
}
--> evmbin/./src/info.rs:153:3
|
153 | }
| ^ expected expression
error: expected expression, found
}
--> evmbin/./src/info.rs:160:3
|
160 | }
| ^ expected expression
error: expected expression, found
}
--> evmbin/./src/info.rs:167:3
|
167 | }
| ^ expected expression
error[E0433]: failed to resolve: use of undeclared type or module
tx_input
--> evmbin/./src/main.rs:221:7
|
221 | tx_input::std_json_err_only();
| ^^^^^^^^ use of undeclared type or module
tx_input
error[E0433]: failed to resolve: use of undeclared type or module
tx_input
--> evmbin/./src/main.rs:225:7
|
225 | tx_input::std_json_out_only();
| ^^^^^^^^ use of undeclared type or module
tx_input
error[E0433]: failed to resolve: use of undeclared type or module
tx_input
--> evmbin/./src/main.rs:229:7
|
229 | tx_input::std_json_default();
| ^^^^^^^^ use of undeclared type or module
tx_input
error[E0433]: failed to resolve: use of undeclared type or module
tx_input
--> evmbin/./src/main.rs:237:7
|
237 | tx_input::json_default();
| ^^^^^^^^ use of undeclared type or module
tx_input
error[E0433]: failed to resolve: use of undeclared type or module
tx_input
--> evmbin/./src/main.rs:241:7
|
241 | tx_input::simple_default();
| ^^^^^^^^ use of undeclared type or module
tx_input
error[E0308]: mismatched types
--> evmbin/./src/info.rs:137:15
|
137 | informant: display::std_json::Informant::err_only(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter, found struct
display::std_json::Informant
|
= note: expected type
T
found type
display::std_json::Informant<std::io::Stderr, std::io::Stderr>
error[E0063]: missing fields
env_info
,fork_spec_name
,post_root
and 5 other fields in initializer ofinfo::TxInput<'_, _>
--> evmbin/./src/info.rs:136:3
|
136 | TxInput {
| ^^^^^^^ missing
env_info
,fork_spec_name
,post_root
and 5 other fieldserror[E0308]: mismatched types
--> evmbin/./src/info.rs:144:15
|
144 | informant: display::std_json::Informant::out_only(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter, found struct
display::std_json::Informant
|
= note: expected type
T
found type
display::std_json::Informant<std::io::Stdout, std::io::Stdout>
error[E0063]: missing fields
env_info
,fork_spec_name
,post_root
and 5 other fields in initializer ofinfo::TxInput<'_, _>
--> evmbin/./src/info.rs:143:3
|
143 | TxInput {
| ^^^^^^^ missing
env_info
,fork_spec_name
,post_root
and 5 other fieldserror[E0308]: mismatched types
--> evmbin/./src/info.rs:151:15
|
151 | informant: display::std_json::Informant::default(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter, found struct
display::std_json::Informant
|
= note: expected type
T
found type
display::std_json::Informant<std::io::Stderr, std::io::Stdout>
error[E0063]: missing fields
env_info
,fork_spec_name
,post_root
and 5 other fields in initializer ofinfo::TxInput<'_, _>
--> evmbin/./src/info.rs:150:3
|
150 | TxInput {
| ^^^^^^^ missing
env_info
,fork_spec_name
,post_root
and 5 other fieldserror[E0308]: mismatched types
--> evmbin/./src/info.rs:158:15
|
158 | informant: display::json::Informant::default(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter, found struct
display::json::Informant
|
= note: expected type
T
found type
display::json::Informant
error[E0063]: missing fields
env_info
,fork_spec_name
,post_root
and 5 other fields in initializer ofinfo::TxInput<'_, _>
--> evmbin/./src/info.rs:157:3
|
157 | TxInput {
| ^^^^^^^ missing
env_info
,fork_spec_name
,post_root
and 5 other fieldserror[E0308]: mismatched types
--> evmbin/./src/info.rs:165:15
|
165 | informant: display::simple::Informant::default(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter, found struct
display::simple::Informant
|
= note: expected type
T
found type
display::simple::Informant
error[E0063]: missing fields
env_info
,fork_spec_name
,post_root
and 5 other fields in initializer ofinfo::TxInput<'_, _>
--> evmbin/./src/info.rs:164:3
|
164 | TxInput {
| ^^^^^^^ missing
env_info
,fork_spec_name
,post_root
and 5 other fieldserror: aborting due to 20 previous errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
tx_input.spec
perhaps be namedfork_spec
(andspec_name
befork_spec_name
)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes great idea. I definitely think
fork_spec
is a better name than justspec
. Yes I think we should renamespec_name
tofork_spec_name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed commits with those changes in commits 2e17bb3 and b828e33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change strictly required for something? It seems you have to clone the spec anyway, so maybe better take it by value than by reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried what you recommended but I haven't been able to implement it successfully as it opened a can of worms. This is where I got to ed5e667
Compiling evmbin v0.1.0 (/home/ltfschoen/code/github/paritytech/parity-ethereum-master/evmbin) error[E0504]: cannot move `params` into closure because it is borrowed --> evmbin/./src/info.rs:95:34 | 94 | run(spec, trie_spec, ¶ms.gas, spec.genesis_state(), |mut client| { | ---------- borrow of `params.gas` occurs here 95 | let result = match client.call(params, &mut trace::NoopTracer, &mut informant) { | ^^^^^^ move into closure occurs here
error[E0504]: cannot move
tx_input
into closure because it is borrowed--> evmbin/./src/info.rs:153:43
|
152 | let result = run(&spec_checked, trie_spec, &tx_input.transaction.gas, &pre_state, |mut client| {
| -------------------- borrow of
tx_input.transaction
occurs here153 | let result = client.transact(&env_info, tx_input.transaction, trace::NoopTracer, tx_input.informant);
| ^^^^^^^^ move into closure occurs here
error[E0382]: capture of partially moved value:
tx_input
--> evmbin/./src/info.rs:153:43
|
136 | let TxInput { name, idx, spec, pre_state, post_root, env_info, trie_spec, .. } = tx_input;
| --------- value moved here
...
153 | let result = client.transact(&env_info, tx_input.transaction, trace::NoopTracer, tx_input.informant);
| ^^^^^^^^ value captured here after move
|
= note: move occurs because
tx_input.trie_spec
has typeethcore::TrieSpec
, which does not implement theCopy
traiterror: aborting due to 3 previous errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, if you destructure
tx_input
you can't really move it around. just destructuretransaction
as well and pass it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that worked, very slick! I've pushed changes in this commit 4b98474