mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
core/types: always return non-nil chainID
This commit is contained in:
parent
6957cddc8a
commit
163e4639ec
4 changed files with 16 additions and 8 deletions
|
|
@ -97,7 +97,6 @@ func TestStateProcessorErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
var mkBlobTx = func(nonce uint64, to common.Address, gasLimit uint64, gasTipCap, gasFeeCap, blobGasFeeCap *big.Int, hashes []common.Hash) *types.Transaction {
|
var mkBlobTx = func(nonce uint64, to common.Address, gasLimit uint64, gasTipCap, gasFeeCap, blobGasFeeCap *big.Int, hashes []common.Hash) *types.Transaction {
|
||||||
tx, err := types.SignTx(types.NewTx(&types.BlobTx{
|
tx, err := types.SignTx(types.NewTx(&types.BlobTx{
|
||||||
ChainID: new(uint256.Int),
|
|
||||||
Nonce: nonce,
|
Nonce: nonce,
|
||||||
GasTipCap: uint256.MustFromBig(gasTipCap),
|
GasTipCap: uint256.MustFromBig(gasTipCap),
|
||||||
GasFeeCap: uint256.MustFromBig(gasFeeCap),
|
GasFeeCap: uint256.MustFromBig(gasFeeCap),
|
||||||
|
|
@ -114,7 +113,6 @@ func TestStateProcessorErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
var mkSetCodeTx = func(nonce uint64, to common.Address, gasLimit uint64, gasTipCap, gasFeeCap *big.Int, authlist []types.SetCodeAuthorization) *types.Transaction {
|
var mkSetCodeTx = func(nonce uint64, to common.Address, gasLimit uint64, gasTipCap, gasFeeCap *big.Int, authlist []types.SetCodeAuthorization) *types.Transaction {
|
||||||
tx, err := types.SignTx(types.NewTx(&types.SetCodeTx{
|
tx, err := types.SignTx(types.NewTx(&types.SetCodeTx{
|
||||||
ChainID: new(uint256.Int),
|
|
||||||
Nonce: nonce,
|
Nonce: nonce,
|
||||||
GasTipCap: uint256.MustFromBig(gasTipCap),
|
GasTipCap: uint256.MustFromBig(gasTipCap),
|
||||||
GasFeeCap: uint256.MustFromBig(gasFeeCap),
|
GasFeeCap: uint256.MustFromBig(gasFeeCap),
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ func (s pragueSigner) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big
|
||||||
}
|
}
|
||||||
// Check that chain ID of tx matches the signer. We also accept ID zero here,
|
// Check that chain ID of tx matches the signer. We also accept ID zero here,
|
||||||
// because it indicates that the chain ID was not specified in the tx.
|
// because it indicates that the chain ID was not specified in the tx.
|
||||||
if txdata.ChainID.Sign() != 0 && txdata.ChainID.CmpBig(s.chainId) != 0 {
|
if tx.ChainId().Sign() != 0 && tx.ChainId().Cmp(s.chainId) != 0 {
|
||||||
return nil, nil, nil, fmt.Errorf("%w: have %d want %d", ErrInvalidChainId, txdata.ChainID, s.chainId)
|
return nil, nil, nil, fmt.Errorf("%w: have %d want %d", ErrInvalidChainId, txdata.ChainID, s.chainId)
|
||||||
}
|
}
|
||||||
R, S, _ = decodeSignature(sig)
|
R, S, _ = decodeSignature(sig)
|
||||||
|
|
@ -287,7 +287,7 @@ func (s cancunSigner) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big
|
||||||
}
|
}
|
||||||
// Check that chain ID of tx matches the signer. We also accept ID zero here,
|
// Check that chain ID of tx matches the signer. We also accept ID zero here,
|
||||||
// because it indicates that the chain ID was not specified in the tx.
|
// because it indicates that the chain ID was not specified in the tx.
|
||||||
if txdata.ChainID.Sign() != 0 && txdata.ChainID.CmpBig(s.chainId) != 0 {
|
if tx.ChainId().Sign() != 0 && tx.ChainId().Cmp(s.chainId) != 0 {
|
||||||
return nil, nil, nil, fmt.Errorf("%w: have %d want %d", ErrInvalidChainId, txdata.ChainID, s.chainId)
|
return nil, nil, nil, fmt.Errorf("%w: have %d want %d", ErrInvalidChainId, txdata.ChainID, s.chainId)
|
||||||
}
|
}
|
||||||
R, S, _ = decodeSignature(sig)
|
R, S, _ = decodeSignature(sig)
|
||||||
|
|
|
||||||
|
|
@ -150,8 +150,13 @@ func (tx *BlobTx) copy() TxData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// accessors for innerTx.
|
// accessors for innerTx.
|
||||||
func (tx *BlobTx) txType() byte { return BlobTxType }
|
func (tx *BlobTx) txType() byte { return BlobTxType }
|
||||||
func (tx *BlobTx) chainID() *big.Int { return tx.ChainID.ToBig() }
|
func (tx *BlobTx) chainID() *big.Int {
|
||||||
|
if tx.ChainID == nil {
|
||||||
|
return new(big.Int)
|
||||||
|
}
|
||||||
|
return tx.ChainID.ToBig()
|
||||||
|
}
|
||||||
func (tx *BlobTx) accessList() AccessList { return tx.AccessList }
|
func (tx *BlobTx) accessList() AccessList { return tx.AccessList }
|
||||||
func (tx *BlobTx) data() []byte { return tx.Data }
|
func (tx *BlobTx) data() []byte { return tx.Data }
|
||||||
func (tx *BlobTx) gas() uint64 { return tx.Gas }
|
func (tx *BlobTx) gas() uint64 { return tx.Gas }
|
||||||
|
|
|
||||||
|
|
@ -179,8 +179,13 @@ func (tx *SetCodeTx) copy() TxData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// accessors for innerTx.
|
// accessors for innerTx.
|
||||||
func (tx *SetCodeTx) txType() byte { return SetCodeTxType }
|
func (tx *SetCodeTx) txType() byte { return SetCodeTxType }
|
||||||
func (tx *SetCodeTx) chainID() *big.Int { return tx.ChainID.ToBig() }
|
func (tx *SetCodeTx) chainID() *big.Int {
|
||||||
|
if tx.ChainID == nil {
|
||||||
|
return new(big.Int)
|
||||||
|
}
|
||||||
|
return tx.ChainID.ToBig()
|
||||||
|
}
|
||||||
func (tx *SetCodeTx) accessList() AccessList { return tx.AccessList }
|
func (tx *SetCodeTx) accessList() AccessList { return tx.AccessList }
|
||||||
func (tx *SetCodeTx) data() []byte { return tx.Data }
|
func (tx *SetCodeTx) data() []byte { return tx.Data }
|
||||||
func (tx *SetCodeTx) gas() uint64 { return tx.Gas }
|
func (tx *SetCodeTx) gas() uint64 { return tx.Gas }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue