common

package
v0.1.0-beta6-bridge-tmp Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2025 License: Apache-2.0, MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Uint32ByteSize = 4
	Uint64ByteSize = 8
)
View Source
const (
	// AGGORACLE name to identify the aggoracle component
	AGGORACLE = "aggoracle"
	// BRIDGE name to identify the bridge component (have RPC)
	BRIDGE = "bridge"
	// CLAIM_SPONSOR name to identify the claim sponsor component
	CLAIM_SPONSOR = "claim-sponsor" //nolint:stylecheck
	// PROVER name to identify the prover component
	PROVER = "prover"
	// AGGSENDER name to identify the aggsender component
	AGGSENDER = "aggsender"
	// L1INFOTREESYNC name to identify the l1infotreesync component
	L1INFOTREESYNC = "l1infotreesync"
)

Variables

View Source
var (
	TimeProvider = time.Now
)
View Source
var (
	ZeroHash = common.HexToHash("0x0")
)

Functions

func BigIntToLittleEndianBytes

func BigIntToLittleEndianBytes(n *big.Int) []byte

BigIntToLittleEndianBytes converts a big.Int to a 32-byte little-endian representation. big.Int is capped to 32 bytes

func BytesToUint32

func BytesToUint32(bytes []byte) uint32

BytesToUint32 converts a byte slice to a uint32. If byte slice is shorter than 4 bytes, it is padded with 0s. In case it is longer than 4 bytes, it panics.

func BytesToUint64

func BytesToUint64(bytes []byte) uint64

BytesToUint64 converts a byte slice to a uint64

func CalculateAccInputHash

func CalculateAccInputHash(
	logger *log.Logger,
	oldAccInputHash common.Hash,
	batchData []byte,
	l1InfoRoot common.Hash,
	timestampLimit uint64,
	sequencerAddr common.Address,
	forcedBlockhashL1 common.Hash,
) common.Hash

CalculateAccInputHash computes the hash of accumulated input data for a given batch.

func NewKeyFromKeystore

func NewKeyFromKeystore(cfg types.KeystoreFileConfig) (*ecdsa.PrivateKey, error)

NewKeyFromKeystore creates a private key from a keystore file

func Uint32ToBytes

func Uint32ToBytes(num uint32) []byte

Uint32ToBytes converts a uint32 to a byte slice in big-endian order

func Uint64ToBytes

func Uint64ToBytes(num uint64) []byte

Uint64ToBytes converts a uint64 to a byte slice

Types

type Config

type Config struct {
	// IsValidiumMode has the value true if the sequence sender is running in validium mode.
	IsValidiumMode bool `mapstructure:"IsValidiumMode"`
	// NetworkID is the networkID of the CDK being run
	NetworkID uint32 `mapstructure:"NetworkID"`
	// Contract Versions: elderberry, banana
	ContractVersions string            `mapstructure:"ContractVersions"`
	Translator       translator.Config `mapstructure:"Translator"`
	// L2URL is the URL of the L2 node
	L2RPC ethermanconfig.RPCClientConfig `mapstructure:"L2RPC"`
}

Config holds the configuration for the CDK.

type Logger added in v0.2.0

type Logger interface {
	Fatalf(format string, args ...interface{})
	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
}

Logger is an interface that defines the methods to log messages

type RateLimit added in v0.0.2

type RateLimit struct {
	// contains filtered or unexported fields
}

RateLimit is a rate limiter

func NewRateLimit added in v0.0.2

func NewRateLimit(cfg RateLimitConfig) *RateLimit

NewRateLimit creates a new RateLimit

func (*RateLimit) Call added in v0.0.2

func (r *RateLimit) Call(msg string, allowToSleep bool) *time.Duration

Call is used before making a call, it will sleep if the rate limit is reached if param allowToSleep is true

func (*RateLimit) String added in v0.0.2

func (r *RateLimit) String() string

String returns a string representation of the RateLimit

type RateLimitConfig added in v0.0.2

type RateLimitConfig struct {
	NumRequests int            `mapstructure:"NumRequests"`
	Interval    types.Duration `mapstructure:"Interval"`
}

RateLimitConfig is the configuration for the rate limit, if NumRequests==0 or Interval==0, the rate limit is disabled

func NewRateLimitConfig added in v0.0.2

func NewRateLimitConfig(numRequests int, period time.Duration) RateLimitConfig

NewRateLimitConfig creates a new RateLimitConfig

func (RateLimitConfig) Enabled added in v0.0.2

func (r RateLimitConfig) Enabled() bool

Enabled returns true if the rate limit is enabled

func (RateLimitConfig) String added in v0.0.2

func (r RateLimitConfig) String() string

String returns a string representation of the RateLimitConfig

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL