-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add flag to init account state from genesis json file for fakenet #424
base: develop
Are you sure you want to change the base?
Conversation
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.
Let me explain the points:
... create test accounts and contracts at the beginning of the test, not by genesis.
Ethereum/hive uses that way along with genesis.json (see example). I just suggest to use single approach, not both.
... to see full account history in the test scenario and don't keep genesis state in mind.
The same idea described at ethereum/hive, and I don't know why they move some test contracts to the genesis.json as binary blobs without sources. Looks like ethreum/hive is immature yet.
So I prefer to change hive go-opera tests but don't change go-opera for testing.
Here is the some ready snippets for you :
- have a contract source;
- build it with
go generate
command; - deploy it;
- fund the test account by validator;
} | ||
|
||
func FakeGenesisStoreWithRulesAndStart(num idx.Validator, balance, stake *big.Int, rules opera.Rules, epoch idx.Epoch, block idx.Block) *genesisstore.Store { | ||
func FakeGenesisStoreWithRulesAndStart(num idx.Validator, balance, stake *big.Int, rules opera.Rules, epoch idx.Epoch, block idx.Block, g *core.Genesis) *genesisstore.Store { |
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.
No needs to use whole core.Genesis
when you need core.Genesis.Alloc
only.
Anyway ethreum core.Genesis
is foreign struct for go-opera, no reasons to use it at all. Let's keep fake genesis as simple as possible (i.e. as it is).
The way I suggest is create test accounts and contracts at the beginning of the test, not by genesis. It is more clean to see full account history in the test scenario and don't keep genesis state in mind.
okay, I understand your concern. By the way, I still open to change smth that can be easier for testing and much compatibility with hive-node to save effort to change smth big on hive go-opera. Currently, I just use the genesis for init account but we might need to add some rule config as well to test the fork/upgrade chain. I think they use contracts on genesis block as they noted here (tbh, I still cannot figure out why they need to fund account from a vault smart contract like that neither). using contract blob in genesis It's not kind of immature, it's supported by ethereum so they re-use in hive for testing purpose.
Deploy a new smart contract for testing is not hard, but the goal of the rpc test is to check the JSON RPC API only. And hive is end-2-end testing so we didn't do like unit test as snippets code. By the way, I change the PR as draft to discuss more and will update later. |
to more convenient for running testing by using fakenet, we introduce the
--init genesis.json
flag to be able allocate some account and pre-compiled contract for testing.the genesis json file example
to run fakenet with a genesis file