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

feat: precompiled contract poc #172

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

dudong2
Copy link

@dudong2 dudong2 commented Sep 4, 2024

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@dudong2 dudong2 changed the title feat: App level precompile feat: precompiled contract poc Sep 4, 2024
@dudong2 dudong2 self-assigned this Sep 9, 2024
@dudong2 dudong2 added the enhancement New feature or request label Sep 9, 2024
defer store.mtx.Unlock()

// deep copy of cValue
// TODO(dudong2): deep copy? or shallow copy?
Copy link
Collaborator

Choose a reason for hiding this comment

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

[Question] Is there any other reason you comment TODO?

If type of val.value is slice of other reference type, it will be shallow copied but in this case, deep copy takes place.

I executed this code in golang playground and checked built-in copy function copies value of reference type variable.

    a := []byte("abcd")
	b := make([]byte, len(a))
	copy(b, a)

	a = []byte("1234")

	fmt.Println(&a[0] == &b[0])
	fmt.Println(a)
	fmt.Println(b)

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure if the copy of cValue needs to be a deep copy. I'd go with a deep copy first, and if there are performance issues, i'll need to devise another method.


// deep copy of cValue
// TODO(dudong2): deep copy? or shallow copy?
cache2 := make(map[string]*cValue, len(store.cache))
Copy link
Collaborator

Choose a reason for hiding this comment

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

[Suggestion] It is chores but I suggest, we can use copiedCache, clonedCache instaed of cache2. This suggestion can be applied to other changes of this PR

Copy link
Author

Choose a reason for hiding this comment

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

updated.

Copy link
Collaborator

Choose a reason for hiding this comment

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

checked.

Copy link
Collaborator

@cloudgray cloudgray left a comment

Choose a reason for hiding this comment

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

LGTM, but I had a few questions out of curiosity, so I left some comments

@cloudgray cloudgray self-requested a review September 11, 2024 06:18
@jasonsong0
Copy link

LGTM.

[suggestion]
Since cacheKVStore can only have KVStore as its parent, a deep copy is necessary.
It would be good to check the overhead of deep copying and consider improving this later.

Copy link
Collaborator

@cloudgray cloudgray left a comment

Choose a reason for hiding this comment

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

LGTM!

@dudong2 dudong2 force-pushed the feat/precompiled-bank-contract branch from 2df2237 to 746c27b Compare September 11, 2024 10:28
@dudong2
Copy link
Author

dudong2 commented Sep 11, 2024

rebased due to Send restriction PoC

@dudong2 dudong2 merged commit d2486fb into basechain/abci1.0/develop Sep 11, 2024
19 of 24 checks passed
@dudong2 dudong2 deleted the feat/precompiled-bank-contract branch September 11, 2024 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants