Skip to content

Commit

Permalink
Merge branch 'main' into rf/block-mined-timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
debendraoli authored May 26, 2024
2 parents e20d8c0 + 7213dc1 commit 4ba0bb2
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 133 deletions.
166 changes: 76 additions & 90 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,105 +2,60 @@

All notable changes to this project will be documented in this file.

## [1.1.0] - 2024-03-18

### Added

- Support for cosmos chain
- Xcall contract support
- CallMessage event listener for all supported chains
- Fee related operations cmd. `getFee`, `setFee` and `claimFee`
- Structured events for easier event handling

### Changed

- Wallet encryption and decryption
- GO version to 1.22.1
## [1.2.6] - 2024-05-26

### Fixed

- Incorrect icon chain balance calculation.
- SetAdmin also checks for the admin address to avoid setting the admin address to the same address.
- Retries is less error prone now, only retries after set interval (5s) when failed.
- Fixed the issue when initilizing config file.

### Migration from 1.0.0 to 1.1.0

We have added support for cosmos chains and xcall contract support. To migrate from 1.0.0 to 1.1.0, you need to update the configuration file and add the cosmos chain details. The configuration file is backward compatible, so you can add the cosmos chain details without affecting the existing configuration.

Major changes in this release is the wallet encryption and decryption. Previously we only encrypted the keystore password, now we encrypt the entire keystore file adding an extra layer of security. The relay will automatically decrypt the keystore file and use it to sign the messages.

We have also added the xcall execution contract support. The relay will now listen to the call message event and execute the xcall contract.

Exection will respect the fees set on configuration. The relay will now calculate the fees and execute the contract.

Migrate keystore files to the new format by running the following command:

**important**: Before running the command, make sure you have the AWS KMS key id. You can get the KMS key id by running the `crly config show` command.

```shell
aws kms encrypt --key-id <kms-key-id> --plaintext fileb://path/to/keystore.json --output text --query CiphertextBlob | base64 -d > path/to/keystore/address
```
- Cosmos contracts subscriptions respects the configured contracts
- RPC failures are are handled more elegently, switches to the polling and back to the subscriptions
- Other improvements and bug fixes

Example when migrating the icon chain keystore file where its nid is `0x2.icon` and the wallet address is `0x0B958dd815195F73d6B9B91bFDF1639457678FEb`:
### Refactor

verify keystore exists:
- Icon `progressInterval` notification block is not incremented to handle rpc failures

```shell
ls $HOME/.centralized-relay/keystore/0x2.icon/0x0B958dd815195F73d6B9B91bFDF1639457678FEb.json
```
## [1.2.5] - 2024-05-18

Encrypt the keystore file:
### Fixed

```shell
aws kms encrypt --key-id <insert-key-id-here> --plaintext fileb://$HOME/.centralized-relay/keystore/0x2.icon/0x0B958dd815195F73d6B9B91bFDF1639457678FEb.json --output text --query CiphertextBlob | base64 -d > "$HOME/keystore/0x2.icon/0x0B958dd815195F73d6B9B91bFDF1639457678FEb"
```
- Wrong params sent when estimating gas for the evm chain `executeCall`

Move the encrypted wallet passphrase to the new location:
## [1.2.4] - 2024-05-17

```shell
mv $HOME/keystore/0x2.icon/0x0B958dd815195F73d6B9B91bFDF1639457678FEb.password $HOME/.centralized relay/keystore/0x2.icon/0x0B958dd815195F73d6B9B91bFDF1639457678FEb.pass
```
### Added

### Additional Information
- Support for the injective chain

- All the keystore relayer files are located in the `keystore` directory.
`ls $HOME/.centralized-relay/keystore`
### Fixed

- The version `1.0.0` keystore files for chain are located in the inside the its `nid` directory in a following format:
`keystore/<nid>/<wallet-address>.json`
- Gas Estimation for the evm chain
- Cosmos sdk global config bech32 prefixes
- Other improvements and bug fixes

## [1.1.1] - 2024-03-21
## [1.2.3] - 2024-05-14

### Added

- Websocket support for evm chain

### Fixed

- AWS Region detection
- Static binary build
- Gas adjustment from config

## [1.1.2] - 2024-03-22
## [1.2.2] - 2024-05-01

### Fixed

- Region detection for AWS
- Priority 0 (high) for `start-height` evm
- Panic too many packets map access
- Avoid nonce increment when fixing the nonce error while sending the transaction

## [1.1.3] - 2024-03-27
## [1.2.1] - 2024-04-30

### Added
### Fixed

- Route manually from height (on chain)
- Websocket connection disconnect issue with icon chain
- Use `eth_gasPrice` for the gas price calculation all the time
- Other improvements and bug fixes
- Use block mined timeout instead of polling when waiting for transcation

### Fixed
### Removed

- Increase delivery failure by trying for per 15 seconds after initial failures.
- Panics when subscribing to the event result.
- AWS ec2 instance profile detection.
- Other improvements and bug fixes.
- Icon redunant polling code

## [1.2.0] - 2024-04-09

Expand All @@ -126,39 +81,70 @@ Move the encrypted wallet passphrase to the new location:

- Height sync is no longer necessary.

## [1.2.1] - 2024-04-30
## [1.1.3] - 2024-03-27

### Fixed
### Added

- Websocket connection disconnect issue with icon chain
- Use `eth_gasPrice` for the gas price calculation all the time
- Other improvements and bug fixes
- Use block mined timeout instead of polling when waiting for transcation
- Route manually from height (on chain)

### Removed
### Fixed

- Icon redunant polling code
- Increase delivery failure by trying for per 15 seconds after initial failures.
- Panics when subscribing to the event result.
- AWS ec2 instance profile detection.
- Other improvements and bug fixes.

## [1.2.2] - 2024-05-01
## [1.1.2] - 2024-03-22

### Fixed

- Avoid nonce increment when fixing the nonce error while sending the transaction
- Region detection for AWS
- Priority 0 (high) for `start-height` evm
- Panic too many packets map access

# [1.2.3] - 2024-05-14
## [1.1.1] - 2024-03-21

### Added

- Gas adjustment from config
- Websocket support for evm chain

## [1.2.4] - 2024-05-17
### Fixed

- AWS Region detection
- Static binary build

## [1.1.0] - 2024-03-18

### Added

- Support for the injective chain
- Support for cosmos chain
- Xcall contract support
- CallMessage event listener for all supported chains
- Fee related operations cmd. `getFee`, `setFee` and `claimFee`
- Structured events for easier event handling

### Changed

- Wallet encryption and decryption
- GO version to 1.22.1

### Fixed

- Gas Estimation for the evm chain
- Cosmos sdk global config bech32 prefixes
- Other improvements and bug fixes
- Incorrect icon chain balance calculation.
- SetAdmin also checks for the admin address to avoid setting the admin address to the same address.
- Retries is less error prone now, only retries after set interval (5s) when failed.
- Fixed the issue when initilizing config file.

### Migration from 1.0.0 to 1.1.0

We have added support for cosmos chains and xcall contract support. To migrate from 1.0.0 to 1.1.0, you need to update the configuration file and add the cosmos chain details. The configuration file is backward compatible, so you can add the cosmos chain details without affecting the existing configuration.

Major changes in this release is the wallet encryption and decryption. Previously we only encrypted the keystore password, now we encrypt the entire keystore file adding an extra layer of security. The relay will automatically decrypt the keystore file and use it to sign the messages.

We have also added the xcall execution contract support. The relay will now listen to the call message event and execute the xcall contract.

Exection will respect the fees set on configuration. The relay will now calculate the fees and execute the contract.

Migrate keystore files to the new format by running the following command:

**important**: Before running the command, make sure you have the AWS KMS key id. You can get the KMS key id by running the `crly config show` command.
8 changes: 4 additions & 4 deletions relayer/chains/evm/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (p *Provider) startFromHeight(ctx context.Context, lastSavedHeight uint64)
}

