Skip to content

Commit 14ffde8

Browse files
authored
Merge pull request #20 from maticnetwork/develop
Develop
2 parents 67260a7 + 1fc442e commit 14ffde8

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

consensus/bor/bor.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,15 @@ func (c *Bor) commitSpan(
10481048
return err
10491049
}
10501050

1051+
// check if chain id matches with heimdall span
1052+
if heimdallSpan.ChainID != c.chainConfig.ChainID.String() {
1053+
return fmt.Errorf(
1054+
"Chain id proposed span, %s, and bor chain id, %s, doesn't match",
1055+
heimdallSpan.ChainID,
1056+
c.chainConfig.ChainID,
1057+
)
1058+
}
1059+
10511060
// get validators bytes
10521061
var validators []MinimalVal
10531062
for _, val := range heimdallSpan.ValidatorSet.Validators {
@@ -1167,11 +1176,22 @@ func (c *Bor) CommitStates(
11671176
if err := json.Unmarshal(response.Result, &eventRecord); err != nil {
11681177
return err
11691178
}
1179+
1180+
// check if chain id matches with event record
1181+
if eventRecord.ChainID != "" && eventRecord.ChainID != c.chainConfig.ChainID.String() {
1182+
return fmt.Errorf(
1183+
"Chain id proposed state in span, %s, and bor chain id, %s, doesn't match",
1184+
eventRecord.ChainID,
1185+
c.chainConfig.ChainID,
1186+
)
1187+
}
1188+
11701189
log.Info("→ committing new state",
11711190
"id", eventRecord.ID,
11721191
"contract", eventRecord.Contract,
11731192
"data", hex.EncodeToString(eventRecord.Data),
11741193
"txHash", eventRecord.TxHash,
1194+
"chainID", eventRecord.ChainID,
11751195
)
11761196

11771197
recordBytes, err := rlp.EncodeToBytes(eventRecord)

consensus/bor/clerk.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ type EventRecord struct {
1212
Data hexutil.Bytes `json:"data" yaml:"data"`
1313
TxHash common.Hash `json:"tx_hash" yaml:"tx_hash"`
1414
LogIndex uint64 `json:"log_index" yaml:"log_index"`
15+
ChainID string `json:"bor_chain_id" yaml:"bor_chain_id"`
1516
}

0 commit comments

Comments
 (0)