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): handleCandidateBacked signal #4364

Open
wants to merge 48 commits into
base: feat/parachain
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 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
e9b4852
feature: implement HandleIntroduceSecondedCandidate
rebonat0 Nov 28, 2024
15feb1b
progress: started tests
rebonat0 Nov 28, 2024
fe27ee3
added test case example
rebonat0 Nov 28, 2024
a8960d8
implement HandleIntroduceSecondedCandidate on processMessage
rebonat0 Nov 28, 2024
a53f150
added tests
rebonat0 Nov 28, 2024
038dfce
added new view instance on NewProspectiveParachains
rebonat0 Nov 28, 2024
0465a41
added more test scenarios
rebonat0 Nov 28, 2024
5abd1e3
chore: fix loop conditional
EclesioMeloJunior Dec 3, 2024
9c6cc56
feat: implement candidate backed
viniciussiqueir4 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
1835388
Merge branch 'feat/parachain' into eclesio/fragment-chain-impl
EclesioMeloJunior Jan 6, 2025
ee66827
chore: adjust types
EclesioMeloJunior Jan 6, 2025
3ba5603
chore: nolint unused funcs
EclesioMeloJunior Jan 6, 2025
c6884a0
chore: merge upstream:eclesio-fragment-chain-impl
viniciussiqueir4 Jan 31, 2025
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
214 changes: 214 additions & 0 deletions dot/parachain/prospective-parachains/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
package prospectiveparachains

import (
"errors"
"fmt"

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

var (
errCandidateAlreadyKnown = errors.New("candidate already known")
errZeroLengthCycle = errors.New("candidate's parent head is equal to its output head. Would introduce a cycle") //nolint:lll
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") //nolint:lll,unused
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") //nolint:lll
errPersistedValidationDataMismatch = errors.New("candidate does not match the persisted validation data provided alongside it") //nolint:lll
errAppliedNonexistentCodeUpgrade = errors.New("applied non existent code upgrade")
errDmpAdvancementRule = errors.New("dmp advancement rule")
errCodeUpgradeRestricted = errors.New("code upgrade restricted")
)

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 parachaintypes.BlockNumber
// The previous seen block number, which did not match `number`.
prev parachaintypes.BlockNumber
}

func (e errUnexpectedAncestor) Error() string {
return fmt.Sprintf("unexpected ancestor %d, expected %d", e.number, e.prev)
}

type errDisallowedHrmpWatermark struct {
BlockNumber parachaintypes.BlockNumber
}

func (e *errDisallowedHrmpWatermark) Error() string {
return fmt.Sprintf("DisallowedHrmpWatermark(BlockNumber: %d)", e.BlockNumber)
}

type errNoSuchHrmpChannel struct {
paraID parachaintypes.ParaID
}

func (e *errNoSuchHrmpChannel) Error() string {
return fmt.Sprintf("NoSuchHrmpChannel(ParaId: %d)", e.paraID)
}

type errHrmpMessagesOverflow struct {
paraID parachaintypes.ParaID
messagesRemaining uint32
messagesSubmitted uint32
}

func (e *errHrmpMessagesOverflow) Error() string {
return fmt.Sprintf("HrmpMessagesOverflow(ParaId: %d, MessagesRemaining: %d, MessagesSubmitted: %d)",
e.paraID, e.messagesRemaining, e.messagesSubmitted)
}

type errHrmpBytesOverflow struct {
paraID parachaintypes.ParaID
bytesRemaining uint32
bytesSubmitted uint32
}

func (e *errHrmpBytesOverflow) Error() string {
return fmt.Sprintf("HrmpBytesOverflow(ParaId: %d, BytesRemaining: %d, BytesSubmitted: %d)",
e.paraID, e.bytesRemaining, e.bytesSubmitted)
}

type errUmpMessagesOverflow struct {
messagesRemaining uint32
messagesSubmitted uint32
}

func (e *errUmpMessagesOverflow) Error() string {
return fmt.Sprintf("UmpMessagesOverflow(MessagesRemaining: %d, MessagesSubmitted: %d)",
e.messagesRemaining, e.messagesSubmitted)
}

type errUmpBytesOverflow struct {
bytesRemaining uint32
bytesSubmitted uint32
}

func (e *errUmpBytesOverflow) Error() string {
return fmt.Sprintf("UmpBytesOverflow(BytesRemaining: %d, BytesSubmitted: %d)", e.bytesRemaining, e.bytesSubmitted)
}

type errDmpMessagesUnderflow struct {
messagesRemaining uint32
messagesProcessed uint32
}

func (e *errDmpMessagesUnderflow) Error() string {
return fmt.Sprintf("DmpMessagesUnderflow(MessagesRemaining: %d, MessagesProcessed: %d)",
e.messagesRemaining, e.messagesProcessed)
}

type errValidationCodeMismatch struct {
expected parachaintypes.ValidationCodeHash
got parachaintypes.ValidationCodeHash
}

func (e *errValidationCodeMismatch) Error() string {
return fmt.Sprintf("ValidationCodeMismatch(Expected: %v, Got: %v)", e.expected, e.got)
}

type errOutputsInvalid struct {
ModificationError error
}

func (e *errOutputsInvalid) Error() string {
return fmt.Sprintf("OutputsInvalid(ModificationError: %v)", e.ModificationError)
}

type errCodeSizeTooLarge struct {
maxAllowed uint32
newSize uint32
}

func (e *errCodeSizeTooLarge) Error() string {
return fmt.Sprintf("CodeSizeTooLarge(MaxAllowed: %d, NewSize: %d)", e.maxAllowed, e.newSize)
}

type errRelayParentTooOld struct {
minAllowed parachaintypes.BlockNumber
current parachaintypes.BlockNumber
}

func (e *errRelayParentTooOld) Error() string {
return fmt.Sprintf("RelayParentTooOld(MinAllowed: %d, Current: %d)", e.minAllowed, e.current)
}

type errUmpMessagesPerCandidateOverflow struct {
messagesAllowed uint32
messagesSubmitted uint32
}

func (e *errUmpMessagesPerCandidateOverflow) Error() string {
return fmt.Sprintf("UmpMessagesPerCandidateOverflow(MessagesAllowed: %d, MessagesSubmitted: %d)",
e.messagesAllowed, e.messagesSubmitted)
}

type errHrmpMessagesPerCandidateOverflow struct {
messagesAllowed uint32
messagesSubmitted uint32
}

func (e *errHrmpMessagesPerCandidateOverflow) Error() string {
return fmt.Sprintf("HrmpMessagesPerCandidateOverflow(MessagesAllowed: %d, MessagesSubmitted: %d)",
e.messagesAllowed, e.messagesSubmitted)
}

type errHrmpMessagesDescendingOrDuplicate struct {
index uint
}

func (e *errHrmpMessagesDescendingOrDuplicate) Error() string {
return fmt.Sprintf("HrmpMessagesDescendingOrDuplicate(Index: %d)", e.index)
}
Loading
Loading