Skip to content

Commit

Permalink
Merge branch 'ethereum:master' into portal
Browse files Browse the repository at this point in the history
  • Loading branch information
GrapeBaBa authored Jul 25, 2024
2 parents 5bf4c2b + ac0f220 commit 7b8ce85
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion beacon/types/beacon_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func BlockFromJSON(forkName string, data []byte) (*BeaconBlock, error) {
case "capella":
obj = new(capella.BeaconBlock)
default:
return nil, fmt.Errorf("unsupported fork: " + forkName)
return nil, fmt.Errorf("unsupported fork: %s", forkName)
}
if err := json.Unmarshal(data, obj); err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion beacon/types/exec_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func ExecutionHeaderFromJSON(forkName string, data []byte) (*ExecutionHeader, er
case "deneb":
obj = new(deneb.ExecutionPayloadHeader)
default:
return nil, fmt.Errorf("unsupported fork: " + forkName)
return nil, fmt.Errorf("unsupported fork: %s", forkName)
}
if err := json.Unmarshal(data, obj); err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion cmd/devp2p/rlpxcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func rlpxPing(ctx *cli.Context) error {
n := getNodeArg(ctx)
tcpEndpoint, ok := n.TCPEndpoint()
if !ok {
return fmt.Errorf("node has no TCP endpoint")
return errors.New("node has no TCP endpoint")
}
fd, err := net.Dial("tcp", tcpEndpoint.String())
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions eth/tracers/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ func TestTracingWithOverrides(t *testing.T) {
byte(vm.PUSH1), 00,
byte(vm.RETURN),
}),
StateDiff: &map[common.Hash]common.Hash{
StateDiff: map[common.Hash]common.Hash{
common.HexToHash("0x03"): common.HexToHash("0x11"),
},
},
Expand Down Expand Up @@ -898,25 +898,25 @@ func newAccounts(n int) (accounts []Account) {
return accounts
}

func newRPCBalance(balance *big.Int) **hexutil.Big {
func newRPCBalance(balance *big.Int) *hexutil.Big {
rpcBalance := (*hexutil.Big)(balance)
return &rpcBalance
return rpcBalance
}

func newRPCBytes(bytes []byte) *hexutil.Bytes {
rpcBytes := hexutil.Bytes(bytes)
return &rpcBytes
}

func newStates(keys []common.Hash, vals []common.Hash) *map[common.Hash]common.Hash {
func newStates(keys []common.Hash, vals []common.Hash) map[common.Hash]common.Hash {
if len(keys) != len(vals) {
panic("invalid input")
}
m := make(map[common.Hash]common.Hash)
for i := 0; i < len(keys); i++ {
m[keys[i]] = vals[i]
}
return &m
return m
}

func TestTraceChain(t *testing.T) {
Expand Down
16 changes: 8 additions & 8 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -968,11 +968,11 @@ func (api *BlockChainAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rp
// if stateDiff is set, all diff will be applied first and then execute the call
// message.
type OverrideAccount struct {
Nonce *hexutil.Uint64 `json:"nonce"`
Code *hexutil.Bytes `json:"code"`
Balance **hexutil.Big `json:"balance"`
State *map[common.Hash]common.Hash `json:"state"`
StateDiff *map[common.Hash]common.Hash `json:"stateDiff"`
Nonce *hexutil.Uint64 `json:"nonce"`
Code *hexutil.Bytes `json:"code"`
Balance *hexutil.Big `json:"balance"`
State map[common.Hash]common.Hash `json:"state"`
StateDiff map[common.Hash]common.Hash `json:"stateDiff"`
}

// StateOverride is the collection of overridden accounts.
Expand All @@ -994,19 +994,19 @@ func (diff *StateOverride) Apply(statedb *state.StateDB) error {
}
// Override account balance.
if account.Balance != nil {
u256Balance, _ := uint256.FromBig((*big.Int)(*account.Balance))
u256Balance, _ := uint256.FromBig((*big.Int)(account.Balance))
statedb.SetBalance(addr, u256Balance, tracing.BalanceChangeUnspecified)
}
if account.State != nil && account.StateDiff != nil {
return fmt.Errorf("account %s has both 'state' and 'stateDiff'", addr.Hex())
}
// Replace entire state if caller requires.
if account.State != nil {
statedb.SetStorage(addr, *account.State)
statedb.SetStorage(addr, account.State)
}
// Apply state diff into specified accounts.
if account.StateDiff != nil {
for key, value := range *account.StateDiff {
for key, value := range account.StateDiff {
statedb.SetState(addr, key, value)
}
}
Expand Down
6 changes: 3 additions & 3 deletions internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ func TestCall(t *testing.T) {
overrides: StateOverride{
randomAccounts[2].addr: OverrideAccount{
Code: hex2Bytes("6080604052348015600f57600080fd5b506004361060285760003560e01c80638381f58a14602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea2646970667358221220eab35ffa6ab2adfe380772a48b8ba78e82a1b820a18fcb6f59aa4efb20a5f60064736f6c63430007040033"),
StateDiff: &map[common.Hash]common.Hash{{}: common.BigToHash(big.NewInt(123))},
StateDiff: map[common.Hash]common.Hash{{}: common.BigToHash(big.NewInt(123))},
},
},
want: "0x000000000000000000000000000000000000000000000000000000000000007b",
Expand Down Expand Up @@ -1345,9 +1345,9 @@ func newAccounts(n int) (accounts []account) {
return accounts
}

func newRPCBalance(balance *big.Int) **hexutil.Big {
func newRPCBalance(balance *big.Int) *hexutil.Big {
rpcBalance := (*hexutil.Big)(balance)
return &rpcBalance
return rpcBalance
}

func hex2Bytes(str string) *hexutil.Bytes {
Expand Down
4 changes: 2 additions & 2 deletions p2p/enr/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (v IPv4Addr) ENRKey() string { return "ip" }
func (v IPv4Addr) EncodeRLP(w io.Writer) error {
addr := netip.Addr(v)
if !addr.Is4() {
return fmt.Errorf("address is not IPv4")
return errors.New("address is not IPv4")
}
enc := rlp.NewEncoderBuffer(w)
bytes := addr.As4()
Expand All @@ -204,7 +204,7 @@ func (v IPv6Addr) ENRKey() string { return "ip6" }
func (v IPv6Addr) EncodeRLP(w io.Writer) error {
addr := netip.Addr(v)
if !addr.Is6() {
return fmt.Errorf("address is not IPv6")
return errors.New("address is not IPv6")
}
enc := rlp.NewEncoderBuffer(w)
bytes := addr.As16()
Expand Down

0 comments on commit 7b8ce85

Please sign in to comment.