forked from celestiaorg/celestia-node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nodebuilder/state): Provide stubbed state module if a core endpo…
…int not provided (celestiaorg#2577) This is a pre-requisite for celestiaorg#2511 It makes a check in CoreAccessor constructor to see if a core endpoint was provided, and returns nil CoreAccessor if not. A stubbed state module will then be provided if no core endpoint was provided so that errors are more readable. Previously, node start logic relied on the fact that the grpc Dial inside CoreAccessor.Start was non-blocking so it could silently fail under the hood and any calls made on state Module would return errors from the inability to reach the address that is the default for the core config (which was confusing). (cherry picked from commit 13e9b1f)
- Loading branch information
Showing
10 changed files
with
167 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package state | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
"github.com/cosmos/cosmos-sdk/x/staking/types" | ||
|
||
"github.com/celestiaorg/celestia-node/blob" | ||
"github.com/celestiaorg/celestia-node/state" | ||
) | ||
|
||
var ErrNoStateAccess = errors.New("node is running without state access") | ||
|
||
// stubbedStateModule provides a stub for the state module to return | ||
// errors when state endpoints are accessed without a running connection | ||
// to a core endpoint. | ||
type stubbedStateModule struct{} | ||
|
||
func (s stubbedStateModule) IsStopped(context.Context) bool { | ||
return true | ||
} | ||
|
||
func (s stubbedStateModule) AccountAddress(context.Context) (state.Address, error) { | ||
return state.Address{}, ErrNoStateAccess | ||
} | ||
|
||
func (s stubbedStateModule) Balance(context.Context) (*state.Balance, error) { | ||
return nil, ErrNoStateAccess | ||
} | ||
|
||
func (s stubbedStateModule) BalanceForAddress( | ||
context.Context, | ||
state.Address, | ||
) (*state.Balance, error) { | ||
return nil, ErrNoStateAccess | ||
} | ||
|
||
func (s stubbedStateModule) Transfer( | ||
_ context.Context, | ||
_ state.AccAddress, | ||
_, _ state.Int, | ||
_ uint64, | ||
) (*state.TxResponse, error) { | ||
return nil, ErrNoStateAccess | ||
} | ||
|
||
func (s stubbedStateModule) SubmitTx(context.Context, state.Tx) (*state.TxResponse, error) { | ||
return nil, ErrNoStateAccess | ||
} | ||
|
||
func (s stubbedStateModule) SubmitPayForBlob( | ||
context.Context, | ||
state.Int, | ||
uint64, | ||
[]*blob.Blob, | ||
) (*state.TxResponse, error) { | ||
return nil, ErrNoStateAccess | ||
} | ||
|
||
func (s stubbedStateModule) CancelUnbondingDelegation( | ||
_ context.Context, | ||
_ state.ValAddress, | ||
_, _, _ state.Int, | ||
_ uint64, | ||
) (*state.TxResponse, error) { | ||
return nil, ErrNoStateAccess | ||
} | ||
|
||
func (s stubbedStateModule) BeginRedelegate( | ||
_ context.Context, | ||
_, _ state.ValAddress, | ||
_, _ state.Int, | ||
_ uint64, | ||
) (*state.TxResponse, error) { | ||
return nil, ErrNoStateAccess | ||
} | ||
|
||
func (s stubbedStateModule) Undelegate( | ||
_ context.Context, | ||
_ state.ValAddress, | ||
_, _ state.Int, | ||
_ uint64, | ||
) (*state.TxResponse, error) { | ||
return nil, ErrNoStateAccess | ||
} | ||
|
||
func (s stubbedStateModule) Delegate( | ||
_ context.Context, | ||
_ state.ValAddress, | ||
_, _ state.Int, | ||
_ uint64, | ||
) (*state.TxResponse, error) { | ||
return nil, ErrNoStateAccess | ||
} | ||
|
||
func (s stubbedStateModule) QueryDelegation( | ||
context.Context, | ||
state.ValAddress, | ||
) (*types.QueryDelegationResponse, error) { | ||
return nil, ErrNoStateAccess | ||
} | ||
|
||
func (s stubbedStateModule) QueryUnbonding( | ||
context.Context, | ||
state.ValAddress, | ||
) (*types.QueryUnbondingDelegationResponse, error) { | ||
return nil, ErrNoStateAccess | ||
} | ||
|
||
func (s stubbedStateModule) QueryRedelegations( | ||
_ context.Context, | ||
_, _ state.ValAddress, | ||
) (*types.QueryRedelegationsResponse, error) { | ||
return nil, ErrNoStateAccess | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters