Skip to content

Commit

Permalink
GasPrice and MinerTip should only be called in Zone and fixed ethclient
Browse files Browse the repository at this point in the history
  • Loading branch information
jdowning100 committed Oct 18, 2024
1 parent 8187d11 commit 7b92c52
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
12 changes: 4 additions & 8 deletions core/rawdb/accessors_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,12 +787,14 @@ func TestAddressOutpointsStorage(t *testing.T) {
TxHash: common.Hash{1},
Index: uint16(1),
Denomination: uint8(1),
Lock: big.NewInt(0),
}

outpoint2 := types.OutpointAndDenomination{
TxHash: common.Hash{2},
Index: uint16(1),
Denomination: uint8(1),
Lock: big.NewInt(0),
}

outpointMap := map[string]*types.OutpointAndDenomination{
Expand All @@ -811,17 +813,11 @@ func TestAddressOutpointsStorage(t *testing.T) {
WriteAddressOutpoints(db, addressOutpointMap)

if entry := ReadOutpointsForAddress(db, address); len(entry) == 0 || *entry[outpoint.Key()] != outpoint {
if len(entry) > 0 {
t.Fatalf("expected: %v \n found: %v", entry[outpoint.Key()], outpoint)
}
t.Fatal("Stored outpoint not found")
require.Equal(t, outpoint, *entry[outpoint.Key()])
}

if entry := ReadOutpointsForAddress(db, address2); len(entry) == 0 || *entry[outpoint2.Key()] != outpoint2 {
if len(entry) > 0 {
t.Fatalf("expected: %v \n found: %v", entry[outpoint2.Key()], outpoint2)
}
t.Fatal("Stored outpoint not found")
require.Equal(t, outpoint2, *entry[outpoint2.Key()])
}
}

Expand Down
6 changes: 6 additions & 0 deletions internal/quaiapi/quai_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,17 @@ func NewPublicQuaiAPI(b Backend) *PublicQuaiAPI {

// GasPrice returns a suggestion for a gas price for legacy transactions.
func (s *PublicQuaiAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) {
if s.b.NodeLocation().Context() != common.ZONE_CTX {
return (*hexutil.Big)(big.NewInt(0)), errors.New("gasPrice call can only be made in zone chain")
}
return (*hexutil.Big)(s.b.GetMinGasPrice()), nil
}

// MinerTip returns the gas price of the pool
func (s *PublicQuaiAPI) MinerTip(ctx context.Context) *hexutil.Big {
if s.b.NodeLocation().Context() != common.ZONE_CTX {
return (*hexutil.Big)(big.NewInt(0))
}
return (*hexutil.Big)(s.b.GetPoolGasPrice())
}

Expand Down
4 changes: 2 additions & 2 deletions quaiclient/ethclient/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ func (ec *Client) ContractSizeAt(ctx context.Context, account common.MixedcaseAd
return (*big.Int)(&result), err
}

func (ec *Client) GetOutpointsByAddress(ctx context.Context, address common.MixedcaseAddress) (map[string]*types.OutpointAndDenomination, error) {
var outpoints map[string]*types.OutpointAndDenomination
func (ec *Client) GetOutpointsByAddress(ctx context.Context, address common.MixedcaseAddress) ([]*types.OutpointAndDenomination, error) {
var outpoints []*types.OutpointAndDenomination
err := ec.c.CallContext(ctx, &outpoints, "quai_getOutpointsByAddress", address.Original())
return outpoints, err
}
Expand Down

0 comments on commit 7b92c52

Please sign in to comment.