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

feat(prospective-parachains): Implement FragmentChain #4337

Open
wants to merge 36 commits into
base: feat/parachain
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
afa3e68
feat: starting the fragment chain implementation
EclesioMeloJunior Nov 11, 2024
404f5fe
feat: implemented `CandidateStorage`
EclesioMeloJunior Nov 12, 2024
6648464
feat: create `Scope`, working on inclusionemulator.Fragment
EclesioMeloJunior Nov 13, 2024
5119649
wip: implementing `validateAgainstConstraints`
EclesioMeloJunior Nov 14, 2024
e072160
feat: implement `BackedChain`
EclesioMeloJunior Nov 14, 2024
0de059a
wip: `FragmentChain` struct implementation
EclesioMeloJunior Nov 15, 2024
0388b02
feat: full `FragmentChain` implementation done
EclesioMeloJunior Nov 16, 2024
1b796b8
chore: wip fragment chain tests
EclesioMeloJunior Nov 19, 2024
f11ee4f
chore: `TestPopulateAndCheckPotential` done
EclesioMeloJunior Nov 21, 2024
6a001c8
feat: bring polkadot-sdk test coverage to fragment chain
EclesioMeloJunior Nov 21, 2024
6b30bc6
chore: remove dsstore
EclesioMeloJunior Nov 26, 2024
5f01ccb
chore: change loopt
EclesioMeloJunior Nov 28, 2024
987c880
Merge branch 'feat/parachain' into eclesio/fragment-chain-impl
EclesioMeloJunior Nov 28, 2024
5abd1e3
chore: fix loop conditional
EclesioMeloJunior Dec 3, 2024
54e0adb
chore: address comment
EclesioMeloJunior Dec 5, 2024
78dfef1
chore: address comments
EclesioMeloJunior Dec 6, 2024
e55b6ce
chore: test snakecase
EclesioMeloJunior Dec 6, 2024
2f60868
wip: fixing failing tests
EclesioMeloJunior Dec 6, 2024
041f161
chore: fix `TestScopeOnlyTakesAncestorsUpToMin` test
EclesioMeloJunior Dec 9, 2024
082bb9c
chore: loop until maxDepth + 1
EclesioMeloJunior Dec 9, 2024
153b7d6
Merge branch 'feat/parachain' into eclesio/fragment-chain-impl
EclesioMeloJunior Dec 9, 2024
7d716c7
chore: gofmt
EclesioMeloJunior Dec 9, 2024
1dfeb76
chore: address lint warns
EclesioMeloJunior Dec 9, 2024
ba8ede8
chore: removed `Unconnected` method
EclesioMeloJunior Dec 10, 2024
ef35ba9
chore: remove `candidates` method
EclesioMeloJunior Dec 10, 2024
6e28164
chore: added logs
EclesioMeloJunior Dec 10, 2024
b65841c
Merge branch 'feat/parachain' into eclesio/fragment-chain-impl
EclesioMeloJunior Dec 10, 2024
30062cf
chore: address comments
EclesioMeloJunior Dec 12, 2024
8d80d2d
Merge branch 'eclesio/fragment-chain-impl' of github.com:ChainSafe/go…
EclesioMeloJunior Dec 12, 2024
e484624
Merge branch 'feat/parachain' into eclesio/fragment-chain-impl
EclesioMeloJunior Dec 12, 2024
42a7345
chore: fix misspelling
EclesioMeloJunior Dec 12, 2024
87e096c
Merge branch 'eclesio/fragment-chain-impl' of github.com:ChainSafe/go…
EclesioMeloJunior Dec 12, 2024
71085e7
chore: make types unexported
EclesioMeloJunior Dec 12, 2024
da18a0b
Trigger Build
EclesioMeloJunior Dec 13, 2024
d16b056
chore: addressing comments
EclesioMeloJunior Dec 14, 2024
e5d8019
chore: small comments
EclesioMeloJunior Dec 14, 2024
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
82 changes: 82 additions & 0 deletions dot/parachain/prospective-parachains/fragment-chain/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package fragmentchain

import (
"errors"
"fmt"

parachaintypes "github.com/ChainSafe/gossamer/dot/parachain/types"
"github.com/ChainSafe/gossamer/lib/common"
)

var (
ErrCandidateAlradyKnown = errors.New("candidate already known")
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
ErrZeroLengthCycle = errors.New("candidate's parent head is equal to its output head. Would introduce a cycle")
ErrCycle = errors.New("candidate would introduce a cycle")
ErrMultiplePaths = errors.New("candidate would introduce two paths to the same output state")
ErrIntroduceBackedCandidate = errors.New("attempting to directly introduce a Backed candidate. It should first be introduced as Seconded")
ErrParentCandidateNotFound = errors.New("could not find parent of the candidate")
ErrRelayParentMovedBackwards = errors.New("relay parent would move backwards from the latest candidate in the chain")
ErrPersistedValidationDataMismatch = errors.New("candidate does not match the persisted validation data provided alongside it")
ErrCandidateEntryZeroLengthCycle = errors.New("candidate's parent head is equal to its output head. Would introduce a cycle")
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
)

type ErrRelayParentPrecedesCandidatePendingAvailability struct {
relayParentA, relayParentB common.Hash
}

func (e ErrRelayParentPrecedesCandidatePendingAvailability) Error() string {
return fmt.Sprintf("relay parent %x of the candidate precedes the relay parent %x of a pending availability candidate",
e.relayParentA, e.relayParentB)
}

type ErrForkWithCandidatePendingAvailability struct {
candidateHash parachaintypes.CandidateHash
}

func (e ErrForkWithCandidatePendingAvailability) Error() string {
return fmt.Sprintf("candidate would introduce a fork with a pending availability candidate: %x", e.candidateHash.Value)
}

type ErrForkChoiceRule struct {
candidateHash parachaintypes.CandidateHash
}

func (e ErrForkChoiceRule) Error() string {
return fmt.Sprintf("fork selection rule favours another candidate: %x", e.candidateHash.Value)
}

type ErrComputeConstraints struct {
modificationErr error
}

func (e ErrComputeConstraints) Error() string {
return fmt.Sprintf("could not compute candidate constraints: %s", e.modificationErr)
}

type ErrCheckAgainstConstraints struct {
fragmentValidityErr error
}

func (e ErrCheckAgainstConstraints) Error() string {
return fmt.Sprintf("candidate violates constraints: %s", e.fragmentValidityErr)
}

type ErrRelayParentNotInScope struct {
relayParentA, relayParentB common.Hash
}

func (e ErrRelayParentNotInScope) Error() string {
return fmt.Sprintf("relay parent %s not in scope, earliest relay parent allowed %s",
e.relayParentA.String(), e.relayParentB.String())
}

type ErrUnexpectedAncestor struct {
// The block number that this error occurred at
Number uint
// The previous seen block number, which did not match `number`.
Prev uint
}

func (e ErrUnexpectedAncestor) Error() string {
return fmt.Sprintf("unexpected ancestor %d, expected %d", e.Number, e.Prev)
}
Loading
Loading