mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-10 14:03:46 +00:00
check bor chain id for commit span and state
This commit is contained in:
parent
b343bd10c6
commit
cfac491edb
2 changed files with 21 additions and 0 deletions
|
|
@ -1048,6 +1048,15 @@ func (c *Bor) commitSpan(
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if chain id matches with heimdall span
|
||||||
|
if heimdallSpan.ChainID != c.chainConfig.ChainID.String() {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"Chain id proposed span, %s, and bor chain id, %s, doesn't match",
|
||||||
|
heimdallSpan.ChainID,
|
||||||
|
c.chainConfig.ChainID,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// get validators bytes
|
// get validators bytes
|
||||||
var validators []MinimalVal
|
var validators []MinimalVal
|
||||||
for _, val := range heimdallSpan.ValidatorSet.Validators {
|
for _, val := range heimdallSpan.ValidatorSet.Validators {
|
||||||
|
|
@ -1167,11 +1176,22 @@ func (c *Bor) CommitStates(
|
||||||
if err := json.Unmarshal(response.Result, &eventRecord); err != nil {
|
if err := json.Unmarshal(response.Result, &eventRecord); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if chain id matches with event record
|
||||||
|
if eventRecord.ChainID != "" && eventRecord.ChainID != c.chainConfig.ChainID.String() {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"Chain id proposed state in span, %s, and bor chain id, %s, doesn't match",
|
||||||
|
eventRecord.ChainID,
|
||||||
|
c.chainConfig.ChainID,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
log.Info("→ committing new state",
|
log.Info("→ committing new state",
|
||||||
"id", eventRecord.ID,
|
"id", eventRecord.ID,
|
||||||
"contract", eventRecord.Contract,
|
"contract", eventRecord.Contract,
|
||||||
"data", hex.EncodeToString(eventRecord.Data),
|
"data", hex.EncodeToString(eventRecord.Data),
|
||||||
"txHash", eventRecord.TxHash,
|
"txHash", eventRecord.TxHash,
|
||||||
|
"chainID", eventRecord.ChainID,
|
||||||
)
|
)
|
||||||
|
|
||||||
recordBytes, err := rlp.EncodeToBytes(eventRecord)
|
recordBytes, err := rlp.EncodeToBytes(eventRecord)
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,5 @@ type EventRecord struct {
|
||||||
Data hexutil.Bytes `json:"data" yaml:"data"`
|
Data hexutil.Bytes `json:"data" yaml:"data"`
|
||||||
TxHash common.Hash `json:"tx_hash" yaml:"tx_hash"`
|
TxHash common.Hash `json:"tx_hash" yaml:"tx_hash"`
|
||||||
LogIndex uint64 `json:"log_index" yaml:"log_index"`
|
LogIndex uint64 `json:"log_index" yaml:"log_index"`
|
||||||
|
ChainID string `json:"bor_chain_id" yaml:"bor_chain_id"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue