Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions consensus/consortium/common/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func (c *ContractIntegrator) WrapUpEpoch(opts *ApplyTransactOpts) error {
false,
nil,
nil,
nil,
)

if err = ApplyTransaction(msg, opts); err != nil {
Expand Down Expand Up @@ -249,6 +250,7 @@ func (c *ContractIntegrator) SubmitBlockReward(opts *ApplyTransactOpts) error {
false,
nil,
nil,
nil,
)

if err = ApplyTransaction(msg, opts); err != nil {
Expand Down Expand Up @@ -282,6 +284,7 @@ func (c *ContractIntegrator) Slash(opts *ApplyTransactOpts, spoiledValidator com
false,
nil,
nil,
nil,
)

if err = ApplyTransaction(msg, opts); err != nil {
Expand Down Expand Up @@ -313,6 +316,7 @@ func (c *ContractIntegrator) FinalityReward(opts *ApplyTransactOpts, votedValida
false,
nil,
nil,
nil,
)

if err = ApplyTransaction(msg, opts); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion consensus/consortium/common/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func TestApplyTransaction(t *testing.T) {
t.Fatal(err)
}
msg := types.NewMessage(minerAddr, tx.To(), tx.Nonce(), tx.Value(), tx.Gas(),
tx.GasPrice(), tx.GasFeeCap(), tx.GasTipCap(), tx.Data(), nil, false, nil, nil)
tx.GasPrice(), tx.GasFeeCap(), tx.GasTipCap(), tx.Data(), nil, false, nil, nil, nil)

state, err := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ func NewMessage(
isFake bool,
blobFeeCap *big.Int,
blobHashes []common.Hash,
authList []Authorization,
) Message {
return Message{
from: from,
Expand All @@ -644,6 +645,7 @@ func NewMessage(
expiredTime: 0,
blobGasFeeCap: blobFeeCap,
blobHashes: blobHashes,
authList: authList,
}
}

Expand Down
1 change: 1 addition & 0 deletions eth/gasestimator/gasestimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func execute(ctx context.Context, call core.Message, opts *Options, gasLimit uin
true,
call.BlobGasFeeCap(),
call.BlobHashes(),
nil,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This msg will be passed to core.ApplyMessage, so missing authList field will cause estimating gas failed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, this is big, but passing AuthList requires to update the core.Message interface => introduce more complexity to this PR. At the moment, it haven't broken any test yet and gas estimation is not implemented in state_transistion. So update it together with state_transition?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM!!

)

// Execute the call and separate execution faults caused by a lack of gas or
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/internal/tracetest/calltrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func TestInternals(t *testing.T) {
}, false, rawdb.HashScheme)
defer triedb.Close()
evm := vm.NewEVM(context, txContext, statedb, params.MainnetChainConfig, vm.Config{Tracer: tc.tracer})
msg := types.NewMessage(origin, &to, 0, big.NewInt(0), 50000, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, false, nil, nil)
msg := types.NewMessage(origin, &to, 0, big.NewInt(0), 50000, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, false, nil, nil, nil)
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(msg.Gas()))
if _, err := st.TransitionDb(); err != nil {
t.Fatalf("test %v: failed to execute transaction: %v", tc.name, err)
Expand Down
22 changes: 21 additions & 1 deletion internal/ethapi/transaction_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ type TransactionArgs struct {
Commitments []kzg4844.Commitment `json:"commitments"`
Proofs []kzg4844.Proof `json:"proofs"`

// For SetCodeTxType
AuthorizationList []types.Authorization `json:"authorizationList"`

// This configures whether blobs are allowed to be passed.
blobSidecarAllowed bool
}
Expand Down Expand Up @@ -297,7 +300,7 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (t
if args.BlobHashes != nil && args.BlobFeeCap == nil {
args.BlobFeeCap = new(hexutil.Big)
}
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, gasFeeCap, gasTipCap, data, accessList, true, (*big.Int)(args.BlobFeeCap), args.BlobHashes)
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, gasFeeCap, gasTipCap, data, accessList, true, (*big.Int)(args.BlobFeeCap), args.BlobHashes, args.AuthorizationList)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added from #29

return msg, nil
}

