Skip to content
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

[Stubbed] Greg/startup #71

Closed
wants to merge 10 commits into from
Closed

[Stubbed] Greg/startup #71

wants to merge 10 commits into from

Conversation

GregTheGreek
Copy link
Member

NOTE :: Most functionality is stubbed, but closely resembles what the end state should be. This will help to open up more functionalities, specifically surrounding state transitioning.

I began creating the start functionality. Currently, I have a stubbed start method that polls the eth1.x validator deposit contract. Once the ChainStart log is emitted a promise is returned to begin the rest of the beacon chain functionality.

Caveats (outside of stubbed functionality):

  • The polling needs to be continued for additional top ups or deposits. Potentially move current code into a helper for that.
  • There is a promise returned from the start(), this doesn't really make sense, but perhaps a .then() could suffice.

@CLAassistant
Copy link

CLAassistant commented Dec 31, 2018

CLA assistant check
All committers have signed the CLA.

@GregTheGreek GregTheGreek added this to In progress in Phase0 via automation Dec 31, 2018
Phase0 automation moved this from In progress to Needs review Dec 31, 2018
beaconChain/constants/constants.ts Outdated Show resolved Hide resolved
// Listen for Eth1Deposit logs
provider.on(depositFilter, (previousReceiptRoot: hash32[], data: DepositData, totalDepositcount: uint64, log) => {
const newDeposit: Deposit = formatDeposit(previousReceiptRoot, data, totalDepositcount);
deposits.push(newDeposit);
Copy link
Member

Choose a reason for hiding this comment

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

Whats the point of storing the deposits here? Should we maybe provide a function to allow their retrieval instead of discarding them in this code block?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure what you mean by discarding...
This is where classes could be very useful, and we can store to a state variable. But the objective here is we need to retrieve the deposits until chainstart emits then we take the formatted deposit[] and pass it to the next function in start to generate initial state

Copy link
Member

@ansermino ansermino Jan 1, 2019

Choose a reason for hiding this comment

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

Correct me if I'm wrong, deposits will only added until the ChainStart event resolves the promise. ie. future deposits won't be captured here. It does seem a class structure would be a way to resolve this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, that's why I created the deposits helper. Um unsure with the current spec at what point a new deposit needs to be captured. I.e what point in the state transition.

* intial state data.
* @returns {Promise<ChainStart>}
*/
const waitForChainStart = () => {
Copy link
Member

Choose a reason for hiding this comment

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

I think its plausible to test this functionality at this point, the notion of waiting for the ChainStart log isn't going to change. Please add tests if you agree.

Copy link
Member Author

@GregTheGreek GregTheGreek Dec 31, 2018

Choose a reason for hiding this comment

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

You know you're actually right. I'll probably have to import the vyper contract? Unless #66 gets closed

Copy link
Member

Choose a reason for hiding this comment

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

#66 has been closed

Copy link
Member Author

Choose a reason for hiding this comment

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

After some thought, you're right I can test this. The tests will only cover the actual chainstart functionality and not the deposits for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we want to add truffle/embark? Before continuing we'll need to discuss if we want a framework for testing smart contracts or not

Copy link
Member

Choose a reason for hiding this comment

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

What about etherlime? It uses ethers.

Copy link
Member Author

Choose a reason for hiding this comment

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

etherlime looks good. Still need to figure out what we want to do. Ultimately, we could do it manually.


// Smart contract addresses
export const MAINNET_DEPOSIT_ADDRESS = "0x0"; // Address for teh deposit function on ethereum.
export const DEPOSIT_CONTRACT_BLOCK_NUMBER = 5222222;
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain the use case for this?

Copy link
Member Author

@GregTheGreek GregTheGreek Dec 31, 2018

Choose a reason for hiding this comment

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

It actually should be stubbed to "tbd". But it's the block at which the contract is deployed, so we can start looking for receipts at that block number, and then work forward.

Will add comments

Copy link
Member

Choose a reason for hiding this comment

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

Isn't that what the ChainStart event is for? As I understand it deposits made after are still valid so I don't see the point in differentiating those made before and from those made after.

Copy link
Member Author

Choose a reason for hiding this comment

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

MMM good call. Pretty sure I added this earlier in the implementation

Copy link
Member Author

@GregTheGreek GregTheGreek Jan 1, 2019

Choose a reason for hiding this comment

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

Slight confusion, the ChainStart event is not for this. This is to reset to the block at which the contract is created at. This way we can begin looking at all deposits up to the ChainStart event.

As mentioned before, perhaps we need to re-org this a bit.

@GregTheGreek
Copy link
Member Author

Closing per #76 -- May use for spare parts later on

Phase0 automation moved this from Needs review to Done Jan 7, 2019
@ChainSafeSystems ChainSafeSystems deleted the greg/startup branch February 11, 2019 18:53
wemeetagain added a commit that referenced this pull request Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Phase0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants