Skip to content

Commit

Permalink
Merge pull request #214 from icon-project/feat/gas-optimize
Browse files Browse the repository at this point in the history
rf: gas adjustment and step adjustment in config
  • Loading branch information
debendraoli authored May 14, 2024
2 parents 775084b + 4dc80a8 commit a7a5a1f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,9 @@ Move the encrypted wallet passphrase to the new location:
### Removed

- Icon redunant polling code

# [1.2.3] - 2024-05-14

### Added

- Gas adjustment from config
6 changes: 3 additions & 3 deletions relayer/chains/evm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type Config struct {
Concurrency uint64 `json:"concurrency" yaml:"concurrency"`
FinalityBlock uint64 `json:"finality-block" yaml:"finality-block"`
NID string `json:"nid" yaml:"nid"`
GasBuffer uint64 `json:"gas-buffer" yaml:"gas-buffer"`
GasAdjustment uint64 `json:"gas-adjustment" yaml:"gas-adjustment"`
HomeDir string `json:"-" yaml:"-"`
}

Expand Down Expand Up @@ -129,8 +129,8 @@ func (p *Config) Validate() error {
}

func (p *Config) sanitize() error {
if p.GasBuffer == 0 {
p.GasBuffer = 10
if p.GasAdjustment == 0 {
p.GasAdjustment = 10
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion relayer/chains/evm/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (p *Provider) SendTransaction(ctx context.Context, opts *bind.TransactOpts,
return nil, fmt.Errorf("gas price less than minimum: %d", gasLimit)
}

opts.GasLimit = gasLimit + gasLimit*p.cfg.GasBuffer/100
opts.GasLimit = gasLimit + gasLimit*p.cfg.GasAdjustment/100

switch message.EventType {
// check estimated gas and gas price
Expand Down
28 changes: 14 additions & 14 deletions relayer/chains/icon/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ import (
)

type Config struct {
ChainName string `json:"-" yaml:"-"`
RPCUrl string `json:"rpc-url" yaml:"rpc-url"`
Address string `json:"address" yaml:"address"`
StartHeight uint64 `json:"start-height" yaml:"start-height"` // would be of highest priority
Contracts relayerTypes.ContractConfigMap `json:"contracts" yaml:"contracts"`
NetworkID int64 `json:"network-id" yaml:"network-id"`
FinalityBlock uint64 `json:"finality-block" yaml:"finality-block"`
NID string `json:"nid" yaml:"nid"`
StepMin int64 `json:"step-min" yaml:"step-min"`
StepLimit int64 `json:"step-limit" yaml:"step-limit"`
StepBuffer int `json:"step-buffer" yaml:"step-buffer"`
HomeDir string `json:"-" yaml:"-"`
ChainName string `json:"-" yaml:"-"`
RPCUrl string `json:"rpc-url" yaml:"rpc-url"`
Address string `json:"address" yaml:"address"`
StartHeight uint64 `json:"start-height" yaml:"start-height"` // would be of highest priority
Contracts relayerTypes.ContractConfigMap `json:"contracts" yaml:"contracts"`
NetworkID int64 `json:"network-id" yaml:"network-id"`
FinalityBlock uint64 `json:"finality-block" yaml:"finality-block"`
NID string `json:"nid" yaml:"nid"`
StepMin int64 `json:"step-min" yaml:"step-min"`
StepLimit int64 `json:"step-limit" yaml:"step-limit"`
StepAdjustment int `json:"step-adjustment" yaml:"step-adjustment"`
HomeDir string `json:"-" yaml:"-"`
}

// NewProvider returns new Icon provider
Expand Down Expand Up @@ -66,8 +66,8 @@ func (c *Config) Validate() error {
}

func (c *Config) sanitize() error {
if c.StepBuffer == 0 {
c.StepBuffer = 10
if c.StepAdjustment == 0 {
c.StepAdjustment = 10
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion relayer/chains/icon/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (p *Provider) SendTransaction(ctx context.Context, msg *IconMessage) ([]byt
}
// increase step limit by step buffer

steps := int64(stepVal + stepVal*p.cfg.StepBuffer/100)
steps := int64(stepVal + stepVal*p.cfg.StepAdjustment/100)

if steps > p.cfg.StepLimit {
return nil, fmt.Errorf("step limit is too high: %d", steps)
Expand Down

0 comments on commit a7a5a1f

Please sign in to comment.