Expand All @@ -306,6 +309,23 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (t
func (args *TransactionArgs) toTransaction() *types.Transaction {
var data types.TxData
switch {
case len(args.AuthorizationList) != 0:
al := types.AccessList{}
if args.AccessList != nil {
al = *args.AccessList
}
data = &types.SetCodeTx{
To: *args.To,
ChainID: args.ChainID.ToInt().Uint64(),
Nonce: uint64(*args.Nonce),
Gas: uint64(*args.Gas),
GasFeeCap: uint256.MustFromBig((*big.Int)(args.MaxFeePerGas)),
GasTipCap: uint256.MustFromBig((*big.Int)(args.MaxPriorityFeePerGas)),
Value: uint256.MustFromBig((*big.Int)(args.Value)),
Data: args.data(),
AccessList: al,
AuthList: args.AuthorizationList,
}
case len(args.BlobHashes) != 0:
al := types.AccessList{}
if args.AccessList != nil {
Expand Down
4 changes: 2 additions & 2 deletions les/odr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
from := statedb.GetOrNewStateObject(bankAddr)
from.SetBalance(math.MaxBig256)

msg := callmsg{types.NewMessage(from.Address(), &testContractAddr, 0, new(big.Int), 100000, big.NewInt(params.InitialBaseFee), big.NewInt(params.InitialBaseFee), new(big.Int), data, nil, true, nil, nil)}
msg := callmsg{types.NewMessage(from.Address(), &testContractAddr, 0, new(big.Int), 100000, big.NewInt(params.InitialBaseFee), big.NewInt(params.InitialBaseFee), new(big.Int), data, nil, true, nil, nil, nil)}

context := core.NewEVMBlockContext(header, bc, nil)
txContext := core.NewEVMTxContext(msg)
Expand All @@ -151,7 +151,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
header := lc.GetHeaderByHash(bhash)
state := light.NewState(ctx, header, lc.Odr())
state.SetBalance(bankAddr, math.MaxBig256)
msg := callmsg{types.NewMessage(bankAddr, &testContractAddr, 0, new(big.Int), 100000, big.NewInt(params.InitialBaseFee), big.NewInt(params.InitialBaseFee), new(big.Int), data, nil, true, nil, nil)}
msg := callmsg{types.NewMessage(bankAddr, &testContractAddr, 0, new(big.Int), 100000, big.NewInt(params.InitialBaseFee), big.NewInt(params.InitialBaseFee), new(big.Int), data, nil, true, nil, nil, nil)}
context := core.NewEVMBlockContext(header, lc, nil)
txContext := core.NewEVMTxContext(msg)
vmenv := vm.NewEVM(context, txContext, state, config, vm.Config{NoBaseFee: true})
Expand Down
2 changes: 1 addition & 1 deletion light/odr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, bc *core.BlockChain

// Perform read-only call.
st.SetBalance(testBankAddress, math.MaxBig256)
msg := callmsg{types.NewMessage(testBankAddress, &testContractAddr, 0, new(big.Int), 1000000, big.NewInt(params.InitialBaseFee), big.NewInt(params.InitialBaseFee), new(big.Int), data, nil, true, nil, nil)}
msg := callmsg{types.NewMessage(testBankAddress, &testContractAddr, 0, new(big.Int), 1000000, big.NewInt(params.InitialBaseFee), big.NewInt(params.InitialBaseFee), new(big.Int), data, nil, true, nil, nil, nil)}
txContext := core.NewEVMTxContext(msg)
context := core.NewEVMBlockContext(header, chain, nil)
vmenv := vm.NewEVM(context, txContext, st, config, vm.Config{NoBaseFee: true})
Expand Down
4 changes: 3 additions & 1 deletion tests/state_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,10 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (core.Messa
return nil, fmt.Errorf("no gas price provided")
}

// TODO: pass authList as go-ethereum did, leave it to "tests" update tasks
// https://github.com/ethereum/go-ethereum/blob/aaaf01d71232d1b7da5ab2ae9258f7fb9f22b1bf/tests/state_test_util.go#L479
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is complicated, need state_transition involvement, leave it to later PRs

msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, gasPrice,
tx.MaxFeePerGas, tx.MaxPriorityFeePerGas, data, accessList, false, nil, nil)
tx.MaxFeePerGas, tx.MaxPriorityFeePerGas, data, accessList, false, nil, nil, nil)
return msg, nil
}

Expand Down