Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

fix setting author in setChainParams for --test mode #4922

Merged
merged 3 commits into from
Apr 4, 2018
Merged

Conversation

winsvega
Copy link
Contributor

when setChainParams was called. coinbase author was not reset correctly

@winsvega winsvega requested a review from axic March 29, 2018 12:40
@gumb0
Copy link
Member

gumb0 commented Mar 29, 2018

Interesting, could it fix RPC tests?

@@ -60,8 +60,9 @@ void ClientTest::setChainParams(string const& _genesis)
if (params.sealEngineName != "NoProof")
BOOST_THROW_EXCEPTION(ChainParamsNotNoProof() << errinfo_comment("Provided configuration is not well formatted."));

setAuthor(params.author); // Must be called before reopenChain !!!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why must it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see at reopenChain it replaces the author from m_preSeal.
so setAuthor would set an author for the m_preSeal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it should fix author for rpc tests. but we don't run that script anymore.

Copy link
Member

@gumb0 gumb0 Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this reopenChain is called only from here.
(also from Client::killChain() which looks to be not used and should be removed)

If so, set the author from params.author inside reopenChain instead of "backup and restore author" logic there

reopenChain(params, WithExisting::Kill);
setAuthor(params.author); //for some reason author is not being set
completeSync(); // set sync state to idle for mining
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this? What happens without it?

Copy link
Contributor Author

@winsvega winsvega Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this. sync state is not being set to idle (sometimes) and test_mineblock does not work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function doesn't do anything related to the sync, I don't think it's the right place for this... Can you maybe move it up the stack, to where setChainParams() is called? (comleteSync() is a public method)

Copy link
Contributor Author

@winsvega winsvega Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

completeSync does not do anything related to Sync ?
anyway without this function the sync state is not idle and new blocks not being mined in test mode.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant not completeSync but setChainParams

@codecov-io
Copy link

codecov-io commented Mar 29, 2018

Codecov Report

Merging #4922 into develop will decrease coverage by 1.96%.
The diff coverage is 92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #4922      +/-   ##
==========================================
- Coverage    60.56%   58.6%   -1.97%     
==========================================
  Files          349     348       -1     
  Lines        28218   23715    -4503     
  Branches      2895    2720     -175     
==========================================
- Hits         17089   13897    -3192     
+ Misses       10160    8905    -1255     
+ Partials       969     913      -56

h->reset();
h->completeSync(); // set sync state to idle for mining
Copy link
Contributor Author

@winsvega winsvega Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gumb0 this looks like kostil` around m_state variable that must be set to Idle. but I am afraid that changing it in internal funcs might break the client.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You move it down the stack instead of up the stack, as I asked. This is probably even worse.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is setChainParams called for your case? Can you put completeSync call there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setChainParams is test client method. so the best place is to keep it where it was. or make it a separate method of the test client. (which is unnecessary)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already ClientTest::completeSync(), you could call it from from RPC method implementation Test::test_setChainParams() (add asClientTest(m_eth).completeSync(); there), similar to what happens in Test::test_rewindToBlock(). It still would be ugly, but less so.

Starting eth --test doesn't enable sync by itself, can you find out at which moment does it become enabled? (the stack where BlockChainSync::m_state changes)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the moment where it changes is strange. it works for 1 time and then it set to notSynced after blockchain reset.

@chfast
Copy link
Member

chfast commented Mar 30, 2018

Why nobody is adding unit tests along with the fixes?

@gumb0
Copy link
Member

gumb0 commented Apr 3, 2018

Yeah, maybe try to to create a unit test for Client::reopenChain
We don't have any for test mode-specific functions though, I think

@chfast
Copy link
Member

chfast commented Apr 3, 2018

Can you also squash commits before merging?

using namespace dev::p2p;
namespace fs = boost::filesystem;

std::unique_ptr<dev::WebThreeDirect> g_web3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you make it global and not the member of the fixture class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how to access fixture from the test case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test cases are methods of the fixture.

Copy link
Member

@gumb0 gumb0 Apr 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ this or more likely methods of a subclass of a fixture class, so you would access web3 member just like web3 (it should be public or protected)

@gumb0
Copy link
Member

gumb0 commented Apr 3, 2018

Please convert all tabs to spaces in libweb3jsonrpc/Test.cpp

@winsvega
Copy link
Contributor Author

winsvega commented Apr 3, 2018

huh set author still does not work on mac

You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file ClientTest.cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add this. There is no information added with this comment.

@winsvega
Copy link
Contributor Author

winsvega commented Apr 4, 2018

@chfast the test was failing on macOS when the web3 was declared as global variable in cpp.
when I moved it into the class it seems to work.

@chfast
Copy link
Member

chfast commented Apr 4, 2018

RandomCodeTests/rndStateTest (Failed)

Copy link
Member

@chfast chfast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, but check out the failing tests.

@winsvega
Copy link
Contributor Author

winsvega commented Apr 4, 2018

random test failure is a bug. sometimes gasLimit is wrong and transaction is not being executed. thus post state check errors out. better fix in a separate PR

@winsvega winsvega merged commit 740da50 into develop Apr 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants