Rework senders blacklist

This commit is contained in:
Kirill Fedoseev 2022-05-22 13:12:30 +04:00
parent ee787b1a6a
commit 1da539d42b
4 changed files with 33 additions and 28 deletions

View File

@ -272,20 +272,20 @@
},
"end_block": {
"type": "integer"
},
"blacklisted_senders": {
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$"
}
}
},
"required": [
"address"
]
}
},
"erc_to_native_blacklisted_senders": {
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$"
}
}
},
"required": [

View File

@ -80,9 +80,9 @@ bridges:
end_block: 9884448
- address: 0x6B175474E89094C44Da98b954EedeAC495271d0F
start_block: 8928158
erc_to_native_blacklisted_senders:
- 0x0000000000000000000000000000000000000000
- 0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643
blacklisted_senders:
- 0x0000000000000000000000000000000000000000
- 0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643
alerts:
unknown_erc_to_native_message_confirmation:
unknown_erc_to_native_message_execution:

View File

@ -32,23 +32,23 @@ type ReloadJobConfig struct {
}
type TokenConfig struct {
Address common.Address `yaml:"address"`
StartBlock uint `yaml:"start_block"`
EndBlock uint `yaml:"end_block"`
Address common.Address `yaml:"address"`
StartBlock uint `yaml:"start_block"`
EndBlock uint `yaml:"end_block"`
BlacklistedSenders []common.Address `yaml:"blacklisted_senders"`
}
type BridgeSideConfig struct {
ChainName string `yaml:"chain"`
Chain *ChainConfig `yaml:"-"`
Address common.Address `yaml:"address"`
ValidatorContractAddress common.Address `yaml:"validator_contract_address"`
StartBlock uint `yaml:"start_block"`
BlockConfirmations uint `yaml:"required_block_confirmations"`
MaxBlockRangeSize uint `yaml:"max_block_range_size"`
RefetchEvents []*ReloadJobConfig `yaml:"refetch_events"`
WhitelistedSenders []common.Address `yaml:"whitelisted_senders"`
ErcToNativeTokens []TokenConfig `yaml:"erc_to_native_tokens"`
ErcToNativeBlacklistedSenders []common.Address `yaml:"erc_to_native_blacklisted_senders"`
ChainName string `yaml:"chain"`
Chain *ChainConfig `yaml:"-"`
Address common.Address `yaml:"address"`
ValidatorContractAddress common.Address `yaml:"validator_contract_address"`
StartBlock uint `yaml:"start_block"`
BlockConfirmations uint `yaml:"required_block_confirmations"`
MaxBlockRangeSize uint `yaml:"max_block_range_size"`
RefetchEvents []*ReloadJobConfig `yaml:"refetch_events"`
WhitelistedSenders []common.Address `yaml:"whitelisted_senders"`
ErcToNativeTokens []TokenConfig `yaml:"erc_to_native_tokens"`
}
type BridgeAlertConfig struct {

View File

@ -65,9 +65,14 @@ func (p *BridgeEventHandler) HandleErcToNativeTransfer(ctx context.Context, log
from := data["from"].(common.Address)
value := data["value"].(*big.Int)
for _, addr := range p.cfg.Foreign.ErcToNativeBlacklistedSenders {
if from == addr {
return nil
for _, token := range p.cfg.Foreign.ErcToNativeTokens {
if token.Address == log.Address {
for _, addr := range token.BlacklistedSenders {
if from == addr {
return nil
}
}
break
}
}
logs, err := p.repo.Logs.FindByTxHash(ctx, log.TransactionHash)