-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix setting author in setChainParams for --test mode #4922
Conversation
Interesting, could it fix RPC tests? |
libethereum/ClientTest.cpp
Outdated
@@ -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 !!! |
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.
Why must 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.
see at reopenChain it replaces the author from m_preSeal.
so setAuthor would set an author for the m_preSeal
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 it should fix author for rpc tests. but we don't run that script anymore.
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.
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
libethereum/ClientTest.cpp
Outdated
reopenChain(params, WithExisting::Kill); | ||
setAuthor(params.author); //for some reason author is not being set | ||
completeSync(); // set sync state to idle for mining |
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.
Why this? What happens without 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.
without this. sync state is not being set to idle (sometimes) and test_mineblock does not work
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.
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)
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.
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.
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 meant not completeSync
but setChainParams
Codecov Report
@@ 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 |
libethereum/Client.cpp
Outdated
h->reset(); | ||
h->completeSync(); // set sync state to idle for mining |
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.
@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.
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.
You move it down the stack instead of up the stack, as I asked. This is probably even worse.
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.
Where is setChainParams
called for your case? Can you put completeSync
call there?
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.
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)
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.
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)
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.
the moment where it changes is strange. it works for 1 time and then it set to notSynced after blockchain reset.
Why nobody is adding unit tests along with the fixes? |
Yeah, maybe try to to create a unit test for |
Can you also squash commits before merging? |
using namespace dev::p2p; | ||
namespace fs = boost::filesystem; | ||
|
||
std::unique_ptr<dev::WebThreeDirect> g_web3; |
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.
Why do you make it global and not the member of the fixture class?
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.
how to access fixture from the test case?
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.
test cases are methods of the fixture.
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.
^ 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)
Please convert all tabs to spaces in |
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 |
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.
Don't add this. There is no information added with this comment.
convert tabs to spaces in Test.cpp
@chfast the test was failing on macOS when the web3 was declared as global variable in cpp. |
|
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.
Code looks good, but check out the failing tests.
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 |
when setChainParams was called. coinbase author was not reset correctly