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

Feature/etherman+synchronizer #4

Merged
merged 8 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions etherman/etherman.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package etherman

import (
"log"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/hermeznetwork/hermez-core/etherman/smartcontracts/proofofefficiency"
"github.com/hermeznetwork/hermez-core/state"
"github.com/ethereum/go-ethereum/ethclient"
)
type EtherMan struct {
EtherClient *ethclient.Client
PoE *proofofefficiency.Proofofefficiency
}

func NewEtherman(url string, poeAddr common.Address) (*EtherMan, error) {
//TODO
//Connect to ethereum node
ethClient, err := ethclient.Dial(url)
if err != nil {
log.Printf("error connecting to %s: %+v", url, err)
return nil, err
}
poe, err := proofofefficiency.NewProofofefficiency(poeAddr, ethClient)
if err != nil {
return nil, err
}

return &EtherMan{EtherClient: ethClient, PoE: poe}, nil
}

// EthBlockByNumber function retrieves the ethereum block information by ethereum block number
func (etherMan *EtherMan) EthBlockByNumber(blockNum int64) (types.Block, error) {
//TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

I strongly recommend replacing TODO with panic("not implemented yet")

return types.Block{}, nil
}

// GetBatchesByBlock function retrieves the batches information that are included in a specific ethereum block
func (etherMan *EtherMan) GetBatchesByBlock(blockNum int64) ([]state.Batch, error) {
//TODO
return []state.Batch{}, nil
}

// GetBatchesFromBlockTo function retrieves the batches information that are included in all this ethereum blocks
//from block x to block y
func (etherMan *EtherMan) GetBatchesFromBlockTo(fromBlock uint, toBlock uint) ([]state.Batch, error) {
//TODO
return []state.Batch{}, nil
}

// SendBatch function allows the sequencer send a new batch proposal to the rollup
func (etherMan *EtherMan) SendBatch(batch state.Batch) (common.Hash, error) {
//TODO
return common.Hash{}, nil
}

// ConsolidateBatch function allows the agregator send the proof for a batch and consolidate it
func (etherMan *EtherMan) ConsolidateBatch(batch state.Batch, proof state.Proof) (common.Hash, error) {
//TODO
return common.Hash{}, nil
}
Loading