diff --git a/state/helper.go b/state/helper.go index bdd9c64bbd..4b637c31fa 100644 --- a/state/helper.go +++ b/state/helper.go @@ -117,7 +117,7 @@ func EncodeTransaction(tx types.Transaction, effectivePercentage uint8, forkID u } // EncodeUnsignedTransaction RLP encodes the given unsigned transaction -func EncodeUnsignedTransaction(tx types.Transaction, chainID uint64, forcedNonce *uint64) ([]byte, error) { +func EncodeUnsignedTransaction(tx types.Transaction, chainID uint64, forcedNonce *uint64, forkID uint64) ([]byte, error) { v, _ := new(big.Int).SetString("0x1c", 0) r, _ := new(big.Int).SetString("0xa54492cfacf71aef702421b7fbc70636537a7b2fbe5718c5ed970a001bb7756b", 0) s, _ := new(big.Int).SetString("0x2e9fb27acc75955b898f0b12ec52aa34bf08f01db654374484b80bf12f0d841e", 0) @@ -151,6 +151,10 @@ func EncodeUnsignedTransaction(tx types.Transaction, chainID uint64, forcedNonce newSPadded := fmt.Sprintf("%064s", s.Text(hex.Base)) newVPadded := fmt.Sprintf("%02s", newV.Text(hex.Base)) effectivePercentageAsHex := fmt.Sprintf("%x", MaxEffectivePercentage) + // Only add EffectiveGasprice if forkID is equal or higher than 5 + if forkID < forkID5 { + effectivePercentageAsHex = "" + } txData, err := hex.DecodeString(hex.EncodeToString(txCodedRlp) + newRPadded + newSPadded + newVPadded + effectivePercentageAsHex) if err != nil { return nil, err diff --git a/state/transaction.go b/state/transaction.go index 633932e8f9..1107ec2e17 100644 --- a/state/transaction.go +++ b/state/transaction.go @@ -793,13 +793,14 @@ func (s *State) internalProcessUnsignedTransaction(ctx context.Context, tx *type } } - batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, &nonce) + forkID := s.GetForkIDByBatchNumber(lastBatch.BatchNumber) + + batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, &nonce, forkID) if err != nil { log.Errorf("error encoding unsigned transaction ", err) return nil, err } - forkID := s.GetForkIDByBatchNumber(lastBatch.BatchNumber) // Create Batch processBatchRequest := &pb.ProcessBatchRequest{ OldBatchNum: lastBatch.BatchNumber, @@ -1036,13 +1037,14 @@ func (s *State) EstimateGas(transaction *types.Transaction, senderAddress common Data: transaction.Data(), }) - batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, nil) + forkID := s.GetForkIDByBatchNumber(lastBatch.BatchNumber) + + batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, nil, forkID) if err != nil { log.Errorf("error encoding unsigned transaction ", err) return false, false, gasUsed, nil, err } - forkID := s.GetForkIDByBatchNumber(lastBatch.BatchNumber) // Create a batch to be sent to the executor processBatchRequest := &pb.ProcessBatchRequest{ OldBatchNum: lastBatch.BatchNumber,