-
Notifications
You must be signed in to change notification settings - Fork 38
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
Align RPC with geth #1841
Align RPC with geth #1841
Conversation
@@ -145,33 +144,68 @@ func ExtractAddress(param interface{}) (*gethcommon.Address, error) { | |||
} | |||
|
|||
// ExtractOptionalBlockNumber defaults nil or empty block number params to latest block number | |||
func ExtractOptionalBlockNumber(params []interface{}, idx int) (*gethrpc.BlockNumber, error) { | |||
func ExtractOptionalBlockNumber(params []interface{}, idx int) (*gethrpc.BlockNumberOrHash, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the geth api can send either a block number or a hash.
We currently only support the former, but this change creates the plumbing for both
@@ -13,7 +17,7 @@ import ( | |||
"github.com/ten-protocol/go-ten/go/enclave/events" | |||
) | |||
|
|||
func GetTransactionReceiptValidate(reqParams []any, builder *CallBuilder[gethcommon.Hash, types.Receipt], _ *EncryptionManager) error { | |||
func GetTransactionReceiptValidate(reqParams []any, builder *CallBuilder[gethcommon.Hash, map[string]interface{}], _ *EncryptionManager) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the geth api actually returns a map when you ask for receipts.
@@ -2,6 +2,8 @@ package obsclient | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes in this file are aligning with geth
@@ -235,7 +225,7 @@ func (c *EncRPCClient) executeSensitiveCall(ctx context.Context, result interfac | |||
|
|||
// If there is no encrypted response then this is equivalent to nil response | |||
if rawResult.EncUserResponse == nil || len(rawResult.EncUserResponse) == 0 { | |||
return ErrNilResponse | |||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that error has no equivalent in geth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 , 2 minor comments added
@@ -47,7 +47,8 @@ func EstimateGasValidate(reqParams []any, builder *CallBuilder[CallParamsWithBlo | |||
} | |||
|
|||
builder.From = callMsg.From | |||
builder.Param = &CallParamsWithBlock{callMsg, blockNumber} | |||
// todo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: What needs to be done here or can be this todo removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to support retrieval by hash. Currently it only works by height
@@ -56,7 +56,7 @@ func GetTransactionExecute(builder *CallBuilder[gethcommon.Hash, RpcTransaction] | |||
// Unlike in the Geth impl, we hardcode the use of a London signer. | |||
// todo (#1553) - once the enclave's genesis.json is set, retrieve the signer type using `types.MakeSigner` | |||
signer := types.NewLondonSigner(tx.ChainId()) | |||
rpcTx := newRPCTransaction(tx, blockHash, blockNumber, index, gethcommon.Big0, signer) | |||
rpcTx := newRPCTransaction(tx, blockHash, blockNumber, index, rpc.config.BaseFee, signer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity.. do we want to have it configurable? Before it was hardcoded to 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently we have a static configured base fee.
Eventually, it needs to be dynamic.
The problem here was that this was returning 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me so long as tests are all behaving. One minor thing I think needs fixing.
tools/faucet/faucet/faucet.go
Outdated
@@ -85,7 +83,7 @@ func (f *Faucet) validateTx(tx *types.Transaction) error { | |||
for now := time.Now(); time.Since(now) < _timeout; time.Sleep(time.Second) { | |||
receipt, err := f.client.TransactionReceipt(context.Background(), tx.Hash()) | |||
if err != nil { | |||
if errors.Is(err, rpc.ErrNilResponse) { | |||
if receipt == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still need to check the type of error here is ethereum.NotFound
I think? Else it'll keep waiting when the node is down for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good spot. this logic is dodgy here
Why this change is needed
What changes were made as part of this PR
PR checks pre-merging
Please indicate below by ticking the checkbox that you have read and performed the required
PR checks