Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 53bbcd4

Browse files
committedOct 29, 2024
internal/ethapi: rework setDefaults for tx args so fee logic is separate (ethereum#25197)
1 parent 7689dff commit 53bbcd4

File tree

2 files changed

+517
-50
lines changed

2 files changed

+517
-50
lines changed
 

‎internal/ethapi/transaction_args.go

+68-50
Original file line numberDiff line numberDiff line change
@@ -75,56 +75,8 @@ func (args *TransactionArgs) data() []byte {
7575

7676
// setDefaults fills in default values for unspecified tx fields.
7777
func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
78-
if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) {
79-
return errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
80-
}
81-
// After london, default to 1559 unless gasPrice is set
82-
head := b.CurrentHeader()
83-
// If user specifies both maxPriorityfee and maxFee, then we do not
84-
// need to consult the chain for defaults. It's definitely a London tx.
85-
if args.MaxPriorityFeePerGas == nil || args.MaxFeePerGas == nil {
86-
// In this clause, user left some fields unspecified.
87-
if b.ChainConfig().IsEIP1559(head.Number) && args.GasPrice == nil {
88-
if args.MaxPriorityFeePerGas == nil {
89-
tip, err := b.SuggestGasTipCap(ctx)
90-
if err != nil {
91-
return err
92-
}
93-
args.MaxPriorityFeePerGas = (*hexutil.Big)(tip)
94-
}
95-
if args.MaxFeePerGas == nil {
96-
gasFeeCap := new(big.Int).Add(
97-
(*big.Int)(args.MaxPriorityFeePerGas),
98-
new(big.Int).Mul(head.BaseFee, big.NewInt(2)),
99-
)
100-
args.MaxFeePerGas = (*hexutil.Big)(gasFeeCap)
101-
}
102-
if args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 {
103-
return fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", args.MaxFeePerGas, args.MaxPriorityFeePerGas)
104-
}
105-
} else {
106-
if args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil {
107-
return errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet")
108-
}
109-
if args.GasPrice == nil {
110-
price, err := b.SuggestGasTipCap(ctx)
111-
if err != nil {
112-
return err
113-
}
114-
if b.ChainConfig().IsEIP1559(head.Number) {
115-
// The legacy tx gas price suggestion should not add 2x base fee
116-
// because all fees are consumed, so it would result in a spiral
117-
// upwards.
118-
price.Add(price, head.BaseFee)
119-
}
120-
args.GasPrice = (*hexutil.Big)(price)
121-
}
122-
}
123-
} else {
124-
// Both maxPriorityfee and maxFee set by caller. Sanity-check their internal relation
125-
if args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 {
126-
return fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", args.MaxFeePerGas, args.MaxPriorityFeePerGas)
127-
}
78+
if err := args.setFeeDefaults(ctx, b); err != nil {
79+
return err
12880
}
12981
if args.Value == nil {
13082
args.Value = new(hexutil.Big)
@@ -178,6 +130,72 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
178130
return nil
179131
}
180132

133+
// setFeeDefaults fills in default fee values for unspecified tx fields.
134+
func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) error {
135+
// If both gasPrice and at least one of the EIP-1559 fee parameters are specified, error.
136+
if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) {
137+
return errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
138+
}
139+
// If the tx has completely specified a fee mechanism, no default is needed. This allows users
140+
// who are not yet synced past London to get defaults for other tx values. See
141+
// https://github.com/ethereum/go-ethereum/pull/23274 for more information.
142+
eip1559ParamsSet := args.MaxFeePerGas != nil && args.MaxPriorityFeePerGas != nil
143+
if (args.GasPrice != nil && !eip1559ParamsSet) || (args.GasPrice == nil && eip1559ParamsSet) {
144+
// Sanity check the EIP-1559 fee parameters if present.
145+
if args.GasPrice == nil && args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 {
146+
return fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", args.MaxFeePerGas, args.MaxPriorityFeePerGas)
147+
}
148+
return nil
149+
}
150+
// Now attempt to fill in default value depending on whether London is active or not.
151+
head := b.CurrentHeader()
152+
if b.ChainConfig().IsEIP1559(head.Number) {
153+
// London is active, set maxPriorityFeePerGas and maxFeePerGas.
154+
if err := args.setLondonFeeDefaults(ctx, head, b); err != nil {
155+
return err
156+
}
157+
} else {
158+
if args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil {
159+
return fmt.Errorf("maxFeePerGas and maxPriorityFeePerGas are not valid before London is active")
160+
}
161+
// London not active, set gas price.
162+
price, err := b.SuggestGasTipCap(ctx)
163+
if err != nil {
164+
return err
165+
}
166+
args.GasPrice = (*hexutil.Big)(price)
167+
}
168+
return nil
169+
}
170+
171+
// setLondonFeeDefaults fills in reasonable default fee values for unspecified fields.
172+
func (args *TransactionArgs) setLondonFeeDefaults(ctx context.Context, head *types.Header, b Backend) error {
173+
// Set maxPriorityFeePerGas if it is missing.
174+
if args.MaxPriorityFeePerGas == nil {
175+
tip, err := b.SuggestGasTipCap(ctx)
176+
if err != nil {
177+
return err
178+
}
179+
args.MaxPriorityFeePerGas = (*hexutil.Big)(tip)
180+
}
181+
// Set maxFeePerGas if it is missing.
182+
if args.MaxFeePerGas == nil {
183+
// Set the max fee to be 2 times larger than the previous block's base fee.
184+
// The additional slack allows the tx to not become invalidated if the base
185+
// fee is rising.
186+
val := new(big.Int).Add(
187+
args.MaxPriorityFeePerGas.ToInt(),
188+
new(big.Int).Mul(head.BaseFee, big.NewInt(2)),
189+
)
190+
args.MaxFeePerGas = (*hexutil.Big)(val)
191+
}
192+
// Both EIP-1559 fee parameters are now set; sanity check them.
193+
if args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 {
194+
return fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", args.MaxFeePerGas, args.MaxPriorityFeePerGas)
195+
}
196+
return nil
197+
}
198+
181199
// ToMessage converts the transaction arguments to the Message type used by the
182200
// core evm. This method is used in calls and traces that do not require a real
183201
// live transaction.
+449
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,449 @@
1+
// Copyright 2022 The go-ethereum Authors
2+
// This file is part of the go-ethereum library.
3+
//
4+
// The go-ethereum library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Lesser General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// The go-ethereum library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Lesser General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Lesser General Public License
15+
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
16+
17+
package ethapi
18+
19+
import (
20+
"context"
21+
"fmt"
22+
"math/big"
23+
"reflect"
24+
"testing"
25+
"time"
26+
27+
ethereum "github.com/XinFinOrg/XDPoSChain"
28+
"github.com/XinFinOrg/XDPoSChain/XDCx"
29+
"github.com/XinFinOrg/XDPoSChain/XDCx/tradingstate"
30+
"github.com/XinFinOrg/XDPoSChain/XDCxlending"
31+
"github.com/XinFinOrg/XDPoSChain/accounts"
32+
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind"
33+
"github.com/XinFinOrg/XDPoSChain/common"
34+
"github.com/XinFinOrg/XDPoSChain/common/hexutil"
35+
"github.com/XinFinOrg/XDPoSChain/consensus"
36+
"github.com/XinFinOrg/XDPoSChain/core"
37+
"github.com/XinFinOrg/XDPoSChain/core/bloombits"
38+
"github.com/XinFinOrg/XDPoSChain/core/state"
39+
"github.com/XinFinOrg/XDPoSChain/core/types"
40+
"github.com/XinFinOrg/XDPoSChain/core/vm"
41+
"github.com/XinFinOrg/XDPoSChain/eth/downloader"
42+
"github.com/XinFinOrg/XDPoSChain/ethdb"
43+
"github.com/XinFinOrg/XDPoSChain/event"
44+
"github.com/XinFinOrg/XDPoSChain/params"
45+
"github.com/XinFinOrg/XDPoSChain/rpc"
46+
)
47+
48+
// TestSetFeeDefaults tests the logic for filling in default fee values works as expected.
49+
func TestSetFeeDefaults(t *testing.T) {
50+
type test struct {
51+
name string
52+
isLondon bool
53+
in *TransactionArgs
54+
want *TransactionArgs
55+
err error
56+
}
57+
58+
var (
59+
b = newBackendMock()
60+
fortytwo = (*hexutil.Big)(big.NewInt(42))
61+
maxFee = (*hexutil.Big)(new(big.Int).Add(new(big.Int).Mul(b.current.BaseFee, big.NewInt(2)), fortytwo.ToInt()))
62+
al = &types.AccessList{types.AccessTuple{Address: common.Address{0xaa}, StorageKeys: []common.Hash{{0x01}}}}
63+
)
64+
65+
tests := []test{
66+
// Legacy txs
67+
{
68+
"legacy tx pre-London",
69+
false,
70+
&TransactionArgs{},
71+
&TransactionArgs{GasPrice: fortytwo},
72+
nil,
73+
},
74+
{
75+
"legacy tx post-London, explicit gas price",
76+
true,
77+
&TransactionArgs{GasPrice: fortytwo},
78+
&TransactionArgs{GasPrice: fortytwo},
79+
nil,
80+
},
81+
82+
// Access list txs
83+
{
84+
"access list tx pre-London",
85+
false,
86+
&TransactionArgs{AccessList: al},
87+
&TransactionArgs{AccessList: al, GasPrice: fortytwo},
88+
nil,
89+
},
90+
{
91+
"access list tx post-London, explicit gas price",
92+
false,
93+
&TransactionArgs{AccessList: al, GasPrice: fortytwo},
94+
&TransactionArgs{AccessList: al, GasPrice: fortytwo},
95+
nil,
96+
},
97+
{
98+
"access list tx post-London",
99+
true,
100+
&TransactionArgs{AccessList: al},
101+
&TransactionArgs{AccessList: al, MaxFeePerGas: maxFee, MaxPriorityFeePerGas: fortytwo},
102+
nil,
103+
},
104+
{
105+
"access list tx post-London, only max fee",
106+
true,
107+
&TransactionArgs{AccessList: al, MaxFeePerGas: maxFee},
108+
&TransactionArgs{AccessList: al, MaxFeePerGas: maxFee, MaxPriorityFeePerGas: fortytwo},
109+
nil,
110+
},
111+
{
112+
"access list tx post-London, only priority fee",
113+
true,
114+
&TransactionArgs{AccessList: al, MaxFeePerGas: maxFee},
115+
&TransactionArgs{AccessList: al, MaxFeePerGas: maxFee, MaxPriorityFeePerGas: fortytwo},
116+
nil,
117+
},
118+
119+
// Dynamic fee txs
120+
{
121+
"dynamic tx post-London",
122+
true,
123+
&TransactionArgs{},
124+
&TransactionArgs{MaxFeePerGas: maxFee, MaxPriorityFeePerGas: fortytwo},
125+
nil,
126+
},
127+
{
128+
"dynamic tx post-London, only max fee",
129+
true,
130+
&TransactionArgs{MaxFeePerGas: maxFee},
131+
&TransactionArgs{MaxFeePerGas: maxFee, MaxPriorityFeePerGas: fortytwo},
132+
nil,
133+
},
134+
{
135+
"dynamic tx post-London, only priority fee",
136+
true,
137+
&TransactionArgs{MaxFeePerGas: maxFee},
138+
&TransactionArgs{MaxFeePerGas: maxFee, MaxPriorityFeePerGas: fortytwo},
139+
nil,
140+
},
141+
{
142+
"dynamic fee tx pre-London, maxFee set",
143+
false,
144+
&TransactionArgs{MaxFeePerGas: maxFee},
145+
nil,
146+
fmt.Errorf("maxFeePerGas and maxPriorityFeePerGas are not valid before London is active"),
147+
},
148+
{
149+
"dynamic fee tx pre-London, priorityFee set",
150+
false,
151+
&TransactionArgs{MaxPriorityFeePerGas: fortytwo},
152+
nil,
153+
fmt.Errorf("maxFeePerGas and maxPriorityFeePerGas are not valid before London is active"),
154+
},
155+
{
156+
"dynamic fee tx, maxFee < priorityFee",
157+
true,
158+
&TransactionArgs{MaxFeePerGas: maxFee, MaxPriorityFeePerGas: (*hexutil.Big)(big.NewInt(1000))},
159+
nil,
160+
fmt.Errorf("maxFeePerGas (0x3e) < maxPriorityFeePerGas (0x3e8)"),
161+
},
162+
{
163+
"dynamic fee tx, maxFee < priorityFee while setting default",
164+
true,
165+
&TransactionArgs{MaxFeePerGas: (*hexutil.Big)(big.NewInt(7))},
166+
nil,
167+
fmt.Errorf("maxFeePerGas (0x7) < maxPriorityFeePerGas (0x2a)"),
168+
},
169+
170+
// Misc
171+
{
172+
"set all fee parameters",
173+
false,
174+
&TransactionArgs{GasPrice: fortytwo, MaxFeePerGas: maxFee, MaxPriorityFeePerGas: fortytwo},
175+
nil,
176+
fmt.Errorf("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified"),
177+
},
178+
{
179+
"set gas price and maxPriorityFee",
180+
false,
181+
&TransactionArgs{GasPrice: fortytwo, MaxPriorityFeePerGas: fortytwo},
182+
nil,
183+
fmt.Errorf("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified"),
184+
},
185+
{
186+
"set gas price and maxFee",
187+
true,
188+
&TransactionArgs{GasPrice: fortytwo, MaxFeePerGas: maxFee},
189+
nil,
190+
fmt.Errorf("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified"),
191+
},
192+
}
193+
194+
ctx := context.Background()
195+
for i, test := range tests {
196+
if test.isLondon {
197+
b.activateLondon()
198+
} else {
199+
b.deactivateLondon()
200+
}
201+
got := test.in
202+
err := got.setFeeDefaults(ctx, b)
203+
if err != nil && err.Error() == test.err.Error() {
204+
// Test threw expected error.
205+
continue
206+
} else if err != nil {
207+
t.Fatalf("test %d (%s): unexpected error: %s", i, test.name, err)
208+
}
209+
if !reflect.DeepEqual(got, test.want) {
210+
t.Fatalf("test %d (%s): did not fill defaults as expected: (got: %v, want: %v)", i, test.name, got, test.want)
211+
}
212+
}
213+
}
214+
215+
type backendMock struct {
216+
current *types.Header
217+
config *params.ChainConfig
218+
}
219+
220+
func newBackendMock() *backendMock {
221+
config := &params.ChainConfig{
222+
ChainId: big.NewInt(42),
223+
HomesteadBlock: big.NewInt(0),
224+
DAOForkBlock: nil,
225+
DAOForkSupport: true,
226+
EIP150Block: big.NewInt(0),
227+
EIP155Block: big.NewInt(0),
228+
EIP158Block: big.NewInt(0),
229+
ByzantiumBlock: big.NewInt(0),
230+
ConstantinopleBlock: big.NewInt(0),
231+
PetersburgBlock: big.NewInt(0),
232+
IstanbulBlock: big.NewInt(0),
233+
BerlinBlock: big.NewInt(0),
234+
Eip1559Block: big.NewInt(1000),
235+
}
236+
return &backendMock{
237+
current: &types.Header{
238+
Difficulty: big.NewInt(10000000000),
239+
Number: big.NewInt(1100),
240+
GasLimit: 8_000_000,
241+
GasUsed: 8_000_000,
242+
Time: big.NewInt(555),
243+
Extra: make([]byte, 32),
244+
BaseFee: big.NewInt(10),
245+
},
246+
config: config,
247+
}
248+
}
249+
250+
func (b *backendMock) activateLondon() {
251+
b.current.Number = big.NewInt(1100)
252+
}
253+
254+
func (b *backendMock) deactivateLondon() {
255+
b.current.Number = big.NewInt(900)
256+
}
257+
258+
func (b *backendMock) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
259+
return big.NewInt(42), nil
260+
}
261+
262+
func (b *backendMock) CurrentHeader() *types.Header { return b.current }
263+
264+
func (b *backendMock) ChainConfig() *params.ChainConfig { return b.config }
265+
266+
// Other methods needed to implement Backend interface.
267+
func (b *backendMock) SyncProgress() ethereum.SyncProgress { return ethereum.SyncProgress{} }
268+
func (b *backendMock) FeeHistory(ctx context.Context, blockCount int, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) {
269+
return nil, nil, nil, nil, nil
270+
}
271+
func (b *backendMock) ChainDb() ethdb.Database { return nil }
272+
func (b *backendMock) AccountManager() *accounts.Manager { return nil }
273+
func (b *backendMock) ExtRPCEnabled() bool { return false }
274+
func (b *backendMock) RPCGasCap() uint64 { return 0 }
275+
func (b *backendMock) RPCEVMTimeout() time.Duration { return time.Second }
276+
func (b *backendMock) RPCTxFeeCap() float64 { return 0 }
277+
func (b *backendMock) UnprotectedAllowed() bool { return false }
278+
func (b *backendMock) SetHead(number uint64) {}
279+
280+
func (b *backendMock) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) {
281+
return nil, nil
282+
}
283+
284+
func (b *backendMock) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
285+
return nil, nil
286+
}
287+
288+
func (b *backendMock) HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Header, error) {
289+
return nil, nil
290+
}
291+
292+
func (b *backendMock) CurrentBlock() *types.Block { return nil }
293+
294+
func (b *backendMock) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) {
295+
return nil, nil
296+
}
297+
298+
func (b *backendMock) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) {
299+
return nil, nil
300+
}
301+
302+
func (b *backendMock) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error) {
303+
return nil, nil
304+
}
305+
306+
func (b *backendMock) StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error) {
307+
return nil, nil, nil
308+
}
309+
310+
func (b *backendMock) StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error) {
311+
return nil, nil, nil
312+
}
313+
314+
func (b *backendMock) PendingBlockAndReceipts() (*types.Block, types.Receipts) { return nil, nil }
315+
316+
func (b *backendMock) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
317+
return nil, nil
318+
}
319+
320+
func (b *backendMock) GetTd(common.Hash) *big.Int {
321+
return nil
322+
}
323+
324+
func (b *backendMock) GetEVM(context.Context, core.Message, *state.StateDB, *tradingstate.TradingStateDB, *types.Header, *vm.Config) (*vm.EVM, func() error, error) {
325+
return nil, nil, nil
326+
}
327+
328+
func (b *backendMock) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription { return nil }
329+
func (b *backendMock) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription {
330+
return nil
331+
}
332+
func (b *backendMock) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription {
333+
return nil
334+
}
335+
func (b *backendMock) SendTx(ctx context.Context, signedTx *types.Transaction) error { return nil }
336+
func (b *backendMock) GetTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) {
337+
return nil, [32]byte{}, 0, 0, nil
338+
}
339+
func (b *backendMock) GetPoolTransactions() (types.Transactions, error) { return nil, nil }
340+
func (b *backendMock) GetPoolTransaction(txHash common.Hash) *types.Transaction { return nil }
341+
func (b *backendMock) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error) {
342+
return 0, nil
343+
}
344+
func (b *backendMock) Stats() (pending int, queued int) { return 0, 0 }
345+
func (b *backendMock) TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions) {
346+
return nil, nil
347+
}
348+
func (b *backendMock) TxPoolContentFrom(addr common.Address) (types.Transactions, types.Transactions) {
349+
return nil, nil
350+
}
351+
func (b *backendMock) SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription { return nil }
352+
func (b *backendMock) BloomStatus() (uint64, uint64) { return 0, 0 }
353+
func (b *backendMock) GetLogs(ctx context.Context, blockHash common.Hash, number uint64) ([][]*types.Log, error) {
354+
return nil, nil
355+
}
356+
func (b *backendMock) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession) {}
357+
func (b *backendMock) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription { return nil }
358+
func (b *backendMock) SubscribePendingLogsEvent(ch chan<- []*types.Log) event.Subscription {
359+
return nil
360+
}
361+
func (b *backendMock) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription {
362+
return nil
363+
}
364+
365+
func (b *backendMock) Engine() consensus.Engine { return nil }
366+
367+
func (b *backendMock) AreTwoBlockSamePath(bh1 common.Hash, bh2 common.Hash) bool {
368+
return true
369+
}
370+
371+
func (b *backendMock) Downloader() *downloader.Downloader {
372+
return nil
373+
}
374+
375+
func (b *backendMock) EventMux() *event.TypeMux {
376+
return nil
377+
}
378+
379+
func (b *backendMock) GetBlock(context.Context, common.Hash) (*types.Block, error) {
380+
return nil, nil
381+
}
382+
383+
func (b *backendMock) GetBlocksHashCache(blockNr uint64) []common.Hash {
384+
return []common.Hash{}
385+
}
386+
387+
func (b *backendMock) GetEngine() consensus.Engine {
388+
return nil
389+
}
390+
391+
func (b *backendMock) GetEpochDuration() *big.Int {
392+
return nil
393+
}
394+
395+
func (b *backendMock) GetIPCClient() (bind.ContractBackend, error) {
396+
return nil, nil
397+
}
398+
399+
func (b *backendMock) GetMasternodesCap(uint64) map[common.Address]*big.Int {
400+
return nil
401+
}
402+
403+
func (b *backendMock) GetOrderNonce(common.Hash) (uint64, error) {
404+
return 0, nil
405+
}
406+
407+
func (b *backendMock) GetBody(ctx context.Context, hash common.Hash, number rpc.BlockNumber) (*types.Body, error) {
408+
return nil, nil
409+
}
410+
411+
func (b *backendMock) GetRewardByHash(common.Hash) map[string]map[string]map[string]*big.Int {
412+
return nil
413+
}
414+
415+
func (b *backendMock) GetVotersCap(*big.Int, common.Address, []common.Address) map[common.Address]*big.Int {
416+
return nil
417+
}
418+
419+
func (b *backendMock) GetVotersRewards(common.Address) map[common.Address]*big.Int {
420+
return nil
421+
}
422+
423+
func (b *backendMock) LendingService() *XDCxlending.Lending {
424+
return nil
425+
}
426+
427+
func (b *backendMock) OrderStats() (int, int) {
428+
return 0, 0
429+
}
430+
431+
func (b *backendMock) OrderTxPoolContent() (map[common.Address]types.OrderTransactions, map[common.Address]types.OrderTransactions) {
432+
return nil, nil
433+
}
434+
435+
func (b *backendMock) ProtocolVersion() int {
436+
return 0
437+
}
438+
439+
func (b *backendMock) SendLendingTx(context.Context, *types.LendingTransaction) error {
440+
return nil
441+
}
442+
443+
func (b *backendMock) SendOrderTx(context.Context, *types.OrderTransaction) error {
444+
return nil
445+
}
446+
447+
func (b *backendMock) XDCxService() *XDCx.XDCX {
448+
return nil
449+
}

0 commit comments

Comments
 (0)