Enable cross-shard transaction at CrossTxEpoch+1

This is to allow for all 4 shards to roll into CrossTxEpoch and start
having cross-shard-transaction-related fields in block header/body
before the fields are actually used.  Otherwise, if a shard A enters
CrossTxEpoch before shard B does and sends a cross-shard receipt to
shard B, it cannot be processed because chain B still lacks the incoming
receipts field.
pull/1550/head
Eugene Kim 5 years ago
parent 30c8c66b39
commit e9e09b7650
  1. 2
      core/state_processor.go
  2. 14
      internal/params/config.go

@ -127,7 +127,7 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
if txType != types.SameShardTx && !config.IsCrossTx(header.Epoch()) {
return nil, nil, 0, fmt.Errorf(
"cannot handle cross-shard transaction before epoch %v (now %v)",
"cannot handle cross-shard transaction until after epoch %v (now %v)",
config.CrossTxEpoch, header.Epoch())
}

@ -99,9 +99,19 @@ func (c *ChainConfig) IsEIP155(epoch *big.Int) bool {
return isForked(c.EIP155Epoch, epoch)
}
// IsCrossTx returns whether cross-shard transaction is enabled in the given epoch.
// IsCrossTx returns whether cross-shard transaction is enabled in the given
// epoch.
//
// Note that this is different from comparing epoch against CrossTxEpoch.
// Cross-shard transaction is enabled from CrossTxEpoch+1 and on, in order to
// allow for all shards to roll into CrossTxEpoch and become able to handle
// ingress receipts. In other words, cross-shard transaction fields are
// introduced at CrossTxEpoch, but these fields are not used until
// CrossTxEpoch+1, when cross-shard transactions are actually accepted by the
// network.
func (c *ChainConfig) IsCrossTx(epoch *big.Int) bool {
return isForked(c.CrossTxEpoch, epoch)
crossTxEpoch := new(big.Int).Add(c.CrossTxEpoch, common.Big1)
return isForked(crossTxEpoch, epoch)
}
// IsCrossLink returns whether epoch is either equal to the CrossLink fork epoch or greater.

Loading…
Cancel
Save