Documentation ¶
Index ¶
- Constants
- Variables
- func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, ...) (sdk.Tx, error)
- func MergeBalances(balancesSlice ...[]banktypes.Balance) []banktypes.Balance
- func MustGetClientResponse[T Response](resp T, app QueryClient, req Request, url string) T
- func MustGetResponse[T Response](resp T, app QueryableApp, req Request, url string) (T, uint32)
- func MustGetResponseWithHeight[T Response](resp T, app QueryableApp, req Request, url string, height int64) T
- func MustIntFromString(s string) sdk.Int
- func MustUnmarshalResultData(codec codec.Codec, data []byte, ptr codec.ProtoMarshaler)
- func NewDefaultValidatorSet() *tmtypes.ValidatorSet
- func NewValidatorSet(count int) *tmtypes.ValidatorSet
- func QueryApp[T Response](resp T, app QueryClient, req Request, url string, height int64) (T, error)
- func UnmarshalResultData(codec codec.Codec, data []byte, ptr codec.ProtoMarshaler) error
- type AccountI
- type GenesisAccount
- type PeptideApp
- func (a *PeptideApp) Clone() *PeptideApp
- func (a *PeptideApp) CommitAndBeginNextBlock(timestamp eth.Uint64Quantity) *PeptideApp
- func (a *PeptideApp) CurrentHeader() *tmproto.Header
- func (a *PeptideApp) DefaultGenesis() app.GenesisState
- func (a *PeptideApp) ExportGenesis() app.GenesisState
- func (a *PeptideApp) GetAccount(addr sdk.AccAddress) AccountI
- func (a *PeptideApp) GetETH(addr sdk.AccAddress, height int64) (*sdkmath.Int, error)
- func (a *PeptideApp) ImportAppStateAndValidators(exported *servertypes.ExportedApp) abci.ResponseInitChain
- func (a *PeptideApp) Init(appState []byte, initialHeight int64, genesisTime time.Time) *tmproto.Header
- func (a *PeptideApp) InitChainWithEmptyGenesis() abci.ResponseInitChain
- func (a *PeptideApp) InitChainWithGenesisState(state app.GenesisState) abci.ResponseInitChain
- func (a *PeptideApp) InitChainWithGenesisStateAndHeight(state []byte, height int64) abci.ResponseInitChain
- func (a *PeptideApp) LastHeader() *tmproto.Header
- func (a *PeptideApp) MultiDelegationGenesis(genAccs []GenesisAccount, balances []banktypes.Balance, ...) app.GenesisState
- func (a *PeptideApp) MultiSignAndDeliverMsgs(signers []*SignerAccount, msgs ...sdk.Msg) (sdk.Tx, *sdk.Result, *sdk.GasInfo, error)
- func (a *PeptideApp) NewUncachedContextWithHeight(height int64) context.Context
- func (a *PeptideApp) NewUncachedSdkContext() sdk.Context
- func (a *PeptideApp) NewWrappedUncachedContext() context.Context
- func (a *PeptideApp) OnCommit(timestamp eth.Uint64Quantity)
- func (a *PeptideApp) ReportMetrics()
- func (a *PeptideApp) Resume(lastHeader *tmproto.Header, genesisState []byte) error
- func (a *PeptideApp) RollbackToHeight(height int64) error
- func (a *PeptideApp) RunMsgs(ctx sdk.Context, msgs ...sdk.Msg) (*sdk.Result, error)
- func (a *PeptideApp) SignAndDeliverMsgs(signer *SignerAccount, msgs ...sdk.Msg) (sdk.Tx, *sdk.Result, *sdk.GasInfo, error)
- func (a *PeptideApp) SignMsgs(signers []*SignerAccount, msg ...sdk.Msg) (sdk.Tx, error)
- func (a *PeptideApp) SimpleGenesis(genAccs SignerAccounts, valAccs SignerAccounts, balances ...banktypes.Balance) app.GenesisState
- func (a *PeptideApp) WrapSDKContext(ctx sdk.Context) context.Context
- type PeptideAppOptions
- type PrivKey
- type QueryClient
- type QueryableApp
- type Request
- type Response
- type SignerAccount
- type SignerAccounts
- type SingleDelegation
- type TxSigner
- type ValidatorDelegation
- type ValidatorSetDelegation
Constants ¶
const (
DefaultGenTxGas = 200000000
)
Variables ¶
var DefaultConsensusParams = &tmproto.ConsensusParams{ Block: &tmproto.BlockParams{ MaxBytes: 200000, MaxGas: 200000000, }, Evidence: &tmproto.EvidenceParams{ MaxAgeNumBlocks: 302400, MaxAgeDuration: 504 * time.Hour, MaxBytes: 10000, }, Validator: &tmproto.ValidatorParams{ PubKeyTypes: []string{ tmtypes.ABCIPubKeyTypeEd25519, }, }, }
Functions ¶
func GenTx ¶
func GenTx( gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, r *rand.Rand, signerAccounts ...*SignerAccount, ) (sdk.Tx, error)
GenTx generates a signed mock transaction. func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) {
func MustGetClientResponse ¶
func MustGetClientResponse[T Response](resp T, app QueryClient, req Request, url string) T
MustGetClientResponse is a helper function that sends a query to an abci query client and unmarshals the response into the provided response type. It panics if the query fails or if the response cannot be unmarshaled.
func MustGetResponse ¶
func MustGetResponse[T Response](resp T, app QueryableApp, req Request, url string) (T, uint32)
MustGetResponse is a helper function that sends a query to a chain App and unmarshals the response into the provided response type. It panics if the query fails or if the response cannot be unmarshaled.
func MustGetResponseWithHeight ¶
func MustGetResponseWithHeight[T Response](resp T, app QueryableApp, req Request, url string, height int64) T
MustGetResponseWithHeight is a helper function that sends a query to a chain App and unmarshals the response into the provided response type. It panics if the query fails or if the response cannot be unmarshaled.
func MustIntFromString ¶
func MustUnmarshalResultData ¶
func MustUnmarshalResultData(codec codec.Codec, data []byte, ptr codec.ProtoMarshaler)
MustUnmarshalResultData unmarshals sdk.Result data to a provided response type or panics.
func NewDefaultValidatorSet ¶
func NewDefaultValidatorSet() *tmtypes.ValidatorSet
NewDefaultValidatorSet returns a ValidatorSet with one random Validator
func NewValidatorSet ¶
func NewValidatorSet(count int) *tmtypes.ValidatorSet
NewValidatorSet returns a default ValidatorSet with `count` random Validators
func QueryApp ¶
func QueryApp[T Response](resp T, app QueryClient, req Request, url string, height int64) (T, error)
QueryApp is a helper function that sends a query to an abci query client and unmarshals the response into the provided response type. It returns the response and an error if the query fails or if the response cannot be unmarshaled.
func UnmarshalResultData ¶
UnmarshalResultData unmarshals sdk.Result data to a provided response type.
Types ¶
type GenesisAccount ¶
type GenesisAccount = authtypes.GenesisAccount
type PeptideApp ¶
type PeptideApp struct { // App is the ABCI-compatible App // TODO: IMPORT YOUR ABCI APP HERE *app.App ValSet *tmtypes.ValidatorSet EncodingConfig *params.EncodingConfig ChainId string BondDenom string VotingPowerReduction sdk.Int // contains filtered or unexported fields }
PeptideApp extends the ABCI-compatible App with additional op-stack L2 chain features
func NewWithOptions ¶
func NewWithOptions(options PeptideAppOptions, logger tmlog.Logger) *PeptideApp
New creates application instance with in-memory database and disabled logging.
func (*PeptideApp) Clone ¶
func (a *PeptideApp) Clone() *PeptideApp
Clone returns a new PeptideApp with genesis state from the current PeptideApp. The new app will have the same validator set `ValSet` as the current app. Note the new PeptideApp is not committed yet. Call CommitAndBeginBlock to commit.
Useful for testing module genesis export/import.
func (*PeptideApp) CommitAndBeginNextBlock ¶
func (a *PeptideApp) CommitAndBeginNextBlock(timestamp eth.Uint64Quantity) *PeptideApp
Commit pending changes to chain state and start a new block. Will error if there is no deliverState, eg. InitChain is not called before first block.
func (*PeptideApp) CurrentHeader ¶
func (a *PeptideApp) CurrentHeader() *tmproto.Header
CurrentHeader is the header that is being built, which is not committed yet
func (*PeptideApp) DefaultGenesis ¶
func (a *PeptideApp) DefaultGenesis() app.GenesisState
DefaultGenesis create a default GenesisState, which is a map with module name as keys and JSON-marshaled genesisState per module as values
func (*PeptideApp) ExportGenesis ¶
func (a *PeptideApp) ExportGenesis() app.GenesisState
ExportGenesis returns a copy of the app's genesis state
func (*PeptideApp) GetAccount ¶
func (a *PeptideApp) GetAccount(addr sdk.AccAddress) AccountI
Return account from committed state
func (*PeptideApp) GetETH ¶
func (a *PeptideApp) GetETH(addr sdk.AccAddress, height int64) (*sdkmath.Int, error)
GetETH returns the ETH balance of an account in wei
func (*PeptideApp) ImportAppStateAndValidators ¶
func (a *PeptideApp) ImportAppStateAndValidators( exported *servertypes.ExportedApp, ) abci.ResponseInitChain
ImportAppStateAndValidators imports the application state, init height, and validators from ExportedApp defined by the chain App
func (*PeptideApp) Init ¶
func (a *PeptideApp) Init(appState []byte, initialHeight int64, genesisTime time.Time) *tmproto.Header
This is what initiates the chain app initialisation. It's only meant to be called when the genesis is being sealed so the genesis block can be produced. - It triggers a call into the base app's InitChain() - Commits the app state to disk so it can be persisted across executions - Returns a "genesis header" with the genesis block height and app state hash
func (*PeptideApp) InitChainWithEmptyGenesis ¶
func (a *PeptideApp) InitChainWithEmptyGenesis() abci.ResponseInitChain
func (*PeptideApp) InitChainWithGenesisState ¶
func (a *PeptideApp) InitChainWithGenesisState(state app.GenesisState) abci.ResponseInitChain
func (*PeptideApp) InitChainWithGenesisStateAndHeight ¶
func (a *PeptideApp) InitChainWithGenesisStateAndHeight(state []byte, height int64) abci.ResponseInitChain
func (*PeptideApp) LastHeader ¶
func (a *PeptideApp) LastHeader() *tmproto.Header
LastHeader is the header that was committed, either as a genesis block header or the latest committed block header
func (*PeptideApp) MultiDelegationGenesis ¶
func (a *PeptideApp) MultiDelegationGenesis( genAccs []GenesisAccount, balances []banktypes.Balance, delegators SignerAccounts, validators SignerAccounts, delegations ValidatorSetDelegation, ) app.GenesisState
MultiDelegationGenesis creates a genesis with given genesis accounts `genAccs` and validators, and delegations. Each validator must be delegated with staking tokens ≥ 1 voting power, ie. a.ReductionVotingPower x 1. `delegations` must be the same length as `validators`, where its index is for validators.
func (*PeptideApp) MultiSignAndDeliverMsgs ¶
func (a *PeptideApp) MultiSignAndDeliverMsgs( signers []*SignerAccount, msgs ...sdk.Msg, ) (sdk.Tx, *sdk.Result, *sdk.GasInfo, error)
MultiSignAndDeliverMsgs signs a list of Msgs `msg` with multiple `signers`, and delivers it to the chain app
func (*PeptideApp) NewUncachedContextWithHeight ¶
func (a *PeptideApp) NewUncachedContextWithHeight(height int64) context.Context
Return a SDK context wrapped in Go context, which is required by GRPC handler
func (*PeptideApp) NewUncachedSdkContext ¶
func (a *PeptideApp) NewUncachedSdkContext() sdk.Context
Return a Cosmos-SDK context
func (*PeptideApp) NewWrappedUncachedContext ¶
func (a *PeptideApp) NewWrappedUncachedContext() context.Context
Return a SDK context wrapped in Go context, which is required by GRPC handler
func (*PeptideApp) OnCommit ¶
func (a *PeptideApp) OnCommit(timestamp eth.Uint64Quantity)
OnCommit updates the last header and current header after App Commit or InitChain
func (*PeptideApp) ReportMetrics ¶
func (a *PeptideApp) ReportMetrics()
func (*PeptideApp) Resume ¶
func (a *PeptideApp) Resume(lastHeader *tmproto.Header, genesisState []byte) error
Resume the normal activity after a (chain) restart. It sets the required pointers according to the last known header (that comes from the block store) and calls into the base app's BeginBlock()
func (*PeptideApp) RollbackToHeight ¶
func (a *PeptideApp) RollbackToHeight(height int64) error
Rolls back the app state (i.e. commit multi store from the base app) to the specified height (version) If successful, the latest committed version is that of "height"
func (*PeptideApp) RunMsgs ¶
RunMsgs execute a list of L1 Msgs that are not signed by any L2 account NOTE: these msgs must be executed at the beginning of a block, before any L2 txs are executed
Logic is similar to ABCI app tx execution, but adjusted for L1 deposit txs TODO: cache context in case of revert
func (*PeptideApp) SignAndDeliverMsgs ¶
func (a *PeptideApp) SignAndDeliverMsgs( signer *SignerAccount, msgs ...sdk.Msg, ) (sdk.Tx, *sdk.Result, *sdk.GasInfo, error)
SignAndDeliverMsgs signs a list of Msgs `msg` with a single `signer`, and delivers it to the chain app
func (*PeptideApp) SignMsgs ¶
func (a *PeptideApp) SignMsgs(signers []*SignerAccount, msg ...sdk.Msg) (sdk.Tx, error)
SignMsgs signs a list of Msgs `msg` with `signers`
func (*PeptideApp) SimpleGenesis ¶
func (a *PeptideApp) SimpleGenesis( genAccs SignerAccounts, valAccs SignerAccounts, balances ...banktypes.Balance, ) app.GenesisState
SimpleGenesis creates a genesis with given genesis accounts `genAccs` and one derived validator. The first genesis account is used for delegation with bond amount of 1 voting power.
`balances` should include staking tokens for all transactor accounts in `genAccs`. If left empty, `a.VotingPowerReduction` ie. 1 voting power worth staking tokens will be added for each account.
Validators are saved in `a.ValSet` for block production later.
func (*PeptideApp) WrapSDKContext ¶
func (a *PeptideApp) WrapSDKContext(ctx sdk.Context) context.Context
Convert a SDK context to Go context
type PeptideAppOptions ¶
type PrivKey ¶
type PrivKey = cryptotypes.PrivKey
type QueryClient ¶
type QueryClient interface {
QuerySync(req abci.RequestQuery) (*abci.ResponseQuery, error)
}
type QueryableApp ¶
type QueryableApp interface {
Query(req abci.RequestQuery) (res abci.ResponseQuery)
}
type SignerAccount ¶
type SignerAccount struct { GenesisAccount PrivKey }
func NewEd25519SignerAccount ¶
func NewEd25519SignerAccount(acctNumber, seqNumber uint64) *SignerAccount
NewEd25519SignerAccount creates a new SignerAccount with the given account number and sequence number baced by ed25519
func NewSecp256k1SignerAccount ¶
func NewSecp256k1SignerAccount(acctNumber, seqNumber uint64) *SignerAccount
NewSecp256k1SignerAccount creates a new SignerAccount with the given account number and sequence number
func NewSignerAccount ¶
func NewSignerAccount(genesisAccount GenesisAccount, privKey PrivKey) *SignerAccount
func (*SignerAccount) MarshalJSON ¶
func (sa *SignerAccount) MarshalJSON() ([]byte, error)
func (*SignerAccount) UnmarshalJSON ¶
func (sa *SignerAccount) UnmarshalJSON(bz []byte) error
type SignerAccounts ¶
type SignerAccounts []*SignerAccount
func NewSignerAccounts ¶
func NewSignerAccounts(n uint64, startingSeqNum uint64) SignerAccounts
NewSignerAccounts creates a list of Secp256k1 SignerAccount with the given number of accounts `n` and starting sequence number `startingSeqNum`
func NewValidatorSignerAccounts ¶
func NewValidatorSignerAccounts(n uint64, startingSeqNum uint64) SignerAccounts
NewSignerAccounts creates a list of ed25519 SignerAccount with the given number of accounts `n` and starting sequence number `startingSeqNum`
func (SignerAccounts) Addresses ¶
func (a SignerAccounts) Addresses() []string
Addresses return a slice of bech32 encoded addresses prefixed with `Bech32PrefixAccAddr`
func (SignerAccounts) GetGenesisAccounts ¶
func (a SignerAccounts) GetGenesisAccounts() []GenesisAccount
func (SignerAccounts) NewBalances ¶
type SingleDelegation ¶
type TxSigner ¶
type TxSigner struct {
// contains filtered or unexported fields
}
TxSigner represents a group of signers that can sign a transaction. all tx related configs can be cached and can be changed when needed.
func NewTxSigner ¶
func NewTxSigner( txConfig client.TxConfig, feeAmt sdk.Coins, gas uint64, chainID string, ) TxSigner
NewTxSigner creates a new TxSigner.
type ValidatorDelegation ¶
type ValidatorDelegation []SingleDelegation
type ValidatorSetDelegation ¶
type ValidatorSetDelegation []ValidatorDelegation