mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
gofmt -w -r 'interface {} -> any' .
This commit is contained in:
parent
127d1f42bb
commit
f506aa1c27
198 changed files with 836 additions and 836 deletions
|
|
@ -60,7 +60,7 @@ func JSON(reader io.Reader) (ABI, error) {
|
||||||
// of 4 bytes and arguments are all 32 bytes.
|
// of 4 bytes and arguments are all 32 bytes.
|
||||||
// Method ids are created from the first 4 bytes of the hash of the
|
// Method ids are created from the first 4 bytes of the hash of the
|
||||||
// methods string signature. (signature = baz(uint32,string32))
|
// methods string signature. (signature = baz(uint32,string32))
|
||||||
func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) {
|
func (abi ABI) Pack(name string, args ...any) ([]byte, error) {
|
||||||
// Fetch the ABI of the requested method
|
// Fetch the ABI of the requested method
|
||||||
if name == "" {
|
if name == "" {
|
||||||
// constructor
|
// constructor
|
||||||
|
|
@ -105,7 +105,7 @@ func (abi ABI) getArguments(name string, data []byte) (Arguments, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unpack unpacks the output according to the abi specification.
|
// Unpack unpacks the output according to the abi specification.
|
||||||
func (abi ABI) Unpack(name string, data []byte) ([]interface{}, error) {
|
func (abi ABI) Unpack(name string, data []byte) ([]any, error) {
|
||||||
args, err := abi.getArguments(name, data)
|
args, err := abi.getArguments(name, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -116,7 +116,7 @@ func (abi ABI) Unpack(name string, data []byte) ([]interface{}, error) {
|
||||||
// UnpackIntoInterface unpacks the output in v according to the abi specification.
|
// UnpackIntoInterface unpacks the output in v according to the abi specification.
|
||||||
// It performs an additional copy. Please only use, if you want to unpack into a
|
// It performs an additional copy. Please only use, if you want to unpack into a
|
||||||
// structure that does not strictly conform to the abi structure (e.g. has additional arguments)
|
// structure that does not strictly conform to the abi structure (e.g. has additional arguments)
|
||||||
func (abi ABI) UnpackIntoInterface(v interface{}, name string, data []byte) error {
|
func (abi ABI) UnpackIntoInterface(v any, name string, data []byte) error {
|
||||||
args, err := abi.getArguments(name, data)
|
args, err := abi.getArguments(name, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -129,7 +129,7 @@ func (abi ABI) UnpackIntoInterface(v interface{}, name string, data []byte) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnpackIntoMap unpacks a log into the provided map[string]interface{}.
|
// UnpackIntoMap unpacks a log into the provided map[string]interface{}.
|
||||||
func (abi ABI) UnpackIntoMap(v map[string]interface{}, name string, data []byte) (err error) {
|
func (abi ABI) UnpackIntoMap(v map[string]any, name string, data []byte) (err error) {
|
||||||
args, err := abi.getArguments(name, data)
|
args, err := abi.getArguments(name, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -839,8 +839,8 @@ func TestUnpackEventIntoMap(t *testing.T) {
|
||||||
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
|
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
receivedMap := map[string]interface{}{}
|
receivedMap := map[string]any{}
|
||||||
expectedReceivedMap := map[string]interface{}{
|
expectedReceivedMap := map[string]any{
|
||||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
"amount": big.NewInt(1),
|
"amount": big.NewInt(1),
|
||||||
"memo": []byte{88},
|
"memo": []byte{88},
|
||||||
|
|
@ -861,7 +861,7 @@ func TestUnpackEventIntoMap(t *testing.T) {
|
||||||
t.Error("unpacked `received` map does not match expected map")
|
t.Error("unpacked `received` map does not match expected map")
|
||||||
}
|
}
|
||||||
|
|
||||||
receivedAddrMap := map[string]interface{}{}
|
receivedAddrMap := map[string]any{}
|
||||||
if err = abi.UnpackIntoMap(receivedAddrMap, "receivedAddr", data); err != nil {
|
if err = abi.UnpackIntoMap(receivedAddrMap, "receivedAddr", data); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
@ -890,7 +890,7 @@ func TestUnpackMethodIntoMap(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests a method with no outputs
|
// Tests a method with no outputs
|
||||||
receiveMap := map[string]interface{}{}
|
receiveMap := map[string]any{}
|
||||||
if err = abi.UnpackIntoMap(receiveMap, "receive", data); err != nil {
|
if err = abi.UnpackIntoMap(receiveMap, "receive", data); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
@ -899,7 +899,7 @@ func TestUnpackMethodIntoMap(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests a method with only outputs
|
// Tests a method with only outputs
|
||||||
sendMap := map[string]interface{}{}
|
sendMap := map[string]any{}
|
||||||
if err = abi.UnpackIntoMap(sendMap, "send", data); err != nil {
|
if err = abi.UnpackIntoMap(sendMap, "send", data); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
@ -911,7 +911,7 @@ func TestUnpackMethodIntoMap(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests a method with outputs and inputs
|
// Tests a method with outputs and inputs
|
||||||
getMap := map[string]interface{}{}
|
getMap := map[string]any{}
|
||||||
if err = abi.UnpackIntoMap(getMap, "get", data); err != nil {
|
if err = abi.UnpackIntoMap(getMap, "get", data); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
@ -940,7 +940,7 @@ func TestUnpackIntoMapNamingConflict(t *testing.T) {
|
||||||
if len(data)%32 == 0 {
|
if len(data)%32 == 0 {
|
||||||
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
|
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
|
||||||
}
|
}
|
||||||
getMap := map[string]interface{}{}
|
getMap := map[string]any{}
|
||||||
if err = abi.UnpackIntoMap(getMap, "get", data); err == nil {
|
if err = abi.UnpackIntoMap(getMap, "get", data); err == nil {
|
||||||
t.Error("naming conflict between two methods; error expected")
|
t.Error("naming conflict between two methods; error expected")
|
||||||
}
|
}
|
||||||
|
|
@ -959,7 +959,7 @@ func TestUnpackIntoMapNamingConflict(t *testing.T) {
|
||||||
if len(data)%32 == 0 {
|
if len(data)%32 == 0 {
|
||||||
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
|
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
|
||||||
}
|
}
|
||||||
receivedMap := map[string]interface{}{}
|
receivedMap := map[string]any{}
|
||||||
if err = abi.UnpackIntoMap(receivedMap, "received", data); err != nil {
|
if err = abi.UnpackIntoMap(receivedMap, "received", data); err != nil {
|
||||||
t.Error("naming conflict between two events; no error expected")
|
t.Error("naming conflict between two events; no error expected")
|
||||||
}
|
}
|
||||||
|
|
@ -986,7 +986,7 @@ func TestUnpackIntoMapNamingConflict(t *testing.T) {
|
||||||
if len(data)%32 == 0 {
|
if len(data)%32 == 0 {
|
||||||
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
|
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
|
||||||
}
|
}
|
||||||
expectedReceivedMap := map[string]interface{}{
|
expectedReceivedMap := map[string]any{
|
||||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
"amount": big.NewInt(1),
|
"amount": big.NewInt(1),
|
||||||
"memo": []byte{88},
|
"memo": []byte{88},
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ var (
|
||||||
"bytes32", "bytes"}
|
"bytes32", "bytes"}
|
||||||
)
|
)
|
||||||
|
|
||||||
func unpackPack(abi ABI, method string, input []byte) ([]interface{}, bool) {
|
func unpackPack(abi ABI, method string, input []byte) ([]any, bool) {
|
||||||
if out, err := abi.Unpack(method, input); err == nil {
|
if out, err := abi.Unpack(method, input); err == nil {
|
||||||
_, err := abi.Pack(method, out...)
|
_, err := abi.Pack(method, out...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -77,7 +77,7 @@ func unpackPack(abi ABI, method string, input []byte) ([]interface{}, bool) {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func packUnpack(abi ABI, method string, input *[]interface{}) bool {
|
func packUnpack(abi ABI, method string, input *[]any) bool {
|
||||||
if packed, err := abi.Pack(method, input); err == nil {
|
if packed, err := abi.Pack(method, input); err == nil {
|
||||||
outptr := reflect.New(reflect.TypeOf(input))
|
outptr := reflect.New(reflect.TypeOf(input))
|
||||||
err := abi.UnpackIntoInterface(outptr.Interface(), method, packed)
|
err := abi.UnpackIntoInterface(outptr.Interface(), method, packed)
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
|
||||||
}
|
}
|
||||||
buffer := new(bytes.Buffer)
|
buffer := new(bytes.Buffer)
|
||||||
|
|
||||||
funcs := map[string]interface{}{
|
funcs := map[string]any{
|
||||||
"bindtype": bindType,
|
"bindtype": bindType,
|
||||||
"bindtopictype": bindTopicType,
|
"bindtopictype": bindTopicType,
|
||||||
"capitalise": abi.ToCamelCase,
|
"capitalise": abi.ToCamelCase,
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,7 @@ func BindV2(types []string, abis []string, bytecodes []string, pkg string, libs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer := new(bytes.Buffer)
|
buffer := new(bytes.Buffer)
|
||||||
funcs := map[string]interface{}{
|
funcs := map[string]any{
|
||||||
"bindtype": bindType,
|
"bindtype": bindType,
|
||||||
"bindtopictype": bindTopicType,
|
"bindtopictype": bindTopicType,
|
||||||
"capitalise": abi.ToCamelCase,
|
"capitalise": abi.ToCamelCase,
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ func NewBoundContract(address common.Address, abi abi.ABI, caller ContractCaller
|
||||||
return bind2.NewBoundContract(address, abi, caller, transactor, filterer)
|
return bind2.NewBoundContract(address, abi, caller, transactor, filterer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeployContract(opts *TransactOpts, abi abi.ABI, bytecode []byte, backend ContractBackend, params ...interface{}) (common.Address, *types.Transaction, *BoundContract, error) {
|
func DeployContract(opts *TransactOpts, abi abi.ABI, bytecode []byte, backend ContractBackend, params ...any) (common.Address, *types.Transaction, *BoundContract, error) {
|
||||||
packed, err := abi.Pack("", params...)
|
packed, err := abi.Pack("", params...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.Address{}, nil, nil, err
|
return common.Address{}, nil, nil, err
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ func TestUnpackIndexedStringTyLogIntoMap(t *testing.T) {
|
||||||
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
||||||
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
||||||
|
|
||||||
expectedReceivedMap := map[string]interface{}{
|
expectedReceivedMap := map[string]any{
|
||||||
"name": hash,
|
"name": hash,
|
||||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
"amount": big.NewInt(1),
|
"amount": big.NewInt(1),
|
||||||
|
|
@ -216,7 +216,7 @@ func TestUnpackAnonymousLogIntoMap(t *testing.T) {
|
||||||
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
||||||
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
||||||
|
|
||||||
var received map[string]interface{}
|
var received map[string]any
|
||||||
err := bc.UnpackLogIntoMap(received, "received", mockLog)
|
err := bc.UnpackLogIntoMap(received, "received", mockLog)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("unpacking anonymous event is not supported")
|
t.Error("unpacking anonymous event is not supported")
|
||||||
|
|
@ -243,7 +243,7 @@ func TestUnpackIndexedSliceTyLogIntoMap(t *testing.T) {
|
||||||
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
||||||
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
||||||
|
|
||||||
expectedReceivedMap := map[string]interface{}{
|
expectedReceivedMap := map[string]any{
|
||||||
"names": hash,
|
"names": hash,
|
||||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
"amount": big.NewInt(1),
|
"amount": big.NewInt(1),
|
||||||
|
|
@ -269,7 +269,7 @@ func TestUnpackIndexedArrayTyLogIntoMap(t *testing.T) {
|
||||||
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
||||||
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
||||||
|
|
||||||
expectedReceivedMap := map[string]interface{}{
|
expectedReceivedMap := map[string]any{
|
||||||
"addresses": hash,
|
"addresses": hash,
|
||||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
"amount": big.NewInt(1),
|
"amount": big.NewInt(1),
|
||||||
|
|
@ -296,7 +296,7 @@ func TestUnpackIndexedFuncTyLogIntoMap(t *testing.T) {
|
||||||
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
||||||
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
||||||
|
|
||||||
expectedReceivedMap := map[string]interface{}{
|
expectedReceivedMap := map[string]any{
|
||||||
"function": functionTy,
|
"function": functionTy,
|
||||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
"amount": big.NewInt(1),
|
"amount": big.NewInt(1),
|
||||||
|
|
@ -319,7 +319,7 @@ func TestUnpackIndexedBytesTyLogIntoMap(t *testing.T) {
|
||||||
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
||||||
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
||||||
|
|
||||||
expectedReceivedMap := map[string]interface{}{
|
expectedReceivedMap := map[string]any{
|
||||||
"content": hash,
|
"content": hash,
|
||||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
"amount": big.NewInt(1),
|
"amount": big.NewInt(1),
|
||||||
|
|
@ -374,8 +374,8 @@ func TestTransactGasFee(t *testing.T) {
|
||||||
assert.True(mt.suggestGasPriceCalled)
|
assert.True(mt.suggestGasPriceCalled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func unpackAndCheck(t *testing.T, bc *bind.BoundContract, expected map[string]interface{}, mockLog types.Log) {
|
func unpackAndCheck(t *testing.T, bc *bind.BoundContract, expected map[string]any, mockLog types.Log) {
|
||||||
received := make(map[string]interface{})
|
received := make(map[string]any)
|
||||||
if err := bc.UnpackLogIntoMap(received, "received", mockLog); err != nil {
|
if err := bc.UnpackLogIntoMap(received, "received", mockLog); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
@ -411,7 +411,7 @@ func TestCall(t *testing.T) {
|
||||||
name, method string
|
name, method string
|
||||||
opts *bind.CallOpts
|
opts *bind.CallOpts
|
||||||
mc bind.ContractCaller
|
mc bind.ContractCaller
|
||||||
results *[]interface{}
|
results *[]any
|
||||||
wantErr bool
|
wantErr bool
|
||||||
wantErrExact error
|
wantErrExact error
|
||||||
}{{
|
}{{
|
||||||
|
|
@ -547,7 +547,7 @@ func TestCall(t *testing.T) {
|
||||||
codeAtBytes: []byte{0},
|
codeAtBytes: []byte{0},
|
||||||
},
|
},
|
||||||
method: method,
|
method: method,
|
||||||
results: &[]interface{}{0},
|
results: &[]any{0},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
}}
|
}}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ func (e Error) String() string {
|
||||||
return e.str
|
return e.str
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Error) Unpack(data []byte) (interface{}, error) {
|
func (e *Error) Unpack(data []byte) (any, error) {
|
||||||
if len(data) < 4 {
|
if len(data) < 4 {
|
||||||
return "", fmt.Errorf("insufficient data for unpacking: have %d, want at least 4", len(data))
|
return "", fmt.Errorf("insufficient data for unpacking: have %d, want at least 4", len(data))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,6 @@ func typeCheck(t Type, value reflect.Value) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// typeErr returns a formatted type casting error.
|
// typeErr returns a formatted type casting error.
|
||||||
func typeErr(expected, got interface{}) error {
|
func typeErr(expected, got any) error {
|
||||||
return fmt.Errorf("abi: cannot use %v as type %v as argument", got, expected)
|
return fmt.Errorf("abi: cannot use %v as type %v as argument", got, expected)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -215,8 +215,8 @@ func TestEventTupleUnpack(t *testing.T) {
|
||||||
addr := common.HexToAddress("0x00Ce0d46d924CC8437c806721496599FC3FFA268")
|
addr := common.HexToAddress("0x00Ce0d46d924CC8437c806721496599FC3FFA268")
|
||||||
var testCases = []struct {
|
var testCases = []struct {
|
||||||
data string
|
data string
|
||||||
dest interface{}
|
dest any
|
||||||
expected interface{}
|
expected any
|
||||||
jsonLog []byte
|
jsonLog []byte
|
||||||
error string
|
error string
|
||||||
name string
|
name string
|
||||||
|
|
@ -229,8 +229,8 @@ func TestEventTupleUnpack(t *testing.T) {
|
||||||
"Can unpack ERC20 Transfer event into structure",
|
"Can unpack ERC20 Transfer event into structure",
|
||||||
}, {
|
}, {
|
||||||
transferData1,
|
transferData1,
|
||||||
&[]interface{}{&bigint},
|
&[]any{&bigint},
|
||||||
&[]interface{}{&bigintExpected},
|
&[]any{&bigintExpected},
|
||||||
jsonEventTransfer,
|
jsonEventTransfer,
|
||||||
"",
|
"",
|
||||||
"Can unpack ERC20 Transfer event into slice",
|
"Can unpack ERC20 Transfer event into slice",
|
||||||
|
|
@ -274,8 +274,8 @@ func TestEventTupleUnpack(t *testing.T) {
|
||||||
"Can unpack Pledge event into structure",
|
"Can unpack Pledge event into structure",
|
||||||
}, {
|
}, {
|
||||||
pledgeData1,
|
pledgeData1,
|
||||||
&[]interface{}{&common.Address{}, &bigint, &[3]byte{}},
|
&[]any{&common.Address{}, &bigint, &[3]byte{}},
|
||||||
&[]interface{}{
|
&[]any{
|
||||||
&addr,
|
&addr,
|
||||||
&bigintExpected2,
|
&bigintExpected2,
|
||||||
&[3]byte{'u', 's', 'd'}},
|
&[3]byte{'u', 's', 'd'}},
|
||||||
|
|
@ -284,8 +284,8 @@ func TestEventTupleUnpack(t *testing.T) {
|
||||||
"Can unpack Pledge event into slice",
|
"Can unpack Pledge event into slice",
|
||||||
}, {
|
}, {
|
||||||
pledgeData1,
|
pledgeData1,
|
||||||
&[3]interface{}{&common.Address{}, &bigint, &[3]byte{}},
|
&[3]any{&common.Address{}, &bigint, &[3]byte{}},
|
||||||
&[3]interface{}{
|
&[3]any{
|
||||||
&addr,
|
&addr,
|
||||||
&bigintExpected2,
|
&bigintExpected2,
|
||||||
&[3]byte{'u', 's', 'd'}},
|
&[3]byte{'u', 's', 'd'}},
|
||||||
|
|
@ -294,8 +294,8 @@ func TestEventTupleUnpack(t *testing.T) {
|
||||||
"Can unpack Pledge event into an array",
|
"Can unpack Pledge event into an array",
|
||||||
}, {
|
}, {
|
||||||
pledgeData1,
|
pledgeData1,
|
||||||
&[]interface{}{new(int), 0, 0},
|
&[]any{new(int), 0, 0},
|
||||||
&[]interface{}{},
|
&[]any{},
|
||||||
jsonEventPledge,
|
jsonEventPledge,
|
||||||
"abi: cannot unmarshal common.Address in to int",
|
"abi: cannot unmarshal common.Address in to int",
|
||||||
"Can not unpack Pledge event into slice with wrong types",
|
"Can not unpack Pledge event into slice with wrong types",
|
||||||
|
|
@ -308,15 +308,15 @@ func TestEventTupleUnpack(t *testing.T) {
|
||||||
"Can not unpack Pledge event into struct with wrong filed types",
|
"Can not unpack Pledge event into struct with wrong filed types",
|
||||||
}, {
|
}, {
|
||||||
pledgeData1,
|
pledgeData1,
|
||||||
&[]interface{}{common.Address{}, new(big.Int)},
|
&[]any{common.Address{}, new(big.Int)},
|
||||||
&[]interface{}{},
|
&[]any{},
|
||||||
jsonEventPledge,
|
jsonEventPledge,
|
||||||
"abi: insufficient number of arguments for unpack, want 3, got 2",
|
"abi: insufficient number of arguments for unpack, want 3, got 2",
|
||||||
"Can not unpack Pledge event into too short slice",
|
"Can not unpack Pledge event into too short slice",
|
||||||
}, {
|
}, {
|
||||||
pledgeData1,
|
pledgeData1,
|
||||||
new(map[string]interface{}),
|
new(map[string]any),
|
||||||
&[]interface{}{},
|
&[]any{},
|
||||||
jsonEventPledge,
|
jsonEventPledge,
|
||||||
"abi:[2] cannot unmarshal tuple in to map[string]interface {}",
|
"abi:[2] cannot unmarshal tuple in to map[string]interface {}",
|
||||||
"Can not unpack Pledge event into map",
|
"Can not unpack Pledge event into map",
|
||||||
|
|
@ -343,7 +343,7 @@ func TestEventTupleUnpack(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func unpackTestEventData(dest interface{}, hexData string, jsonEvent []byte, assert *assert.Assertions) error {
|
func unpackTestEventData(dest any, hexData string, jsonEvent []byte, assert *assert.Assertions) error {
|
||||||
data, err := hex.DecodeString(hexData)
|
data, err := hex.DecodeString(hexData)
|
||||||
assert.NoError(err, "Hex data should be a correct hex-string")
|
assert.NoError(err, "Hex data should be a correct hex-string")
|
||||||
var e Event
|
var e Event
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
|
|
||||||
type packUnpackTest struct {
|
type packUnpackTest struct {
|
||||||
def string
|
def string
|
||||||
unpacked interface{}
|
unpacked any
|
||||||
packed string
|
packed string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ import (
|
||||||
// into:
|
// into:
|
||||||
//
|
//
|
||||||
// type TupleT struct { X *big.Int }
|
// type TupleT struct { X *big.Int }
|
||||||
func ConvertType(in interface{}, proto interface{}) interface{} {
|
func ConvertType(in any, proto any) any {
|
||||||
protoType := reflect.TypeOf(proto)
|
protoType := reflect.TypeOf(proto)
|
||||||
if reflect.TypeOf(in).ConvertibleTo(protoType) {
|
if reflect.TypeOf(in).ConvertibleTo(protoType) {
|
||||||
return reflect.ValueOf(in).Convert(protoType).Interface()
|
return reflect.ValueOf(in).Convert(protoType).Interface()
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import (
|
||||||
type reflectTest struct {
|
type reflectTest struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
struc interface{}
|
struc any
|
||||||
want map[string]string
|
want map[string]string
|
||||||
err string
|
err string
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ func parseElementaryType(unescapedSelector string) (string, string, error) {
|
||||||
return parsedType, rest, nil
|
return parsedType, rest, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseCompositeType(unescapedSelector string) ([]interface{}, string, error) {
|
func parseCompositeType(unescapedSelector string) ([]any, string, error) {
|
||||||
if len(unescapedSelector) == 0 || unescapedSelector[0] != '(' {
|
if len(unescapedSelector) == 0 || unescapedSelector[0] != '(' {
|
||||||
return nil, "", fmt.Errorf("expected '(', got %c", unescapedSelector[0])
|
return nil, "", fmt.Errorf("expected '(', got %c", unescapedSelector[0])
|
||||||
}
|
}
|
||||||
|
|
@ -92,7 +92,7 @@ func parseCompositeType(unescapedSelector string) ([]interface{}, string, error)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", fmt.Errorf("failed to parse type: %v", err)
|
return nil, "", fmt.Errorf("failed to parse type: %v", err)
|
||||||
}
|
}
|
||||||
result := []interface{}{parsedType}
|
result := []any{parsedType}
|
||||||
for len(rest) > 0 && rest[0] != ')' {
|
for len(rest) > 0 && rest[0] != ')' {
|
||||||
parsedType, rest, err = parseType(rest[1:])
|
parsedType, rest, err = parseType(rest[1:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -109,7 +109,7 @@ func parseCompositeType(unescapedSelector string) ([]interface{}, string, error)
|
||||||
return result, rest[1:], nil
|
return result, rest[1:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseType(unescapedSelector string) (interface{}, string, error) {
|
func parseType(unescapedSelector string) (any, string, error) {
|
||||||
if len(unescapedSelector) == 0 {
|
if len(unescapedSelector) == 0 {
|
||||||
return nil, "", errors.New("empty type")
|
return nil, "", errors.New("empty type")
|
||||||
}
|
}
|
||||||
|
|
@ -120,14 +120,14 @@ func parseType(unescapedSelector string) (interface{}, string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func assembleArgs(args []interface{}) ([]ArgumentMarshaling, error) {
|
func assembleArgs(args []any) ([]ArgumentMarshaling, error) {
|
||||||
arguments := make([]ArgumentMarshaling, 0)
|
arguments := make([]ArgumentMarshaling, 0)
|
||||||
for i, arg := range args {
|
for i, arg := range args {
|
||||||
// generate dummy name to avoid unmarshal issues
|
// generate dummy name to avoid unmarshal issues
|
||||||
name := fmt.Sprintf("name%d", i)
|
name := fmt.Sprintf("name%d", i)
|
||||||
if s, ok := arg.(string); ok {
|
if s, ok := arg.(string); ok {
|
||||||
arguments = append(arguments, ArgumentMarshaling{name, s, s, nil, false})
|
arguments = append(arguments, ArgumentMarshaling{name, s, s, nil, false})
|
||||||
} else if components, ok := arg.([]interface{}); ok {
|
} else if components, ok := arg.([]any); ok {
|
||||||
subArgs, err := assembleArgs(components)
|
subArgs, err := assembleArgs(components)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to assemble components: %v", err)
|
return nil, fmt.Errorf("failed to assemble components: %v", err)
|
||||||
|
|
@ -154,7 +154,7 @@ func ParseSelector(unescapedSelector string) (SelectorMarshaling, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return SelectorMarshaling{}, fmt.Errorf("failed to parse selector '%s': %v", unescapedSelector, err)
|
return SelectorMarshaling{}, fmt.Errorf("failed to parse selector '%s': %v", unescapedSelector, err)
|
||||||
}
|
}
|
||||||
args := []interface{}{}
|
args := []any{}
|
||||||
if len(rest) >= 2 && rest[0] == '(' && rest[1] == ')' {
|
if len(rest) >= 2 && rest[0] == '(' && rest[1] == ')' {
|
||||||
rest = rest[2:]
|
rest = rest[2:]
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import (
|
||||||
|
|
||||||
func TestParseSelector(t *testing.T) {
|
func TestParseSelector(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
mkType := func(types ...interface{}) []ArgumentMarshaling {
|
mkType := func(types ...any) []ArgumentMarshaling {
|
||||||
var result []ArgumentMarshaling
|
var result []ArgumentMarshaling
|
||||||
for i, typeOrComponents := range types {
|
for i, typeOrComponents := range types {
|
||||||
name := fmt.Sprintf("name%d", i)
|
name := fmt.Sprintf("name%d", i)
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// MakeTopics converts a filter query argument list into a filter topic set.
|
// MakeTopics converts a filter query argument list into a filter topic set.
|
||||||
func MakeTopics(query ...[]interface{}) ([][]common.Hash, error) {
|
func MakeTopics(query ...[]any) ([][]common.Hash, error) {
|
||||||
topics := make([][]common.Hash, len(query))
|
topics := make([][]common.Hash, len(query))
|
||||||
for i, filter := range query {
|
for i, filter := range query {
|
||||||
for _, rule := range filter {
|
for _, rule := range filter {
|
||||||
|
|
@ -112,18 +112,18 @@ func genIntType(rule int64, size uint) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseTopics converts the indexed topic fields into actual log field values.
|
// ParseTopics converts the indexed topic fields into actual log field values.
|
||||||
func ParseTopics(out interface{}, fields Arguments, topics []common.Hash) error {
|
func ParseTopics(out any, fields Arguments, topics []common.Hash) error {
|
||||||
return parseTopicWithSetter(fields, topics,
|
return parseTopicWithSetter(fields, topics,
|
||||||
func(arg Argument, reconstr interface{}) {
|
func(arg Argument, reconstr any) {
|
||||||
field := reflect.ValueOf(out).Elem().FieldByName(ToCamelCase(arg.Name))
|
field := reflect.ValueOf(out).Elem().FieldByName(ToCamelCase(arg.Name))
|
||||||
field.Set(reflect.ValueOf(reconstr))
|
field.Set(reflect.ValueOf(reconstr))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseTopicsIntoMap converts the indexed topic field-value pairs into map key-value pairs.
|
// ParseTopicsIntoMap converts the indexed topic field-value pairs into map key-value pairs.
|
||||||
func ParseTopicsIntoMap(out map[string]interface{}, fields Arguments, topics []common.Hash) error {
|
func ParseTopicsIntoMap(out map[string]any, fields Arguments, topics []common.Hash) error {
|
||||||
return parseTopicWithSetter(fields, topics,
|
return parseTopicWithSetter(fields, topics,
|
||||||
func(arg Argument, reconstr interface{}) {
|
func(arg Argument, reconstr any) {
|
||||||
out[arg.Name] = reconstr
|
out[arg.Name] = reconstr
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -133,7 +133,7 @@ func ParseTopicsIntoMap(out map[string]interface{}, fields Arguments, topics []c
|
||||||
//
|
//
|
||||||
// Note, dynamic types cannot be reconstructed since they get mapped to Keccak256
|
// Note, dynamic types cannot be reconstructed since they get mapped to Keccak256
|
||||||
// hashes as the topic value!
|
// hashes as the topic value!
|
||||||
func parseTopicWithSetter(fields Arguments, topics []common.Hash, setter func(Argument, interface{})) error {
|
func parseTopicWithSetter(fields Arguments, topics []common.Hash, setter func(Argument, any)) error {
|
||||||
// Sanity check that the fields and topics match up
|
// Sanity check that the fields and topics match up
|
||||||
if len(fields) != len(topics) {
|
if len(fields) != len(topics) {
|
||||||
return errors.New("topic/field count mismatch")
|
return errors.New("topic/field count mismatch")
|
||||||
|
|
@ -143,7 +143,7 @@ func parseTopicWithSetter(fields Arguments, topics []common.Hash, setter func(Ar
|
||||||
if !arg.Indexed {
|
if !arg.Indexed {
|
||||||
return errors.New("non-indexed field in topic reconstruction")
|
return errors.New("non-indexed field in topic reconstruction")
|
||||||
}
|
}
|
||||||
var reconstr interface{}
|
var reconstr any
|
||||||
switch arg.Type.T {
|
switch arg.Type.T {
|
||||||
case TupleTy:
|
case TupleTy:
|
||||||
return errors.New("tuple type in topic reconstruction")
|
return errors.New("tuple type in topic reconstruction")
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import (
|
||||||
func TestMakeTopics(t *testing.T) {
|
func TestMakeTopics(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
type args struct {
|
type args struct {
|
||||||
query [][]interface{}
|
query [][]any
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|
@ -39,25 +39,25 @@ func TestMakeTopics(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"support fixed byte types, right padded to 32 bytes",
|
"support fixed byte types, right padded to 32 bytes",
|
||||||
args{[][]interface{}{{[5]byte{1, 2, 3, 4, 5}}}},
|
args{[][]any{{[5]byte{1, 2, 3, 4, 5}}}},
|
||||||
[][]common.Hash{{common.Hash{1, 2, 3, 4, 5}}},
|
[][]common.Hash{{common.Hash{1, 2, 3, 4, 5}}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"support common hash types in topics",
|
"support common hash types in topics",
|
||||||
args{[][]interface{}{{common.Hash{1, 2, 3, 4, 5}}}},
|
args{[][]any{{common.Hash{1, 2, 3, 4, 5}}}},
|
||||||
[][]common.Hash{{common.Hash{1, 2, 3, 4, 5}}},
|
[][]common.Hash{{common.Hash{1, 2, 3, 4, 5}}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"support address types in topics",
|
"support address types in topics",
|
||||||
args{[][]interface{}{{common.Address{1, 2, 3, 4, 5}}}},
|
args{[][]any{{common.Address{1, 2, 3, 4, 5}}}},
|
||||||
[][]common.Hash{{common.Hash{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5}}},
|
[][]common.Hash{{common.Hash{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5}}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"support positive *big.Int types in topics",
|
"support positive *big.Int types in topics",
|
||||||
args{[][]interface{}{
|
args{[][]any{
|
||||||
{big.NewInt(1)},
|
{big.NewInt(1)},
|
||||||
{big.NewInt(1).Lsh(big.NewInt(2), 254)},
|
{big.NewInt(1).Lsh(big.NewInt(2), 254)},
|
||||||
}},
|
}},
|
||||||
|
|
@ -69,7 +69,7 @@ func TestMakeTopics(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"support negative *big.Int types in topics",
|
"support negative *big.Int types in topics",
|
||||||
args{[][]interface{}{
|
args{[][]any{
|
||||||
{big.NewInt(-1)},
|
{big.NewInt(-1)},
|
||||||
{big.NewInt(math.MinInt64)},
|
{big.NewInt(math.MinInt64)},
|
||||||
}},
|
}},
|
||||||
|
|
@ -81,7 +81,7 @@ func TestMakeTopics(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"support boolean types in topics",
|
"support boolean types in topics",
|
||||||
args{[][]interface{}{
|
args{[][]any{
|
||||||
{true},
|
{true},
|
||||||
{false},
|
{false},
|
||||||
}},
|
}},
|
||||||
|
|
@ -93,7 +93,7 @@ func TestMakeTopics(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"support int/uint(8/16/32/64) types in topics",
|
"support int/uint(8/16/32/64) types in topics",
|
||||||
args{[][]interface{}{
|
args{[][]any{
|
||||||
{int8(-2)},
|
{int8(-2)},
|
||||||
{int16(-3)},
|
{int16(-3)},
|
||||||
{int32(-4)},
|
{int32(-4)},
|
||||||
|
|
@ -125,13 +125,13 @@ func TestMakeTopics(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"support string types in topics",
|
"support string types in topics",
|
||||||
args{[][]interface{}{{"hello world"}}},
|
args{[][]any{{"hello world"}}},
|
||||||
[][]common.Hash{{crypto.Keccak256Hash([]byte("hello world"))}},
|
[][]common.Hash{{crypto.Keccak256Hash([]byte("hello world"))}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"support byte slice types in topics",
|
"support byte slice types in topics",
|
||||||
args{[][]interface{}{{[]byte{1, 2, 3}}}},
|
args{[][]any{{[]byte{1, 2, 3}}}},
|
||||||
[][]common.Hash{{crypto.Keccak256Hash([]byte{1, 2, 3})}},
|
[][]common.Hash{{crypto.Keccak256Hash([]byte{1, 2, 3})}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
|
@ -155,7 +155,7 @@ func TestMakeTopics(t *testing.T) {
|
||||||
want := [][]common.Hash{{common.HexToHash("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")}}
|
want := [][]common.Hash{{common.HexToHash("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")}}
|
||||||
|
|
||||||
in := big.NewInt(-1)
|
in := big.NewInt(-1)
|
||||||
got, err := MakeTopics([]interface{}{in})
|
got, err := MakeTopics([]any{in})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("makeTopics() error = %v", err)
|
t.Fatalf("makeTopics() error = %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -169,9 +169,9 @@ func TestMakeTopics(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
createObj func() interface{}
|
createObj func() any
|
||||||
resultObj func() interface{}
|
resultObj func() any
|
||||||
resultMap func() map[string]interface{}
|
resultMap func() map[string]any
|
||||||
fields Arguments
|
fields Arguments
|
||||||
topics []common.Hash
|
topics []common.Hash
|
||||||
}
|
}
|
||||||
|
|
@ -212,10 +212,10 @@ func setupTopicsTests() []topicTest {
|
||||||
{
|
{
|
||||||
name: "support fixed byte types, right padded to 32 bytes",
|
name: "support fixed byte types, right padded to 32 bytes",
|
||||||
args: args{
|
args: args{
|
||||||
createObj: func() interface{} { return &bytesStruct{} },
|
createObj: func() any { return &bytesStruct{} },
|
||||||
resultObj: func() interface{} { return &bytesStruct{StaticBytes: [5]byte{1, 2, 3, 4, 5}} },
|
resultObj: func() any { return &bytesStruct{StaticBytes: [5]byte{1, 2, 3, 4, 5}} },
|
||||||
resultMap: func() map[string]interface{} {
|
resultMap: func() map[string]any {
|
||||||
return map[string]interface{}{"staticBytes": [5]byte{1, 2, 3, 4, 5}}
|
return map[string]any{"staticBytes": [5]byte{1, 2, 3, 4, 5}}
|
||||||
},
|
},
|
||||||
fields: Arguments{Argument{
|
fields: Arguments{Argument{
|
||||||
Name: "staticBytes",
|
Name: "staticBytes",
|
||||||
|
|
@ -231,10 +231,10 @@ func setupTopicsTests() []topicTest {
|
||||||
{
|
{
|
||||||
name: "int8 with negative value",
|
name: "int8 with negative value",
|
||||||
args: args{
|
args: args{
|
||||||
createObj: func() interface{} { return &int8Struct{} },
|
createObj: func() any { return &int8Struct{} },
|
||||||
resultObj: func() interface{} { return &int8Struct{Int8Value: -1} },
|
resultObj: func() any { return &int8Struct{Int8Value: -1} },
|
||||||
resultMap: func() map[string]interface{} {
|
resultMap: func() map[string]any {
|
||||||
return map[string]interface{}{"int8Value": int8(-1)}
|
return map[string]any{"int8Value": int8(-1)}
|
||||||
},
|
},
|
||||||
fields: Arguments{Argument{
|
fields: Arguments{Argument{
|
||||||
Name: "int8Value",
|
Name: "int8Value",
|
||||||
|
|
@ -251,10 +251,10 @@ func setupTopicsTests() []topicTest {
|
||||||
{
|
{
|
||||||
name: "int256 with negative value",
|
name: "int256 with negative value",
|
||||||
args: args{
|
args: args{
|
||||||
createObj: func() interface{} { return &int256Struct{} },
|
createObj: func() any { return &int256Struct{} },
|
||||||
resultObj: func() interface{} { return &int256Struct{Int256Value: big.NewInt(-1)} },
|
resultObj: func() any { return &int256Struct{Int256Value: big.NewInt(-1)} },
|
||||||
resultMap: func() map[string]interface{} {
|
resultMap: func() map[string]any {
|
||||||
return map[string]interface{}{"int256Value": big.NewInt(-1)}
|
return map[string]any{"int256Value": big.NewInt(-1)}
|
||||||
},
|
},
|
||||||
fields: Arguments{Argument{
|
fields: Arguments{Argument{
|
||||||
Name: "int256Value",
|
Name: "int256Value",
|
||||||
|
|
@ -271,10 +271,10 @@ func setupTopicsTests() []topicTest {
|
||||||
{
|
{
|
||||||
name: "hash type",
|
name: "hash type",
|
||||||
args: args{
|
args: args{
|
||||||
createObj: func() interface{} { return &hashStruct{} },
|
createObj: func() any { return &hashStruct{} },
|
||||||
resultObj: func() interface{} { return &hashStruct{crypto.Keccak256Hash([]byte("stringtopic"))} },
|
resultObj: func() any { return &hashStruct{crypto.Keccak256Hash([]byte("stringtopic"))} },
|
||||||
resultMap: func() map[string]interface{} {
|
resultMap: func() map[string]any {
|
||||||
return map[string]interface{}{"hashValue": crypto.Keccak256Hash([]byte("stringtopic"))}
|
return map[string]any{"hashValue": crypto.Keccak256Hash([]byte("stringtopic"))}
|
||||||
},
|
},
|
||||||
fields: Arguments{Argument{
|
fields: Arguments{Argument{
|
||||||
Name: "hashValue",
|
Name: "hashValue",
|
||||||
|
|
@ -290,13 +290,13 @@ func setupTopicsTests() []topicTest {
|
||||||
{
|
{
|
||||||
name: "function type",
|
name: "function type",
|
||||||
args: args{
|
args: args{
|
||||||
createObj: func() interface{} { return &funcStruct{} },
|
createObj: func() any { return &funcStruct{} },
|
||||||
resultObj: func() interface{} {
|
resultObj: func() any {
|
||||||
return &funcStruct{[24]byte{255, 255, 255, 255, 255, 255, 255, 255,
|
return &funcStruct{[24]byte{255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}}
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}}
|
||||||
},
|
},
|
||||||
resultMap: func() map[string]interface{} {
|
resultMap: func() map[string]any {
|
||||||
return map[string]interface{}{"funcValue": [24]byte{255, 255, 255, 255, 255, 255, 255, 255,
|
return map[string]any{"funcValue": [24]byte{255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}}
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}}
|
||||||
},
|
},
|
||||||
fields: Arguments{Argument{
|
fields: Arguments{Argument{
|
||||||
|
|
@ -314,9 +314,9 @@ func setupTopicsTests() []topicTest {
|
||||||
{
|
{
|
||||||
name: "error on topic/field count mismatch",
|
name: "error on topic/field count mismatch",
|
||||||
args: args{
|
args: args{
|
||||||
createObj: func() interface{} { return nil },
|
createObj: func() any { return nil },
|
||||||
resultObj: func() interface{} { return nil },
|
resultObj: func() any { return nil },
|
||||||
resultMap: func() map[string]interface{} { return make(map[string]interface{}) },
|
resultMap: func() map[string]any { return make(map[string]any) },
|
||||||
fields: Arguments{Argument{
|
fields: Arguments{Argument{
|
||||||
Name: "tupletype",
|
Name: "tupletype",
|
||||||
Type: tupleType,
|
Type: tupleType,
|
||||||
|
|
@ -329,9 +329,9 @@ func setupTopicsTests() []topicTest {
|
||||||
{
|
{
|
||||||
name: "error on unindexed arguments",
|
name: "error on unindexed arguments",
|
||||||
args: args{
|
args: args{
|
||||||
createObj: func() interface{} { return &int256Struct{} },
|
createObj: func() any { return &int256Struct{} },
|
||||||
resultObj: func() interface{} { return &int256Struct{} },
|
resultObj: func() any { return &int256Struct{} },
|
||||||
resultMap: func() map[string]interface{} { return make(map[string]interface{}) },
|
resultMap: func() map[string]any { return make(map[string]any) },
|
||||||
fields: Arguments{Argument{
|
fields: Arguments{Argument{
|
||||||
Name: "int256Value",
|
Name: "int256Value",
|
||||||
Type: int256Type,
|
Type: int256Type,
|
||||||
|
|
@ -347,9 +347,9 @@ func setupTopicsTests() []topicTest {
|
||||||
{
|
{
|
||||||
name: "error on tuple in topic reconstruction",
|
name: "error on tuple in topic reconstruction",
|
||||||
args: args{
|
args: args{
|
||||||
createObj: func() interface{} { return &tupleType },
|
createObj: func() any { return &tupleType },
|
||||||
resultObj: func() interface{} { return &tupleType },
|
resultObj: func() any { return &tupleType },
|
||||||
resultMap: func() map[string]interface{} { return make(map[string]interface{}) },
|
resultMap: func() map[string]any { return make(map[string]any) },
|
||||||
fields: Arguments{Argument{
|
fields: Arguments{Argument{
|
||||||
Name: "tupletype",
|
Name: "tupletype",
|
||||||
Type: tupleType,
|
Type: tupleType,
|
||||||
|
|
@ -362,10 +362,10 @@ func setupTopicsTests() []topicTest {
|
||||||
{
|
{
|
||||||
name: "error on improper encoded function",
|
name: "error on improper encoded function",
|
||||||
args: args{
|
args: args{
|
||||||
createObj: func() interface{} { return &funcStruct{} },
|
createObj: func() any { return &funcStruct{} },
|
||||||
resultObj: func() interface{} { return &funcStruct{} },
|
resultObj: func() any { return &funcStruct{} },
|
||||||
resultMap: func() map[string]interface{} {
|
resultMap: func() map[string]any {
|
||||||
return make(map[string]interface{})
|
return make(map[string]any)
|
||||||
},
|
},
|
||||||
fields: Arguments{Argument{
|
fields: Arguments{Argument{
|
||||||
Name: "funcValue",
|
Name: "funcValue",
|
||||||
|
|
@ -410,7 +410,7 @@ func TestParseTopicsIntoMap(t *testing.T) {
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
outMap := make(map[string]interface{})
|
outMap := make(map[string]any)
|
||||||
if err := ParseTopicsIntoMap(outMap, tt.args.fields, tt.args.topics); (err != nil) != tt.wantErr {
|
if err := ParseTopicsIntoMap(outMap, tt.args.fields, tt.args.topics); (err != nil) != tt.wantErr {
|
||||||
t.Errorf("parseTopicsIntoMap() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("parseTopicsIntoMap() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ func TestTypeCheck(t *testing.T) {
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
typ string
|
typ string
|
||||||
components []ArgumentMarshaling
|
components []ArgumentMarshaling
|
||||||
input interface{}
|
input any
|
||||||
err string
|
err string
|
||||||
}{
|
}{
|
||||||
{"uint", nil, big.NewInt(1), "unsupported arg type: uint"},
|
{"uint", nil, big.NewInt(1), "unsupported arg type: uint"},
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// ReadInteger reads the integer based on its kind and returns the appropriate value.
|
// ReadInteger reads the integer based on its kind and returns the appropriate value.
|
||||||
func ReadInteger(typ Type, b []byte) (interface{}, error) {
|
func ReadInteger(typ Type, b []byte) (any, error) {
|
||||||
ret := new(big.Int).SetBytes(b)
|
ret := new(big.Int).SetBytes(b)
|
||||||
|
|
||||||
if typ.T == UintTy {
|
if typ.T == UintTy {
|
||||||
|
|
@ -137,7 +137,7 @@ func readFunctionType(t Type, word []byte) (funcTy [24]byte, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadFixedBytes uses reflection to create a fixed array to be read from.
|
// ReadFixedBytes uses reflection to create a fixed array to be read from.
|
||||||
func ReadFixedBytes(t Type, word []byte) (interface{}, error) {
|
func ReadFixedBytes(t Type, word []byte) (any, error) {
|
||||||
if t.T != FixedBytesTy {
|
if t.T != FixedBytesTy {
|
||||||
return nil, errors.New("abi: invalid type in call to make fixed byte array")
|
return nil, errors.New("abi: invalid type in call to make fixed byte array")
|
||||||
}
|
}
|
||||||
|
|
@ -149,7 +149,7 @@ func ReadFixedBytes(t Type, word []byte) (interface{}, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// forEachUnpack iteratively unpack elements.
|
// forEachUnpack iteratively unpack elements.
|
||||||
func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error) {
|
func forEachUnpack(t Type, output []byte, start, size int) (any, error) {
|
||||||
if size < 0 {
|
if size < 0 {
|
||||||
return nil, fmt.Errorf("cannot marshal input to array, size is negative (%d)", size)
|
return nil, fmt.Errorf("cannot marshal input to array, size is negative (%d)", size)
|
||||||
}
|
}
|
||||||
|
|
@ -189,7 +189,7 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error)
|
||||||
return refSlice.Interface(), nil
|
return refSlice.Interface(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func forTupleUnpack(t Type, output []byte) (interface{}, error) {
|
func forTupleUnpack(t Type, output []byte) (any, error) {
|
||||||
retval := reflect.New(t.GetType()).Elem()
|
retval := reflect.New(t.GetType()).Elem()
|
||||||
virtualArgs := 0
|
virtualArgs := 0
|
||||||
for index, elem := range t.TupleElems {
|
for index, elem := range t.TupleElems {
|
||||||
|
|
@ -221,7 +221,7 @@ func forTupleUnpack(t Type, output []byte) (interface{}, error) {
|
||||||
|
|
||||||
// toGoType parses the output bytes and recursively assigns the value of these bytes
|
// toGoType parses the output bytes and recursively assigns the value of these bytes
|
||||||
// into a go type with accordance with the ABI spec.
|
// into a go type with accordance with the ABI spec.
|
||||||
func toGoType(index int, t Type, output []byte) (interface{}, error) {
|
func toGoType(index int, t Type, output []byte) (any, error) {
|
||||||
if index+32 > len(output) {
|
if index+32 > len(output) {
|
||||||
return nil, fmt.Errorf("abi: cannot marshal in to go type: length insufficient %d require %d", len(output), index+32)
|
return nil, fmt.Errorf("abi: cannot marshal in to go type: length insufficient %d require %d", len(output), index+32)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,10 +99,10 @@ func TestUnpack(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type unpackTest struct {
|
type unpackTest struct {
|
||||||
def string // ABI definition JSON
|
def string // ABI definition JSON
|
||||||
enc string // evm return data
|
enc string // evm return data
|
||||||
want interface{} // the expected output
|
want any // the expected output
|
||||||
err string // empty or error if expected
|
err string // empty or error if expected
|
||||||
}
|
}
|
||||||
|
|
||||||
func (test unpackTest) checkError(err error) error {
|
func (test unpackTest) checkError(err error) error {
|
||||||
|
|
@ -370,16 +370,16 @@ func TestMethodMultiReturn(t *testing.T) {
|
||||||
Int *big.Int
|
Int *big.Int
|
||||||
}
|
}
|
||||||
|
|
||||||
newInterfaceSlice := func(len int) interface{} {
|
newInterfaceSlice := func(len int) any {
|
||||||
slice := make([]interface{}, len)
|
slice := make([]any, len)
|
||||||
return &slice
|
return &slice
|
||||||
}
|
}
|
||||||
|
|
||||||
abi, data, expected := methodMultiReturn(require.New(t))
|
abi, data, expected := methodMultiReturn(require.New(t))
|
||||||
bigint := new(big.Int)
|
bigint := new(big.Int)
|
||||||
var testCases = []struct {
|
var testCases = []struct {
|
||||||
dest interface{}
|
dest any
|
||||||
expected interface{}
|
expected any
|
||||||
error string
|
error string
|
||||||
name string
|
name string
|
||||||
}{{
|
}{{
|
||||||
|
|
@ -393,38 +393,38 @@ func TestMethodMultiReturn(t *testing.T) {
|
||||||
"",
|
"",
|
||||||
"Can unpack into reversed structure",
|
"Can unpack into reversed structure",
|
||||||
}, {
|
}, {
|
||||||
&[]interface{}{&bigint, new(string)},
|
&[]any{&bigint, new(string)},
|
||||||
&[]interface{}{&expected.Int, &expected.String},
|
&[]any{&expected.Int, &expected.String},
|
||||||
"",
|
"",
|
||||||
"Can unpack into a slice",
|
"Can unpack into a slice",
|
||||||
}, {
|
}, {
|
||||||
&[]interface{}{&bigint, ""},
|
&[]any{&bigint, ""},
|
||||||
&[]interface{}{&expected.Int, expected.String},
|
&[]any{&expected.Int, expected.String},
|
||||||
"",
|
"",
|
||||||
"Can unpack into a slice without indirection",
|
"Can unpack into a slice without indirection",
|
||||||
}, {
|
}, {
|
||||||
&[2]interface{}{&bigint, new(string)},
|
&[2]any{&bigint, new(string)},
|
||||||
&[2]interface{}{&expected.Int, &expected.String},
|
&[2]any{&expected.Int, &expected.String},
|
||||||
"",
|
"",
|
||||||
"Can unpack into an array",
|
"Can unpack into an array",
|
||||||
}, {
|
}, {
|
||||||
&[2]interface{}{},
|
&[2]any{},
|
||||||
&[2]interface{}{expected.Int, expected.String},
|
&[2]any{expected.Int, expected.String},
|
||||||
"",
|
"",
|
||||||
"Can unpack into interface array",
|
"Can unpack into interface array",
|
||||||
}, {
|
}, {
|
||||||
newInterfaceSlice(2),
|
newInterfaceSlice(2),
|
||||||
&[]interface{}{expected.Int, expected.String},
|
&[]any{expected.Int, expected.String},
|
||||||
"",
|
"",
|
||||||
"Can unpack into interface slice",
|
"Can unpack into interface slice",
|
||||||
}, {
|
}, {
|
||||||
&[]interface{}{new(int), new(int)},
|
&[]any{new(int), new(int)},
|
||||||
&[]interface{}{&expected.Int, &expected.String},
|
&[]any{&expected.Int, &expected.String},
|
||||||
"abi: cannot unmarshal *big.Int in to int",
|
"abi: cannot unmarshal *big.Int in to int",
|
||||||
"Can not unpack into a slice with wrong types",
|
"Can not unpack into a slice with wrong types",
|
||||||
}, {
|
}, {
|
||||||
&[]interface{}{new(int)},
|
&[]any{new(int)},
|
||||||
&[]interface{}{},
|
&[]any{},
|
||||||
"abi: insufficient number of arguments for unpack, want 2, got 1",
|
"abi: insufficient number of arguments for unpack, want 2, got 1",
|
||||||
"Can not unpack into a slice with wrong types",
|
"Can not unpack into a slice with wrong types",
|
||||||
}}
|
}}
|
||||||
|
|
@ -455,7 +455,7 @@ func TestMultiReturnWithArray(t *testing.T) {
|
||||||
|
|
||||||
ret1, ret1Exp := new([3]uint64), [3]uint64{9, 9, 9}
|
ret1, ret1Exp := new([3]uint64), [3]uint64{9, 9, 9}
|
||||||
ret2, ret2Exp := new(uint64), uint64(8)
|
ret2, ret2Exp := new(uint64), uint64(8)
|
||||||
if err := abi.UnpackIntoInterface(&[]interface{}{ret1, ret2}, "multi", buff.Bytes()); err != nil {
|
if err := abi.UnpackIntoInterface(&[]any{ret1, ret2}, "multi", buff.Bytes()); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
||||||
|
|
@ -480,7 +480,7 @@ func TestMultiReturnWithStringArray(t *testing.T) {
|
||||||
ret2, ret2Exp := new(common.Address), common.HexToAddress("ab1257528b3782fb40d7ed5f72e624b744dffb2f")
|
ret2, ret2Exp := new(common.Address), common.HexToAddress("ab1257528b3782fb40d7ed5f72e624b744dffb2f")
|
||||||
ret3, ret3Exp := new([2]string), [2]string{"Ethereum", "Hello, Ethereum!"}
|
ret3, ret3Exp := new([2]string), [2]string{"Ethereum", "Hello, Ethereum!"}
|
||||||
ret4, ret4Exp := new(bool), false
|
ret4, ret4Exp := new(bool), false
|
||||||
if err := abi.UnpackIntoInterface(&[]interface{}{ret1, ret2, ret3, ret4}, "multi", buff.Bytes()); err != nil {
|
if err := abi.UnpackIntoInterface(&[]any{ret1, ret2, ret3, ret4}, "multi", buff.Bytes()); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
||||||
|
|
@ -519,7 +519,7 @@ func TestMultiReturnWithStringSlice(t *testing.T) {
|
||||||
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000065")) // output[1][1] value
|
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000065")) // output[1][1] value
|
||||||
ret1, ret1Exp := new([]string), []string{"ethereum", "go-ethereum"}
|
ret1, ret1Exp := new([]string), []string{"ethereum", "go-ethereum"}
|
||||||
ret2, ret2Exp := new([]*big.Int), []*big.Int{big.NewInt(100), big.NewInt(101)}
|
ret2, ret2Exp := new([]*big.Int), []*big.Int{big.NewInt(100), big.NewInt(101)}
|
||||||
if err := abi.UnpackIntoInterface(&[]interface{}{ret1, ret2}, "multi", buff.Bytes()); err != nil {
|
if err := abi.UnpackIntoInterface(&[]any{ret1, ret2}, "multi", buff.Bytes()); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
||||||
|
|
@ -560,7 +560,7 @@ func TestMultiReturnWithDeeplyNestedArray(t *testing.T) {
|
||||||
{{0x411, 0x412, 0x413}, {0x421, 0x422, 0x423}},
|
{{0x411, 0x412, 0x413}, {0x421, 0x422, 0x423}},
|
||||||
}
|
}
|
||||||
ret2, ret2Exp := new(uint64), uint64(0x9876)
|
ret2, ret2Exp := new(uint64), uint64(0x9876)
|
||||||
if err := abi.UnpackIntoInterface(&[]interface{}{ret1, ret2}, "multi", buff.Bytes()); err != nil {
|
if err := abi.UnpackIntoInterface(&[]any{ret1, ret2}, "multi", buff.Bytes()); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
if !reflect.DeepEqual(*ret1, ret1Exp) {
|
||||||
|
|
@ -593,7 +593,7 @@ func TestUnmarshal(t *testing.T) {
|
||||||
// marshall mixed bytes (mixedBytes)
|
// marshall mixed bytes (mixedBytes)
|
||||||
p0, p0Exp := []byte{}, common.Hex2Bytes("01020000000000000000")
|
p0, p0Exp := []byte{}, common.Hex2Bytes("01020000000000000000")
|
||||||
p1, p1Exp := [32]byte{}, common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000ddeeff")
|
p1, p1Exp := [32]byte{}, common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000ddeeff")
|
||||||
mixedBytes := []interface{}{&p0, &p1}
|
mixedBytes := []any{&p0, &p1}
|
||||||
|
|
||||||
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000040"))
|
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000040"))
|
||||||
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000ddeeff"))
|
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000ddeeff"))
|
||||||
|
|
@ -1016,7 +1016,7 @@ func TestPackAndUnpackIncompatibleNumber(t *testing.T) {
|
||||||
inputValue *big.Int
|
inputValue *big.Int
|
||||||
unpackErr error
|
unpackErr error
|
||||||
packErr error
|
packErr error
|
||||||
expectValue interface{}
|
expectValue any
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
decodeType: "uint8",
|
decodeType: "uint8",
|
||||||
|
|
|
||||||
|
|
@ -78,12 +78,12 @@ type encryptedKeyJSONV1 struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type CryptoJSON struct {
|
type CryptoJSON struct {
|
||||||
Cipher string `json:"cipher"`
|
Cipher string `json:"cipher"`
|
||||||
CipherText string `json:"ciphertext"`
|
CipherText string `json:"ciphertext"`
|
||||||
CipherParams cipherparamsJSON `json:"cipherparams"`
|
CipherParams cipherparamsJSON `json:"cipherparams"`
|
||||||
KDF string `json:"kdf"`
|
KDF string `json:"kdf"`
|
||||||
KDFParams map[string]interface{} `json:"kdfparams"`
|
KDFParams map[string]any `json:"kdfparams"`
|
||||||
MAC string `json:"mac"`
|
MAC string `json:"mac"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type cipherparamsJSON struct {
|
type cipherparamsJSON struct {
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ func EncryptDataV3(data, auth []byte, scryptN, scryptP int) (CryptoJSON, error)
|
||||||
}
|
}
|
||||||
mac := crypto.Keccak256(derivedKey[16:32], cipherText)
|
mac := crypto.Keccak256(derivedKey[16:32], cipherText)
|
||||||
|
|
||||||
scryptParamsJSON := make(map[string]interface{}, 5)
|
scryptParamsJSON := make(map[string]any, 5)
|
||||||
scryptParamsJSON["n"] = scryptN
|
scryptParamsJSON["n"] = scryptN
|
||||||
scryptParamsJSON["r"] = scryptR
|
scryptParamsJSON["r"] = scryptR
|
||||||
scryptParamsJSON["p"] = scryptP
|
scryptParamsJSON["p"] = scryptP
|
||||||
|
|
@ -199,7 +199,7 @@ func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error) {
|
||||||
// DecryptKey decrypts a key from a json blob, returning the private key itself.
|
// DecryptKey decrypts a key from a json blob, returning the private key itself.
|
||||||
func DecryptKey(keyjson []byte, auth string) (*Key, error) {
|
func DecryptKey(keyjson []byte, auth string) (*Key, error) {
|
||||||
// Parse the json into a simple map to fetch the key version
|
// Parse the json into a simple map to fetch the key version
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]any)
|
||||||
if err := json.Unmarshal(keyjson, &m); err != nil {
|
if err := json.Unmarshal(keyjson, &m); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -359,7 +359,7 @@ func getKDFKey(cryptoJSON CryptoJSON, auth string) ([]byte, error) {
|
||||||
// TODO: can we do without this when unmarshalling dynamic JSON?
|
// TODO: can we do without this when unmarshalling dynamic JSON?
|
||||||
// why do integers in KDF params end up as float64 and not int after
|
// why do integers in KDF params end up as float64 and not int after
|
||||||
// unmarshal?
|
// unmarshal?
|
||||||
func ensureInt(x interface{}) int {
|
func ensureInt(x any) int {
|
||||||
res, ok := x.(int)
|
res, ok := x.(int)
|
||||||
if !ok {
|
if !ok {
|
||||||
res = int(x.(float64))
|
res = int(x.(float64))
|
||||||
|
|
|
||||||
|
|
@ -334,24 +334,24 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if chainID == nil {
|
if chainID == nil {
|
||||||
if txrlp, err = rlp.EncodeToBytes([]interface{}{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data()}); err != nil {
|
if txrlp, err = rlp.EncodeToBytes([]any{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data()}); err != nil {
|
||||||
return common.Address{}, nil, err
|
return common.Address{}, nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if tx.Type() == types.DynamicFeeTxType {
|
if tx.Type() == types.DynamicFeeTxType {
|
||||||
if txrlp, err = rlp.EncodeToBytes([]interface{}{chainID, tx.Nonce(), tx.GasTipCap(), tx.GasFeeCap(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
|
if txrlp, err = rlp.EncodeToBytes([]any{chainID, tx.Nonce(), tx.GasTipCap(), tx.GasFeeCap(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
|
||||||
return common.Address{}, nil, err
|
return common.Address{}, nil, err
|
||||||
}
|
}
|
||||||
// append type to transaction
|
// append type to transaction
|
||||||
txrlp = append([]byte{tx.Type()}, txrlp...)
|
txrlp = append([]byte{tx.Type()}, txrlp...)
|
||||||
} else if tx.Type() == types.AccessListTxType {
|
} else if tx.Type() == types.AccessListTxType {
|
||||||
if txrlp, err = rlp.EncodeToBytes([]interface{}{chainID, tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
|
if txrlp, err = rlp.EncodeToBytes([]any{chainID, tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
|
||||||
return common.Address{}, nil, err
|
return common.Address{}, nil, err
|
||||||
}
|
}
|
||||||
// append type to transaction
|
// append type to transaction
|
||||||
txrlp = append([]byte{tx.Type()}, txrlp...)
|
txrlp = append([]byte{tx.Type()}, txrlp...)
|
||||||
} else if tx.Type() == types.LegacyTxType {
|
} else if tx.Type() == types.LegacyTxType {
|
||||||
if txrlp, err = rlp.EncodeToBytes([]interface{}{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), chainID, big.NewInt(0), big.NewInt(0)}); err != nil {
|
if txrlp, err = rlp.EncodeToBytes([]any{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), chainID, big.NewInt(0), big.NewInt(0)}); err != nil {
|
||||||
return common.Address{}, nil, err
|
return common.Address{}, nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ type EngineAPIError struct {
|
||||||
|
|
||||||
func (e *EngineAPIError) ErrorCode() int { return e.code }
|
func (e *EngineAPIError) ErrorCode() int { return e.code }
|
||||||
func (e *EngineAPIError) Error() string { return e.msg }
|
func (e *EngineAPIError) Error() string { return e.msg }
|
||||||
func (e *EngineAPIError) ErrorData() interface{} {
|
func (e *EngineAPIError) ErrorData() any {
|
||||||
if e.err == nil {
|
if e.err == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ func makeTestHeaderWithMerkleProof(slot, index uint64, value merkle.Value) (type
|
||||||
}
|
}
|
||||||
|
|
||||||
// syncCommittee holds either a blsSyncCommittee or a fake dummySyncCommittee used for testing
|
// syncCommittee holds either a blsSyncCommittee or a fake dummySyncCommittee used for testing
|
||||||
type syncCommittee interface{}
|
type syncCommittee any
|
||||||
|
|
||||||
// committeeSigVerifier verifies sync committee signatures (either proper BLS
|
// committeeSigVerifier verifies sync committee signatures (either proper BLS
|
||||||
// signatures or fake signatures used for testing)
|
// signatures or fake signatures used for testing)
|
||||||
|
|
|
||||||
|
|
@ -1227,7 +1227,7 @@ func doWindowsInstaller(cmdline []string) {
|
||||||
|
|
||||||
// Render NSIS scripts: Installer NSIS contains two installer sections,
|
// Render NSIS scripts: Installer NSIS contains two installer sections,
|
||||||
// first section contains the geth binary, second section holds the dev tools.
|
// first section contains the geth binary, second section holds the dev tools.
|
||||||
templateData := map[string]interface{}{
|
templateData := map[string]any{
|
||||||
"License": "COPYING",
|
"License": "COPYING",
|
||||||
"Geth": gethTool,
|
"Geth": gethTool,
|
||||||
"DevTools": devTools,
|
"DevTools": devTools,
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func die(args ...interface{}) {
|
func die(args ...any) {
|
||||||
fmt.Fprintln(os.Stderr, args...)
|
fmt.Fprintln(os.Stderr, args...)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -779,7 +779,7 @@ func signer(c *cli.Context) error {
|
||||||
go testExternalUI(apiImpl)
|
go testExternalUI(apiImpl)
|
||||||
}
|
}
|
||||||
ui.OnSignerStartup(core.StartupInfo{
|
ui.OnSignerStartup(core.StartupInfo{
|
||||||
Info: map[string]interface{}{
|
Info: map[string]any{
|
||||||
"intapi_version": core.InternalAPIVersion,
|
"intapi_version": core.InternalAPIVersion,
|
||||||
"extapi_version": core.ExternalAPIVersion,
|
"extapi_version": core.ExternalAPIVersion,
|
||||||
"extapi_http": extapiURL,
|
"extapi_http": extapiURL,
|
||||||
|
|
@ -1084,7 +1084,7 @@ func GenDoc(ctx *cli.Context) error {
|
||||||
UserAgent: "Firefox 3.2",
|
UserAgent: "Firefox 3.2",
|
||||||
}
|
}
|
||||||
output []string
|
output []string
|
||||||
add = func(name, desc string, v interface{}) {
|
add = func(name, desc string, v any) {
|
||||||
if data, err := json.MarshalIndent(v, "", " "); err == nil {
|
if data, err := json.MarshalIndent(v, "", " "); err == nil {
|
||||||
output = append(output, fmt.Sprintf("### %s\n\n%s\n\nExample:\n```json\n%s\n```", name, desc, data))
|
output = append(output, fmt.Sprintf("### %s\n\n%s\n\nExample:\n```json\n%s\n```", name, desc, data))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ func dumpNodeURL(out io.Writer, n *enode.Node) {
|
||||||
fmt.Fprintf(out, "URLv4: %s\n", n.URLv4())
|
fmt.Fprintf(out, "URLv4: %s\n", n.URLv4())
|
||||||
}
|
}
|
||||||
|
|
||||||
func dumpRecordKV(kv []interface{}, indent int) string {
|
func dumpRecordKV(kv []any, indent int) string {
|
||||||
// Determine the longest key name for alignment.
|
// Determine the longest key name for alignment.
|
||||||
var out string
|
var out string
|
||||||
var longestKey = 0
|
var longestKey = 0
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,10 @@ func (p *readError) Unwrap() error { return p.err }
|
||||||
func (p *readError) RequestID() []byte { return nil }
|
func (p *readError) RequestID() []byte { return nil }
|
||||||
func (p *readError) SetRequestID([]byte) {}
|
func (p *readError) SetRequestID([]byte) {}
|
||||||
|
|
||||||
func (p *readError) AppendLogInfo(ctx []interface{}) []interface{} { return ctx }
|
func (p *readError) AppendLogInfo(ctx []any) []any { return ctx }
|
||||||
|
|
||||||
// readErrorf creates a readError with the given text.
|
// readErrorf creates a readError with the given text.
|
||||||
func readErrorf(format string, args ...interface{}) *readError {
|
func readErrorf(format string, args ...any) *readError {
|
||||||
return &readError{fmt.Errorf(format, args...)}
|
return &readError{fmt.Errorf(format, args...)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,7 +68,7 @@ type conn struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type logger interface {
|
type logger interface {
|
||||||
Logf(string, ...interface{})
|
Logf(string, ...any)
|
||||||
}
|
}
|
||||||
|
|
||||||
// newConn sets up a connection to the given node.
|
// newConn sets up a connection to the given node.
|
||||||
|
|
@ -231,7 +231,7 @@ func (tc *conn) read(c net.PacketConn) v5wire.Packet {
|
||||||
}
|
}
|
||||||
|
|
||||||
// logf prints to the test log.
|
// logf prints to the test log.
|
||||||
func (tc *conn) logf(format string, args ...interface{}) {
|
func (tc *conn) logf(format string, args ...any) {
|
||||||
if tc.log != nil {
|
if tc.log != nil {
|
||||||
tc.log.Logf("(%s) %s", tc.localNode.ID().TerminalString(), fmt.Sprintf(format, args...))
|
tc.log.Logf("(%s) %s", tc.localNode.ID().TerminalString(), fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ func getNodeArg(ctx *cli.Context) *enode.Node {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func exit(err interface{}) {
|
func exit(err any) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ func nodesetInfo(ctx *cli.Context) error {
|
||||||
// showAttributeCounts prints the distribution of ENR attributes in a node set.
|
// showAttributeCounts prints the distribution of ENR attributes in a node set.
|
||||||
func showAttributeCounts(ns nodeSet) {
|
func showAttributeCounts(ns nodeSet) {
|
||||||
attrcount := make(map[string]int)
|
attrcount := make(map[string]int)
|
||||||
var attrlist []interface{}
|
var attrlist []any
|
||||||
for _, n := range ns {
|
for _, n := range ns {
|
||||||
r := n.N.Record()
|
r := n.N.Record()
|
||||||
attrlist = r.AppendElements(attrlist[:0])[1:]
|
attrlist = r.AppendElements(attrlist[:0])[1:]
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ func getPassphrase(ctx *cli.Context, confirmation bool) string {
|
||||||
|
|
||||||
// mustPrintJSON prints the JSON encoding of the given object and
|
// mustPrintJSON prints the JSON encoding of the given object and
|
||||||
// exits the program with an error message when the marshaling fails.
|
// exits the program with an error message when the marshaling fails.
|
||||||
func mustPrintJSON(jsonObject interface{}) {
|
func mustPrintJSON(jsonObject any) {
|
||||||
str, err := json.MarshalIndent(jsonObject, "", " ")
|
str, err := json.MarshalIndent(jsonObject, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Failed to marshal JSON object: %v", err)
|
utils.Fatalf("Failed to marshal JSON object: %v", err)
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ func (g Alloc) OnAccount(addr *common.Address, dumpAccount state.DumpAccount) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// saveFile marshals the object to the given file
|
// saveFile marshals the object to the given file
|
||||||
func saveFile(baseDir, filename string, data interface{}) error {
|
func saveFile(baseDir, filename string, data any) error {
|
||||||
b, err := json.MarshalIndent(data, "", " ")
|
b, err := json.MarshalIndent(data, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return NewError(ErrorJson, fmt.Errorf("failed marshalling output: %v", err))
|
return NewError(ErrorJson, fmt.Errorf("failed marshalling output: %v", err))
|
||||||
|
|
@ -334,9 +334,9 @@ func saveFile(baseDir, filename string, data interface{}) error {
|
||||||
// dispatchOutput writes the output data to either stderr or stdout, or to the specified
|
// dispatchOutput writes the output data to either stderr or stdout, or to the specified
|
||||||
// files
|
// files
|
||||||
func dispatchOutput(ctx *cli.Context, baseDir string, result *ExecutionResult, alloc Alloc, body hexutil.Bytes, bt map[common.Hash]hexutil.Bytes) error {
|
func dispatchOutput(ctx *cli.Context, baseDir string, result *ExecutionResult, alloc Alloc, body hexutil.Bytes, bt map[common.Hash]hexutil.Bytes) error {
|
||||||
stdOutObject := make(map[string]interface{})
|
stdOutObject := make(map[string]any)
|
||||||
stdErrObject := make(map[string]interface{})
|
stdErrObject := make(map[string]any)
|
||||||
dispatch := func(baseDir, fName, name string, obj interface{}) error {
|
dispatch := func(baseDir, fName, name string, obj any) error {
|
||||||
switch fName {
|
switch fName {
|
||||||
case "stdout":
|
case "stdout":
|
||||||
stdOutObject[name] = obj
|
stdOutObject[name] = obj
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// readFile reads the json-data in the provided path and marshals into dest.
|
// readFile reads the json-data in the provided path and marshals into dest.
|
||||||
func readFile(path, desc string, dest interface{}) error {
|
func readFile(path, desc string, dest any) error {
|
||||||
inFile, err := os.Open(path)
|
inFile, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return NewError(ErrorIO, fmt.Errorf("failed reading %s file: %v", desc, err))
|
return NewError(ErrorIO, fmt.Errorf("failed reading %s file: %v", desc, err))
|
||||||
|
|
|
||||||
|
|
@ -736,7 +736,7 @@ func TestEvmRunRegEx(t *testing.T) {
|
||||||
|
|
||||||
// cmpJson compares the JSON in two byte slices.
|
// cmpJson compares the JSON in two byte slices.
|
||||||
func cmpJson(a, b []byte) (bool, error) {
|
func cmpJson(a, b []byte) (bool, error) {
|
||||||
var j, j2 interface{}
|
var j, j2 any
|
||||||
if err := json.Unmarshal(a, &j); err != nil {
|
if err := json.Unmarshal(a, &j); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ func ws(n int) string {
|
||||||
return strings.Repeat(" ", n)
|
return strings.Repeat(" ", n)
|
||||||
}
|
}
|
||||||
|
|
||||||
func die(args ...interface{}) {
|
func die(args ...any) {
|
||||||
fmt.Fprintln(os.Stderr, args...)
|
fmt.Fprintln(os.Stderr, args...)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
@ -187,7 +187,7 @@ func textToRlp(r io.Reader) ([]byte, error) {
|
||||||
// - an element is either hex-encoded bytes OR a quoted string
|
// - an element is either hex-encoded bytes OR a quoted string
|
||||||
var (
|
var (
|
||||||
scanner = bufio.NewScanner(r)
|
scanner = bufio.NewScanner(r)
|
||||||
obj []interface{}
|
obj []any
|
||||||
stack = list.New()
|
stack = list.New()
|
||||||
)
|
)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
|
|
@ -198,12 +198,12 @@ func textToRlp(r io.Reader) ([]byte, error) {
|
||||||
switch t {
|
switch t {
|
||||||
case "[": // list start
|
case "[": // list start
|
||||||
stack.PushFront(obj)
|
stack.PushFront(obj)
|
||||||
obj = make([]interface{}, 0)
|
obj = make([]any, 0)
|
||||||
case "]", "],": // list end
|
case "]", "],": // list end
|
||||||
parent := stack.Remove(stack.Front()).([]interface{})
|
parent := stack.Remove(stack.Front()).([]any)
|
||||||
obj = append(parent, obj)
|
obj = append(parent, obj)
|
||||||
case "[],": // empty list
|
case "[],": // empty list
|
||||||
obj = append(obj, make([]interface{}, 0))
|
obj = append(obj, make([]any, 0))
|
||||||
default: // element
|
default: // element
|
||||||
data := []byte(t)[:len(t)-1] // cut off comma
|
data := []byte(t)[:len(t)-1] // cut off comma
|
||||||
if data[0] == '"' { // ascii string
|
if data[0] == '"' { // ascii string
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ var ErrImportInterrupted = errors.New("interrupted")
|
||||||
// Fatalf formats a message to standard error and exits the program.
|
// Fatalf formats a message to standard error and exits the program.
|
||||||
// The message is also printed to standard output if standard error
|
// The message is also printed to standard output if standard error
|
||||||
// is redirected to a different file.
|
// is redirected to a different file.
|
||||||
func Fatalf(format string, args ...interface{}) {
|
func Fatalf(format string, args ...any) {
|
||||||
w := io.MultiWriter(os.Stdout, os.Stderr)
|
w := io.MultiWriter(os.Stdout, os.Stderr)
|
||||||
if runtime.GOOS == "windows" || runtime.GOOS == "openbsd" {
|
if runtime.GOOS == "windows" || runtime.GOOS == "openbsd" {
|
||||||
// The SameFile check below doesn't work on Windows neither OpenBSD.
|
// The SameFile check below doesn't work on Windows neither OpenBSD.
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,15 @@ type Contract struct {
|
||||||
// Depending on the source, language version, compiler version, and compiler
|
// Depending on the source, language version, compiler version, and compiler
|
||||||
// options will provide information about how the contract was compiled.
|
// options will provide information about how the contract was compiled.
|
||||||
type ContractInfo struct {
|
type ContractInfo struct {
|
||||||
Source string `json:"source"`
|
Source string `json:"source"`
|
||||||
Language string `json:"language"`
|
Language string `json:"language"`
|
||||||
LanguageVersion string `json:"languageVersion"`
|
LanguageVersion string `json:"languageVersion"`
|
||||||
CompilerVersion string `json:"compilerVersion"`
|
CompilerVersion string `json:"compilerVersion"`
|
||||||
CompilerOptions string `json:"compilerOptions"`
|
CompilerOptions string `json:"compilerOptions"`
|
||||||
SrcMap interface{} `json:"srcMap"`
|
SrcMap any `json:"srcMap"`
|
||||||
SrcMapRuntime string `json:"srcMapRuntime"`
|
SrcMapRuntime string `json:"srcMapRuntime"`
|
||||||
AbiDefinition interface{} `json:"abiDefinition"`
|
AbiDefinition any `json:"abiDefinition"`
|
||||||
UserDoc interface{} `json:"userDoc"`
|
UserDoc any `json:"userDoc"`
|
||||||
DeveloperDoc interface{} `json:"developerDoc"`
|
DeveloperDoc any `json:"developerDoc"`
|
||||||
Metadata string `json:"metadata"`
|
Metadata string `json:"metadata"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,9 @@ type solcOutputV8 struct {
|
||||||
BinRuntime string `json:"bin-runtime"`
|
BinRuntime string `json:"bin-runtime"`
|
||||||
SrcMapRuntime string `json:"srcmap-runtime"`
|
SrcMapRuntime string `json:"srcmap-runtime"`
|
||||||
Bin, SrcMap, Metadata string
|
Bin, SrcMap, Metadata string
|
||||||
Abi interface{}
|
Abi any
|
||||||
Devdoc interface{}
|
Devdoc any
|
||||||
Userdoc interface{}
|
Userdoc any
|
||||||
Hashes map[string]string
|
Hashes map[string]string
|
||||||
}
|
}
|
||||||
Version string
|
Version string
|
||||||
|
|
@ -66,7 +66,7 @@ func ParseCombinedJSON(combinedJSON []byte, source string, languageVersion strin
|
||||||
contracts := make(map[string]*Contract)
|
contracts := make(map[string]*Contract)
|
||||||
for name, info := range output.Contracts {
|
for name, info := range output.Contracts {
|
||||||
// Parse the individual compilation results.
|
// Parse the individual compilation results.
|
||||||
var abi, userdoc, devdoc interface{}
|
var abi, userdoc, devdoc any
|
||||||
if err := json.Unmarshal([]byte(info.Abi), &abi); err != nil {
|
if err := json.Unmarshal([]byte(info.Abi), &abi); err != nil {
|
||||||
return nil, fmt.Errorf("solc: error reading abi definition (%v)", err)
|
return nil, fmt.Errorf("solc: error reading abi definition (%v)", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Report gives off a warning requesting the user to submit an issue to the github tracker.
|
// Report gives off a warning requesting the user to submit an issue to the github tracker.
|
||||||
func Report(extra ...interface{}) {
|
func Report(extra ...any) {
|
||||||
fmt.Fprintln(os.Stderr, "You've encountered a sought after, hard to reproduce bug. Please report this to the developers <3 https://github.com/ethereum/go-ethereum/issues")
|
fmt.Fprintln(os.Stderr, "You've encountered a sought after, hard to reproduce bug. Please report this to the developers <3 https://github.com/ethereum/go-ethereum/issues")
|
||||||
fmt.Fprintln(os.Stderr, extra...)
|
fmt.Fprintln(os.Stderr, extra...)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type marshalTest struct {
|
type marshalTest struct {
|
||||||
input interface{}
|
input any
|
||||||
want string
|
want string
|
||||||
}
|
}
|
||||||
|
|
||||||
type unmarshalTest struct {
|
type unmarshalTest struct {
|
||||||
input string
|
input string
|
||||||
want interface{}
|
want any
|
||||||
wantErr error // if set, decoding must fail on any platform
|
wantErr error // if set, decoding must fail on any platform
|
||||||
wantErr32bit error // if set, decoding must fail on 32bit platforms (used for Uint tests)
|
wantErr32bit error // if set, decoding must fail on 32bit platforms (used for Uint tests)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ func (b Bytes) String() string {
|
||||||
func (b Bytes) ImplementsGraphQLType(name string) bool { return name == "Bytes" }
|
func (b Bytes) ImplementsGraphQLType(name string) bool { return name == "Bytes" }
|
||||||
|
|
||||||
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
|
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
|
||||||
func (b *Bytes) UnmarshalGraphQL(input interface{}) error {
|
func (b *Bytes) UnmarshalGraphQL(input any) error {
|
||||||
var err error
|
var err error
|
||||||
switch input := input.(type) {
|
switch input := input.(type) {
|
||||||
case string:
|
case string:
|
||||||
|
|
@ -213,7 +213,7 @@ func (b *Big) String() string {
|
||||||
func (b Big) ImplementsGraphQLType(name string) bool { return name == "BigInt" }
|
func (b Big) ImplementsGraphQLType(name string) bool { return name == "BigInt" }
|
||||||
|
|
||||||
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
|
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
|
||||||
func (b *Big) UnmarshalGraphQL(input interface{}) error {
|
func (b *Big) UnmarshalGraphQL(input any) error {
|
||||||
var err error
|
var err error
|
||||||
switch input := input.(type) {
|
switch input := input.(type) {
|
||||||
case string:
|
case string:
|
||||||
|
|
@ -321,7 +321,7 @@ func (b Uint64) String() string {
|
||||||
func (b Uint64) ImplementsGraphQLType(name string) bool { return name == "Long" }
|
func (b Uint64) ImplementsGraphQLType(name string) bool { return name == "Long" }
|
||||||
|
|
||||||
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
|
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
|
||||||
func (b *Uint64) UnmarshalGraphQL(input interface{}) error {
|
func (b *Uint64) UnmarshalGraphQL(input any) error {
|
||||||
var err error
|
var err error
|
||||||
switch input := input.(type) {
|
switch input := input.(type) {
|
||||||
case string:
|
case string:
|
||||||
|
|
|
||||||
|
|
@ -193,13 +193,13 @@ func (h *simTimerHeap) Swap(i, j int) {
|
||||||
(*h)[j].index = j
|
(*h)[j].index = j
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *simTimerHeap) Push(x interface{}) {
|
func (h *simTimerHeap) Push(x any) {
|
||||||
t := x.(*simTimer)
|
t := x.(*simTimer)
|
||||||
t.index = len(*h)
|
t.index = len(*h)
|
||||||
*h = append(*h, t)
|
*h = append(*h, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *simTimerHeap) Pop() interface{} {
|
func (h *simTimerHeap) Pop() any {
|
||||||
end := len(*h) - 1
|
end := len(*h) - 1
|
||||||
t := (*h)[end]
|
t := (*h)[end]
|
||||||
t.index = -1
|
t.index = -1
|
||||||
|
|
|
||||||
|
|
@ -40,18 +40,18 @@ type lazyItem struct {
|
||||||
index int
|
index int
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPriority(a interface{}) int64 {
|
func testPriority(a any) int64 {
|
||||||
return a.(*lazyItem).p
|
return a.(*lazyItem).p
|
||||||
}
|
}
|
||||||
|
|
||||||
func testMaxPriority(a interface{}, until mclock.AbsTime) int64 {
|
func testMaxPriority(a any, until mclock.AbsTime) int64 {
|
||||||
i := a.(*lazyItem)
|
i := a.(*lazyItem)
|
||||||
dt := until - i.last
|
dt := until - i.last
|
||||||
i.maxp = i.p + int64(float64(dt)*testAvgRate)
|
i.maxp = i.p + int64(float64(dt)*testAvgRate)
|
||||||
return i.maxp
|
return i.maxp
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSetIndex(a interface{}, i int) {
|
func testSetIndex(a any, i int) {
|
||||||
a.(*lazyItem).index = i
|
a.(*lazyItem).index = i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// LoadJSON reads the given file and unmarshals its content.
|
// LoadJSON reads the given file and unmarshals its content.
|
||||||
func LoadJSON(file string, val interface{}) error {
|
func LoadJSON(file string, val any) error {
|
||||||
content, err := os.ReadFile(file)
|
content, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ func (h Hash) Generate(rand *rand.Rand, size int) reflect.Value {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan implements Scanner for database/sql.
|
// Scan implements Scanner for database/sql.
|
||||||
func (h *Hash) Scan(src interface{}) error {
|
func (h *Hash) Scan(src any) error {
|
||||||
srcB, ok := src.([]byte)
|
srcB, ok := src.([]byte)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("can't scan %T into Hash", src)
|
return fmt.Errorf("can't scan %T into Hash", src)
|
||||||
|
|
@ -192,7 +192,7 @@ func (h Hash) Value() (driver.Value, error) {
|
||||||
func (Hash) ImplementsGraphQLType(name string) bool { return name == "Bytes32" }
|
func (Hash) ImplementsGraphQLType(name string) bool { return name == "Bytes32" }
|
||||||
|
|
||||||
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
|
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
|
||||||
func (h *Hash) UnmarshalGraphQL(input interface{}) error {
|
func (h *Hash) UnmarshalGraphQL(input any) error {
|
||||||
var err error
|
var err error
|
||||||
switch input := input.(type) {
|
switch input := input.(type) {
|
||||||
case string:
|
case string:
|
||||||
|
|
@ -348,7 +348,7 @@ func (a *Address) UnmarshalJSON(input []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan implements Scanner for database/sql.
|
// Scan implements Scanner for database/sql.
|
||||||
func (a *Address) Scan(src interface{}) error {
|
func (a *Address) Scan(src any) error {
|
||||||
srcB, ok := src.([]byte)
|
srcB, ok := src.([]byte)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("can't scan %T into Address", src)
|
return fmt.Errorf("can't scan %T into Address", src)
|
||||||
|
|
@ -369,7 +369,7 @@ func (a Address) Value() (driver.Value, error) {
|
||||||
func (a Address) ImplementsGraphQLType(name string) bool { return name == "Address" }
|
func (a Address) ImplementsGraphQLType(name string) bool { return name == "Address" }
|
||||||
|
|
||||||
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
|
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
|
||||||
func (a *Address) UnmarshalGraphQL(input interface{}) error {
|
func (a *Address) UnmarshalGraphQL(input any) error {
|
||||||
var err error
|
var err error
|
||||||
switch input := input.(type) {
|
switch input := input.(type) {
|
||||||
case string:
|
case string:
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ func TestMixedcaseAccount_Address(t *testing.T) {
|
||||||
|
|
||||||
func TestHash_Scan(t *testing.T) {
|
func TestHash_Scan(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
src interface{}
|
src any
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|
@ -314,7 +314,7 @@ func TestHash_Value(t *testing.T) {
|
||||||
|
|
||||||
func TestAddress_Scan(t *testing.T) {
|
func TestAddress_Scan(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
src interface{}
|
src any
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|
|
||||||
|
|
@ -662,7 +662,7 @@ func CliqueRLP(header *types.Header) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeSigHeader(w io.Writer, header *types.Header) {
|
func encodeSigHeader(w io.Writer, header *types.Header) {
|
||||||
enc := []interface{}{
|
enc := []any{
|
||||||
header.ParentHash,
|
header.ParentHash,
|
||||||
header.UncleHash,
|
header.UncleHash,
|
||||||
header.Coinbase,
|
header.Coinbase,
|
||||||
|
|
|
||||||
|
|
@ -529,7 +529,7 @@ func (ethash *Ethash) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
|
||||||
func (ethash *Ethash) SealHash(header *types.Header) (hash common.Hash) {
|
func (ethash *Ethash) SealHash(header *types.Header) (hash common.Hash) {
|
||||||
hasher := sha3.NewLegacyKeccak256()
|
hasher := sha3.NewLegacyKeccak256()
|
||||||
|
|
||||||
enc := []interface{}{
|
enc := []any{
|
||||||
header.ParentHash,
|
header.ParentHash,
|
||||||
header.UncleHash,
|
header.UncleHash,
|
||||||
header.Coinbase,
|
header.Coinbase,
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ func (b *bridge) SleepBlocks(call jsre.Call) (goja.Value, error) {
|
||||||
type jsonrpcCall struct {
|
type jsonrpcCall struct {
|
||||||
ID int64
|
ID int64
|
||||||
Method string
|
Method string
|
||||||
Params []interface{}
|
Params []any
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send implements the web3 provider "send" method.
|
// Send implements the web3 provider "send" method.
|
||||||
|
|
@ -168,7 +168,7 @@ func (b *bridge) Send(call jsre.Call) (goja.Value, error) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
code := -32603
|
code := -32603
|
||||||
var data interface{}
|
var data any
|
||||||
if err, ok := err.(rpc.Error); ok {
|
if err, ok := err.(rpc.Error); ok {
|
||||||
code = err.ErrorCode()
|
code = err.ErrorCode()
|
||||||
}
|
}
|
||||||
|
|
@ -194,8 +194,8 @@ func (b *bridge) Send(call jsre.Call) (goja.Value, error) {
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setError(resp *goja.Object, code int, msg string, data interface{}) {
|
func setError(resp *goja.Object, code int, msg string, data any) {
|
||||||
err := make(map[string]interface{})
|
err := make(map[string]any)
|
||||||
err["code"] = code
|
err["code"] = code
|
||||||
err["message"] = msg
|
err["message"] = msg
|
||||||
if data != nil {
|
if data != nil {
|
||||||
|
|
|
||||||
|
|
@ -1578,14 +1578,14 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
head = blockChain[len(blockChain)-1]
|
head = blockChain[len(blockChain)-1]
|
||||||
context = []interface{}{
|
context = []any{
|
||||||
"count", stats.processed, "elapsed", common.PrettyDuration(time.Since(start)),
|
"count", stats.processed, "elapsed", common.PrettyDuration(time.Since(start)),
|
||||||
"number", head.Number(), "hash", head.Hash(), "age", common.PrettyAge(time.Unix(int64(head.Time()), 0)),
|
"number", head.Number(), "hash", head.Hash(), "age", common.PrettyAge(time.Unix(int64(head.Time()), 0)),
|
||||||
"size", common.StorageSize(size),
|
"size", common.StorageSize(size),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if stats.ignored > 0 {
|
if stats.ignored > 0 {
|
||||||
context = append(context, []interface{}{"ignored", stats.ignored}...)
|
context = append(context, []any{"ignored", stats.ignored}...)
|
||||||
}
|
}
|
||||||
log.Debug("Imported new block receipts", context...)
|
log.Debug("Imported new block receipts", context...)
|
||||||
return 0, nil
|
return 0, nil
|
||||||
|
|
@ -2693,14 +2693,14 @@ func (bc *BlockChain) SetCanonical(head *types.Block) (common.Hash, error) {
|
||||||
}
|
}
|
||||||
bc.chainHeadFeed.Send(ChainHeadEvent{Header: head.Header()})
|
bc.chainHeadFeed.Send(ChainHeadEvent{Header: head.Header()})
|
||||||
|
|
||||||
context := []interface{}{
|
context := []any{
|
||||||
"number", head.Number(),
|
"number", head.Number(),
|
||||||
"hash", head.Hash(),
|
"hash", head.Hash(),
|
||||||
"root", head.Root(),
|
"root", head.Root(),
|
||||||
"elapsed", time.Since(start),
|
"elapsed", time.Since(start),
|
||||||
}
|
}
|
||||||
if timestamp := time.Unix(int64(head.Time()), 0); time.Since(timestamp) > time.Minute {
|
if timestamp := time.Unix(int64(head.Time()), 0); time.Since(timestamp) > time.Minute {
|
||||||
context = append(context, []interface{}{"age", common.PrettyAge(timestamp)}...)
|
context = append(context, []any{"age", common.PrettyAge(timestamp)}...)
|
||||||
}
|
}
|
||||||
log.Info("Chain head was updated", context...)
|
log.Info("Chain head was updated", context...)
|
||||||
return head.Hash(), nil
|
return head.Hash(), nil
|
||||||
|
|
|
||||||
|
|
@ -56,27 +56,27 @@ func (st *insertStats) report(chain []*types.Block, index int, snapDiffItems, sn
|
||||||
end := chain[index]
|
end := chain[index]
|
||||||
|
|
||||||
// Assemble the log context and send it to the logger
|
// Assemble the log context and send it to the logger
|
||||||
context := []interface{}{
|
context := []any{
|
||||||
"number", end.Number(), "hash", end.Hash(),
|
"number", end.Number(), "hash", end.Hash(),
|
||||||
"blocks", st.processed, "txs", txs, "mgas", float64(st.usedGas) / 1000000,
|
"blocks", st.processed, "txs", txs, "mgas", float64(st.usedGas) / 1000000,
|
||||||
"elapsed", common.PrettyDuration(elapsed), "mgasps", mgasps,
|
"elapsed", common.PrettyDuration(elapsed), "mgasps", mgasps,
|
||||||
}
|
}
|
||||||
if timestamp := time.Unix(int64(end.Time()), 0); time.Since(timestamp) > time.Minute {
|
if timestamp := time.Unix(int64(end.Time()), 0); time.Since(timestamp) > time.Minute {
|
||||||
context = append(context, []interface{}{"age", common.PrettyAge(timestamp)}...)
|
context = append(context, []any{"age", common.PrettyAge(timestamp)}...)
|
||||||
}
|
}
|
||||||
if snapDiffItems != 0 || snapBufItems != 0 { // snapshots enabled
|
if snapDiffItems != 0 || snapBufItems != 0 { // snapshots enabled
|
||||||
context = append(context, []interface{}{"snapdiffs", snapDiffItems}...)
|
context = append(context, []any{"snapdiffs", snapDiffItems}...)
|
||||||
if snapBufItems != 0 { // future snapshot refactor
|
if snapBufItems != 0 { // future snapshot refactor
|
||||||
context = append(context, []interface{}{"snapdirty", snapBufItems}...)
|
context = append(context, []any{"snapdirty", snapBufItems}...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if trieDiffNodes != 0 { // pathdb
|
if trieDiffNodes != 0 { // pathdb
|
||||||
context = append(context, []interface{}{"triediffs", trieDiffNodes}...)
|
context = append(context, []any{"triediffs", trieDiffNodes}...)
|
||||||
}
|
}
|
||||||
context = append(context, []interface{}{"triedirty", triebufNodes}...)
|
context = append(context, []any{"triedirty", triebufNodes}...)
|
||||||
|
|
||||||
if st.ignored > 0 {
|
if st.ignored > 0 {
|
||||||
context = append(context, []interface{}{"ignored", st.ignored}...)
|
context = append(context, []any{"ignored", st.ignored}...)
|
||||||
}
|
}
|
||||||
if setHead {
|
if setHead {
|
||||||
log.Info("Imported new chain segment", context...)
|
log.Info("Imported new chain segment", context...)
|
||||||
|
|
|
||||||
|
|
@ -327,18 +327,18 @@ func (hc *HeaderChain) InsertHeaderChain(chain []*types.Header, start time.Time)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
// Report some public statistics so the user has a clue what's going on
|
// Report some public statistics so the user has a clue what's going on
|
||||||
context := []interface{}{
|
context := []any{
|
||||||
"count", res.imported,
|
"count", res.imported,
|
||||||
"elapsed", common.PrettyDuration(time.Since(start)),
|
"elapsed", common.PrettyDuration(time.Since(start)),
|
||||||
}
|
}
|
||||||
if last := res.lastHeader; last != nil {
|
if last := res.lastHeader; last != nil {
|
||||||
context = append(context, "number", last.Number, "hash", res.lastHash)
|
context = append(context, "number", last.Number, "hash", res.lastHash)
|
||||||
if timestamp := time.Unix(int64(last.Time), 0); time.Since(timestamp) > time.Minute {
|
if timestamp := time.Unix(int64(last.Time), 0); time.Since(timestamp) > time.Minute {
|
||||||
context = append(context, []interface{}{"age", common.PrettyAge(timestamp)}...)
|
context = append(context, []any{"age", common.PrettyAge(timestamp)}...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if res.ignored > 0 {
|
if res.ignored > 0 {
|
||||||
context = append(context, []interface{}{"ignored", res.ignored}...)
|
context = append(context, []any{"ignored", res.ignored}...)
|
||||||
}
|
}
|
||||||
log.Debug("Imported new block headers", context...)
|
log.Debug("Imported new block headers", context...)
|
||||||
return res.status, err
|
return res.status, err
|
||||||
|
|
|
||||||
|
|
@ -287,11 +287,11 @@ func (f *chainFreezer) freeze(db ethdb.KeyValueStore) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log something friendly for the user
|
// Log something friendly for the user
|
||||||
context := []interface{}{
|
context := []any{
|
||||||
"blocks", frozen - first, "elapsed", common.PrettyDuration(time.Since(start)), "number", frozen - 1,
|
"blocks", frozen - first, "elapsed", common.PrettyDuration(time.Since(start)), "number", frozen - 1,
|
||||||
}
|
}
|
||||||
if n := len(ancients); n > 0 {
|
if n := len(ancients); n > 0 {
|
||||||
context = append(context, []interface{}{"hash", ancients[n-1]}...)
|
context = append(context, []any{"hash", ancients[n-1]}...)
|
||||||
}
|
}
|
||||||
log.Debug("Deep froze chain segment", context...)
|
log.Debug("Deep froze chain segment", context...)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ func newFreezerBatch(f *Freezer) *freezerBatch {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append adds an RLP-encoded item of the given kind.
|
// Append adds an RLP-encoded item of the given kind.
|
||||||
func (batch *freezerBatch) Append(kind string, num uint64, item interface{}) error {
|
func (batch *freezerBatch) Append(kind string, num uint64, item any) error {
|
||||||
if table := batch.tables[kind]; table != nil {
|
if table := batch.tables[kind]; table != nil {
|
||||||
return table.Append(num, item)
|
return table.Append(num, item)
|
||||||
}
|
}
|
||||||
|
|
@ -127,7 +127,7 @@ func (batch *freezerTableBatch) reset() {
|
||||||
// Append rlp-encodes and adds data at the end of the freezer table. The item number is a
|
// Append rlp-encodes and adds data at the end of the freezer table. The item number is a
|
||||||
// precautionary parameter to ensure data correctness, but the table will reject already
|
// precautionary parameter to ensure data correctness, but the table will reject already
|
||||||
// existing data.
|
// existing data.
|
||||||
func (batch *freezerTableBatch) Append(item uint64, data interface{}) error {
|
func (batch *freezerTableBatch) Append(item uint64, data any) error {
|
||||||
if item != batch.curItem {
|
if item != batch.curItem {
|
||||||
return fmt.Errorf("%w: have %d want %d", errOutOrderInsertion, item, batch.curItem)
|
return fmt.Errorf("%w: have %d want %d", errOutOrderInsertion, item, batch.curItem)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ func (b *memoryBatch) reset(freezer *MemoryFreezer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append adds an RLP-encoded item.
|
// Append adds an RLP-encoded item.
|
||||||
func (b *memoryBatch) Append(kind string, number uint64, item interface{}) error {
|
func (b *memoryBatch) Append(kind string, number uint64, item any) error {
|
||||||
if b.next[kind] != number {
|
if b.next[kind] != number {
|
||||||
return errOutOrderInsertion
|
return errOutOrderInsertion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,22 +49,22 @@ type generatorStats struct {
|
||||||
// Log creates a contextual log with the given message and the context pulled
|
// Log creates a contextual log with the given message and the context pulled
|
||||||
// from the internally maintained statistics.
|
// from the internally maintained statistics.
|
||||||
func (gs *generatorStats) Log(msg string, root common.Hash, marker []byte) {
|
func (gs *generatorStats) Log(msg string, root common.Hash, marker []byte) {
|
||||||
var ctx []interface{}
|
var ctx []any
|
||||||
if root != (common.Hash{}) {
|
if root != (common.Hash{}) {
|
||||||
ctx = append(ctx, []interface{}{"root", root}...)
|
ctx = append(ctx, []any{"root", root}...)
|
||||||
}
|
}
|
||||||
// Figure out whether we're after or within an account
|
// Figure out whether we're after or within an account
|
||||||
switch len(marker) {
|
switch len(marker) {
|
||||||
case common.HashLength:
|
case common.HashLength:
|
||||||
ctx = append(ctx, []interface{}{"at", common.BytesToHash(marker)}...)
|
ctx = append(ctx, []any{"at", common.BytesToHash(marker)}...)
|
||||||
case 2 * common.HashLength:
|
case 2 * common.HashLength:
|
||||||
ctx = append(ctx, []interface{}{
|
ctx = append(ctx, []any{
|
||||||
"in", common.BytesToHash(marker[:common.HashLength]),
|
"in", common.BytesToHash(marker[:common.HashLength]),
|
||||||
"at", common.BytesToHash(marker[common.HashLength:]),
|
"at", common.BytesToHash(marker[common.HashLength:]),
|
||||||
}...)
|
}...)
|
||||||
}
|
}
|
||||||
// Add the usual measurements
|
// Add the usual measurements
|
||||||
ctx = append(ctx, []interface{}{
|
ctx = append(ctx, []any{
|
||||||
"accounts", gs.accounts,
|
"accounts", gs.accounts,
|
||||||
"slots", gs.slots,
|
"slots", gs.slots,
|
||||||
"storage", gs.storage,
|
"storage", gs.storage,
|
||||||
|
|
@ -77,7 +77,7 @@ func (gs *generatorStats) Log(msg string, root common.Hash, marker []byte) {
|
||||||
left := math.MaxUint64 - binary.BigEndian.Uint64(marker[:8])
|
left := math.MaxUint64 - binary.BigEndian.Uint64(marker[:8])
|
||||||
|
|
||||||
speed := done/uint64(time.Since(gs.start)/time.Millisecond+1) + 1 // +1s to avoid division by zero
|
speed := done/uint64(time.Since(gs.start)/time.Millisecond+1) + 1 // +1s to avoid division by zero
|
||||||
ctx = append(ctx, []interface{}{
|
ctx = append(ctx, []any{
|
||||||
"eta", common.PrettyDuration(time.Duration(left/speed) * time.Millisecond),
|
"eta", common.PrettyDuration(time.Duration(left/speed) * time.Millisecond),
|
||||||
}...)
|
}...)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ func (stat *generateStats) report() {
|
||||||
stat.lock.RLock()
|
stat.lock.RLock()
|
||||||
defer stat.lock.RUnlock()
|
defer stat.lock.RUnlock()
|
||||||
|
|
||||||
ctx := []interface{}{
|
ctx := []any{
|
||||||
"accounts", stat.accounts,
|
"accounts", stat.accounts,
|
||||||
"slots", stat.slots,
|
"slots", stat.slots,
|
||||||
"elapsed", common.PrettyDuration(time.Since(stat.start)),
|
"elapsed", common.PrettyDuration(time.Since(stat.start)),
|
||||||
|
|
@ -185,7 +185,7 @@ func (stat *generateStats) report() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx = append(ctx, []interface{}{
|
ctx = append(ctx, []any{
|
||||||
"eta", common.PrettyDuration(eta),
|
"eta", common.PrettyDuration(eta),
|
||||||
}...)
|
}...)
|
||||||
}
|
}
|
||||||
|
|
@ -198,12 +198,12 @@ func (stat *generateStats) reportDone() {
|
||||||
stat.lock.RLock()
|
stat.lock.RLock()
|
||||||
defer stat.lock.RUnlock()
|
defer stat.lock.RUnlock()
|
||||||
|
|
||||||
var ctx []interface{}
|
var ctx []any
|
||||||
ctx = append(ctx, []interface{}{"accounts", stat.accounts}...)
|
ctx = append(ctx, []any{"accounts", stat.accounts}...)
|
||||||
if stat.slots != 0 {
|
if stat.slots != 0 {
|
||||||
ctx = append(ctx, []interface{}{"slots", stat.slots}...)
|
ctx = append(ctx, []any{"slots", stat.slots}...)
|
||||||
}
|
}
|
||||||
ctx = append(ctx, []interface{}{"elapsed", common.PrettyDuration(time.Since(stat.start))}...)
|
ctx = append(ctx, []any{"elapsed", common.PrettyDuration(time.Since(stat.start))}...)
|
||||||
log.Info("Iterated snapshot", ctx...)
|
log.Info("Iterated snapshot", ctx...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -313,7 +313,7 @@ func (dl *diskLayer) generateRange(ctx *generatorContext, trieId *trie.ID, prefi
|
||||||
last := result.last()
|
last := result.last()
|
||||||
|
|
||||||
// Construct contextual logger
|
// Construct contextual logger
|
||||||
logCtx := []interface{}{"kind", kind, "prefix", hexutil.Encode(prefix)}
|
logCtx := []any{"kind", kind, "prefix", hexutil.Encode(prefix)}
|
||||||
if len(origin) > 0 {
|
if len(origin) > 0 {
|
||||||
logCtx = append(logCtx, "origin", hexutil.Encode(origin))
|
logCtx = append(logCtx, "origin", hexutil.Encode(origin))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -590,7 +590,7 @@ func forEachStorage(s *StateDB, addr common.Address, cb func(key, value common.H
|
||||||
func (test *snapshotTest) checkEqual(state, checkstate *StateDB) error {
|
func (test *snapshotTest) checkEqual(state, checkstate *StateDB) error {
|
||||||
for _, addr := range test.addrs {
|
for _, addr := range test.addrs {
|
||||||
var err error
|
var err error
|
||||||
checkeq := func(op string, a, b interface{}) bool {
|
checkeq := func(op string, a, b any) bool {
|
||||||
if err == nil && !reflect.DeepEqual(a, b) {
|
if err == nil && !reflect.DeepEqual(a, b) {
|
||||||
err = fmt.Errorf("got %s(%s) == %v, want %v", op, addr.Hex(), a, b)
|
err = fmt.Errorf("got %s(%s) == %v, want %v", op, addr.Hex(), a, b)
|
||||||
return false
|
return false
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,11 @@ func (h nonceHeap) Len() int { return len(h) }
|
||||||
func (h nonceHeap) Less(i, j int) bool { return h[i] < h[j] }
|
func (h nonceHeap) Less(i, j int) bool { return h[i] < h[j] }
|
||||||
func (h nonceHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
|
func (h nonceHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
|
||||||
|
|
||||||
func (h *nonceHeap) Push(x interface{}) {
|
func (h *nonceHeap) Push(x any) {
|
||||||
*h = append(*h, x.(uint64))
|
*h = append(*h, x.(uint64))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *nonceHeap) Pop() interface{} {
|
func (h *nonceHeap) Pop() any {
|
||||||
old := *h
|
old := *h
|
||||||
n := len(old)
|
n := len(old)
|
||||||
x := old[n-1]
|
x := old[n-1]
|
||||||
|
|
@ -515,12 +515,12 @@ func (h *priceHeap) cmp(a, b *types.Transaction) int {
|
||||||
return a.GasTipCapCmp(b)
|
return a.GasTipCapCmp(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *priceHeap) Push(x interface{}) {
|
func (h *priceHeap) Push(x any) {
|
||||||
tx := x.(*types.Transaction)
|
tx := x.(*types.Transaction)
|
||||||
h.list = append(h.list, tx)
|
h.list = append(h.list, tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *priceHeap) Pop() interface{} {
|
func (h *priceHeap) Pop() any {
|
||||||
old := h.list
|
old := h.list
|
||||||
n := len(old)
|
n := len(old)
|
||||||
x := old[n-1]
|
x := old[n-1]
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ type Block struct {
|
||||||
// These fields are used by package eth to track
|
// These fields are used by package eth to track
|
||||||
// inter-peer block relay.
|
// inter-peer block relay.
|
||||||
ReceivedAt time.Time
|
ReceivedAt time.Time
|
||||||
ReceivedFrom interface{}
|
ReceivedFrom any
|
||||||
}
|
}
|
||||||
|
|
||||||
// "external" block encoding. used for eth protocol, etc.
|
// "external" block encoding. used for eth protocol, etc.
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ func TestBlockEncoding(t *testing.T) {
|
||||||
t.Fatal("decode error: ", err)
|
t.Fatal("decode error: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
check := func(f string, got, want interface{}) {
|
check := func(f string, got, want any) {
|
||||||
if !reflect.DeepEqual(got, want) {
|
if !reflect.DeepEqual(got, want) {
|
||||||
t.Errorf("%s mismatch: got %v, want %v", f, got, want)
|
t.Errorf("%s mismatch: got %v, want %v", f, got, want)
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +77,7 @@ func TestEIP1559BlockEncoding(t *testing.T) {
|
||||||
t.Fatal("decode error: ", err)
|
t.Fatal("decode error: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
check := func(f string, got, want interface{}) {
|
check := func(f string, got, want any) {
|
||||||
if !reflect.DeepEqual(got, want) {
|
if !reflect.DeepEqual(got, want) {
|
||||||
t.Errorf("%s mismatch: got %v, want %v", f, got, want)
|
t.Errorf("%s mismatch: got %v, want %v", f, got, want)
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +142,7 @@ func TestEIP2718BlockEncoding(t *testing.T) {
|
||||||
t.Fatal("decode error: ", err)
|
t.Fatal("decode error: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
check := func(f string, got, want interface{}) {
|
check := func(f string, got, want any) {
|
||||||
if !reflect.DeepEqual(got, want) {
|
if !reflect.DeepEqual(got, want) {
|
||||||
t.Errorf("%s mismatch: got %v, want %v", f, got, want)
|
t.Errorf("%s mismatch: got %v, want %v", f, got, want)
|
||||||
}
|
}
|
||||||
|
|
@ -204,7 +204,7 @@ func TestEIP4844BlockEncoding(t *testing.T) {
|
||||||
t.Fatal("decode error: ", err)
|
t.Fatal("decode error: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
check := func(f string, got, want interface{}) {
|
check := func(f string, got, want any) {
|
||||||
if !reflect.DeepEqual(got, want) {
|
if !reflect.DeepEqual(got, want) {
|
||||||
t.Errorf("%s mismatch: got %v, want %v", f, got, want)
|
t.Errorf("%s mismatch: got %v, want %v", f, got, want)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,12 @@ import (
|
||||||
|
|
||||||
// hasherPool holds LegacyKeccak256 buffer for rlpHash.
|
// hasherPool holds LegacyKeccak256 buffer for rlpHash.
|
||||||
var hasherPool = sync.Pool{
|
var hasherPool = sync.Pool{
|
||||||
New: func() interface{} { return crypto.NewKeccakState() },
|
New: func() any { return crypto.NewKeccakState() },
|
||||||
}
|
}
|
||||||
|
|
||||||
// encodeBufferPool holds temporary encoder buffers for DeriveSha and TX encoding.
|
// encodeBufferPool holds temporary encoder buffers for DeriveSha and TX encoding.
|
||||||
var encodeBufferPool = sync.Pool{
|
var encodeBufferPool = sync.Pool{
|
||||||
New: func() interface{} { return new(bytes.Buffer) },
|
New: func() any { return new(bytes.Buffer) },
|
||||||
}
|
}
|
||||||
|
|
||||||
// getPooledBuffer retrieves a buffer from the pool and creates a byte slice of the
|
// getPooledBuffer retrieves a buffer from the pool and creates a byte slice of the
|
||||||
|
|
@ -54,7 +54,7 @@ func getPooledBuffer(size uint64) ([]byte, *bytes.Buffer, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// rlpHash encodes x and hashes the encoded bytes.
|
// rlpHash encodes x and hashes the encoded bytes.
|
||||||
func rlpHash(x interface{}) (h common.Hash) {
|
func rlpHash(x any) (h common.Hash) {
|
||||||
sha := hasherPool.Get().(crypto.KeccakState)
|
sha := hasherPool.Get().(crypto.KeccakState)
|
||||||
defer hasherPool.Put(sha)
|
defer hasherPool.Put(sha)
|
||||||
sha.Reset()
|
sha.Reset()
|
||||||
|
|
@ -65,7 +65,7 @@ func rlpHash(x interface{}) (h common.Hash) {
|
||||||
|
|
||||||
// prefixedRlpHash writes the prefix into the hasher before rlp-encoding x.
|
// prefixedRlpHash writes the prefix into the hasher before rlp-encoding x.
|
||||||
// It's used for typed transactions.
|
// It's used for typed transactions.
|
||||||
func prefixedRlpHash(prefix byte, x interface{}) (h common.Hash) {
|
func prefixedRlpHash(prefix byte, x any) (h common.Hash) {
|
||||||
sha := hasherPool.Get().(crypto.KeccakState)
|
sha := hasherPool.Get().(crypto.KeccakState)
|
||||||
defer hasherPool.Put(sha)
|
defer hasherPool.Put(sha)
|
||||||
sha.Reset()
|
sha.Reset()
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import (
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
)
|
)
|
||||||
|
|
||||||
func decodeEncode(input []byte, val interface{}) error {
|
func decodeEncode(input []byte, val any) error {
|
||||||
if err := rlp.DecodeBytes(input, val); err != nil {
|
if err := rlp.DecodeBytes(input, val); err != nil {
|
||||||
// not valid rlp, nothing to do
|
// not valid rlp, nothing to do
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -54,8 +54,8 @@ func fuzzRlp(t *testing.T, input []byte) {
|
||||||
if elems, _, err := rlp.SplitList(input); err == nil {
|
if elems, _, err := rlp.SplitList(input); err == nil {
|
||||||
rlp.CountValues(elems)
|
rlp.CountValues(elems)
|
||||||
}
|
}
|
||||||
rlp.NewStream(bytes.NewReader(input), 0).Decode(new(interface{}))
|
rlp.NewStream(bytes.NewReader(input), 0).Decode(new(any))
|
||||||
if err := decodeEncode(input, new(interface{})); err != nil {
|
if err := decodeEncode(input, new(any)); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -73,7 +73,7 @@ func fuzzRlp(t *testing.T, input []byte) {
|
||||||
Bool bool
|
Bool bool
|
||||||
Raw rlp.RawValue
|
Raw rlp.RawValue
|
||||||
Slice []*Types
|
Slice []*Types
|
||||||
Iface []interface{}
|
Iface []any
|
||||||
}
|
}
|
||||||
var v Types
|
var v Types
|
||||||
if err := decodeEncode(input, &v); err != nil {
|
if err := decodeEncode(input, &v); err != nil {
|
||||||
|
|
@ -89,7 +89,7 @@ func fuzzRlp(t *testing.T, input []byte) {
|
||||||
Raw rlp.RawValue
|
Raw rlp.RawValue
|
||||||
Slice []*AllTypes
|
Slice []*AllTypes
|
||||||
Array [3]*AllTypes
|
Array [3]*AllTypes
|
||||||
Iface []interface{}
|
Iface []any
|
||||||
}
|
}
|
||||||
var v AllTypes
|
var v AllTypes
|
||||||
if err := decodeEncode(input, &v); err != nil {
|
if err := decodeEncode(input, &v); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -491,7 +491,7 @@ func TestTransactionSizes(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestYParityJSONUnmarshalling(t *testing.T) {
|
func TestYParityJSONUnmarshalling(t *testing.T) {
|
||||||
baseJson := map[string]interface{}{
|
baseJson := map[string]any{
|
||||||
// type is filled in by the test
|
// type is filled in by the test
|
||||||
"chainId": "0x7",
|
"chainId": "0x7",
|
||||||
"nonce": "0x0",
|
"nonce": "0x0",
|
||||||
|
|
@ -503,7 +503,7 @@ func TestYParityJSONUnmarshalling(t *testing.T) {
|
||||||
"maxFeePerBlobGas": "0x3b9aca00",
|
"maxFeePerBlobGas": "0x3b9aca00",
|
||||||
"value": "0x0",
|
"value": "0x0",
|
||||||
"input": "0x",
|
"input": "0x",
|
||||||
"accessList": []interface{}{},
|
"accessList": []any{},
|
||||||
"blobVersionedHashes": []string{
|
"blobVersionedHashes": []string{
|
||||||
"0x010657f37554c781402a22917dee2f75def7ab966d7b770905398eba3c444014",
|
"0x010657f37554c781402a22917dee2f75def7ab966d7b770905398eba3c444014",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ func benchRLP(b *testing.B, encode bool) {
|
||||||
signer := NewLondonSigner(big.NewInt(1337))
|
signer := NewLondonSigner(big.NewInt(1337))
|
||||||
for _, tc := range []struct {
|
for _, tc := range []struct {
|
||||||
name string
|
name string
|
||||||
obj interface{}
|
obj any
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"legacy-header",
|
"legacy-header",
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import (
|
||||||
|
|
||||||
func TestPush(t *testing.T) {
|
func TestPush(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
input interface{}
|
input any
|
||||||
expected string
|
expected string
|
||||||
}{
|
}{
|
||||||
// native ints
|
// native ints
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var stackPool = sync.Pool{
|
var stackPool = sync.Pool{
|
||||||
New: func() interface{} {
|
New: func() any {
|
||||||
return &Stack{data: make([]uint256.Int, 0, 16)}
|
return &Stack{data: make([]uint256.Int, 0, 16)}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ func HashData(kh KeccakState, data []byte) (h common.Hash) {
|
||||||
|
|
||||||
// CreateAddress creates an ethereum address given the bytes and the nonce
|
// CreateAddress creates an ethereum address given the bytes and the nonce
|
||||||
func CreateAddress(b common.Address, nonce uint64) common.Address {
|
func CreateAddress(b common.Address, nonce uint64) common.Address {
|
||||||
data, _ := rlp.EncodeToBytes([]interface{}{b, nonce})
|
data, _ := rlp.EncodeToBytes([]any{b, nonce})
|
||||||
return common.BytesToAddress(Keccak256(data)[12:])
|
return common.BytesToAddress(Keccak256(data)[12:])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,9 +98,9 @@ func (api *DebugAPI) Preimage(ctx context.Context, hash common.Hash) (hexutil.By
|
||||||
|
|
||||||
// BadBlockArgs represents the entries in the list returned when bad blocks are queried.
|
// BadBlockArgs represents the entries in the list returned when bad blocks are queried.
|
||||||
type BadBlockArgs struct {
|
type BadBlockArgs struct {
|
||||||
Hash common.Hash `json:"hash"`
|
Hash common.Hash `json:"hash"`
|
||||||
Block map[string]interface{} `json:"block"`
|
Block map[string]any `json:"block"`
|
||||||
RLP string `json:"rlp"`
|
RLP string `json:"rlp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBadBlocks returns a list of the last 'bad blocks' that the client has seen on the network
|
// GetBadBlocks returns a list of the last 'bad blocks' that the client has seen on the network
|
||||||
|
|
@ -113,7 +113,7 @@ func (api *DebugAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs, error)
|
||||||
for _, block := range blocks {
|
for _, block := range blocks {
|
||||||
var (
|
var (
|
||||||
blockRlp string
|
blockRlp string
|
||||||
blockJSON map[string]interface{}
|
blockJSON map[string]any
|
||||||
)
|
)
|
||||||
if rlpBytes, err := rlp.EncodeToBytes(block); err != nil {
|
if rlpBytes, err := rlp.EncodeToBytes(block); err != nil {
|
||||||
blockRlp = err.Error() // Hacky, but hey, it works
|
blockRlp = err.Error() // Hacky, but hey, it works
|
||||||
|
|
@ -447,7 +447,7 @@ func (api *DebugAPI) GetTrieFlushInterval() (string, error) {
|
||||||
|
|
||||||
// StateSize returns the current state size statistics from the state size tracker.
|
// StateSize returns the current state size statistics from the state size tracker.
|
||||||
// Returns an error if the state size tracker is not initialized or if stats are not ready.
|
// Returns an error if the state size tracker is not initialized or if stats are not ready.
|
||||||
func (api *DebugAPI) StateSize(blockHashOrNumber *rpc.BlockNumberOrHash) (interface{}, error) {
|
func (api *DebugAPI) StateSize(blockHashOrNumber *rpc.BlockNumberOrHash) (any, error) {
|
||||||
sizer := api.eth.blockchain.StateSizer()
|
sizer := api.eth.blockchain.StateSizer()
|
||||||
if sizer == nil {
|
if sizer == nil {
|
||||||
return nil, errors.New("state size tracker is not enabled")
|
return nil, errors.New("state size tracker is not enabled")
|
||||||
|
|
@ -477,7 +477,7 @@ func (api *DebugAPI) StateSize(blockHashOrNumber *rpc.BlockNumberOrHash) (interf
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("state size of %s is not available", s)
|
return nil, fmt.Errorf("state size of %s is not available", s)
|
||||||
}
|
}
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"stateRoot": stats.StateRoot,
|
"stateRoot": stats.StateRoot,
|
||||||
"blockNumber": hexutil.Uint64(stats.BlockNumber),
|
"blockNumber": hexutil.Uint64(stats.BlockNumber),
|
||||||
"accounts": hexutil.Uint64(stats.Accounts),
|
"accounts": hexutil.Uint64(stats.Accounts),
|
||||||
|
|
|
||||||
|
|
@ -370,7 +370,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
func makeExtraData(extra []byte) []byte {
|
func makeExtraData(extra []byte) []byte {
|
||||||
if len(extra) == 0 {
|
if len(extra) == 0 {
|
||||||
// create default extradata
|
// create default extradata
|
||||||
extra, _ = rlp.EncodeToBytes([]interface{}{
|
extra, _ = rlp.EncodeToBytes([]any{
|
||||||
uint(gethversion.Major<<16 | gethversion.Minor<<8 | gethversion.Patch),
|
uint(gethversion.Major<<16 | gethversion.Minor<<8 | gethversion.Patch),
|
||||||
"geth",
|
"geth",
|
||||||
runtime.Version(),
|
runtime.Version(),
|
||||||
|
|
|
||||||
|
|
@ -250,12 +250,12 @@ func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payl
|
||||||
finalized := api.remoteBlocks.get(update.FinalizedBlockHash)
|
finalized := api.remoteBlocks.get(update.FinalizedBlockHash)
|
||||||
|
|
||||||
// Header advertised via a past newPayload request. Start syncing to it.
|
// Header advertised via a past newPayload request. Start syncing to it.
|
||||||
context := []interface{}{"number", header.Number, "hash", header.Hash()}
|
context := []any{"number", header.Number, "hash", header.Hash()}
|
||||||
if update.FinalizedBlockHash != (common.Hash{}) {
|
if update.FinalizedBlockHash != (common.Hash{}) {
|
||||||
if finalized == nil {
|
if finalized == nil {
|
||||||
context = append(context, []interface{}{"finalized", "unknown"}...)
|
context = append(context, []any{"finalized", "unknown"}...)
|
||||||
} else {
|
} else {
|
||||||
context = append(context, []interface{}{"finalized", finalized.Number}...)
|
context = append(context, []any{"finalized", finalized.Number}...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Info("Forkchoice requested sync to new head", context...)
|
log.Info("Forkchoice requested sync to new head", context...)
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ type DownloaderAPI struct {
|
||||||
d *Downloader
|
d *Downloader
|
||||||
chain *core.BlockChain
|
chain *core.BlockChain
|
||||||
mux *event.TypeMux
|
mux *event.TypeMux
|
||||||
installSyncSubscription chan chan interface{}
|
installSyncSubscription chan chan any
|
||||||
uninstallSyncSubscription chan *uninstallSyncSubscriptionRequest
|
uninstallSyncSubscription chan *uninstallSyncSubscriptionRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ func NewDownloaderAPI(d *Downloader, chain *core.BlockChain, m *event.TypeMux) *
|
||||||
d: d,
|
d: d,
|
||||||
chain: chain,
|
chain: chain,
|
||||||
mux: m,
|
mux: m,
|
||||||
installSyncSubscription: make(chan chan interface{}),
|
installSyncSubscription: make(chan chan any),
|
||||||
uninstallSyncSubscription: make(chan *uninstallSyncSubscriptionRequest),
|
uninstallSyncSubscription: make(chan *uninstallSyncSubscriptionRequest),
|
||||||
}
|
}
|
||||||
go api.eventLoop()
|
go api.eventLoop()
|
||||||
|
|
@ -67,7 +67,7 @@ func NewDownloaderAPI(d *Downloader, chain *core.BlockChain, m *event.TypeMux) *
|
||||||
func (api *DownloaderAPI) eventLoop() {
|
func (api *DownloaderAPI) eventLoop() {
|
||||||
var (
|
var (
|
||||||
sub = api.mux.Subscribe(StartEvent{})
|
sub = api.mux.Subscribe(StartEvent{})
|
||||||
syncSubscriptions = make(map[chan interface{}]struct{})
|
syncSubscriptions = make(map[chan any]struct{})
|
||||||
checkInterval = time.Second * 60
|
checkInterval = time.Second * 60
|
||||||
checkTimer = time.NewTimer(checkInterval)
|
checkTimer = time.NewTimer(checkInterval)
|
||||||
|
|
||||||
|
|
@ -143,7 +143,7 @@ func (api *DownloaderAPI) Syncing(ctx context.Context) (*rpc.Subscription, error
|
||||||
rpcSub := notifier.CreateSubscription()
|
rpcSub := notifier.CreateSubscription()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
statuses := make(chan interface{})
|
statuses := make(chan any)
|
||||||
sub := api.SubscribeSyncStatus(statuses)
|
sub := api.SubscribeSyncStatus(statuses)
|
||||||
defer sub.Unsubscribe()
|
defer sub.Unsubscribe()
|
||||||
|
|
||||||
|
|
@ -168,15 +168,15 @@ type SyncingResult struct {
|
||||||
|
|
||||||
// uninstallSyncSubscriptionRequest uninstalls a syncing subscription in the API event loop.
|
// uninstallSyncSubscriptionRequest uninstalls a syncing subscription in the API event loop.
|
||||||
type uninstallSyncSubscriptionRequest struct {
|
type uninstallSyncSubscriptionRequest struct {
|
||||||
c chan interface{}
|
c chan any
|
||||||
uninstalled chan interface{}
|
uninstalled chan any
|
||||||
}
|
}
|
||||||
|
|
||||||
// SyncStatusSubscription represents a syncing subscription.
|
// SyncStatusSubscription represents a syncing subscription.
|
||||||
type SyncStatusSubscription struct {
|
type SyncStatusSubscription struct {
|
||||||
api *DownloaderAPI // register subscription in event loop of this api instance
|
api *DownloaderAPI // register subscription in event loop of this api instance
|
||||||
c chan interface{} // channel where events are broadcasted to
|
c chan any // channel where events are broadcasted to
|
||||||
unsubOnce sync.Once // make sure unsubscribe logic is executed once
|
unsubOnce sync.Once // make sure unsubscribe logic is executed once
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unsubscribe uninstalls the subscription from the DownloadAPI event loop.
|
// Unsubscribe uninstalls the subscription from the DownloadAPI event loop.
|
||||||
|
|
@ -184,7 +184,7 @@ type SyncStatusSubscription struct {
|
||||||
// after this method returns.
|
// after this method returns.
|
||||||
func (s *SyncStatusSubscription) Unsubscribe() {
|
func (s *SyncStatusSubscription) Unsubscribe() {
|
||||||
s.unsubOnce.Do(func() {
|
s.unsubOnce.Do(func() {
|
||||||
req := uninstallSyncSubscriptionRequest{s.c, make(chan interface{})}
|
req := uninstallSyncSubscriptionRequest{s.c, make(chan any)}
|
||||||
s.api.uninstallSyncSubscription <- &req
|
s.api.uninstallSyncSubscription <- &req
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
@ -201,7 +201,7 @@ func (s *SyncStatusSubscription) Unsubscribe() {
|
||||||
|
|
||||||
// SubscribeSyncStatus creates a subscription that will broadcast new synchronisation updates.
|
// SubscribeSyncStatus creates a subscription that will broadcast new synchronisation updates.
|
||||||
// The given channel must receive interface values, the result can either be a SyncingResult or false.
|
// The given channel must receive interface values, the result can either be a SyncingResult or false.
|
||||||
func (api *DownloaderAPI) SubscribeSyncStatus(status chan interface{}) *SyncStatusSubscription {
|
func (api *DownloaderAPI) SubscribeSyncStatus(status chan any) *SyncStatusSubscription {
|
||||||
api.installSyncSubscription <- status
|
api.installSyncSubscription <- status
|
||||||
return &SyncStatusSubscription{api: api, c: status}
|
return &SyncStatusSubscription{api: api, c: status}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -355,15 +355,15 @@ func (q *queue) Results(block bool) []*fetchResult {
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *queue) Stats() []interface{} {
|
func (q *queue) Stats() []any {
|
||||||
q.lock.RLock()
|
q.lock.RLock()
|
||||||
defer q.lock.RUnlock()
|
defer q.lock.RUnlock()
|
||||||
|
|
||||||
return q.stats()
|
return q.stats()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *queue) stats() []interface{} {
|
func (q *queue) stats() []any {
|
||||||
return []interface{}{
|
return []any{
|
||||||
"receiptTasks", q.receiptTaskQueue.Size(),
|
"receiptTasks", q.receiptTaskQueue.Size(),
|
||||||
"blockTasks", q.blockTaskQueue.Size(),
|
"blockTasks", q.blockTaskQueue.Size(),
|
||||||
"itemSize", q.resultSize,
|
"itemSize", q.resultSize,
|
||||||
|
|
@ -536,7 +536,7 @@ func (q *queue) ExpireReceipts(peer string) int {
|
||||||
// Note, this method expects the queue lock to be already held. The reason the
|
// Note, this method expects the queue lock to be already held. The reason the
|
||||||
// lock is not obtained in here is that the parameters already need to access
|
// lock is not obtained in here is that the parameters already need to access
|
||||||
// the queue, so they already need a lock anyway.
|
// the queue, so they already need a lock anyway.
|
||||||
func (q *queue) expire(peer string, pendPool map[string]*fetchRequest, taskQueue interface{}) int {
|
func (q *queue) expire(peer string, pendPool map[string]*fetchRequest, taskQueue any) int {
|
||||||
// Retrieve the request being expired and log an error if it's non-existent,
|
// Retrieve the request being expired and log an error if it's non-existent,
|
||||||
// as there's no order of events that should lead to such expirations.
|
// as there's no order of events that should lead to such expirations.
|
||||||
req := pendPool[peer]
|
req := pendPool[peer]
|
||||||
|
|
|
||||||
|
|
@ -1125,7 +1125,7 @@ func (s *skeleton) processResponse(res *headerResponse) (linked bool, merged boo
|
||||||
// the syncer's internal state is corrupted. Do try to fix it, but
|
// the syncer's internal state is corrupted. Do try to fix it, but
|
||||||
// be very vocal about the fault.
|
// be very vocal about the fault.
|
||||||
default:
|
default:
|
||||||
var context []interface{}
|
var context []any
|
||||||
|
|
||||||
for i := range s.progress.Subchains[1:] {
|
for i := range s.progress.Subchains[1:] {
|
||||||
context = append(context, fmt.Sprintf("stale_head_%d", i+1))
|
context = append(context, fmt.Sprintf("stale_head_%d", i+1))
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// MarshalTOML marshals as TOML.
|
// MarshalTOML marshals as TOML.
|
||||||
func (c Config) MarshalTOML() (interface{}, error) {
|
func (c Config) MarshalTOML() (any, error) {
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Genesis *core.Genesis `toml:",omitempty"`
|
Genesis *core.Genesis `toml:",omitempty"`
|
||||||
NetworkId uint64
|
NetworkId uint64
|
||||||
|
|
@ -119,7 +119,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalTOML unmarshals from TOML.
|
// UnmarshalTOML unmarshals from TOML.
|
||||||
func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
func (c *Config) UnmarshalTOML(unmarshal func(any) error) error {
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Genesis *core.Genesis `toml:",omitempty"`
|
Genesis *core.Genesis `toml:",omitempty"`
|
||||||
NetworkId *uint64
|
NetworkId *uint64
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ type isUnderpriced int
|
||||||
// runner.
|
// runner.
|
||||||
type txFetcherTest struct {
|
type txFetcherTest struct {
|
||||||
init func() *TxFetcher
|
init func() *TxFetcher
|
||||||
steps []interface{}
|
steps []any
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that transaction announcements with associated metadata are added to a
|
// Tests that transaction announcements with associated metadata are added to a
|
||||||
|
|
@ -99,7 +99,7 @@ func TestTransactionFetcherWaiting(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Initial announcement to get something into the waitlist
|
// Initial announcement to get something into the waitlist
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{types.LegacyTxType, types.LegacyTxType}, sizes: []uint32{111, 222}},
|
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{types.LegacyTxType, types.LegacyTxType}, sizes: []uint32{111, 222}},
|
||||||
isWaiting(map[string][]announce{
|
isWaiting(map[string][]announce{
|
||||||
|
|
@ -301,7 +301,7 @@ func TestTransactionFetcherSkipWaiting(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Push an initial announcement through to the scheduled stage
|
// Push an initial announcement through to the scheduled stage
|
||||||
doTxNotify{
|
doTxNotify{
|
||||||
peer: "A",
|
peer: "A",
|
||||||
|
|
@ -391,7 +391,7 @@ func TestTransactionFetcherSingletonRequesting(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Push an initial announcement through to the scheduled stage
|
// Push an initial announcement through to the scheduled stage
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{types.LegacyTxType, types.LegacyTxType}, sizes: []uint32{111, 222}},
|
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{types.LegacyTxType, types.LegacyTxType}, sizes: []uint32{111, 222}},
|
||||||
isWaiting(map[string][]announce{
|
isWaiting(map[string][]announce{
|
||||||
|
|
@ -499,7 +499,7 @@ func TestTransactionFetcherFailedRescheduling(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Push an initial announcement through to the scheduled stage
|
// Push an initial announcement through to the scheduled stage
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{types.LegacyTxType, types.LegacyTxType}, sizes: []uint32{111, 222}},
|
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{types.LegacyTxType, types.LegacyTxType}, sizes: []uint32{111, 222}},
|
||||||
isWaiting(map[string][]announce{
|
isWaiting(map[string][]announce{
|
||||||
|
|
@ -582,7 +582,7 @@ func TestTransactionFetcherCleanup(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Push an initial announcement through to the scheduled stage
|
// Push an initial announcement through to the scheduled stage
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
||||||
isWaiting(map[string][]announce{
|
isWaiting(map[string][]announce{
|
||||||
|
|
@ -626,7 +626,7 @@ func TestTransactionFetcherCleanupEmpty(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Push an initial announcement through to the scheduled stage
|
// Push an initial announcement through to the scheduled stage
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
||||||
isWaiting(map[string][]announce{
|
isWaiting(map[string][]announce{
|
||||||
|
|
@ -669,7 +669,7 @@ func TestTransactionFetcherMissingRescheduling(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Push an initial announcement through to the scheduled stage
|
// Push an initial announcement through to the scheduled stage
|
||||||
doTxNotify{peer: "A",
|
doTxNotify{peer: "A",
|
||||||
hashes: []common.Hash{testTxsHashes[0], testTxsHashes[1], testTxsHashes[2]},
|
hashes: []common.Hash{testTxsHashes[0], testTxsHashes[1], testTxsHashes[2]},
|
||||||
|
|
@ -730,7 +730,7 @@ func TestTransactionFetcherMissingCleanup(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Push an initial announcement through to the scheduled stage
|
// Push an initial announcement through to the scheduled stage
|
||||||
doTxNotify{peer: "A",
|
doTxNotify{peer: "A",
|
||||||
hashes: []common.Hash{testTxsHashes[0], testTxsHashes[1]},
|
hashes: []common.Hash{testTxsHashes[0], testTxsHashes[1]},
|
||||||
|
|
@ -779,7 +779,7 @@ func TestTransactionFetcherBroadcasts(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Set up three transactions to be in different stats, waiting, queued and fetching
|
// Set up three transactions to be in different stats, waiting, queued and fetching
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
||||||
doWait{time: txArriveTimeout, step: true},
|
doWait{time: txArriveTimeout, step: true},
|
||||||
|
|
@ -833,7 +833,7 @@ func TestTransactionFetcherWaitTimerResets(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}}, types: []byte{types.LegacyTxType}, sizes: []uint32{111}},
|
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}}, types: []byte{types.LegacyTxType}, sizes: []uint32{111}},
|
||||||
isWaiting(map[string][]announce{
|
isWaiting(map[string][]announce{
|
||||||
"A": {
|
"A": {
|
||||||
|
|
@ -905,7 +905,7 @@ func TestTransactionFetcherTimeoutRescheduling(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Push an initial announcement through to the scheduled stage
|
// Push an initial announcement through to the scheduled stage
|
||||||
doTxNotify{
|
doTxNotify{
|
||||||
peer: "A",
|
peer: "A",
|
||||||
|
|
@ -981,7 +981,7 @@ func TestTransactionFetcherTimeoutTimerResets(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}}, types: []byte{types.LegacyTxType}, sizes: []uint32{111}},
|
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}}, types: []byte{types.LegacyTxType}, sizes: []uint32{111}},
|
||||||
doWait{time: txArriveTimeout, step: true},
|
doWait{time: txArriveTimeout, step: true},
|
||||||
doTxNotify{peer: "B", hashes: []common.Hash{{0x02}}, types: []byte{types.LegacyTxType}, sizes: []uint32{222}},
|
doTxNotify{peer: "B", hashes: []common.Hash{{0x02}}, types: []byte{types.LegacyTxType}, sizes: []uint32{222}},
|
||||||
|
|
@ -1059,7 +1059,7 @@ func TestTransactionFetcherRateLimiting(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Announce all the transactions, wait a bit and ensure only a small
|
// Announce all the transactions, wait a bit and ensure only a small
|
||||||
// percentage gets requested
|
// percentage gets requested
|
||||||
doTxNotify{peer: "A", hashes: hashes, types: ts, sizes: sizes},
|
doTxNotify{peer: "A", hashes: hashes, types: ts, sizes: sizes},
|
||||||
|
|
@ -1089,7 +1089,7 @@ func TestTransactionFetcherBandwidthLimiting(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Announce mid size transactions from A to verify that multiple
|
// Announce mid size transactions from A to verify that multiple
|
||||||
// ones can be piled into a single request.
|
// ones can be piled into a single request.
|
||||||
doTxNotify{peer: "A",
|
doTxNotify{peer: "A",
|
||||||
|
|
@ -1206,7 +1206,7 @@ func TestTransactionFetcherDoSProtection(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Announce half of the transaction and wait for them to be scheduled
|
// Announce half of the transaction and wait for them to be scheduled
|
||||||
doTxNotify{peer: "A", hashes: hashesA[:maxTxAnnounces/2], types: typesA[:maxTxAnnounces/2], sizes: sizesA[:maxTxAnnounces/2]},
|
doTxNotify{peer: "A", hashes: hashesA[:maxTxAnnounces/2], types: typesA[:maxTxAnnounces/2], sizes: sizesA[:maxTxAnnounces/2]},
|
||||||
doTxNotify{peer: "B", hashes: hashesB[:maxTxAnnounces/2-1], types: typesB[:maxTxAnnounces/2-1], sizes: sizesB[:maxTxAnnounces/2-1]},
|
doTxNotify{peer: "B", hashes: hashesB[:maxTxAnnounces/2-1], types: typesB[:maxTxAnnounces/2-1], sizes: sizesB[:maxTxAnnounces/2-1]},
|
||||||
|
|
@ -1285,7 +1285,7 @@ func TestTransactionFetcherUnderpricedDedup(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Deliver a transaction through the fetcher, but reject as underpriced
|
// Deliver a transaction through the fetcher, but reject as underpriced
|
||||||
doTxNotify{peer: "A",
|
doTxNotify{peer: "A",
|
||||||
hashes: []common.Hash{testTxsHashes[0], testTxsHashes[1]},
|
hashes: []common.Hash{testTxsHashes[0], testTxsHashes[1]},
|
||||||
|
|
@ -1340,7 +1340,7 @@ func TestTransactionFetcherUnderpricedDoSProtection(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// Generate a set of steps to announce and deliver the entire set of transactions
|
// Generate a set of steps to announce and deliver the entire set of transactions
|
||||||
var steps []interface{}
|
var steps []any
|
||||||
for i := 0; i < maxTxUnderpricedSetSize/maxTxRetrievals; i++ {
|
for i := 0; i < maxTxUnderpricedSetSize/maxTxRetrievals; i++ {
|
||||||
steps = append(steps, doTxNotify{
|
steps = append(steps, doTxNotify{
|
||||||
peer: "A",
|
peer: "A",
|
||||||
|
|
@ -1380,7 +1380,7 @@ func TestTransactionFetcherUnderpricedDoSProtection(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: append(steps, []interface{}{
|
steps: append(steps, []any{
|
||||||
// The preparation of the test has already been done in `steps`, add the last check
|
// The preparation of the test has already been done in `steps`, add the last check
|
||||||
doTxNotify{
|
doTxNotify{
|
||||||
peer: "A",
|
peer: "A",
|
||||||
|
|
@ -1408,7 +1408,7 @@ func TestTransactionFetcherOutOfBoundDeliveries(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Deliver something out of the blue
|
// Deliver something out of the blue
|
||||||
isWaiting(nil),
|
isWaiting(nil),
|
||||||
isScheduled{nil, nil, nil},
|
isScheduled{nil, nil, nil},
|
||||||
|
|
@ -1467,7 +1467,7 @@ func TestTransactionFetcherDrop(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Set up a few hashes into various stages
|
// Set up a few hashes into various stages
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}}, types: []byte{types.LegacyTxType}, sizes: []uint32{111}},
|
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}}, types: []byte{types.LegacyTxType}, sizes: []uint32{111}},
|
||||||
doWait{time: txArriveTimeout, step: true},
|
doWait{time: txArriveTimeout, step: true},
|
||||||
|
|
@ -1541,7 +1541,7 @@ func TestTransactionFetcherDropRescheduling(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Set up a few hashes into various stages
|
// Set up a few hashes into various stages
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}}, types: []byte{types.LegacyTxType}, sizes: []uint32{111}},
|
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}}, types: []byte{types.LegacyTxType}, sizes: []uint32{111}},
|
||||||
doWait{time: txArriveTimeout, step: true},
|
doWait{time: txArriveTimeout, step: true},
|
||||||
|
|
@ -1587,7 +1587,7 @@ func TestInvalidAnnounceMetadata(t *testing.T) {
|
||||||
func(peer string) { drop <- peer },
|
func(peer string) { drop <- peer },
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Initial announcement to get something into the waitlist
|
// Initial announcement to get something into the waitlist
|
||||||
doTxNotify{
|
doTxNotify{
|
||||||
peer: "A",
|
peer: "A",
|
||||||
|
|
@ -1670,7 +1670,7 @@ func TestTransactionFetcherFuzzCrash01(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Get a transaction into fetching mode and make it dangling with a broadcast
|
// Get a transaction into fetching mode and make it dangling with a broadcast
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
||||||
doWait{time: txArriveTimeout, step: true},
|
doWait{time: txArriveTimeout, step: true},
|
||||||
|
|
@ -1698,7 +1698,7 @@ func TestTransactionFetcherFuzzCrash02(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Get a transaction into fetching mode and make it dangling with a broadcast
|
// Get a transaction into fetching mode and make it dangling with a broadcast
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
||||||
doWait{time: txArriveTimeout, step: true},
|
doWait{time: txArriveTimeout, step: true},
|
||||||
|
|
@ -1728,7 +1728,7 @@ func TestTransactionFetcherFuzzCrash03(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Get a transaction into fetching mode and make it dangling with a broadcast
|
// Get a transaction into fetching mode and make it dangling with a broadcast
|
||||||
doTxNotify{
|
doTxNotify{
|
||||||
peer: "A",
|
peer: "A",
|
||||||
|
|
@ -1770,7 +1770,7 @@ func TestTransactionFetcherFuzzCrash04(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Get a transaction into fetching mode and make it dangling with a broadcast
|
// Get a transaction into fetching mode and make it dangling with a broadcast
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
||||||
doWait{time: txArriveTimeout, step: true},
|
doWait{time: txArriveTimeout, step: true},
|
||||||
|
|
@ -1800,7 +1800,7 @@ func TestBlobTransactionAnnounce(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
// Initial announcement to get something into the waitlist
|
// Initial announcement to get something into the waitlist
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{types.LegacyTxType, types.LegacyTxType}, sizes: []uint32{111, 222}},
|
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{types.LegacyTxType, types.LegacyTxType}, sizes: []uint32{111, 222}},
|
||||||
isWaiting(map[string][]announce{
|
isWaiting(map[string][]announce{
|
||||||
|
|
@ -1870,7 +1870,7 @@ func TestTransactionFetcherDropAlternates(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
doTxNotify{peer: "A", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
||||||
doWait{time: txArriveTimeout, step: true},
|
doWait{time: txArriveTimeout, step: true},
|
||||||
doTxNotify{peer: "B", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
doTxNotify{peer: "B", hashes: []common.Hash{testTxsHashes[0]}, types: []byte{testTxs[0].Type()}, sizes: []uint32{uint32(testTxs[0].Size())}},
|
||||||
|
|
@ -1926,7 +1926,7 @@ func TestTransactionFetcherWrongMetadata(t *testing.T) {
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
steps: []interface{}{
|
steps: []any{
|
||||||
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{0xff, types.LegacyTxType}, sizes: []uint32{111, 222}},
|
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}, types: []byte{0xff, types.LegacyTxType}, sizes: []uint32{111, 222}},
|
||||||
isWaiting(map[string][]announce{
|
isWaiting(map[string][]announce{
|
||||||
"A": {
|
"A": {
|
||||||
|
|
|
||||||
|
|
@ -365,7 +365,7 @@ func (api *FilterAPI) TransactionReceipts(ctx context.Context, filter *Transacti
|
||||||
case receiptsWithTxs := <-matchedReceipts:
|
case receiptsWithTxs := <-matchedReceipts:
|
||||||
if len(receiptsWithTxs) > 0 {
|
if len(receiptsWithTxs) > 0 {
|
||||||
// Convert to the same format as eth_getTransactionReceipt
|
// Convert to the same format as eth_getTransactionReceipt
|
||||||
marshaledReceipts := make([]map[string]interface{}, len(receiptsWithTxs))
|
marshaledReceipts := make([]map[string]any, len(receiptsWithTxs))
|
||||||
for i, receiptWithTx := range receiptsWithTxs {
|
for i, receiptWithTx := range receiptsWithTxs {
|
||||||
marshaledReceipts[i] = ethapi.MarshalReceipt(
|
marshaledReceipts[i] = ethapi.MarshalReceipt(
|
||||||
receiptWithTx.Receipt,
|
receiptWithTx.Receipt,
|
||||||
|
|
@ -546,7 +546,7 @@ func (api *FilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*types.Lo
|
||||||
//
|
//
|
||||||
// For pending transaction and block filters the result is []common.Hash.
|
// For pending transaction and block filters the result is []common.Hash.
|
||||||
// (pending)Log filters return []Log.
|
// (pending)Log filters return []Log.
|
||||||
func (api *FilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error) {
|
func (api *FilterAPI) GetFilterChanges(id rpc.ID) (any, error) {
|
||||||
api.filtersMu.Lock()
|
api.filtersMu.Lock()
|
||||||
defer api.filtersMu.Unlock()
|
defer api.filtersMu.Unlock()
|
||||||
|
|
||||||
|
|
@ -589,7 +589,7 @@ func (api *FilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return []interface{}{}, errFilterNotFound
|
return []any{}, errFilterNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
// returnHashes is a helper that will return an empty hash array case the given hash array is nil,
|
// returnHashes is a helper that will return an empty hash array case the given hash array is nil,
|
||||||
|
|
@ -616,8 +616,8 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
|
||||||
BlockHash *common.Hash `json:"blockHash"`
|
BlockHash *common.Hash `json:"blockHash"`
|
||||||
FromBlock *rpc.BlockNumber `json:"fromBlock"`
|
FromBlock *rpc.BlockNumber `json:"fromBlock"`
|
||||||
ToBlock *rpc.BlockNumber `json:"toBlock"`
|
ToBlock *rpc.BlockNumber `json:"toBlock"`
|
||||||
Addresses interface{} `json:"address"`
|
Addresses any `json:"address"`
|
||||||
Topics []interface{} `json:"topics"`
|
Topics []any `json:"topics"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var raw input
|
var raw input
|
||||||
|
|
@ -646,7 +646,7 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
|
||||||
if raw.Addresses != nil {
|
if raw.Addresses != nil {
|
||||||
// raw.Address can contain a single address or an array of addresses
|
// raw.Address can contain a single address or an array of addresses
|
||||||
switch rawAddr := raw.Addresses.(type) {
|
switch rawAddr := raw.Addresses.(type) {
|
||||||
case []interface{}:
|
case []any:
|
||||||
for i, addr := range rawAddr {
|
for i, addr := range rawAddr {
|
||||||
if strAddr, ok := addr.(string); ok {
|
if strAddr, ok := addr.(string); ok {
|
||||||
addr, err := decodeAddress(strAddr)
|
addr, err := decodeAddress(strAddr)
|
||||||
|
|
@ -689,7 +689,7 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
|
||||||
}
|
}
|
||||||
args.Topics[i] = []common.Hash{top}
|
args.Topics[i] = []common.Hash{top}
|
||||||
|
|
||||||
case []interface{}:
|
case []any:
|
||||||
// or case e.g. [null, "topic0", "topic1"]
|
// or case e.g. [null, "topic0", "topic1"]
|
||||||
if len(topic) > maxSubTopics {
|
if len(topic) > maxSubTopics {
|
||||||
return errExceedMaxTopics
|
return errExceedMaxTopics
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ func (h *ethHandler) RunPeer(peer *eth.Peer, hand eth.Handler) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PeerInfo retrieves all known `eth` information about a peer.
|
// PeerInfo retrieves all known `eth` information about a peer.
|
||||||
func (h *ethHandler) PeerInfo(id enode.ID) interface{} {
|
func (h *ethHandler) PeerInfo(id enode.ID) any {
|
||||||
if p := h.peers.peer(id.String()); p != nil {
|
if p := h.peers.peer(id.String()); p != nil {
|
||||||
return p.info()
|
return p.info()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ func (h *testEthHandler) Chain() *core.BlockChain { panic("no backi
|
||||||
func (h *testEthHandler) TxPool() eth.TxPool { panic("no backing tx pool") }
|
func (h *testEthHandler) TxPool() eth.TxPool { panic("no backing tx pool") }
|
||||||
func (h *testEthHandler) AcceptTxs() bool { return true }
|
func (h *testEthHandler) AcceptTxs() bool { return true }
|
||||||
func (h *testEthHandler) RunPeer(*eth.Peer, eth.Handler) error { panic("not used in tests") }
|
func (h *testEthHandler) RunPeer(*eth.Peer, eth.Handler) error { panic("not used in tests") }
|
||||||
func (h *testEthHandler) PeerInfo(enode.ID) interface{} { panic("not used in tests") }
|
func (h *testEthHandler) PeerInfo(enode.ID) any { panic("not used in tests") }
|
||||||
|
|
||||||
func (h *testEthHandler) Handle(peer *eth.Peer, packet eth.Packet) error {
|
func (h *testEthHandler) Handle(peer *eth.Peer, packet eth.Packet) error {
|
||||||
switch packet := packet.(type) {
|
switch packet := packet.(type) {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ func (h *snapHandler) RunPeer(peer *snap.Peer, hand snap.Handler) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PeerInfo retrieves all known `snap` information about a peer.
|
// PeerInfo retrieves all known `snap` information about a peer.
|
||||||
func (h *snapHandler) PeerInfo(id enode.ID) interface{} {
|
func (h *snapHandler) PeerInfo(id enode.ID) any {
|
||||||
if p := h.peers.peer(id.String()); p != nil {
|
if p := h.peers.peer(id.String()); p != nil {
|
||||||
if p.snapExt != nil {
|
if p.snapExt != nil {
|
||||||
return p.snapExt.info()
|
return p.snapExt.info()
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,9 @@ type Request struct {
|
||||||
sink chan *Response // Channel to deliver the response on
|
sink chan *Response // Channel to deliver the response on
|
||||||
cancel chan struct{} // Channel to cancel requests ahead of time
|
cancel chan struct{} // Channel to cancel requests ahead of time
|
||||||
|
|
||||||
code uint64 // Message code of the request packet
|
code uint64 // Message code of the request packet
|
||||||
want uint64 // Message code of the response packet
|
want uint64 // Message code of the response packet
|
||||||
data interface{} // Data content of the request packet
|
data any // Data content of the request packet
|
||||||
|
|
||||||
Peer string // Demultiplexer if cross-peer requests are batched together
|
Peer string // Demultiplexer if cross-peer requests are batched together
|
||||||
Sent time.Time // Timestamp when the request was sent
|
Sent time.Time // Timestamp when the request was sent
|
||||||
|
|
@ -101,8 +101,8 @@ type Response struct {
|
||||||
code uint64 // Response packet type to cross validate with request
|
code uint64 // Response packet type to cross validate with request
|
||||||
|
|
||||||
Req *Request // Original request to cross-reference with
|
Req *Request // Original request to cross-reference with
|
||||||
Res interface{} // Remote response for the request query
|
Res any // Remote response for the request query
|
||||||
Meta interface{} // Metadata generated locally on the receiver thread
|
Meta any // Metadata generated locally on the receiver thread
|
||||||
Time time.Duration // Time it took for the request to be served
|
Time time.Duration // Time it took for the request to be served
|
||||||
Done chan error // Channel to signal message handling to the reader
|
Done chan error // Channel to signal message handling to the reader
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +138,7 @@ func (p *Peer) dispatchRequest(req *Request) error {
|
||||||
|
|
||||||
// dispatchResponse fulfils a pending request and delivers it to the requested
|
// dispatchResponse fulfils a pending request and delivers it to the requested
|
||||||
// sink.
|
// sink.
|
||||||
func (p *Peer) dispatchResponse(res *Response, metadata func() interface{}) error {
|
func (p *Peer) dispatchResponse(res *Response, metadata func() any) error {
|
||||||
resOp := &response{
|
resOp := &response{
|
||||||
res: res,
|
res: res,
|
||||||
fail: make(chan error),
|
fail: make(chan error),
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ type Backend interface {
|
||||||
RunPeer(peer *Peer, handler Handler) error
|
RunPeer(peer *Peer, handler Handler) error
|
||||||
|
|
||||||
// PeerInfo retrieves all known `eth` information about a peer.
|
// PeerInfo retrieves all known `eth` information about a peer.
|
||||||
PeerInfo(id enode.ID) interface{}
|
PeerInfo(id enode.ID) any
|
||||||
|
|
||||||
// Handle is a callback to be invoked when a data packet is received from
|
// Handle is a callback to be invoked when a data packet is received from
|
||||||
// the remote peer. Only packets not consumed by the protocol handler will
|
// the remote peer. Only packets not consumed by the protocol handler will
|
||||||
|
|
@ -113,10 +113,10 @@ func MakeProtocols(backend Backend, network uint64, disc enode.Iterator) []p2p.P
|
||||||
return Handle(backend, peer)
|
return Handle(backend, peer)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
NodeInfo: func() interface{} {
|
NodeInfo: func() any {
|
||||||
return nodeInfo(backend.Chain(), network)
|
return nodeInfo(backend.Chain(), network)
|
||||||
},
|
},
|
||||||
PeerInfo: func(id enode.ID) interface{} {
|
PeerInfo: func(id enode.ID) any {
|
||||||
return backend.PeerInfo(id)
|
return backend.PeerInfo(id)
|
||||||
},
|
},
|
||||||
DialCandidates: disc,
|
DialCandidates: disc,
|
||||||
|
|
@ -162,7 +162,7 @@ func Handle(backend Backend, peer *Peer) error {
|
||||||
|
|
||||||
type msgHandler func(backend Backend, msg Decoder, peer *Peer) error
|
type msgHandler func(backend Backend, msg Decoder, peer *Peer) error
|
||||||
type Decoder interface {
|
type Decoder interface {
|
||||||
Decode(val interface{}) error
|
Decode(val any) error
|
||||||
Time() time.Time
|
Time() time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ func (b *testBackend) RunPeer(peer *Peer, handler Handler) error {
|
||||||
// is omitted and we will just give control back to the handler.
|
// is omitted and we will just give control back to the handler.
|
||||||
return handler(peer)
|
return handler(peer)
|
||||||
}
|
}
|
||||||
func (b *testBackend) PeerInfo(enode.ID) interface{} { panic("not implemented") }
|
func (b *testBackend) PeerInfo(enode.ID) any { panic("not implemented") }
|
||||||
|
|
||||||
func (b *testBackend) AcceptTxs() bool {
|
func (b *testBackend) AcceptTxs() bool {
|
||||||
return true
|
return true
|
||||||
|
|
@ -554,7 +554,7 @@ type decoder struct {
|
||||||
msg []byte
|
msg []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d decoder) Decode(val interface{}) error {
|
func (d decoder) Decode(val any) error {
|
||||||
buffer := bytes.NewBuffer(d.msg)
|
buffer := bytes.NewBuffer(d.msg)
|
||||||
s := rlp.NewStream(buffer, uint64(len(d.msg)))
|
s := rlp.NewStream(buffer, uint64(len(d.msg)))
|
||||||
return s.Decode(val)
|
return s.Decode(val)
|
||||||
|
|
|
||||||
|
|
@ -356,7 +356,7 @@ func handleBlockHeaders(backend Backend, msg Decoder, peer *Peer) error {
|
||||||
if err := msg.Decode(res); err != nil {
|
if err := msg.Decode(res); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
metadata := func() interface{} {
|
metadata := func() any {
|
||||||
hashes := make([]common.Hash, len(res.BlockHeadersRequest))
|
hashes := make([]common.Hash, len(res.BlockHeadersRequest))
|
||||||
for i, header := range res.BlockHeadersRequest {
|
for i, header := range res.BlockHeadersRequest {
|
||||||
hashes[i] = header.Hash()
|
hashes[i] = header.Hash()
|
||||||
|
|
@ -376,7 +376,7 @@ func handleBlockBodies(backend Backend, msg Decoder, peer *Peer) error {
|
||||||
if err := msg.Decode(res); err != nil {
|
if err := msg.Decode(res); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
metadata := func() interface{} {
|
metadata := func() any {
|
||||||
var (
|
var (
|
||||||
txsHashes = make([]common.Hash, len(res.BlockBodiesResponse))
|
txsHashes = make([]common.Hash, len(res.BlockBodiesResponse))
|
||||||
uncleHashes = make([]common.Hash, len(res.BlockBodiesResponse))
|
uncleHashes = make([]common.Hash, len(res.BlockBodiesResponse))
|
||||||
|
|
@ -412,7 +412,7 @@ func handleReceipts[L ReceiptsList](backend Backend, msg Decoder, peer *Peer) er
|
||||||
res.List[i].setBuffers(buffers)
|
res.List[i].setBuffers(buffers)
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata := func() interface{} {
|
metadata := func() any {
|
||||||
hasher := trie.NewStackTrie(nil)
|
hasher := trie.NewStackTrie(nil)
|
||||||
hashes := make([]common.Hash, len(res.List))
|
hashes := make([]common.Hash, len(res.List))
|
||||||
for i := range res.List {
|
for i := range res.List {
|
||||||
|
|
|
||||||
|
|
@ -44,11 +44,11 @@ func testHandshake(t *testing.T, protocol uint) {
|
||||||
)
|
)
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
code uint64
|
code uint64
|
||||||
data interface{}
|
data any
|
||||||
want error
|
want error
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
code: TransactionsMsg, data: []interface{}{},
|
code: TransactionsMsg, data: []any{},
|
||||||
want: errNoStatusMsg,
|
want: errNoStatusMsg,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ func TestMessages(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range []struct {
|
for i, tc := range []struct {
|
||||||
message interface{}
|
message any
|
||||||
want []byte
|
want []byte
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ type Backend interface {
|
||||||
RunPeer(peer *Peer, handler Handler) error
|
RunPeer(peer *Peer, handler Handler) error
|
||||||
|
|
||||||
// PeerInfo retrieves all known `snap` information about a peer.
|
// PeerInfo retrieves all known `snap` information about a peer.
|
||||||
PeerInfo(id enode.ID) interface{}
|
PeerInfo(id enode.ID) any
|
||||||
|
|
||||||
// Handle is a callback to be invoked when a data packet is received from
|
// Handle is a callback to be invoked when a data packet is received from
|
||||||
// the remote peer. Only packets not consumed by the protocol handler will
|
// the remote peer. Only packets not consumed by the protocol handler will
|
||||||
|
|
@ -97,10 +97,10 @@ func MakeProtocols(backend Backend) []p2p.Protocol {
|
||||||
return Handle(backend, peer)
|
return Handle(backend, peer)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
NodeInfo: func() interface{} {
|
NodeInfo: func() any {
|
||||||
return nodeInfo(backend.Chain())
|
return nodeInfo(backend.Chain())
|
||||||
},
|
},
|
||||||
PeerInfo: func(id enode.ID) interface{} {
|
PeerInfo: func(id enode.ID) any {
|
||||||
return backend.PeerInfo(id)
|
return backend.PeerInfo(id)
|
||||||
},
|
},
|
||||||
Attributes: []enr.Entry{&enrEntry{}},
|
Attributes: []enr.Entry{&enrEntry{}},
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ func FuzzTrieNodes(f *testing.F) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func doFuzz(input []byte, obj interface{}, code int) {
|
func doFuzz(input []byte, obj any, code int) {
|
||||||
bc := getChain()
|
bc := getChain()
|
||||||
defer bc.Stop()
|
defer bc.Stop()
|
||||||
fuzz.NewFromGoFuzz(input).Fuzz(obj)
|
fuzz.NewFromGoFuzz(input).Fuzz(obj)
|
||||||
|
|
@ -136,10 +136,10 @@ type dummyBackend struct {
|
||||||
chain *core.BlockChain
|
chain *core.BlockChain
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dummyBackend) Chain() *core.BlockChain { return d.chain }
|
func (d *dummyBackend) Chain() *core.BlockChain { return d.chain }
|
||||||
func (d *dummyBackend) RunPeer(*Peer, Handler) error { return nil }
|
func (d *dummyBackend) RunPeer(*Peer, Handler) error { return nil }
|
||||||
func (d *dummyBackend) PeerInfo(enode.ID) interface{} { return "Foo" }
|
func (d *dummyBackend) PeerInfo(enode.ID) any { return "Foo" }
|
||||||
func (d *dummyBackend) Handle(*Peer, Packet) error { return nil }
|
func (d *dummyBackend) Handle(*Peer, Packet) error { return nil }
|
||||||
|
|
||||||
type dummyRW struct {
|
type dummyRW struct {
|
||||||
code uint64
|
code uint64
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ type StdTraceConfig struct {
|
||||||
// txTraceResult is the result of a single transaction trace.
|
// txTraceResult is the result of a single transaction trace.
|
||||||
type txTraceResult struct {
|
type txTraceResult struct {
|
||||||
TxHash common.Hash `json:"txHash"` // transaction hash
|
TxHash common.Hash `json:"txHash"` // transaction hash
|
||||||
Result interface{} `json:"result,omitempty"` // Trace results produced by the tracer
|
Result any `json:"result,omitempty"` // Trace results produced by the tracer
|
||||||
Error string `json:"error,omitempty"` // Trace failure produced by the tracer
|
Error string `json:"error,omitempty"` // Trace failure produced by the tracer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -863,7 +863,7 @@ func containsTx(block *types.Block, hash common.Hash) bool {
|
||||||
|
|
||||||
// TraceTransaction returns the structured logs created during the execution of EVM
|
// TraceTransaction returns the structured logs created during the execution of EVM
|
||||||
// and returns them as a JSON object.
|
// and returns them as a JSON object.
|
||||||
func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
|
func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (any, error) {
|
||||||
found, _, blockHash, blockNumber, index := api.backend.GetCanonicalTransaction(hash)
|
found, _, blockHash, blockNumber, index := api.backend.GetCanonicalTransaction(hash)
|
||||||
if !found {
|
if !found {
|
||||||
// Warn in case tx indexer is not done.
|
// Warn in case tx indexer is not done.
|
||||||
|
|
@ -911,7 +911,7 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *
|
||||||
// after executing the specified block. However, if a transaction index is provided,
|
// after executing the specified block. However, if a transaction index is provided,
|
||||||
// the trace will be conducted on the state after executing the specified transaction
|
// the trace will be conducted on the state after executing the specified transaction
|
||||||
// within the specified block.
|
// within the specified block.
|
||||||
func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig) (interface{}, error) {
|
func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceCallConfig) (any, error) {
|
||||||
// Try to retrieve the specified block
|
// Try to retrieve the specified block
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
|
|
@ -1006,7 +1006,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
|
||||||
// traceTx configures a new tracer according to the provided configuration, and
|
// traceTx configures a new tracer according to the provided configuration, and
|
||||||
// executes the given message in the provided environment. The return value will
|
// executes the given message in the provided environment. The return value will
|
||||||
// be tracer dependent.
|
// be tracer dependent.
|
||||||
func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *core.Message, txctx *Context, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig, precompiles vm.PrecompiledContracts) (interface{}, error) {
|
func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *core.Message, txctx *Context, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig, precompiles vm.PrecompiledContracts) (any, error) {
|
||||||
var (
|
var (
|
||||||
tracer *Tracer
|
tracer *Tracer
|
||||||
err error
|
err error
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ func testFlatCallTracer(tracerName string, dirPath string, t *testing.T) {
|
||||||
|
|
||||||
// jsonEqualFlat is similar to reflect.DeepEqual, but does a 'bounce' via json prior to
|
// jsonEqualFlat is similar to reflect.DeepEqual, but does a 'bounce' via json prior to
|
||||||
// comparison
|
// comparison
|
||||||
func jsonEqualFlat(x, y interface{}) bool {
|
func jsonEqualFlat(x, y any) bool {
|
||||||
xTrace := new([]flatCallTrace)
|
xTrace := new([]flatCallTrace)
|
||||||
yTrace := new([]flatCallTrace)
|
yTrace := new([]flatCallTrace)
|
||||||
if xj, err := json.Marshal(x); err == nil {
|
if xj, err := json.Marshal(x); err == nil {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ type account struct {
|
||||||
// prestateTracerTest defines a single test to check the stateDiff tracer against.
|
// prestateTracerTest defines a single test to check the stateDiff tracer against.
|
||||||
type prestateTracerTest struct {
|
type prestateTracerTest struct {
|
||||||
tracerTestEnv
|
tracerTestEnv
|
||||||
Result interface{} `json:"result"`
|
Result any `json:"result"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrestateTracerLegacy(t *testing.T) {
|
func TestPrestateTracerLegacy(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -643,7 +643,7 @@ func testSupplyTracer(t *testing.T, genesis *core.Genesis, gen func(b *core.Bloc
|
||||||
return output, chain, nil
|
return output, chain, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func compareAsJSON(t *testing.T, expected interface{}, actual interface{}) {
|
func compareAsJSON(t *testing.T, expected any, actual any) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
want, err := json.Marshal(expected)
|
want, err := json.Marshal(expected)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ type rpcBlock struct {
|
||||||
Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"`
|
Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *Client) getBlock(ctx context.Context, method string, args ...interface{}) (*types.Block, error) {
|
func (ec *Client) getBlock(ctx context.Context, method string, args ...any) (*types.Block, error) {
|
||||||
var raw json.RawMessage
|
var raw json.RawMessage
|
||||||
err := ec.c.CallContext(ctx, &raw, method, args...)
|
err := ec.c.CallContext(ctx, &raw, method, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -186,7 +186,7 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface
|
||||||
for i := range reqs {
|
for i := range reqs {
|
||||||
reqs[i] = rpc.BatchElem{
|
reqs[i] = rpc.BatchElem{
|
||||||
Method: "eth_getUncleByBlockHashAndIndex",
|
Method: "eth_getUncleByBlockHashAndIndex",
|
||||||
Args: []interface{}{body.Hash, hexutil.EncodeUint64(uint64(i))},
|
Args: []any{body.Hash, hexutil.EncodeUint64(uint64(i))},
|
||||||
Result: &uncles[i],
|
Result: &uncles[i],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -774,8 +774,8 @@ func toBlockNumArg(number *big.Int) string {
|
||||||
return fmt.Sprintf("<invalid %d>", number)
|
return fmt.Sprintf("<invalid %d>", number)
|
||||||
}
|
}
|
||||||
|
|
||||||
func toCallArg(msg ethereum.CallMsg) interface{} {
|
func toCallArg(msg ethereum.CallMsg) any {
|
||||||
arg := map[string]interface{}{
|
arg := map[string]any{
|
||||||
"from": msg.From,
|
"from": msg.From,
|
||||||
"to": msg.To,
|
"to": msg.To,
|
||||||
}
|
}
|
||||||
|
|
@ -886,9 +886,9 @@ func (s SimulateBlock) MarshalJSON() ([]byte, error) {
|
||||||
type Alias struct {
|
type Alias struct {
|
||||||
BlockOverrides *ethereum.BlockOverrides `json:"blockOverrides,omitempty"`
|
BlockOverrides *ethereum.BlockOverrides `json:"blockOverrides,omitempty"`
|
||||||
StateOverrides map[common.Address]ethereum.OverrideAccount `json:"stateOverrides,omitempty"`
|
StateOverrides map[common.Address]ethereum.OverrideAccount `json:"stateOverrides,omitempty"`
|
||||||
Calls []interface{} `json:"calls"`
|
Calls []any `json:"calls"`
|
||||||
}
|
}
|
||||||
calls := make([]interface{}, len(s.Calls))
|
calls := make([]any, len(s.Calls))
|
||||||
for i, call := range s.Calls {
|
for i, call := range s.Calls {
|
||||||
calls[i] = toCallArg(call)
|
calls[i] = toCallArg(call)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -244,8 +244,8 @@ func toBlockNumArg(number *big.Int) string {
|
||||||
return fmt.Sprintf("<invalid %d>", number)
|
return fmt.Sprintf("<invalid %d>", number)
|
||||||
}
|
}
|
||||||
|
|
||||||
func toCallArg(msg ethereum.CallMsg) interface{} {
|
func toCallArg(msg ethereum.CallMsg) any {
|
||||||
arg := map[string]interface{}{
|
arg := map[string]any{
|
||||||
"from": msg.From,
|
"from": msg.From,
|
||||||
"to": msg.To,
|
"to": msg.To,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ func TestToFilterArg(t *testing.T) {
|
||||||
for _, testCase := range []struct {
|
for _, testCase := range []struct {
|
||||||
name string
|
name string
|
||||||
input ethereum.FilterQuery
|
input ethereum.FilterQuery
|
||||||
output interface{}
|
output any
|
||||||
err error
|
err error
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
@ -61,7 +61,7 @@ func TestToFilterArg(t *testing.T) {
|
||||||
ToBlock: big.NewInt(2),
|
ToBlock: big.NewInt(2),
|
||||||
Topics: [][]common.Hash{},
|
Topics: [][]common.Hash{},
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"address": addresses,
|
"address": addresses,
|
||||||
"fromBlock": "0x1",
|
"fromBlock": "0x1",
|
||||||
"toBlock": "0x2",
|
"toBlock": "0x2",
|
||||||
|
|
@ -75,7 +75,7 @@ func TestToFilterArg(t *testing.T) {
|
||||||
Addresses: addresses,
|
Addresses: addresses,
|
||||||
Topics: [][]common.Hash{},
|
Topics: [][]common.Hash{},
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"address": addresses,
|
"address": addresses,
|
||||||
"fromBlock": "0x0",
|
"fromBlock": "0x0",
|
||||||
"toBlock": "latest",
|
"toBlock": "latest",
|
||||||
|
|
@ -91,7 +91,7 @@ func TestToFilterArg(t *testing.T) {
|
||||||
ToBlock: big.NewInt(-1),
|
ToBlock: big.NewInt(-1),
|
||||||
Topics: [][]common.Hash{},
|
Topics: [][]common.Hash{},
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"address": addresses,
|
"address": addresses,
|
||||||
"fromBlock": "pending",
|
"fromBlock": "pending",
|
||||||
"toBlock": "pending",
|
"toBlock": "pending",
|
||||||
|
|
@ -106,7 +106,7 @@ func TestToFilterArg(t *testing.T) {
|
||||||
BlockHash: &blockHash,
|
BlockHash: &blockHash,
|
||||||
Topics: [][]common.Hash{},
|
Topics: [][]common.Hash{},
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"address": addresses,
|
"address": addresses,
|
||||||
"blockHash": blockHash,
|
"blockHash": blockHash,
|
||||||
"topics": [][]common.Hash{},
|
"topics": [][]common.Hash{},
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ type AncientWriter interface {
|
||||||
// AncientWriteOp is given to the function argument of ModifyAncients.
|
// AncientWriteOp is given to the function argument of ModifyAncients.
|
||||||
type AncientWriteOp interface {
|
type AncientWriteOp interface {
|
||||||
// Append adds an RLP-encoded item.
|
// Append adds an RLP-encoded item.
|
||||||
Append(kind string, number uint64, item interface{}) error
|
Append(kind string, number uint64, item any) error
|
||||||
|
|
||||||
// AppendRaw adds an item without RLP-encoding it.
|
// AppendRaw adds an item without RLP-encoding it.
|
||||||
AppendRaw(kind string, number uint64, item []byte) error
|
AppendRaw(kind string, number uint64, item []byte) error
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ func NewCustom(file string, namespace string, customize func(options *opt.Option
|
||||||
options := configureOptions(customize)
|
options := configureOptions(customize)
|
||||||
logger := log.New("database", file)
|
logger := log.New("database", file)
|
||||||
usedCache := options.GetBlockCacheCapacity() + options.GetWriteBuffer()*2
|
usedCache := options.GetBlockCacheCapacity() + options.GetWriteBuffer()*2
|
||||||
logCtx := []interface{}{"cache", common.StorageSize(usedCache), "handles", options.GetOpenFilesCacheCapacity()}
|
logCtx := []any{"cache", common.StorageSize(usedCache), "handles", options.GetOpenFilesCacheCapacity()}
|
||||||
if options.ReadOnly {
|
if options.ReadOnly {
|
||||||
logCtx = append(logCtx, "readonly", "true")
|
logCtx = append(logCtx, "readonly", "true")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue