Skip to content

Add support for a few more backend features #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions arbitrum/apibackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ func (a *APIBackend) GetAPIs() []rpc.API {
Service: filters.NewPublicFilterAPI(a, false, 5*time.Minute),
Public: true,
})

apis = append(apis, rpc.API{
Namespace: "net",
Version: "1.0",
Service: NewPublicNetAPI(a.ChainConfig().ChainID.Uint64()),
Public: true,
})

return apis
}

Expand All @@ -53,7 +61,7 @@ func (a *APIBackend) SyncProgress() ethereum.SyncProgress {
}

func (a *APIBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
panic("not implemented") // TODO: Implement
return big.NewInt(1), nil // TODO: Implement
}

func (a *APIBackend) FeeHistory(ctx context.Context, blockCount int, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) {
Expand All @@ -73,7 +81,7 @@ func (a *APIBackend) ExtRPCEnabled() bool {
}

func (a *APIBackend) RPCGasCap() uint64 {
panic("not implemented") // TODO: Implement
return a.b.ethConfig.RPCGasCap
}

func (a *APIBackend) RPCTxFeeCap() float64 {
Expand Down Expand Up @@ -164,11 +172,17 @@ func (a *APIBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.R
}

func (a *APIBackend) GetTd(ctx context.Context, hash common.Hash) *big.Int {
panic("not implemented") // TODO: Implement
return a.b.blockChain.GetTdByHash(hash)
}

func (a *APIBackend) GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header, vmConfig *vm.Config) (*vm.EVM, func() error, error) {
panic("not implemented") // TODO: Implement
vmError := func() error { return nil }
if vmConfig == nil {
vmConfig = a.b.blockChain.GetVMConfig()
}
txContext := core.NewEVMTxContext(msg)
context := core.NewEVMBlockContext(header, a.b.blockChain, nil)
return vm.NewEVM(context, txContext, state, a.b.blockChain.Config(), *vmConfig), vmError, nil
}

func (a *APIBackend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription {
Expand Down
20 changes: 20 additions & 0 deletions arbitrum/net.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package arbitrum

import (
"fmt"
)

// PublicNetAPI offers network related RPC methods
type PublicNetAPI struct {
networkVersion uint64
}

// NewPublicNetAPI creates a new net API instance.
func NewPublicNetAPI(networkVersion uint64) *PublicNetAPI {
return &PublicNetAPI{networkVersion}
}

// Version returns the current ethereum protocol version.
func (s *PublicNetAPI) Version() string {
return fmt.Sprintf("%d", s.networkVersion)
}