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

accounts/abi/bind: link dependent libs in deploy #19718

Merged
merged 10 commits into from
Jul 8, 2019

Conversation

gballet
Copy link
Member

@gballet gballet commented Jun 14, 2019

This PR addresses #17010

Upon loading the solc output, abigen will make a list of potential "linker" references to pass the template. If a linker reference is found, a call to the library deployment code will be added to the contact deployment code, and the bytecode will be updated with the deployment address.

I also had to change the way bind was being tested: now the test has to specify all dependent ABIs and bytecodes, as well as the list of contract dependencies. Basically, this assumes an input a bit closer to what abigen provides to the Bind function.

@gballet gballet changed the title [WIP] accounts, abigen: link dependent libs in deploy accounts, abigen: link dependent libs in deploy Jun 17, 2019
@gballet gballet requested review from karalabe and ligi June 17, 2019 15:55
@gballet
Copy link
Member Author

gballet commented Jun 17, 2019

@ligi could you please have a look at the java code being generated?

@gballet gballet closed this Jun 17, 2019
@gballet gballet reopened this Jun 17, 2019
@gballet
Copy link
Member Author

gballet commented Jun 17, 2019

Didn't mean to close this 🤦‍♂️

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM (haven't tested)

@fjl fjl changed the title accounts, abigen: link dependent libs in deploy accounts/abi/bind: link dependent libs in deploy Jun 24, 2019
@gballet gballet force-pushed the abigen-support-mixins branch 3 times, most recently from f60e9c9 to 6268729 Compare July 3, 2019 09:34
@gballet gballet force-pushed the abigen-support-mixins branch from 6268729 to 1ee8697 Compare July 3, 2019 16:02
@gballet gballet added this to the 1.9.0 milestone Jul 3, 2019
@rjl493456442 rjl493456442 self-assigned this Jul 4, 2019
accounts/abi/bind/bind.go Outdated Show resolved Hide resolved
cmd/abigen/main.go Show resolved Hide resolved
@rjl493456442
Copy link
Member

rjl493456442 commented Jul 5, 2019

A few changes I made

diff --git a/cmd/abigen/main.go b/cmd/abigen/main.go
index 16cb0df08..ab70b6f46 100644
--- a/cmd/abigen/main.go
+++ b/cmd/abigen/main.go
@@ -22,6 +22,7 @@ import (
 	"fmt"
 	"io/ioutil"
 	"os"
 	"strings"
 
 	"github.com/ethereum/go-ethereum/accounts/abi/bind"
@@ -82,7 +83,7 @@ func main() {
 		bins  []string
 		types []string
 		sigs  []map[string]string
-		libs  map[string]string
+		libs  = make(map[string]string)
 	)
 	if *solFlag != "" || *vyFlag != "" || *abiFlag == "-" {
 		// Generate the list of types to exclude from binding
@@ -151,7 +152,19 @@ func main() {
 				os.Exit(-1)
 			}
 		}

But we can't get the library bin from the input, how can we deploy the library first?

@rjl493456442
Copy link
Member

rjl493456442 commented Jul 5, 2019

The golang part is good to me. But I try the java binding, get these errors

bytecode.replace("__$812de29bd0a57d8fddaebd9e2f77569c6c$__", setInst.Address);

Error: can't resolve method replace(java.lang.String, org.etherem.geth.Address)

should be bytecode.replace("__$812de29bd0a57d8fddaebd9e2f77569c6c$__", setInst.Address.getHex().substring(2));

And also if we have multi contracts(e.g. contract + library), we will have 2 java public classes which can't be defined in single java class file.
For library class, we should remove the public.

Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

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

LGTM

@gballet gballet merged commit 5bc9ccf into ethereum:master Jul 8, 2019
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Dec 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Dec 21, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Dec 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Dec 28, 2024
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.

3 participants