Documentation ¶
Index ¶
- Variables
- func CanyonTimeOffset() *hexutil.Uint64
- func CollectAddresses(sd *SetupData, dp *DeployParams) (out []common.Address)
- func EncodePrivKey(priv *ecdsa.PrivateKey) hexutil.Bytes
- func EncodePrivKeyToString(priv *ecdsa.PrivateKey) string
- func Ether(v uint64) *big.Int
- func SystemConfigFromDeployConfig(deployConfig *genesis.DeployConfig) eth.SystemConfig
- func TimeoutCtx(t *testing.T, timeout time.Duration) context.Context
- func WaitBlock(ctx context.Context, client *ethclient.Client, n uint64) error
- func WaitFor(ctx context.Context, rate time.Duration, cb func() (bool, error)) error
- func WaitForSafeHead(ctx context.Context, safeBlockNum uint64, rollupClient *sources.RollupClient) error
- func WaitReceipt(ctx context.Context, client *ethclient.Client, hash common.Hash, status uint64) (*types.Receipt, error)
- func WaitReceiptFail(ctx context.Context, client *ethclient.Client, hash common.Hash) (*types.Receipt, error)
- func WaitReceiptOK(ctx context.Context, client *ethclient.Client, hash common.Hash) (*types.Receipt, error)
- func WriteDefaultJWT(t TestingBase) string
- type Addresses
- type AllocParams
- type DeployParams
- type Fetcher
- type HonestL2RPC
- func (m *HonestL2RPC) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error
- func (m *HonestL2RPC) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
- func (m *HonestL2RPC) Close()
- func (m *HonestL2RPC) EthSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (ethereum.Subscription, error)
- func (m *HonestL2RPC) SetTargetBlockNumber(lastValidBlockNumber uint64)
- type MaliciousL2RPC
- func (m *MaliciousL2RPC) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error
- func (m *MaliciousL2RPC) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
- func (m *MaliciousL2RPC) Close()
- func (m *MaliciousL2RPC) EthSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (ethereum.Subscription, error)
- func (m *MaliciousL2RPC) SetTargetBlockNumber(lastValidBlockNumber uint64)
- type MnemonicConfig
- type Secrets
- type SetupData
- type TestParams
- type TestingBase
Constants ¶
This section is empty.
Variables ¶
var DefaultMnemonicConfig = &MnemonicConfig{
Mnemonic: "test test test test test test test test test test test junk",
CliqueSigner: "m/44'/60'/0'/0/0",
TrustedValidator: "m/44'/60'/0'/0/1",
Batcher: "m/44'/60'/0'/0/2",
Deployer: "m/44'/60'/0'/0/3",
Alice: "m/44'/60'/0'/0/4",
SequencerP2P: "m/44'/60'/0'/0/5",
Bob: "m/44'/60'/0'/0/7",
Mallory: "m/44'/60'/0'/0/8",
SysCfgOwner: "m/44'/60'/0'/0/0",
Challenger1: "m/44'/60'/0'/0/11",
Challenger2: "m/44'/60'/0'/0/12",
}
DefaultMnemonicConfig is the default mnemonic used in testing. We prefer a mnemonic rather than direct private keys to make it easier to export all testing keys in external tooling for use during debugging. If these values are changed, it is subject to breaking tests. They must be in sync with the values in the DeployConfig used to create the system.
Functions ¶
func CanyonTimeOffset ¶ added in v1.2.0
func CollectAddresses ¶
func CollectAddresses(sd *SetupData, dp *DeployParams) (out []common.Address)
CollectAddresses constructs a lists of addresses that may be used as fuzzing corpora or random address selection.
func EncodePrivKey ¶
func EncodePrivKey(priv *ecdsa.PrivateKey) hexutil.Bytes
EncodePrivKey encodes the given private key in 32 bytes
func EncodePrivKeyToString ¶
func EncodePrivKeyToString(priv *ecdsa.PrivateKey) string
func Ether ¶
Ether converts a uint64 Ether amount into a *big.Int amount in wei units, for allocating test balances.
func SystemConfigFromDeployConfig ¶
func SystemConfigFromDeployConfig(deployConfig *genesis.DeployConfig) eth.SystemConfig
func WaitForSafeHead ¶
func WaitReceipt ¶
func WaitReceiptFail ¶
func WaitReceiptOK ¶
func WriteDefaultJWT ¶
func WriteDefaultJWT(t TestingBase) string
WriteDefaultJWT writes a testing JWT to the temporary directory of the test and returns the path to the JWT file.
Types ¶
type Addresses ¶
type Addresses struct { Deployer common.Address CliqueSigner common.Address SysCfgOwner common.Address // rollup actors TrustedValidator common.Address Batcher common.Address SequencerP2P common.Address // prefunded L1/L2 accounts for testing Alice common.Address Bob common.Address Mallory common.Address // [Kroma: START] Challenger1 common.Address Challenger2 common.Address }
Addresses bundles the addresses for all common rollup addresses for testing purposes.
type AllocParams ¶
type AllocParams struct { L1Alloc core.GenesisAlloc L2Alloc core.GenesisAlloc PrefundTestUsers bool }
AllocParams defines genesis allocations to apply on top of the genesis generated by deploy parameters. These allocations override existing allocations per account, i.e. the allocations are merged with AllocParams having priority.
type DeployParams ¶
type DeployParams struct { DeployConfig *genesis.DeployConfig MnemonicConfig *MnemonicConfig Secrets *Secrets Addresses *Addresses }
DeployParams bundles the deployment parameters to generate further testing inputs with.
func MakeDeployParams ¶
func MakeDeployParams(t require.TestingT, tp *TestParams) *DeployParams
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
func (*Fetcher) FetchProofAndPair ¶
type HonestL2RPC ¶
type HonestL2RPC struct {
// contains filtered or unexported fields
}
func NewHonestL2RPC ¶
func NewHonestL2RPC(rpc client.RPC) *HonestL2RPC
func (*HonestL2RPC) BatchCallContext ¶
func (*HonestL2RPC) CallContext ¶
func (m *HonestL2RPC) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
func (*HonestL2RPC) Close ¶
func (m *HonestL2RPC) Close()
func (*HonestL2RPC) EthSubscribe ¶
func (m *HonestL2RPC) EthSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (ethereum.Subscription, error)
func (*HonestL2RPC) SetTargetBlockNumber ¶
func (m *HonestL2RPC) SetTargetBlockNumber(lastValidBlockNumber uint64)
SetTargetBlockNumber sets the target block number for challenge. At the m.targetBlockNumber, mocked output root will be returned for `optimism_outputAtBlock` CallContext
type MaliciousL2RPC ¶
type MaliciousL2RPC struct {
// contains filtered or unexported fields
}
func NewMaliciousL2RPC ¶
func NewMaliciousL2RPC(rpc client.RPC) *MaliciousL2RPC
func (*MaliciousL2RPC) BatchCallContext ¶
func (*MaliciousL2RPC) CallContext ¶
func (m *MaliciousL2RPC) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
func (*MaliciousL2RPC) Close ¶
func (m *MaliciousL2RPC) Close()
func (*MaliciousL2RPC) EthSubscribe ¶
func (m *MaliciousL2RPC) EthSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (ethereum.Subscription, error)
func (*MaliciousL2RPC) SetTargetBlockNumber ¶
func (m *MaliciousL2RPC) SetTargetBlockNumber(lastValidBlockNumber uint64)
SetTargetBlockNumber sets the first invalid block number for mocking malicious L2 RPC. After the m.targetBlockNumber, random output root will be returned for `optimism_outputAtBlock` CallContext
type MnemonicConfig ¶
type MnemonicConfig struct { Mnemonic string CliqueSigner string Deployer string SysCfgOwner string // rollup actors TrustedValidator string Batcher string SequencerP2P string // prefunded L1/L2 accounts for testing Alice string Bob string Mallory string // [Kroma: START] Challenger1 string Challenger2 string }
MnemonicConfig configures the private keys for the hive testnet. It's json-serializable, so we can ship it to e.g. the hardhat script client.
func (*MnemonicConfig) Secrets ¶
func (m *MnemonicConfig) Secrets() (*Secrets, error)
Secrets computes the private keys for all mnemonic paths, which can then be kept around for fast precomputed private key access.
type Secrets ¶
type Secrets struct { Deployer *ecdsa.PrivateKey CliqueSigner *ecdsa.PrivateKey SysCfgOwner *ecdsa.PrivateKey // rollup actors TrustedValidator *ecdsa.PrivateKey Batcher *ecdsa.PrivateKey SequencerP2P *ecdsa.PrivateKey // prefunded L1/L2 accounts for testing Alice *ecdsa.PrivateKey Bob *ecdsa.PrivateKey Mallory *ecdsa.PrivateKey // Share the wallet to be able to generate more accounts Wallet *hdwallet.Wallet // [Kroma: START] Challenger1 *ecdsa.PrivateKey Challenger2 *ecdsa.PrivateKey }
Secrets bundles secp256k1 private keys for all common rollup actors for testing purposes.
type SetupData ¶
type SetupData struct { L1Cfg *core.Genesis L2Cfg *core.Genesis RollupCfg *rollup.Config DeploymentsL1 *genesis.L1Deployments }
SetupData bundles the L1, L2, rollup and deployment configuration data: everything for a full test setup.
func Setup ¶
func Setup(t require.TestingT, deployParams *DeployParams, alloc *AllocParams) *SetupData
Setup computes the testing setup configurations from deployment configuration and optional allocation parameters.
type TestParams ¶
type TestParams struct { MaxSequencerDrift uint64 SequencerWindowSize uint64 ChannelTimeout uint64 L1BlockTime uint64 }
TestParams parametrizes the most essential rollup configuration parameters
type TestingBase ¶
type TestingBase interface { Cleanup(func()) Error(args ...any) Errorf(format string, args ...any) Fail() FailNow() Failed() bool Fatal(args ...any) Fatalf(format string, args ...any) Helper() Log(args ...any) Logf(format string, args ...any) Name() string Setenv(key, value string) Skip(args ...any) SkipNow() Skipf(format string, args ...any) Skipped() bool TempDir() string Parallel() }
TestingBase is an interface used for standard Go testing. This interface is used for unit tests, benchmarks, and fuzz tests and also emulated in Hive.
The Go testing.TB interface does not allow extensions by embedding the interface, so we repeat it here.