Skip to content
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

API GetTransactionProof, GetReceiptProof #94

Merged
merged 6 commits into from
Oct 24, 2023
Merged

Conversation

wgr523
Copy link
Collaborator

@wgr523 wgr523 commented Sep 26, 2023

No description provided.

Copy link
Member

@GalaxySciTech GalaxySciTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it need a test script

@liam-lai
Copy link
Collaborator

Yes, please write a test for proofPairList object and deriveTrie function at least

@wanwiset25
Copy link
Collaborator

do we need to put something in web3ext.go for external interface?
something like the below
new web3._extend.Method({ name: 'getV2Block', call: function (args) { return (web3._extend.utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "XDPoS_getV2BlockByHash" : "XDPoS_getV2BlockByNumber"; }, params: 1, inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter]

return nil, fmt.Errorf("key not found")
}

func TestReceiptProof(t *testing.T) {
Copy link
Member

@GalaxySciTech GalaxySciTech Sep 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it is necessary to call GetReceiptProof function in test script

we need test the function

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to write test for calling function like GetReceiptProof or other GetXXX. In the codebase I cannot find any test like this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if use that way how do we ensure the getReceiptProof will no error when we changed some code

Copy link
Collaborator Author

@wgr523 wgr523 Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I don't know. I can only say that in our codebase (and the ethereum codebase xinfin forked) there is no test for api functions. So it is hard to write test for this api function GetReceiptProof

Trieproof fix
@GalaxySciTech
Copy link
Member

it seems Receipt need to add a parameter contractAddress in here

return rlp.Encode(w, &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs})

@wgr523
Copy link
Collaborator Author

wgr523 commented Oct 10, 2023

it seems Receipt need to add a parameter contractAddress in here

return rlp.Encode(w, &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs})

This encoding is written by ethereum yellow paper and I think we should not change it. If we change it, then our code is quite different from ethereum and users may not like it.

The code to compute contractAddress is quite simple and we can compute it whenever we want to use it: in core/state_processor.go

	// if the transaction created a contract, store the creation address in the receipt.
	if msg.To() == nil {
		receipt.ContractAddress = crypto.CreateAddress(vmenv.Context.Origin, tx.Nonce())
	}

(vmenv.Context.Origin is just tx.Sender())

@GalaxySciTech
Copy link
Member

it seems Receipt need to add a parameter contractAddress in here

return rlp.Encode(w, &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs})

This encoding is written by ethereum yellow paper and I think we should not change it. If we change it, then our code is quite different from ethereum and users may not like it.

The code to compute contractAddress is quite simple and we can compute it whenever we want to use it: in core/state_processor.go

	// if the transaction created a contract, store the creation address in the receipt.
	if msg.To() == nil {
		receipt.ContractAddress = crypto.CreateAddress(vmenv.Context.Origin, tx.Nonce())
	}

(vmenv.Context.Origin is just tx.Sender())

i can only get the receiptrlp

the struct only have status bloom log gas

i can not get other parameters

@GalaxySciTech
Copy link
Member

i think if any possible we can implement the eth_getProof function?
this is the reference https://eips.ethereum.org/EIPS/eip-1186

@wgr523 wgr523 changed the title API GetReceiptProof API GetTransactionProof, GetReceiptProof Oct 15, 2023
@wgr523
Copy link
Collaborator Author

wgr523 commented Oct 17, 2023

i think if any possible we can implement the eth_getProof function? this is the reference https://eips.ethereum.org/EIPS/eip-1186

I find the implementation and can do it. But may I ask when do we need eth_getProof? I thought we only need transaction proof and receipt proof.

@GalaxySciTech
Copy link
Member

i think if any possible we can implement the eth_getProof function? this is the reference https://eips.ethereum.org/EIPS/eip-1186

I find the implementation and can do it. But may I ask when do we need eth_getProof? I thought we only need transaction proof and receipt proof.

just forget it , this one just is a another way that deal the cross chain system

@GalaxySciTech GalaxySciTech merged commit 412b38f into master Oct 24, 2023
1 of 2 checks passed
@GalaxySciTech GalaxySciTech deleted the gerui-trie-proof branch October 24, 2023 06:07
@GalaxySciTech GalaxySciTech restored the gerui-trie-proof branch October 31, 2023 06:52
wanwiset25 added a commit that referenced this pull request Oct 31, 2023
* API GetReceiptProof

* API GetReceiptProof test

* add ext interface

* Trieproof fix (#96)

Trieproof fix

* add GetTransactionProof to api

* merge two API into GetTransactionAndReceiptProof

---------

Co-authored-by: wanwiset25 <wanwiset25@gmail.com>
Co-authored-by: Galaxy <30950645+GalaxySciTech@users.noreply.github.com>
wanwiset25 added a commit that referenced this pull request Nov 1, 2023
* cicd test

* typo

* test2

* fix

* fix2

* fix3

* trig

* change workflow name

* chekout step

* fix

* adjust params

* re org files

* bug

* clean output

* Feature testdevelop4 (#113)

* final update

* name

* name

* add enable-0x-prefix flag (#102)

* enable 0x test flag

* rm test file

* change script repo

* API GetTransactionProof, GetReceiptProof (#94)

* API GetReceiptProof

* API GetReceiptProof test

* add ext interface

* Trieproof fix (#96)

Trieproof fix

* add GetTransactionProof to api

* merge two API into GetTransactionAndReceiptProof

---------

Co-authored-by: wanwiset25 <wanwiset25@gmail.com>
Co-authored-by: Galaxy <30950645+GalaxySciTech@users.noreply.github.com>

* first copy  v1.10

* fix all errs outside rpc by adding functions

* fix rpc errors

* upgrade xdc to use gorilla for websocket instead of the native net

* upgrade go to 1.14

* fix issue with the duplicated name of max_socket_path_size from c

* change to self common

* add back the missing committed input parameter

* EpochNumber ummarshal

---------

Co-authored-by: Daniel Liu <139250065@qq.com>
Co-authored-by: wgr523 <wgr523@gmail.com>
Co-authored-by: Galaxy <30950645+GalaxySciTech@users.noreply.github.com>
Co-authored-by: Jianrong <wjrjerome@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants