@celo/contractkit"wrappers/DowntimeSlasher"DowntimeSlasherWrapper

Class: DowntimeSlasherWrapper

Contract handling slashing for Validator downtime using intervals.

Hierarchy

BaseSlasher‹DowntimeSlasher›

DowntimeSlasherWrapper

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

+ new DowntimeSlasherWrapper(kit: ContractKit, contract: DowntimeSlasher): DowntimeSlasherWrapper

Inherited from BaseWrapper.constructor

Defined in packages/sdk/contractkit/src/wrappers/BaseWrapper.ts:30

Parameters:

Name Type
kit ContractKit
contract DowntimeSlasher

Returns: DowntimeSlasherWrapper

Properties

eventTypes

eventTypes: EventsEnum‹T› = Object.keys(this.events).reduce>( (acc, key) => ({ ...acc, [key]: key }), {} as any )

Inherited from BaseWrapper.eventTypes

Defined in packages/sdk/contractkit/src/wrappers/BaseWrapper.ts:61


events

events: DowntimeSlasher["events"] = this.contract.events

Inherited from BaseWrapper.events

Defined in packages/sdk/contractkit/src/wrappers/BaseWrapper.ts:59


getBitmapForInterval

getBitmapForInterval: function = proxyCall( this.contract.methods.getBitmapForInterval, unpackInterval, solidityBytesToString )

Defined in packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts:73

Calculates and returns the signature bitmap for the specified interval. Similar to the parentSealBitmap of every block (where you have which validators were able to sign the previous block), this bitmap shows for that specific interval which validators signed at least one block

param First and last block of the interval.

returns (string) The signature uptime bitmap for the specified interval.

dev startBlock and endBlock must be in the same epoch.

dev The getParentSealBitmap precompile requires that startBlock must be within 4 epochs of the current block.

Type declaration:

▸ (...args: InputArgs): Promise‹Output›

Parameters:

Name Type
...args InputArgs

isBitmapSetForInterval

isBitmapSetForInterval: function = proxyCall(this.contract.methods.isBitmapSetForInterval, unpackInterval)

Defined in packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts:122

Shows if the user already called the setBitmapForInterval for the specific interval.

param First and last block of the interval.

returns True if the user already called the setBitmapForInterval for the specific interval.

Type declaration:

▸ (...args: InputArgs): Promise‹Output›

Parameters:

Name Type
...args InputArgs

lastSlashedBlock

lastSlashedBlock: function = proxyCall(this.contract.methods.lastSlashedBlock, undefined, valueToInt)

Defined in packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts:136

Type declaration:

▸ (...args: InputArgs): Promise‹Output›

Parameters:

Name Type
...args InputArgs

methodIds

methodIds: Record‹keyof T["methods"], string› = Object.keys(this.contract.methods).reduce, string>>( (acc, method: Methods) => { const methodABI = this.contract.options.jsonInterface.find((item) => item.name === method)

  acc[method] =
    methodABI === undefined
      ? '0x'
      : this.kit.connection.getAbiCoder().encodeFunctionSignature(methodABI)

  return acc
},
{} as any

)

Inherited from BaseWrapper.methodIds

Defined in packages/sdk/contractkit/src/wrappers/BaseWrapper.ts:66


setBitmapForInterval

setBitmapForInterval: function = proxySend( this.kit, this.contract.methods.setBitmapForInterval, unpackInterval )

Defined in packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts:85

Calculates and sets the signature bitmap for the specified interval.

param First and last block of the interval.

dev interval.start and interval.end must be in the same epoch.

returns The signature bitmap for the specified interval.

Type declaration:

▸ (...args: InputArgs): CeloTransactionObject‹Output›

Parameters:

Name Type
...args InputArgs

slashableDowntime

slashableDowntime: function = proxyCall(this.contract.methods.slashableDowntime, undefined, valueToInt)

Defined in packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts:37

Returns slashable downtime in blocks.

returns The number of consecutive blocks before a Validator missing from IBFT consensus can be slashed.

Type declaration:

▸ (...args: InputArgs): Promise‹Output›

Parameters:

