mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
Remove BigNonce and NonceManager logic as it has moved to separate RIP
This commit is contained in:
parent
75fd756a25
commit
c6fc74b5f8
6 changed files with 15 additions and 83 deletions
|
|
@ -82,6 +82,17 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
|||
}
|
||||
// Iterate over and process the individual transactions
|
||||
for i, tx := range block.Transactions() {
|
||||
if tx.Type() == types.Rip7560Type {
|
||||
// HandleRip7560Transactions accepts a transaction array and in the future bundle handling will need this
|
||||
tmpTxs := [1]*types.Transaction{tx}
|
||||
_, validatedTxsReceipts, validateTxsLogs, err := HandleRip7560Transactions(tmpTxs[:], 0, statedb, &context.Coinbase, header, gp, p.config, p.bc, cfg)
|
||||
receipts = append(receipts, validatedTxsReceipts...)
|
||||
allLogs = append(allLogs, validateTxsLogs...)
|
||||
if err != nil {
|
||||
return nil, nil, 0, err
|
||||
}
|
||||
continue
|
||||
}
|
||||
msg, err := TransactionToMessage(tx, signer, header.BaseFee)
|
||||
if err != nil {
|
||||
return nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err)
|
||||
|
|
|
|||
|
|
@ -128,71 +128,12 @@ func NewRip7560StateTransition(evm *vm.EVM, msg *Message, gp *GasPool) *StateTra
|
|||
}
|
||||
}
|
||||
|
||||
// GetRip7560AccountNonce reads the two-dimensional RIP-7560 nonce from the given blockchain state
|
||||
func GetRip7560AccountNonce(config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, cfg vm.Config, sender common.Address, nonceKey *big.Int) uint64 {
|
||||
|
||||
// todo: this is a copy paste of 5 lines that need 8 parameters to run, wtf?
|
||||
blockContext := NewEVMBlockContext(header, bc, author)
|
||||
message, err := TransactionToMessage(tx, types.MakeSigner(config, header.Number, header.Time), header.BaseFee)
|
||||
txContext := NewEVMTxContext(message)
|
||||
vmenv := vm.NewEVM(blockContext, txContext, statedb, config, cfg)
|
||||
vmenv.Reset(txContext, statedb) // TODO what does this 'reset' do?
|
||||
|
||||
from := common.HexToAddress("0x0000000000000000000000000000000000000000")
|
||||
// todo: read NM address from global config
|
||||
nonceManager := common.HexToAddress("0xdebc121d1b09bc03ff57fa1f96514d04a1f0f59d")
|
||||
fromBigNonceKey256, _ := uint256.FromBig(nonceKey)
|
||||
key := make([]byte, 24)
|
||||
fromBigNonceKey256.WriteToSlice(key)
|
||||
nonceManagerData := make([]byte, 0)
|
||||
nonceManagerData = append(nonceManagerData[:], sender.Bytes()...)
|
||||
nonceManagerData = append(nonceManagerData[:], key...)
|
||||
|
||||
nonceManagerMsg := &Message{
|
||||
From: from,
|
||||
To: &nonceManager,
|
||||
Value: big.NewInt(0),
|
||||
GasLimit: 100000,
|
||||
GasPrice: big.NewInt(875000000),
|
||||
GasFeeCap: big.NewInt(875000000),
|
||||
GasTipCap: big.NewInt(875000000),
|
||||
Data: nonceManagerData,
|
||||
AccessList: make(types.AccessList, 0),
|
||||
SkipAccountChecks: true,
|
||||
IsRip7560Frame: true,
|
||||
}
|
||||
resultNonceManager, err := ApplyRip7560FrameMessage(vmenv, nonceManagerMsg, gp)
|
||||
if err != nil {
|
||||
// todo: handle
|
||||
return 777
|
||||
}
|
||||
if resultNonceManager.Err != nil {
|
||||
return 888
|
||||
}
|
||||
if resultNonceManager.ReturnData == nil {
|
||||
return 999
|
||||
}
|
||||
return big.NewInt(0).SetBytes(resultNonceManager.ReturnData).Uint64()
|
||||
}
|
||||
|
||||
func ApplyRip7560ValidationPhases(chainConfig *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, cfg vm.Config) (*ValidationPhaseResult, error) {
|
||||
/*** Nonce Manger Frame ***/
|
||||
nonceManagerMsg := prepareNonceManagerMessage(tx, chainConfig)
|
||||
|
||||
stubMsg := prepareStubMessage(tx, chainConfig)
|
||||
blockContext := NewEVMBlockContext(header, bc, author)
|
||||
txContext := NewEVMTxContext(nonceManagerMsg)
|
||||
txContext := NewEVMTxContext(stubMsg)
|
||||
txContext.Origin = *tx.Rip7560TransactionData().Sender
|
||||
evm := vm.NewEVM(blockContext, txContext, statedb, chainConfig, cfg)
|
||||
|
||||
resultNonceManager, err := ApplyRip7560FrameMessage(evm, nonceManagerMsg, gp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
statedb.IntermediateRoot(true)
|
||||
if resultNonceManager.Err != nil {
|
||||
return nil, resultNonceManager.Err
|
||||
}
|
||||
|
||||
/*** Deployer Frame ***/
|
||||
deployerMsg := prepareDeployerMessage(tx, chainConfig)
|
||||
var deploymentUsedGas uint64
|
||||
|
|
@ -340,25 +281,15 @@ func ApplyRip7560ExecutionPhase(config *params.ChainConfig, vpr *ValidationPhase
|
|||
}
|
||||
return receipt, err
|
||||
}
|
||||
|
||||
func prepareNonceManagerMessage(baseTx *types.Transaction, chainConfig *params.ChainConfig) *Message {
|
||||
func prepareStubMessage(baseTx *types.Transaction, chainConfig *params.ChainConfig) *Message {
|
||||
tx := baseTx.Rip7560TransactionData()
|
||||
key := make([]byte, 32)
|
||||
fromBig, _ := uint256.FromBig(tx.BigNonce)
|
||||
fromBig.WriteToSlice(key)
|
||||
|
||||
nonceManagerData := make([]byte, 0)
|
||||
nonceManagerData = append(nonceManagerData[:], tx.Sender.Bytes()...)
|
||||
nonceManagerData = append(nonceManagerData[:], key...)
|
||||
return &Message{
|
||||
From: chainConfig.EntryPointAddress,
|
||||
To: &chainConfig.NonceManagerAddress,
|
||||
Value: big.NewInt(0),
|
||||
GasLimit: 100000,
|
||||
GasPrice: tx.GasFeeCap,
|
||||
GasFeeCap: tx.GasFeeCap,
|
||||
GasTipCap: tx.GasTipCap,
|
||||
Data: nonceManagerData,
|
||||
AccessList: make(types.AccessList, 0),
|
||||
SkipAccountChecks: true,
|
||||
IsRip7560Frame: true,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,5 @@ func (s rip7560Signer) Hash(tx *Transaction) common.Hash {
|
|||
aatx.BuilderFee,
|
||||
aatx.ValidationGas,
|
||||
aatx.PaymasterGas,
|
||||
aatx.BigNonce,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ type Rip7560AccountAbstractionTx struct {
|
|||
ValidationGas uint64
|
||||
PaymasterGas uint64
|
||||
PostOpGas uint64
|
||||
BigNonce *big.Int
|
||||
|
||||
// removed fields
|
||||
To *common.Address
|
||||
|
|
@ -68,7 +67,6 @@ func (tx *Rip7560AccountAbstractionTx) copy() TxData {
|
|||
GasTipCap: new(big.Int),
|
||||
GasFeeCap: new(big.Int),
|
||||
|
||||
BigNonce: new(big.Int),
|
||||
Sender: copyAddressPtr(tx.Sender),
|
||||
Signature: common.CopyBytes(tx.Signature),
|
||||
PaymasterData: common.CopyBytes(tx.PaymasterData),
|
||||
|
|
@ -90,9 +88,6 @@ func (tx *Rip7560AccountAbstractionTx) copy() TxData {
|
|||
if tx.GasFeeCap != nil {
|
||||
cpy.GasFeeCap.Set(tx.GasFeeCap)
|
||||
}
|
||||
if tx.BigNonce != nil {
|
||||
cpy.BigNonce.Set(tx.BigNonce)
|
||||
}
|
||||
if tx.BuilderFee != nil {
|
||||
cpy.BuilderFee.Set(tx.BuilderFee)
|
||||
}
|
||||
|
|
@ -110,7 +105,6 @@ func (tx *Rip7560AccountAbstractionTx) gasTipCap() *big.Int { return tx.GasTi
|
|||
func (tx *Rip7560AccountAbstractionTx) gasPrice() *big.Int { return tx.GasFeeCap }
|
||||
func (tx *Rip7560AccountAbstractionTx) value() *big.Int { return tx.Value }
|
||||
func (tx *Rip7560AccountAbstractionTx) nonce() uint64 { return 0 }
|
||||
func (tx *Rip7560AccountAbstractionTx) bigNonce() *big.Int { return tx.BigNonce }
|
||||
func (tx *Rip7560AccountAbstractionTx) to() *common.Address { return tx.To }
|
||||
|
||||
func (tx *Rip7560AccountAbstractionTx) effectiveGasPrice(dst *big.Int, baseFee *big.Int) *big.Int {
|
||||
|
|
@ -181,7 +175,7 @@ func (tx *Rip7560AccountAbstractionTx) AbiEncode() ([]byte, error) {
|
|||
}
|
||||
record := &Rip7560Transaction{
|
||||
Sender: *tx.Sender,
|
||||
Nonce: tx.BigNonce,
|
||||
Nonce: big.NewInt(int64(tx.Nonce)),
|
||||
ValidationGasLimit: big.NewInt(int64(tx.ValidationGas)),
|
||||
PaymasterGasLimit: big.NewInt(int64(tx.PaymasterGas)),
|
||||
CallGasLimit: big.NewInt(int64(tx.Gas)),
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ type TransactionArgs struct {
|
|||
BuilderFee *hexutil.Big
|
||||
ValidationGas *hexutil.Uint64
|
||||
PaymasterGas *hexutil.Uint64
|
||||
BigNonce *hexutil.Big // AA nonce is 256 bits wide
|
||||
}
|
||||
|
||||
// from retrieves the transaction sender address.
|
||||
|
|
@ -506,7 +505,6 @@ func (args *TransactionArgs) ToTransaction() *types.Transaction {
|
|||
BuilderFee: (*big.Int)(args.BuilderFee),
|
||||
ValidationGas: uint64(*args.ValidationGas),
|
||||
PaymasterGas: uint64(*args.PaymasterGas),
|
||||
BigNonce: (*big.Int)(args.BigNonce),
|
||||
}
|
||||
data = &aatx
|
||||
hash := types.NewTx(data).Hash()
|
||||
|
|
|
|||
|
|
@ -374,7 +374,6 @@ type ChainConfig struct {
|
|||
|
||||
// RIP-7560 specific config parameters
|
||||
EntryPointAddress common.Address `json:"entryPointAddress,omitempty"`
|
||||
NonceManagerAddress common.Address `json:"nonceManagerAddress,omitempty"`
|
||||
DeployerCallerAddress common.Address `json:"deployerCallerAddress,omitempty"`
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue