mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
fix nonce, entrypoint (#17)
- add correct sender address for AA transactions (AA_ENTRY_POINT, and AA_CREATOR for the deployment frame) - disable nonce increment in TransitionDb if the sender is either of these magic addresses - add AA-specific nonce increment for the transaction sender.
This commit is contained in:
parent
4dc333d54f
commit
7f93f508c1
2 changed files with 12 additions and 5 deletions
|
|
@ -19,6 +19,9 @@ const MAGIC_VALUE_PAYMASTER = uint64(0xe0e6183a)
|
||||||
const MAGIC_VALUE_SIGFAIL = uint64(0x31665494)
|
const MAGIC_VALUE_SIGFAIL = uint64(0x31665494)
|
||||||
const PAYMASTER_MAX_CONTEXT_SIZE = 65536
|
const PAYMASTER_MAX_CONTEXT_SIZE = 65536
|
||||||
|
|
||||||
|
var AA_ENTRY_POINT = common.HexToAddress("0x0000000000000000000000000000000000007560")
|
||||||
|
var AA_SENDER_CREATOR = common.HexToAddress("0x00000000000000000000000000000000ffff7560")
|
||||||
|
|
||||||
func PackValidationData(authorizerMagic uint64, validUntil, validAfter uint64) []byte {
|
func PackValidationData(authorizerMagic uint64, validUntil, validAfter uint64) []byte {
|
||||||
|
|
||||||
t := new(big.Int).SetUint64(uint64(validAfter))
|
t := new(big.Int).SetUint64(uint64(validAfter))
|
||||||
|
|
@ -209,6 +212,8 @@ func ApplyRip7560ValidationPhases(chainConfig *params.ChainConfig, bc ChainConte
|
||||||
return nil, fmt.Errorf("account deployment failed: %v", err)
|
return nil, fmt.Errorf("account deployment failed: %v", err)
|
||||||
}
|
}
|
||||||
statedb.IntermediateRoot(true)
|
statedb.IntermediateRoot(true)
|
||||||
|
} else {
|
||||||
|
statedb.SetNonce(*sender, statedb.GetNonce(*sender)+1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Account Validation Frame ***/
|
/*** Account Validation Frame ***/
|
||||||
|
|
@ -355,7 +360,7 @@ func prepareDeployerMessage(baseTx *types.Transaction, config *params.ChainConfi
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &Message{
|
return &Message{
|
||||||
From: config.DeployerCallerAddress,
|
From: AA_SENDER_CREATOR,
|
||||||
To: tx.Deployer,
|
To: tx.Deployer,
|
||||||
Value: big.NewInt(0),
|
Value: big.NewInt(0),
|
||||||
GasLimit: tx.ValidationGas,
|
GasLimit: tx.ValidationGas,
|
||||||
|
|
@ -382,7 +387,7 @@ func prepareAccountValidationMessage(baseTx *types.Transaction, chainConfig *par
|
||||||
txAbiEncoding, err := tx.AbiEncode()
|
txAbiEncoding, err := tx.AbiEncode()
|
||||||
validateTransactionData, err := validateTransactionAbi.Pack("validateTransaction", big.NewInt(0), signingHash, txAbiEncoding)
|
validateTransactionData, err := validateTransactionAbi.Pack("validateTransaction", big.NewInt(0), signingHash, txAbiEncoding)
|
||||||
return &Message{
|
return &Message{
|
||||||
From: chainConfig.EntryPointAddress,
|
From: AA_ENTRY_POINT,
|
||||||
To: tx.Sender,
|
To: tx.Sender,
|
||||||
Value: big.NewInt(0),
|
Value: big.NewInt(0),
|
||||||
GasLimit: tx.ValidationGas - deploymentUsedGas,
|
GasLimit: tx.ValidationGas - deploymentUsedGas,
|
||||||
|
|
@ -430,7 +435,7 @@ func preparePaymasterValidationMessage(baseTx *types.Transaction, config *params
|
||||||
func prepareAccountExecutionMessage(baseTx *types.Transaction, config *params.ChainConfig) *Message {
|
func prepareAccountExecutionMessage(baseTx *types.Transaction, config *params.ChainConfig) *Message {
|
||||||
tx := baseTx.Rip7560TransactionData()
|
tx := baseTx.Rip7560TransactionData()
|
||||||
return &Message{
|
return &Message{
|
||||||
From: config.EntryPointAddress,
|
From: AA_ENTRY_POINT,
|
||||||
To: tx.Sender,
|
To: tx.Sender,
|
||||||
Value: big.NewInt(0),
|
Value: big.NewInt(0),
|
||||||
GasLimit: tx.Gas,
|
GasLimit: tx.Gas,
|
||||||
|
|
@ -462,7 +467,7 @@ func preparePostOpMessage(vpr *ValidationPhaseResult, chainConfig *params.ChainC
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &Message{
|
return &Message{
|
||||||
From: chainConfig.EntryPointAddress,
|
From: AA_ENTRY_POINT,
|
||||||
To: tx.Paymaster,
|
To: tx.Paymaster,
|
||||||
Value: big.NewInt(0),
|
Value: big.NewInt(0),
|
||||||
GasLimit: tx.PaymasterGas - executionResult.UsedGas,
|
GasLimit: tx.PaymasterGas - executionResult.UsedGas,
|
||||||
|
|
|
||||||
|
|
@ -454,7 +454,9 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
|
||||||
ret, _, st.gasRemaining, vmerr = st.evm.Create(sender, msg.Data, st.gasRemaining, value)
|
ret, _, st.gasRemaining, vmerr = st.evm.Create(sender, msg.Data, st.gasRemaining, value)
|
||||||
} else {
|
} else {
|
||||||
// Increment the nonce for the next transaction
|
// Increment the nonce for the next transaction
|
||||||
|
if msg.From != AA_SENDER_CREATOR && msg.From != AA_ENTRY_POINT {
|
||||||
st.state.SetNonce(msg.From, st.state.GetNonce(sender.Address())+1)
|
st.state.SetNonce(msg.From, st.state.GetNonce(sender.Address())+1)
|
||||||
|
}
|
||||||
ret, st.gasRemaining, vmerr = st.evm.Call(sender, st.to(), msg.Data, st.gasRemaining, value)
|
ret, st.gasRemaining, vmerr = st.evm.Call(sender, st.to(), msg.Data, st.gasRemaining, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue