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

Sokol v0: support for first epoch-set transition #2411

Merged
merged 28 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3557c42
broadcast local txs
AskAlexSharov Jul 13, 2021
d63ddc6
Merge branch 'devel' into sokol10
AskAlexSharov Jul 14, 2021
79e0b92
finality checker works
AskAlexSharov Jul 14, 2021
bdc6a27
finality checker works
AskAlexSharov Jul 14, 2021
0a36ac3
Merge branch 'devel' into sokol10
AskAlexSharov Jul 14, 2021
07f0a23
Merge branch 'devel' into sokol10
AskAlexSharov Jul 15, 2021
c3ee02f
Merge branch 'devel' into sokol10
AskAlexSharov Jul 15, 2021
f2a4db3
fix
AskAlexSharov Jul 15, 2021
8022a14
fix finalization
AskAlexSharov Jul 15, 2021
dd934e3
Merge branch 'devel' into sokol10
AskAlexSharov Jul 16, 2021
2a59ffa
save
AskAlexSharov Jul 16, 2021
fe414eb
merge devel
AskAlexSharov Jul 17, 2021
f64ad48
Merge branch 'devel' into sokol10
AskAlexSharov Jul 17, 2021
c083870
lint
AskAlexSharov Jul 17, 2021
14a0cd3
clean
AskAlexSharov Jul 17, 2021
808600c
clean
AskAlexSharov Jul 17, 2021
a1b5648
remove builder
AskAlexSharov Jul 17, 2021
10e0770
save
AskAlexSharov Jul 17, 2021
1732262
build finality never returns error
AskAlexSharov Jul 17, 2021
e91436a
Merge branch 'devel' into sokol10
AskAlexSharov Jul 17, 2021
7e96672
Merge branch 'devel' into sokol10
AskAlexSharov Jul 18, 2021
e9e6591
Merge branch 'devel' into sokol10
AskAlexSharov Jul 20, 2021
67785d0
merge devels
AskAlexSharov Jul 21, 2021
bd07fe3
Merge branch 'devel' into sokol10
AskAlexSharov Jul 21, 2021
1d53873
save
AskAlexSharov Jul 21, 2021
b374414
Merge branch 'devel' into sokol10
AskAlexSharov Jul 21, 2021
8bf5014
implement epoch-set transition
AskAlexSharov Jul 21, 2021
11fbe9c
implement epoch-set transition
AskAlexSharov Jul 21, 2021
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
Prev Previous commit
Next Next commit
lint
  • Loading branch information
