IsCrossTx → AcceptsCrossTx

This clarifies the intended use of the predicate.
pull/1964/head
Eugene Kim 5 years ago
parent 02ba0b309c
commit ef389aa9b5
  1. 4
      core/block_validator.go
  2. 2
      core/blockchain.go
  3. 4
      core/state_processor.go
  4. 8
      internal/params/config.go
  5. 2
      node/node_newblock.go

@ -100,7 +100,7 @@ func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *stat
return fmt.Errorf("invalid receipt root hash (remote: %x local: %x)", header.ReceiptHash(), receiptSha)
}
if v.config.IsCrossTx(block.Epoch()) {
if v.config.AcceptsCrossTx(block.Epoch()) {
cxsSha := types.DeriveMultipleShardsSha(cxReceipts)
if cxsSha != header.OutgoingReceiptHash() {
return fmt.Errorf("invalid cross shard receipt root hash (remote: %x local: %x)", header.OutgoingReceiptHash(), cxsSha)
@ -175,7 +175,7 @@ func CalcGasLimit(parent *types.Block, gasFloor, gasCeil uint64) uint64 {
// ValidateCXReceiptsProof checks whether the given CXReceiptsProof is consistency with itself
func (v *BlockValidator) ValidateCXReceiptsProof(cxp *types.CXReceiptsProof) error {
if !v.config.IsCrossTx(cxp.Header.Epoch()) {
if !v.config.AcceptsCrossTx(cxp.Header.Epoch()) {
return ctxerror.New("[ValidateCXReceiptsProof] cross shard receipt received before cx fork")
}

@ -1102,7 +1102,7 @@ func (bc *BlockChain) WriteBlockWithState(
//// Cross-shard txns
epoch := block.Header().Epoch()
if bc.chainConfig.IsCrossTx(block.Epoch()) {
if bc.chainConfig.AcceptsCrossTx(block.Epoch()) {
shardingConfig := shard.Schedule.InstanceForEpoch(epoch)
shardNum := int(shardingConfig.NumShards())
for i := 0; i < shardNum; i++ {

@ -122,7 +122,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.DB, cfg vm.C
// return true if it is valid
func getTransactionType(config *params.ChainConfig, header *block.Header, tx *types.Transaction) types.TransactionType {
if header.ShardID() == tx.ShardID() && (!config.IsCrossTx(header.Epoch()) || tx.ShardID() == tx.ToShardID()) {
if header.ShardID() == tx.ShardID() && (!config.AcceptsCrossTx(header.Epoch()) || tx.ShardID() == tx.ToShardID()) {
return types.SameShardTx
}
numShards := shard.Schedule.InstanceForEpoch(header.Epoch()).NumShards()
@ -143,7 +143,7 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
return nil, nil, 0, fmt.Errorf("Invalid Transaction Type")
}
if txType != types.SameShardTx && !config.IsCrossTx(header.Epoch()) {
if txType != types.SameShardTx && !config.AcceptsCrossTx(header.Epoch()) {
return nil, nil, 0, fmt.Errorf(
"cannot handle cross-shard transaction until after epoch %v (now %v)",
config.CrossTxEpoch, header.Epoch())

@ -139,8 +139,8 @@ func (c *ChainConfig) IsEIP155(epoch *big.Int) bool {
return isForked(c.EIP155Epoch, epoch)
}
// IsCrossTx returns whether cross-shard transaction is accepted in the given
// epoch.
// AcceptsCrossTx returns whether cross-shard transaction is accepted in the
// given epoch.
//
// Note that this is different from comparing epoch against CrossTxEpoch.
// Cross-shard transaction is accepted from CrossTxEpoch+1 and on, in order to
@ -148,9 +148,7 @@ func (c *ChainConfig) IsEIP155(epoch *big.Int) bool {
// ingress receipts. In other words, cross-shard transaction fields are
// introduced and ingress receipts are processed at CrossTxEpoch, but the shard
// does not accept cross-shard transactions from clients until CrossTxEpoch+1.
//
// TODO ek – rename to AcceptsCrossTx to clarify
func (c *ChainConfig) IsCrossTx(epoch *big.Int) bool {
func (c *ChainConfig) AcceptsCrossTx(epoch *big.Int) bool {
crossTxEpoch := new(big.Int).Add(c.CrossTxEpoch, common.Big1)
return isForked(crossTxEpoch, epoch)
}

@ -167,7 +167,7 @@ func (node *Node) proposeNewBlock() (*types.Block, error) {
}
func (node *Node) proposeReceiptsProof() []*types.CXReceiptsProof {
if !node.Blockchain().Config().IsCrossTx(node.Worker.GetCurrentHeader().Epoch()) {
if !node.Blockchain().Config().AcceptsCrossTx(node.Worker.GetCurrentHeader().Epoch()) {
return []*types.CXReceiptsProof{}
}

Loading…
Cancel
Save