Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename xdai ChainType config to gnosis #12093

Merged
merged 17 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
f6266ec
feat: rename xdai ChainType config to gnosis due to the chain rebrand…
friedemannf Feb 20, 2024
46b0ab6
chore: demote pyroscope-go
friedemannf Feb 20, 2024
644d3f5
chore: rename more occurrences of xdai
friedemannf Feb 20, 2024
2536da6
refactor: retain old value for compatibility reasons, but deprecate a…
friedemannf Feb 20, 2024
0bb6f04
Merge remote-tracking branch 'origin/develop' into SHIP-1067/rename-x…
friedemannf Feb 20, 2024
a9640dc
fix: golangci-lint
friedemannf Feb 20, 2024
8a36d23
refactor: move deprecation warning to deprecationWarnings()
friedemannf Feb 21, 2024
424e79d
Merge remote-tracking branch 'origin/develop' into SHIP-1067/rename-x…
friedemannf Feb 21, 2024
f85a660
Merge remote-tracking branch 'origin/develop' into SHIP-1067/rename-x…
friedemannf Feb 21, 2024
8cf66f9
Merge branch 'develop' into SHIP-1067/rename-xdai-chaintype
friedemannf Feb 21, 2024
0e5fe2c
refactor: sort chainTypes alphabetically and add exhaustive switch stmts
friedemannf Feb 22, 2024
42b13ea
Merge remote-tracking branch 'origin/develop' into SHIP-1067/rename-x…
friedemannf Feb 22, 2024
e411414
Merge remote-tracking branch 'origin/SHIP-1067/rename-xdai-chaintype'…
friedemannf Feb 22, 2024
221a7f4
Merge remote-tracking branch 'origin/develop' into SHIP-1067/rename-x…
friedemannf Mar 8, 2024
3402081
bump deprecating version for xdai chaintype to v2.13.0
friedemannf Mar 8, 2024
998be4d
remove changelog entry and add changeset
friedemannf Mar 8, 2024
5532222
fix config test
friedemannf Mar 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions common/config/chaintype.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
ChainArbitrum ChainType = "arbitrum"
ChainMetis ChainType = "metis"
ChainOptimismBedrock ChainType = "optimismBedrock"
ChainXDai ChainType = "xdai"
ChainGnosis ChainType = "gnosis"
ChainCelo ChainType = "celo"
ChainWeMix ChainType = "wemix"
ChainKroma ChainType = "kroma"
Expand All @@ -22,13 +22,13 @@ const (
)

var ErrInvalidChainType = fmt.Errorf("must be one of %s or omitted", strings.Join([]string{
string(ChainArbitrum), string(ChainMetis), string(ChainXDai), string(ChainOptimismBedrock), string(ChainCelo),
string(ChainArbitrum), string(ChainMetis), string(ChainGnosis), string(ChainOptimismBedrock), string(ChainCelo),
string(ChainKroma), string(ChainWeMix), string(ChainZkSync), string(ChainScroll)}, ", "))

