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": { "end_block": {
"type": "integer" "type": "integer"
},
"blacklisted_senders": {
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$"
}
} }
}, },
"required": [ "required": [
"address" "address"
] ]
} }
},
"erc_to_native_blacklisted_senders": {
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$"
}
} }
}, },
"required": [ "required": [

View File

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

View File

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

View File

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