// Subscribe listens to new blocks and sends them to the channel
func (p *Provider) Subscribe(ctx context.Context, ticker *time.Ticker, blockInfoChan chan *relayertypes.BlockInfo) {
func (p *Provider) Subscribe(ctx context.Context, ticker *time.Ticker, blockInfoChan chan *relayertypes.BlockInfo) error {
ch := make(chan ethTypes.Log)
sub, err := p.client.Subscribe(ctx, ethereum.FilterQuery{
Addresses: p.blockReq.Addresses,
Expand All @@ -254,18 +254,18 @@ func (p *Provider) Subscribe(ctx context.Context, ticker *time.Ticker, blockInfo
if err != nil {
p.log.Error("failed to subscribe", zap.Error(err))
ticker.Reset(time.Second * 3)
return
return err
}
defer sub.Unsubscribe()
p.log.Info("Subscribed to new blocks", zap.Uint64("from", p.blockReq.FromBlock.Uint64()), zap.Any("address", p.blockReq.Addresses))
for {
select {
case <-ctx.Done():
return
return nil
case err := <-sub.Err():
p.log.Error("subscription error", zap.Error(err))
ticker.Reset(time.Second * 3)
return
return p.Listener(ctx, p.GetLastSavedBlockHeight(), blockInfoChan)
case log := <-ch:
message, err := p.getRelayMessageFromLog(log)
if err != nil {
Expand Down
29 changes: 20 additions & 9 deletions relayer/chains/evm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,16 @@ type Config struct {
}

type Provider struct {
client IClient
log *zap.Logger
cfg *Config
StartHeight uint64
blockReq ethereum.FilterQuery
wallet *keystore.Key
kms kms.KMS
contracts map[string]providerTypes.EventMap
NonceTracker types.NonceTrackerI
client IClient
log *zap.Logger
cfg *Config
StartHeight uint64
blockReq ethereum.FilterQuery
wallet *keystore.Key
kms kms.KMS
contracts map[string]providerTypes.EventMap
NonceTracker types.NonceTrackerI
LastSavedHeightFunc func() uint64
}

func (p *Config) NewProvider(ctx context.Context, log *zap.Logger, homepath string, debug bool, chainName string) (provider.ChainProvider, error) {
Expand Down Expand Up @@ -439,3 +440,13 @@ func (p *Provider) EstimateGas(ctx context.Context, message *providerTypes.Messa
}
return p.client.EstimateGas(ctx, msg)
}

// SetLastSavedBlockHeightFunc sets the function to save the last saved block height
func (p *Provider) SetLastSavedHeightFunc(f func() uint64) {
p.LastSavedHeightFunc = f
}

// GetLastSavedBlockHeight returns the last saved block height
func (p *Provider) GetLastSavedBlockHeight() uint64 {
return p.LastSavedHeightFunc()
}
6 changes: 3 additions & 3 deletions relayer/chains/icon/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (p *Provider) Listener(ctx context.Context, lastSavedHeight uint64, incomin
Height: types.NewHexInt(processedheight),
EventFilter: p.GetMonitorEventFilters(),
Logs: types.NewHexInt(1),
ProgressInterval: types.NewHexInt(15),
ProgressInterval: types.NewHexInt(25),
}

for {
Expand All @@ -76,7 +76,7 @@ func (p *Provider) Listener(ctx context.Context, lastSavedHeight uint64, incomin
return err
}
if height > 0 {
eventReq.Height = types.NewHexInt(height + 1)
eventReq.Height = types.NewHexInt(height)
}
return nil
}
Expand Down Expand Up @@ -104,7 +104,7 @@ func (p *Provider) Listener(ctx context.Context, lastSavedHeight uint64, incomin
if errors.Is(err, context.Canceled) {
return
}
time.Sleep(time.Second * 5)
time.Sleep(time.Second * 3)
reconnect()
p.log.Warn("error occured during monitor event", zap.Error(err))
}
Expand Down
23 changes: 17 additions & 6 deletions relayer/chains/icon/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ func (c *Config) Enabled() bool {
}

type Provider struct {
log *zap.Logger
cfg *Config
wallet module.Wallet
client *Client
kms kms.KMS
contracts map[string]providerTypes.EventMap
log *zap.Logger
cfg *Config
wallet module.Wallet
client *Client
kms kms.KMS
contracts map[string]providerTypes.EventMap
LastSavedHeightFunc func() uint64
}

func (p *Provider) NID() string {
Expand Down Expand Up @@ -258,3 +259,13 @@ func (p *Provider) ExecuteRollback(ctx context.Context, sn uint64) error {
}
return nil
}

// SetLastSavedBlockHeightFunc sets the function to save the last saved block height
func (p *Provider) SetLastSavedHeightFunc(f func() uint64) {
p.LastSavedHeightFunc = f
}

// GetLastSavedBlockHeight returns the last saved block height
func (p *Provider) GetLastSavedBlockHeight() uint64 {
return p.LastSavedHeightFunc()
}
Loading

0 comments on commit 4ba0bb2

Please sign in to comment.