// IsValid returns true if the ChainType value is known or empty.
func (c ChainType) IsValid() bool {
switch c {
case "", ChainArbitrum, ChainMetis, ChainOptimismBedrock, ChainXDai, ChainCelo, ChainKroma, ChainWeMix, ChainZkSync, ChainScroll:
case "", ChainArbitrum, ChainMetis, ChainOptimismBedrock, ChainGnosis, ChainCelo, ChainKroma, ChainWeMix, ChainZkSync, ChainScroll:
return true
}
return false
Expand All @@ -41,9 +41,6 @@ func (c ChainType) IsL2() bool {
switch c {
case ChainArbitrum, ChainMetis:
return true

case ChainXDai:
fallthrough
default:
return false
}
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func TestChainScopedConfig_Profiles(t *testing.T) {
{"harmonyMainnet", 1666600000, 500000, "0.00001"},
{"harmonyTestnet", 1666700000, 500000, "0.00001"},

{"xDai", 100, 500000, "0.00001"},
{"gnosisMainnet", 100, 500000, "0.00001"},
}
for _, test := range tests {
tt := test
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/Gnosis_Chiado.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ChainID = '10200'
# Gnoisis Finality is approx 8 minutes @ 12 blocks per minute, so 96 blocks
FinalityDepth = 100
ChainType = 'xdai'
ChainType = 'gnosis'
LogPollInterval = '5s'

[GasEstimator]
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/defaults/Gnosis_Mainnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# With xDai's current maximum of 19 validators then 40 blocks is the maximum possible re-org)
# The mainnet default of 50 blocks is ok here
ChainID = '100'
ChainType = 'xdai'
ChainType = 'gnosis'
LinkContractAddress = '0xE2e73A1c69ecF83F464EFCE6A5be353a37cA09b2'
LogPollInterval = '5s'

Expand Down
29 changes: 15 additions & 14 deletions core/chains/evm/gas/block_history_estimator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,12 +886,12 @@ func TestBlockHistoryEstimator_Recalculate_NoEIP1559(t *testing.T) {
require.Equal(t, assets.NewWeiI(70), price)
})

t.Run("takes into account zero priced transactions if chain is not xDai", func(t *testing.T) {
t.Run("takes into account zero priced transactions if chain is not Gnosis", func(t *testing.T) {
// Because everyone loves free gas!
ethClient := evmtest.NewEthClientMockWithDefaultChain(t)
cfg := gas.NewMockConfig()
bhCfg := newBlockHistoryConfig()

bhCfg := newBlockHistoryConfig()
bhCfg.TransactionPercentileF = uint16(50)

geCfg := &gas.MockGasEstimatorConfig{}
Expand All @@ -908,7 +908,7 @@ func TestBlockHistoryEstimator_Recalculate_NoEIP1559(t *testing.T) {
Number: 0,
Hash: b1Hash,
ParentHash: common.Hash{},
Transactions: cltest.LegacyTransactionsFromGasPrices(0, 0, 0, 0, 100),
Transactions: cltest.LegacyTransactionsFromGasPrices(0, 0, 25, 50, 100),
},
}

Expand All @@ -917,24 +917,22 @@ func TestBlockHistoryEstimator_Recalculate_NoEIP1559(t *testing.T) {
bhe.Recalculate(cltest.Head(0))

price := gas.GetGasPrice(bhe)
require.Equal(t, assets.NewWeiI(0), price)
require.Equal(t, assets.NewWeiI(25), price)
})

t.Run("ignores zero priced transactions on xDai", func(t *testing.T) {
chainID := big.NewInt(100)

t.Run("ignores zero priced transactions only on Gnosis", func(t *testing.T) {
ethClient := evmtest.NewEthClientMock(t)
cfg := gas.NewMockConfig()
bhCfg := newBlockHistoryConfig()

bhCfg := newBlockHistoryConfig()
bhCfg.TransactionPercentileF = uint16(50)

geCfg := &gas.MockGasEstimatorConfig{}
geCfg.EIP1559DynamicFeesF = false
geCfg.PriceMaxF = maxGasPrice
geCfg.PriceMinF = assets.NewWeiI(100)
geCfg.PriceMinF = assets.NewWeiI(11) // Has to be set as Gnosis will only ignore transactions below this price

ibhe := newBlockHistoryEstimatorWithChainID(t, ethClient, cfg, geCfg, bhCfg, *chainID)
ibhe := newBlockHistoryEstimator(t, ethClient, cfg, geCfg, bhCfg)
bhe := gas.BlockHistoryEstimatorFromInterface(ibhe)

b1Hash := utils.NewHash()
Expand All @@ -944,16 +942,19 @@ func TestBlockHistoryEstimator_Recalculate_NoEIP1559(t *testing.T) {
Number: 0,
Hash: b1Hash,
ParentHash: common.Hash{},
Transactions: cltest.LegacyTransactionsFromGasPrices(0, 0, 0, 0, 100),
Transactions: cltest.LegacyTransactionsFromGasPrices(0, 0, 0, 0, 80),
},
}

gas.SetRollingBlockHistory(bhe, blocks)

// chainType is not set - GasEstimator should not ignore zero priced transactions and instead default to PriceMin==11
bhe.Recalculate(cltest.Head(0))
require.Equal(t, assets.NewWeiI(11), gas.GetGasPrice(bhe))

price := gas.GetGasPrice(bhe)
require.Equal(t, assets.NewWeiI(100), price)
// Set chainType to Gnosis - GasEstimator should now ignore zero priced transactions
cfg.ChainTypeF = string(config.ChainGnosis)
bhe.Recalculate(cltest.Head(0))
require.Equal(t, assets.NewWeiI(80), gas.GetGasPrice(bhe))
})

t.Run("handles unreasonably large gas prices (larger than a 64 bit int can hold)", func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions core/chains/evm/gas/chain_specific.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
// chainSpecificIsUsable allows for additional logic specific to a particular
// Config that determines whether a transaction should be used for gas estimation
func chainSpecificIsUsable(tx evmtypes.Transaction, baseFee *assets.Wei, chainType config.ChainType, minGasPriceWei *assets.Wei) bool {
if chainType == config.ChainXDai {
if chainType == config.ChainGnosis {
// GasPrice 0 on most chains is great since it indicates cheap/free transactions.
// However, xDai reserves a special type of "bridge" transaction with 0 gas
// However, Gnosis reserves a special type of "bridge" transaction with 0 gas
// price that is always processed at top priority. Ordinary transactions
// must be priced at least 1GWei, so we have to discard anything priced
// below that (unless the contract is whitelisted).
Expand Down
10 changes: 5 additions & 5 deletions core/config/docs/chains-evm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ BlockBackfillDepth = 10 # Default
# BlockBackfillSkip enables skipping of very long backfills.
BlockBackfillSkip = false # Default
# ChainType is automatically detected from chain ID. Set this to force a certain chain type regardless of chain ID.
# Available types: arbitrum, metis, optimismBedrock, xdai, celo, kroma, wemix, zksync, scroll
# Available types: arbitrum, metis, optimismBedrock, gnosis, celo, kroma, wemix, zksync, scroll
ChainType = 'arbitrum' # Example
# FinalityDepth is the number of blocks after which an ethereum transaction is considered "final". Note that the default is automatically set based on chain ID so it should not be necessary to change this under normal operation.
# FinalityDepth is the number of blocks after which an ethereum transaction is considered "final". Note that the default is automatically set based on chain ID, so it should not be necessary to change this under normal operation.
# BlocksConsideredFinal determines how deeply we look back to ensure that transactions are confirmed onto the longest chain
# There is not a large performance penalty to setting this relatively high (on the order of hundreds)
# It is practically limited by the number of heads we store in the database and should be less than this with a comfortable margin.
# If a transaction is mined in a block more than this many blocks ago, and is reorged out, we will NOT retransmit this transaction and undefined behaviour can occur including gaps in the nonce sequence that require manual intervention to fix.
# Therefore this number represents a number of blocks we consider large enough that no re-org this deep will ever feasibly happen.
# Therefore, this number represents a number of blocks we consider large enough that no re-org this deep will ever feasibly happen.
#
# Special cases:
# `FinalityDepth`=0 would imply that transactions can be final even before they were mined into a block. This is not supported.
Expand Down Expand Up @@ -222,7 +222,7 @@ FeeCapDefault = '100 gwei' # Default
TipCapDefault = '1 wei' # Default
# TipCapMinimum is the minimum gas tip to use when submitting transactions to the blockchain.
#
# Only applies to EIP-1559 transactions)
# (Only applies to EIP-1559 transactions)
TipCapMin = '1 wei' # Default

[EVM.GasEstimator.LimitJobType]
Expand Down Expand Up @@ -260,7 +260,7 @@ CheckInclusionPercentile = 90 # Default
# **ADVANCED**
# EIP1559FeeCapBufferBlocks controls the buffer blocks to add to the current base fee when sending a transaction. By default, the gas bumping threshold + 1 block is used.
#
# Only applies to EIP-1559 transactions)
# (Only applies to EIP-1559 transactions)
EIP1559FeeCapBufferBlocks = 13 # Example
# TransactionPercentile specifies gas price to choose. E.g. if the block history contains four transactions with gas prices `[100, 200, 300, 400]` then picking 25 for this number will give a value of 200. If the calculated gas price is higher than `GasPriceDefault` then the higher price will be used as the base price for new transactions.
#
Expand Down
4 changes: 2 additions & 2 deletions core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ func TestConfig_Validate(t *testing.T) {
- 1: 6 errors:
- ChainType: invalid value (Foo): must not be set with this chain id
- Nodes: missing: must have at least one node
- ChainType: invalid value (Foo): must be one of arbitrum, metis, xdai, optimismBedrock, celo, kroma, wemix, zksync, scroll or omitted
- ChainType: invalid value (Foo): must be one of arbitrum, metis, gnosis, optimismBedrock, celo, kroma, wemix, zksync, scroll or omitted
- HeadTracker.HistoryDepth: invalid value (30): must be equal to or greater than FinalityDepth
- GasEstimator: 2 errors:
- FeeCapDefault: invalid value (101 wei): must be equal to PriceMax (99 wei) since you are using FixedPrice estimation with gas bumping disabled in EIP1559 mode - PriceMax will be used as the FeeCap for transactions instead of FeeCapDefault
Expand All @@ -1199,7 +1199,7 @@ func TestConfig_Validate(t *testing.T) {
- 2: 5 errors:
- ChainType: invalid value (Arbitrum): only "optimismBedrock" can be used with this chain id
- Nodes: missing: must have at least one node
- ChainType: invalid value (Arbitrum): must be one of arbitrum, metis, xdai, optimismBedrock, celo, kroma, wemix, zksync, scroll or omitted
- ChainType: invalid value (Arbitrum): must be one of arbitrum, metis, gnosis, optimismBedrock, celo, kroma, wemix, zksync, scroll or omitted
- FinalityDepth: invalid value (0): must be greater than or equal to 1
- MinIncomingConfirmations: invalid value (0): must be greater than or equal to 1
- 3.Nodes: 5 errors:
Expand Down
2 changes: 1 addition & 1 deletion core/services/ocr/contract_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ func (t *OCRContractTracker) LatestBlockHeight(ctx context.Context) (blockheight
// care about the block height; we have no way of getting the L1 block
// height anyway
return 0, nil
case "", config.ChainArbitrum, config.ChainCelo, config.ChainOptimismBedrock, config.ChainXDai, config.ChainKroma, config.ChainWeMix, config.ChainZkSync, config.ChainScroll:
case "", config.ChainArbitrum, config.ChainCelo, config.ChainOptimismBedrock, config.ChainGnosis, config.ChainKroma, config.ChainWeMix, config.ChainZkSync, config.ChainScroll:
// continue
}
latestBlockHeight := t.getLatestBlockHeight()
Expand Down
2 changes: 1 addition & 1 deletion core/services/ocrcommon/block_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewBlockTranslator(cfg Config, client evmclient.Client, lggr logger.Logger)
switch cfg.ChainType() {
case config.ChainArbitrum:
return NewArbitrumBlockTranslator(client, lggr)
case config.ChainXDai, config.ChainMetis, config.ChainOptimismBedrock:
case config.ChainGnosis, config.ChainMetis, config.ChainOptimismBedrock:
fallthrough
default:
return &l1BlockTranslator{}
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [dev]

### Changed

- The `xdai` `ChainType` has been renamed to `gnosis` to match the chain's new name. The old name is not supported anymore and has to be changed before upgrading.

### Added

- Gas bumping logic to the `SuggestedPriceEstimator`. The bumping mechanism for this estimator refetches the price from the RPC and adds a buffer on top using the greater of `BumpPercent` and `BumpMin`.
Expand Down
14 changes: 7 additions & 7 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2570,7 +2570,7 @@ GasLimit = 5400000
AutoCreateKey = true
BlockBackfillDepth = 10
BlockBackfillSkip = false
ChainType = 'xdai'
ChainType = 'gnosis'
FinalityDepth = 50
FinalityTagEnabled = false
LinkContractAddress = '0xE2e73A1c69ecF83F464EFCE6A5be353a37cA09b2'
Expand Down Expand Up @@ -4187,7 +4187,7 @@ GasLimit = 6500000
AutoCreateKey = true
BlockBackfillDepth = 10
BlockBackfillSkip = false
ChainType = 'xdai'
ChainType = 'gnosis'
FinalityDepth = 100
FinalityTagEnabled = false
LogBackfillBatchSize = 1000
Expand Down Expand Up @@ -5758,18 +5758,18 @@ BlockBackfillSkip enables skipping of very long backfills.
ChainType = 'arbitrum' # Example
```
ChainType is automatically detected from chain ID. Set this to force a certain chain type regardless of chain ID.
Available types: arbitrum, metis, optimismBedrock, xdai, celo, kroma, wemix, zksync, scroll
Available types: arbitrum, metis, optimismBedrock, gnosis, celo, kroma, wemix, zksync, scroll

### FinalityDepth
```toml
FinalityDepth = 50 # Default
```
FinalityDepth is the number of blocks after which an ethereum transaction is considered "final". Note that the default is automatically set based on chain ID so it should not be necessary to change this under normal operation.
FinalityDepth is the number of blocks after which an ethereum transaction is considered "final". Note that the default is automatically set based on chain ID, so it should not be necessary to change this under normal operation.
BlocksConsideredFinal determines how deeply we look back to ensure that transactions are confirmed onto the longest chain
There is not a large performance penalty to setting this relatively high (on the order of hundreds)
It is practically limited by the number of heads we store in the database and should be less than this with a comfortable margin.
If a transaction is mined in a block more than this many blocks ago, and is reorged out, we will NOT retransmit this transaction and undefined behaviour can occur including gaps in the nonce sequence that require manual intervention to fix.
Therefore this number represents a number of blocks we consider large enough that no re-org this deep will ever feasibly happen.
Therefore, this number represents a number of blocks we consider large enough that no re-org this deep will ever feasibly happen.

Special cases:
`FinalityDepth`=0 would imply that transactions can be final even before they were mined into a block. This is not supported.
Expand Down Expand Up @@ -6149,7 +6149,7 @@ TipCapMin = '1 wei' # Default
```
TipCapMinimum is the minimum gas tip to use when submitting transactions to the blockchain.

Only applies to EIP-1559 transactions)
(Only applies to EIP-1559 transactions)

## EVM.GasEstimator.LimitJobType
```toml
Expand Down Expand Up @@ -6249,7 +6249,7 @@ EIP1559FeeCapBufferBlocks = 13 # Example
```
EIP1559FeeCapBufferBlocks controls the buffer blocks to add to the current base fee when sending a transaction. By default, the gas bumping threshold + 1 block is used.

Only applies to EIP-1559 transactions)
(Only applies to EIP-1559 transactions)

### TransactionPercentile
```toml
Expand Down
Loading