AskAlexSharov committed Jul 17, 2021
commit c08387083858bb9b726aef208e71d9f437d27e91
2 changes: 1 addition & 1 deletion cmd/hack/hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -2321,7 +2321,7 @@ func runBlock(ibs *state.IntraBlockState, txnWriter state.StateWriter, blockWrit

if !vmConfig.ReadOnly {
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
if _, err := engine.FinalizeAndAssemble(chainConfig, header, ibs, block.Transactions(), block.Uncles(), receipts, nil, nil, nil); err != nil {
if _, err := engine.FinalizeAndAssemble(chainConfig, header, ibs, block.Transactions(), block.Uncles(), receipts, nil, nil, nil, nil); err != nil {
return nil, fmt.Errorf("finalize of block %d failed: %v", block.NumberU64(), err)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/state/commands/opcode_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ func runBlock(ibs *state.IntraBlockState, txnWriter state.StateWriter, blockWrit

if !vmConfig.ReadOnly {
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
if _, err := engine.FinalizeAndAssemble(chainConfig, header, ibs, block.Transactions(), block.Uncles(), receipts, nil, nil, nil); err != nil {
if _, err := engine.FinalizeAndAssemble(chainConfig, header, ibs, block.Transactions(), block.Uncles(), receipts, nil, nil, nil, nil); err != nil {
return nil, fmt.Errorf("finalize of block %d failed: %v", block.NumberU64(), err)
}

Expand Down
9 changes: 9 additions & 0 deletions consensus/aura/aura.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ func epochTransitionFor2(chain consensus.ChainHeaderReader, e consensus.EpochRea
}
return EpochTransition{BlockNumber: num, BlockHash: hash, ProofRlp: transitionProof}, true
}

//nolint
func epochTransitionFor(chain consensus.ChainHeaderReader, e consensus.EpochReader, parentHash common.Hash) (transition EpochTransition, ok bool) {
// slow path: loop back block by block
for {
Expand Down Expand Up @@ -541,22 +543,26 @@ func (c *AuRa) VerifyFamily(chain consensus.ChainHeaderReader, header *types.Hea
func (c *AuRa) verifyFamily(chain consensus.ChainHeaderReader, e consensus.EpochReader, header *types.Header, call consensus.Call) error {
// TODO: I call it from Initialize - because looks like no much reason to have separated "verifyFamily" call

//nolint
step, err := headerStep(header)
if err != nil {
return err
}
parent := chain.GetHeader(header.ParentHash, header.Number.Uint64()-1)
//nolint
parentStep, err := headerStep(parent)
if err != nil {
return err
}
//nolint
validators, setNumber, err := c.epochSet(chain, e, header, call)
if err != nil {
return err
}
return nil

// Ensure header is from the step after parent.
//nolint
if step == parentStep ||
(header.Number.Uint64() >= c.cfg.ValidateStepTransition && step <= parentStep) {
log.Debug("[engine] Multiple blocks proposed for step", "num", parentStep)
Expand Down Expand Up @@ -865,6 +871,9 @@ func (c *AuRa) Finalize(cc *params.ChainConfig, header *types.Header, state *sta
// check_and_lock_block -> check_epoch_end_signal END

finalized, err := buildFinality(c.EpochManager, chain, e, c.cfg.Validators, header, call)
if err != nil {
return err
}
epochEndProof, err := isEpochEnd(chain, e, finalized, header)
if err != nil {
return err
Expand Down
7 changes: 6 additions & 1 deletion consensus/aura/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ type ReportQueueItem struct {
blockNum uint64
data []byte
}

//nolint
type ReportQueue struct {
sync.RWMutex
list *list.List
Expand All @@ -354,7 +356,7 @@ func (q *ReportQueue) push(addr common.Address, blockNum uint64, data []byte) {
}

// Filters reports of validators that have already been reported or are banned.

//nolint
func (q *ReportQueue) filter(abi aurainterfaces.ValidatorSetABI, client client, ourAddr, contractAddr common.Address) error {
q.Lock()
defer q.Unlock()
Expand Down Expand Up @@ -384,6 +386,7 @@ func (q *ReportQueue) filter(abi aurainterfaces.ValidatorSetABI, client client,
}

// Removes reports from the queue if it contains more than `MAX_QUEUED_REPORTS` entries.
//nolint
func (q *ReportQueue) truncate() {
// The maximum number of reports to keep queued.
const MaxQueuedReports = 10
Expand Down Expand Up @@ -439,6 +442,7 @@ func NewValidatorSafeContract(contractAddress common.Address, posdaoTransition *
//
// Returns a list of contract calls to be pushed onto the new block.
//func generateEngineTransactions(_first bool, _header *types.Header, _call SystemCall) -> Result<Vec<(Address, Bytes)>, EthcoreError>
//nolint
func (s *ValidatorSafeContract) epochSet2(num uint64, chain consensus.ChainHeaderReader, call consensus.Call) (SimpleList, common.Hash, error) {
l, ok := s.getList(call)
if !ok {
Expand Down Expand Up @@ -512,6 +516,7 @@ func (s *ValidatorSafeContract) epochSet(first bool, num uint64, setProof []byte
}

// check a first proof: fetch the validator set at the given block.
//nolint
func checkFirstValidatorSetProof(contract_address common.Address, oldHeader *types.Header, dbItems [][]byte) ([]common.Address, error) {
/*
fn check_first_proof(
Expand Down