Name Type
...args InputArgs

slashingIncentives

slashingIncentives: function = proxyCall( this.contract.methods.slashingIncentives, undefined, (res) => ({ reward: valueToBigNumber(res.reward), penalty: valueToBigNumber(res.penalty), }) )

Inherited from BaseSlasher.slashingIncentives

Defined in packages/sdk/contractkit/src/wrappers/BaseSlasher.ts:69

Returns slashing incentives.

returns Rewards and penalties for slashing.

Type declaration:

▸ (...args: InputArgs): Promise‹Output›

Parameters:

Name Type
...args InputArgs

Accessors

address

get address(): string

Inherited from BaseWrapper.address

Defined in packages/sdk/contractkit/src/wrappers/BaseWrapper.ts:35

Contract address

Returns: string

Methods

getConfig

getConfig(): Promise‹DowntimeSlasherConfig

Defined in packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts:42

Returns current configuration parameters.

Returns: Promise‹DowntimeSlasherConfig


getHumanReadableConfig

getHumanReadableConfig(): Promise‹object›

Defined in packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts:54

dev Returns human readable configuration of the downtime slasher contract

Returns: Promise‹object›

DowntimeSlasherConfig object


getPastEvents

getPastEvents(event: Events‹DowntimeSlasher›, options: PastEventOptions): Promise‹EventLog[]›

Inherited from BaseWrapper.getPastEvents

Defined in packages/sdk/contractkit/src/wrappers/BaseWrapper.ts:55

Contract getPastEvents

Parameters:

Name Type
event Events‹DowntimeSlasher›
options PastEventOptions

Returns: Promise‹EventLog[]›


isBitmapSetForIntervals

isBitmapSetForIntervals(intervals: Interval[]): Promise‹boolean›

Defined in packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts:129

Shows if the user already called the setBitmapForInterval for intervals.

Parameters:

Name Type Description
intervals Interval[] First and last block of the interval.

Returns: Promise‹boolean›

True if the user already called the setBitmapForInterval for intervals.


slashValidator

slashValidator(address: Address, intervals: Interval[]): Promise‹CeloTransactionObject‹void››

Defined in packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts:170

Returns true if the validator did not sign any blocks for the specified overlapping or adjacent intervals.

Parameters:

Name Type Description
address Address Address of the validator account or signer.
intervals Interval[] A list of ordered intervals for which signature bitmaps have already been set.

Returns: Promise‹CeloTransactionObject‹void››


slashableDowntimeIntervalsBefore

slashableDowntimeIntervalsBefore(block?: undefined | number, maximumLength: number): Promise‹Interval[]›

Defined in packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts:98

Calculates intervals which span slashableDowntime before provided block.

dev if block is undefined, latest will be used

Parameters:

Name Type Default Description
block? undefined | number - Block number to build intervals before.
maximumLength number 4000 Maximum length for any interval (limited by gas limit).

Returns: Promise‹Interval[]›

The signature bitmap for the specified interval.


version

version(): Promise‹NonNullable‹T["methods"] extends object ? ContractVersion<> : never››

Inherited from BaseWrapper.version

Defined in packages/sdk/contractkit/src/wrappers/BaseWrapper.ts:39

Returns: Promise‹NonNullable‹T["methods"] extends object ? ContractVersion<> : never››


wasValidatorDownForInterval

wasValidatorDownForInterval(address: Address, interval: Interval): Promise‹boolean›

Defined in packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts:143

Tests if the given validator or signer did not sign any blocks in the interval.

Parameters:

Name Type Description
address Address Address of the validator account or signer.
interval Interval First and last block of the interval.

Returns: Promise‹boolean›


wasValidatorDownForIntervals

wasValidatorDownForIntervals(address: Address, intervals: Interval[]): Promise‹boolean›

Defined in packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts:157

Returns true if the validator did not sign any blocks for the specified overlapping or adjacent intervals.

Parameters:

Name Type Description
address Address Address of the validator account or signer.
intervals Interval[] -

Returns: Promise‹boolean›

True if the validator signature does not appear in any block within the window.