diff --git a/core/types/tx_pol.go b/core/types/tx_pol.go index f5d085e547..4a829455af 100644 --- a/core/types/tx_pol.go +++ b/core/types/tx_pol.go @@ -160,10 +160,10 @@ func getDistributeForData(pubkey *common.Pubkey) ([]byte, error) { } // IsPoLDistribution returns true if the transaction is a PoL distribution. -func IsPoLDistribution(to *common.Address, data []byte, distributorAddress common.Address) bool { +func IsPoLDistribution(from common.Address, to *common.Address, data []byte, distributorAddress common.Address) bool { // Txs that call the `distributeFor(bytes pubkey)` method on the PoL Distributor // contract are also consideredPoL txs. - return to != nil && *to == distributorAddress && isDistributeForCall(data) + return from == params.SystemAddress && to != nil && *to == distributorAddress && isDistributeForCall(data) } // isDistributeForCall returns true if the provided calldata corresponds to a diff --git a/core/types/tx_pol_test.go b/core/types/tx_pol_test.go index 97e332539a..eb2ea4188d 100644 --- a/core/types/tx_pol_test.go +++ b/core/types/tx_pol_test.go @@ -92,26 +92,31 @@ func TestIsPoLDistribution(t *testing.T) { } // Positive case. - if !IsPoLDistribution(&distributor, tx.Data(), distributor) { + if !IsPoLDistribution(params.SystemAddress, &distributor, tx.Data(), distributor) { t.Fatalf("expected IsPoLDistribution to return true for valid PoL call") } // Wrong address. otherAddr := common.HexToAddress("0x0200000000000000000000000000000000000002") - if IsPoLDistribution(&otherAddr, tx.Data(), distributor) { + if IsPoLDistribution(params.SystemAddress, &otherAddr, tx.Data(), distributor) { t.Fatalf("expected false when distributor address mismatches") } // Too-short data. shortData := []byte{0x01, 0x02, 0x03} - if IsPoLDistribution(&distributor, shortData, distributor) { + if IsPoLDistribution(params.SystemAddress, &distributor, shortData, distributor) { t.Fatalf("expected false for data shorter than selector") } // Nil address. - if IsPoLDistribution(nil, tx.Data(), distributor) { + if IsPoLDistribution(params.SystemAddress, nil, tx.Data(), distributor) { t.Fatalf("expected false when to==nil") } + + // Wrong from address. + if IsPoLDistribution(distributor, &distributor, tx.Data(), distributor) { + t.Fatalf("expected false when from address mismatches") + } } // TestPoLTx_RawSignatureValues confirms that PoLTx reports no signature. diff --git a/internal/ethapi/transaction_args.go b/internal/ethapi/transaction_args.go index 2e4aef588b..3502f56244 100644 --- a/internal/ethapi/transaction_args.go +++ b/internal/ethapi/transaction_args.go @@ -463,7 +463,7 @@ func (args *TransactionArgs) ToMessage(baseFee *big.Int, skipNonceCheck, skipEoA SetCodeAuthorizations: args.AuthorizationList, SkipNonceChecks: skipNonceCheck, SkipFromEOACheck: skipEoACheck, - IsPoLTx: isPrague1 && types.IsPoLDistribution(args.To, args.data(), distributorAddress), + IsPoLTx: isPrague1 && types.IsPoLDistribution(args.from(), args.To, args.data(), distributorAddress), } } @@ -472,7 +472,7 @@ func (args *TransactionArgs) ToMessage(baseFee *big.Int, skipNonceCheck, skipEoA func (args *TransactionArgs) ToTransaction(defaultType int, isPrague1 bool, distributorAddress common.Address) *types.Transaction { usedType := types.LegacyTxType switch { - case isPrague1 && types.IsPoLDistribution(args.To, args.data(), distributorAddress): + case isPrague1 && types.IsPoLDistribution(args.from(), args.To, args.data(), distributorAddress): usedType = types.PoLTxType case args.AuthorizationList != nil || defaultType == types.SetCodeTxType: usedType = types.SetCodeTxType