Skip to content

Commit

Permalink
Sync master subnet-evm latest (#27)
Browse files Browse the repository at this point in the history
* - Adding missing import "encoding/json" (used in Stringer-method) (ava-labs#465)

- re-ordering of imports

* fix allow list comments (ava-labs#469)

* fix allow list comments

* cleaner sentences

* use preallocated big nums

* infer allow list role type

* add nil checks (ava-labs#473)

* add nil checks

* add unit test

* use non nil config

* use non-nil configs

---------

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* Warp backend interface and implementation (ava-labs#452)

* base warp backend

* add signature caching

* add docs

* error handling

* pr fixes

* hash unsigned message for key

* quick pr fixes and merge

* save signature instead of whole msg

* use avaGO cache

* rename warpBackend and docs

* fix nits

* Update plugin/evm/warp_backend.go

* Update plugin/evm/warp_backend.go

* fix pr nits

* pr fixes and testing

* type check for caching

* fix imports

* use memdb and remove extra test

* remove unused

* fix imports

* saving message in db and pr fixes

* update copyright

* update backend variable naming

* add comment about saving db vs cache

* Add documentation section to PR template (ava-labs#484)

* remove current rules (ava-labs#481)

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

* add documentation guidelines (ava-labs#486)

* add documentation guidelines

* fix

* parseInt from ENV var (ava-labs#491)

* Add generate precompile script to fix CGO flags issue (ava-labs#489)

* try to fix lint job (ava-labs#499)

* build with avago v1.9.8 (ava-labs#498)

* build with avago v1.9.8

* add indirect deps

* build fix

* another build fix

* try to fix lint job

* Signature Request Handler (ava-labs#459)

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>
Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

* Update codeowners (ava-labs#492)

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

* Get signature endpoint: alternative PR with different packaging (ava-labs#507)

* base warp backend

* add signature caching

* add docs

* error handling

* pr fixes

* basic signature request

* hash unsigned message for key

* implement new Request and RequestHandler interfaces

* signature handler impl without constructing one

* fix import

* quick pr fixes and merge

* quick pr fixes and merge

* save signature instead of whole msg

* use avaGO cache

* rename warpBackend and docs

* fix nits

* Update plugin/evm/warp_backend.go

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* Update plugin/evm/warp_backend.go

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* fix pr nits

* pr fixes and testing

* type check for caching

* handlers and request before tests

* fix imports

* signature handler with stats and test

* use memdb and remove extra test

* remove unused

* fix imports

* fix imports

* nit

* update license year

* use require noError

* saving message in db and pr fixes

* create noop signature handler and refactor code handler

* get signature endpoint

* add api arg to evm client

* Update sync/handlers/handler.go

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* update backend return value

* refactor handlers to network handler

* change constructor of handler stats

* pr cleanups

* warp api

* initialize warp backend

* build fix

* wip

* warp api follows eth api pattern

* cleanup and comments

* clean up response

* fix warp client return type

* nits for get-signature-endpoint (ava-labs#502)

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>
Co-authored-by: Ceyhun Onur <ceyhun.onur@avalabs.org>
Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com>

* resolve merge conflict

* warp: Group packages for symmetry w/ sync

* more reshuffle

* more shuffle

* pr comments

* fix

* update to []byte

* update svc return type

* rename arg

* fix type

* add stats pkg

---------

Co-authored-by: Matthew Lam <matthew.lam@avalabs.org>
Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>
Co-authored-by: cam-schultz <camschultz32@gmail.com>
Co-authored-by: Ceyhun Onur <ceyhun.onur@avalabs.org>
Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com>

* Update github actions to ignore rcs (ava-labs#521)

* Remove unnecessary gasprice updater logic and tests (ava-labs#514)

* Remove unnecessary gasprice updater logic and tests

* Remove comment referencing gas price updater

* Revert default price limit change

* Move set min fee back to vm.go

* Update to retain previous tx pool gas price setting behavior

* Bump avalanchego to v1.9.9-rc.4 (ava-labs#526)

* Bump avalanchego to v1.9.9-rc.4

* Fix imports

* Bump compatibility.json for latest avalanchego release

* Bump AvalancheGo dep to v1.9.9 (ava-labs#530)

* Update AvalancheGo compatibility (ava-labs#531)

* Start v0.4.10 release cycle (ava-labs#533)

* Stateful Precompile Improvements (ava-labs#389)

* move inline string ABIs to separate files and embed them (ava-labs#383)

* move inline string ABIs to separate files and embed them

* fix tests

* fix tests

* unexport function

* Update accounts/abi/bind/bind.go

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

* fix func name

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

* replace getByKey with getByAddress (ava-labs#395)

* rework on panics in precompiles (ava-labs#418)

* rework on panics in precompiles

* Update precompile/allow_list.go

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* Update precompile/fee_config_manager.go

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* Update precompile/fee_config_manager.go

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* fix reviews

* wrap errors in ConfigurePrecompiles

* cleaner errors

* Update utils.go

* Update miner/worker.go

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* Update core/state_processor.go

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* Precompile Specific Packages (ava-labs#420)

* rework on panics in precompiles

* Update precompile/allow_list.go

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* Update precompile/fee_config_manager.go

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* Update precompile/fee_config_manager.go

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* fix reviews

* wrap errors in ConfigurePrecompiles

* cleaner errors

* move reward manager precompile to package (WIP)

* rename files

* fix abi path

* move typecheck

* move precompiles to their own packages

* refactor precompile template

* remove test file

* upate comments

* rm test files

* new allowlist package

* Update precompile/utils.go

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

* Update precompile/nativeminter/contract_native_minter.go

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

* Update precompile/nativeminter/contract_native_minter.go

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

* Update precompile/utils.go

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

* Update precompile/nativeminter/contract_native_minter.go

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

* fix nits

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>
Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

* rename fee manager config struct (ava-labs#427)

* rename struct

* rename fee config managers to fee managers

* fix comments

* Generalized upgrades rb (ava-labs#434)

* introduce precompiles as registrable modules

* add precompile specific contract tests

* remove print debug

* add unmarshal tests

* remove unnecessary func

* fix initial disabled value

* register all modules in core/evm/contract_stateful

* more refactor & test fix

* sync template

* fix more tests

* rename file

* add comment

* rename

* fix linter

* use require error contains

* remove whitespace

* trim mock interface

* sort steps

* reviews

* Update precompile/stateful_precompile_module.go

* Update params/precompile_config.go

* Update params/precompile_config.go

* fix reviews

* add new module to configs and group module functions

* generalized-upgrades-rb review (ava-labs#474)

* keep genesis disabled fix

* nits

* nits

* nit

* review fixes

* Update precompile/allowlist/allowlist.go

* use address in map

* fix linter for embedded keys

* update err messages

* more err update

* remove unnecessary function (ava-labs#478)

* Start work on breaking cyclic dependency (ava-labs#496)

* Update core/state_processor.go

* fix reviews

* Update precompile/contracts/txallowlist/contract_test.go

* Generalized upgrades rb nits0 (ava-labs#512)

* Minor improvements

* restore readOnly

* more updates

* Add back readOnly to allow list tests

* Precompile improvements merge (ava-labs#513)

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>
Co-authored-by: Ceyhun Onur <ceyhun.onur@avalabs.org>
Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com>
Co-authored-by: Matthew Lam <matthew.lam@avalabs.org>
Co-authored-by: cam-schultz <camschultz32@gmail.com>
Co-authored-by: omahs <73983677+omahs@users.noreply.github.com>
Co-authored-by: Anusha <63559942+anusha-ctrl@users.noreply.github.com>
Co-authored-by: Hagen Hübel <hhuebel@itinance.com>
Co-authored-by: minghinmatthewlam <matthew.lam@avalabs.org>
Fix: typos (ava-labs#428)
fix allow list comments (ava-labs#469)
fix CGO flags issue (ava-labs#489)
fix lint job (ava-labs#499)

* review fixes

* minor nits

* fix precompile generator

* fix fee manager config test

* remove debug files

* Update core/state_processor.go

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* fix comments

* restore statedb ordering

* fix configure in reward manager

* precompiles: adds a regression test for the IsDisabled case in AvalancheRules (ava-labs#515)

* Rename configs: alternative (ava-labs#520)

* alternative renaming for precompile configs

* fixes

* update naming

* rename to AllowListConfig

* simplify

* move blackhole check to module registerer (ava-labs#523)

* move blackhole check to module registerer

* check blackhole first

* add unit test

* Add test case for registering module outside of reserved range

---------

Co-authored-by: Aaron Buchwald <aaron.buchwald56@gmail.com>

* precompile: improve test structure (ava-labs#517)

* refactor precompile tests

* minor improvements

* nit

* fix merge

* rename package

* pr comments

* rm file

* merge AllowListTests

* pr comments

* explicit BeforeHook

* wspace

* Mark TestTransactionIndices flaky

---------

Co-authored-by: Aaron Buchwald <aaron.buchwald56@gmail.com>

* nit improvements (ava-labs#529)

* nit improvements

* move comments to README

* Update cmd/precompilegen/template-readme.md

* Rename new config (ava-labs#528)

* rename configurator's new config to make config

* use new built-in to create new config instance

* precompile: just nits (ava-labs#534)

* fix e2e comment in readme (ava-labs#540)

* fix config template for precompilegen (ava-labs#538)

* fix config template for precompilegen

* nits

* nit

* nits

* Update compatibility in README for v0.4.10 (ava-labs#542)

* Bump minimum golang version to v1.20.1 (ava-labs#548)

* Bump minimum golang version to 1.20.1

* Remove debug flag from gh action release

* add whitespace (ava-labs#544)

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* Set minimum golang version to go1.19.6 (ava-labs#551)

* add custom marshaller for GetChainConfigResponse api (ava-labs#546)

* add yet another custom marshaller to GetChainConfigResponse api

* enforce a json len before allocation

* Move chain config wrapper type to params/ and add test

* Fix trailing newline

* Remove flaky unit test

* Add back unit test with JSONeq

---------

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>

* Start coreth migration (ava-labs#552)

* Start coreth migration

* Bump version to v0.4.11 and avalanchego dep

* goimports core/blockchain.go

* Update compatibility.json

* Update compatibility in README

* Bump avalanchego dep to v1.9.10

* Start release cycle v0.4.12 (ava-labs#559)

* start v0.4.12 release cycle

* add setup action to lint ci for proper go version

* Bump version in plugin/evm/version.go

* Remove go version pin

* Revert "Remove go version pin"

This reverts commit e651beb.

* bump golangci-lint-acion to @V3

* bump golangci lint

* try 1.48

* golangci-lint v1.51 and goimports leveldb file

* migrate linting changes from coreth

* goimports and fix diagram comments

* Fix bad goimports changes

---------

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

* remove stderr pipelining (ava-labs#562)

* Add ChainConfig JSON Unmarshaller (ava-labs#554)

* add unmarshaller

* add comments

* Update codeql to v2 (ava-labs#566)

* state modifications as network upgrade (ava-labs#549)

Co-authored-by: Aaron Buchwald <aaron.buchwald56@gmail.com>

* Fix Dockerfile and add Build Image to GH Actions (ava-labs#561)

* Remove specified git version to avoid downgrades breaking docker build

* Add build docker image to unit test action

* Update to use current branch instead of commit for docker image build

* Update docker image script to push image if env var is set

* Add new line to build image script

* Update scripts/constants.sh

Co-authored-by: Sam Batschelet <sam.batschelet@avalabs.org>

* Update docker login

* Update build image action

* Update gh action

* checkout for docker image build

* Set build image ID in gh action with github.ref_name

* Separate CI and release

* remove extra copy

* Update name

* Update variable used in build image id

* Update set var

* Update dockerhub repo

* Revert dockerhub repo name chnge and use Subnet-EVM in tag name

---------

Co-authored-by: Sam Batschelet <sam.batschelet@avalabs.org>

* add compatibility to readme (ava-labs#568)

* Precompile pre post handling (ava-labs#524)

* Re-apply warp precompile interface changes

* Address nits

* Separate predicate storage slot preparation into separate function in statedb

* fix lint

* improve miner enforcePredicates comment

* Add HashSliceToBytes test case for empty slice

* Address comments

* Address comments WIP

* Pre+post handling diff for shared mem precompile

* Separate proposer and general precompile predicates

* Update ShouldVerifyWithContext to return true iff proposer predicate is specified

* Add checkPredicates unit test

* Update .gitignore

* goimports

* update

* goimports config

* Address PR review comments and improve comments

* Fix typo

* Address PR comments

* Add rules into PrepareAccessList

* Only copy bytes in preparePredicates if predicate precompile is active

* Address PR comments

---------

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>

* Warp preparation (ava-labs#573)

* Add warp precompile preparation

* Update hash slice packing

* Remove unnecessary local var

* Add VM type assertion

* Enable Warp API by default

* convert from int->uint for more clarity (ava-labs#575)

* release tickers on shutdown (ava-labs#574)

* release tickers on shutdown

* move shutdownWg.done to other defer block

* simplify functionSignatureRegex (ava-labs#578)

* Remove unused imgs from repo (ava-labs#580)

* Matches go-ethereum/pull/26912/files (ava-labs#582)

* Add ignore unnecessary import to precompile contract template (ava-labs#581)

* trie, accounts/abi: nits: adds err checks (ava-labs#583)

* Adds a test for PeerTracker (ava-labs#576)

* upgrade avalanche go and add logs

* update avalanche go version

* add gotenv and get env variables from .env file

* Revert "add gotenv and get env variables from .env file"

This reverts commit 87b0007.

* refactoring

* upgrade avalanche go to v1.9.14

* use GRPC_ prefix in env variable to inject env variables

---------

Co-authored-by: Hagen Hübel <hhuebel@itinance.com>
Co-authored-by: Ceyhun Onur <ceyhun.onur@avalabs.org>
Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>
Co-authored-by: minghinmatthewlam <matthew.lam@avalabs.org>
Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com>
Co-authored-by: cam-schultz <camschultz32@gmail.com>
Co-authored-by: Patrick O'Grady <prohb125@gmail.com>
Co-authored-by: Sam Batschelet <sam.batschelet@avalabs.org>
  • Loading branch information
10 people authored Mar 27, 2023
1 parent 49a5611 commit dbb75b5
Show file tree
Hide file tree
Showing 205 changed files with 8,251 additions and 5,524 deletions.
10 changes: 4 additions & 6 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

# review whenever someone opens a pull request.

* @ceyonur @darioush @patrick-ogrady @aaronbuchwald
* @ceyonur @darioush @aaronbuchwald

# These owners will be the owner of the contract-examples sub-directory.

contract-examples/ @dasconnor @anusha-ctrl

# These owners will be the owner of the scripts sub-directory.
# Specific directories:

peer/ @anusha-ctrl
contract-examples/ @anusha-ctrl
scripts/ @anusha-ctrl
17 changes: 14 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,31 @@ well as our review and merge procedures quick and simple.

## Coding guidelines

Please make sure your contributions adhere to our coding guidelines:
Please make sure your contributions adhere to our coding and documentation
guidelines:

- Code must adhere to the official Go
[formatting](https://golang.org/doc/effective_go.html#formatting) guidelines
(i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
- Code must be documented adhering to the official Go
[commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
- Pull requests need to be based on and opened against the `master` branch.
- Pull reuqests should include a detailed description
- Commits are required to be signed. See [here](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits)
for information on signing commits.
- Commit messages should be prefixed with the package(s) they modify.
- E.g. "eth, rpc: make trace configs optional"

## Documentation guidelines

- Code should be well commented, so it is easier to read and maintain.
Any complex sections or invariants should be documented explicitly.
- Code must be documented adhering to the official Go
[commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
- Changes with user facing impact (e.g., addition or modification of flags and
options) should be accompanied by a link to a pull request to the [avalanche-docs](https://github.com/ava-labs/avalanche-docs)
repository. [example](https://github.com/ava-labs/avalanche-docs/pull/1119/files).
- Changes that modify a package significantly or add new features should
either update the existing or include a new `README.md` file in that package.

## Can I have feature X

Before you submit a feature request, please check and make sure that it isn't
Expand Down
2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
## How this works

## How this was tested

## How is this documented
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ jobs:
go-version: ${{ matrix.go }}
- run: go mod download
shell: bash
- run: VALIDATOR_PRIVATE_KEY=31b571bf6894a248831ff937bb49f7754509fe93bbd2517c9c73c4144c0e97dc go test ./plugin/evm/... -test.v
- run: GRPC_VALIDATOR_PRIVATE_KEY=31b571bf6894a248831ff937bb49f7754509fe93bbd2517c9c73c4144c0e97dc go test ./plugin/evm/... -test.v
shell: bash
30 changes: 1 addition & 29 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ run:
linters:
disable-all: true
enable:
- deadcode
- goconst
- goimports
- gosimple
- govet
- ineffassign
- misspell
- unconvert
- varcheck
- unused
- whitespace

linters-settings:
Expand All @@ -29,30 +28,3 @@ linters-settings:
goconst:
min-len: 3 # minimum length of string constant
min-occurrences: 6 # minimum number of occurrences

issues:
exclude-rules:
- path: crypto/blake2b/
linters:
- deadcode
- path: crypto/bn256/cloudflare
linters:
- deadcode
- path: p2p/discv5/
linters:
- deadcode
- path: core/vm/instructions_test.go
linters:
- goconst
- path: cmd/faucet/
linters:
- deadcode
- path: core/types/gen_account_rlp.go
linters:
- goimports
- path: core/types/gen_header_rlp.go
linters:
- goimports
- path: core/types/gen_log_rlp.go
linters:
- goimports
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
ARG AVALANCHE_VERSION

# ============= Compilation Stage ================
FROM golang:1.18.5-buster AS builder
RUN apt-get update && apt-get install -y --no-install-recommends bash=5.0-4 git=1:2.20.1-2+deb10u3 make=4.2.1-1.2 gcc=4:8.3.0-1 musl-dev=1.1.21-2 ca-certificates=20200601~deb10u2 linux-headers-amd64
FROM golang:1.19.6-buster AS builder
RUN apt-get update && apt-get install -y --no-install-recommends bash=5.0-4 make=4.2.1-1.2 gcc=4:8.3.0-1 musl-dev=1.1.21-2 ca-certificates=20200601~deb10u2 linux-headers-amd64

WORKDIR /build

Expand All @@ -15,7 +15,7 @@ WORKDIR /build
COPY go.mod go.sum avalanchego* ./

# Download avalanche dependencies using go mod
RUN go mod download && go mod tidy -compat=1.18
RUN go mod download && go mod tidy -compat=1.19

# Copy the code into the container
COPY . .
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hubble v2

To run a fresh local network - run `VALIDATOR_PRIVATE_KEY=31b571bf6894a248831ff937bb49f7754509fe93bbd2517c9c73c4144c0e97dc ./scripts/run_local.sh`
To run a fresh local network - run `GRPC_VALIDATOR_PRIVATE_KEY=31b571bf6894a248831ff937bb49f7754509fe93bbd2517c9c73c4144c0e97dc ./scripts/run_local.sh`
To run on the same network with updated evm code(it preserves all evm state) - run `./scripts/upgrade_local.sh`
To kill network - run `avalanche network clean`

Expand Down Expand Up @@ -53,7 +53,11 @@ The Subnet EVM runs in a separate process from the main AvalancheGo process and
[v0.4.5] AvalancheGo@v1.9.4 (Protocol Version: 20)
[v0.4.6] AvalancheGo@v1.9.4 (Protocol Version: 20)
[v0.4.7] AvalancheGo@v1.9.5 (Protocol Version: 21)
[v0.4.8] AvalancheGo@v1.9.6-v1.9.7 (Protocol Version: 22)
[v0.4.8] AvalancheGo@v1.9.6-v1.9.8 (Protocol Version: 22)
[v0.4.9] AvalancheGo@v1.9.9 (Protocol Version: 23)
[v0.4.10] AvalancheGo@v1.9.9 (Protocol Version: 23)
[v0.4.11] AvalancheGo@v1.9.10 (Protocol Version: 24)
[v0.4.12] AvalancheGo@v1.9.10 (Protocol Version: 24)
```

## API
Expand Down Expand Up @@ -92,7 +96,7 @@ To support these changes, there have been a number of changes to the SubnetEVM b

### Clone Subnet-evm

First install Go 1.18.1 or later. Follow the instructions [here](https://golang.org/doc/install). You can verify by running `go version`.
First install Go 1.19.6 or later. Follow the instructions [here](https://golang.org/doc/install). You can verify by running `go version`.

Set `$GOPATH` environment variable properly for Go to look for Go Workspaces. Please read [this](https://go.dev/doc/gopath_code) for details. You can verify by running `echo $GOPATH`.

Expand Down
6 changes: 5 additions & 1 deletion accounts/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) {
// Returns the topics for the event including the event signature (if non-anonymous event) and
// hashes derived from indexed arguments and the packed data of non-indexed args according to
// the event ABI specification.
// The order of arguments must match the order of the event definition.
// https://docs.soliditylang.org/en/v0.8.17/abi-spec.html#indexed-event-encoding.
// Note: PackEvent does not support array (fixed or dynamic-size) or struct types.
func (abi ABI) PackEvent(name string, args ...interface{}) ([]common.Hash, []byte, error) {
Expand Down Expand Up @@ -364,7 +365,10 @@ func UnpackRevert(data []byte) (string, error) {
if !bytes.Equal(data[:4], revertSelector) {
return "", errors.New("invalid data for unpacking")
}
typ, _ := NewType("string", "", nil)
typ, err := NewType("string", "", nil)
if err != nil {
return "", err
}
unpacked, err := (Arguments{{Type: typ}}).Unpack(data[4:])
if err != nil {
return "", err
Expand Down
34 changes: 20 additions & 14 deletions accounts/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ func TestInvalidABI(t *testing.T) {

// TestConstructor tests a constructor function.
// The test is based on the following contract:
// contract TestConstructor {
// constructor(uint256 a, uint256 b) public{}
//
// contract TestConstructor {
// constructor(uint256 a, uint256 b) public{}
// }
func TestConstructor(t *testing.T) {
json := `[{ "inputs": [{"internalType": "uint256","name": "a","type": "uint256" },{ "internalType": "uint256","name": "b","type": "uint256"}],"stateMutability": "nonpayable","type": "constructor"}]`
Expand Down Expand Up @@ -735,16 +736,19 @@ func TestBareEvents(t *testing.T) {
}

// TestUnpackEvent is based on this contract:
// contract T {
// event received(address sender, uint amount, bytes memo);
// event receivedAddr(address sender);
// function receive(bytes memo) external payable {
// received(msg.sender, msg.value, memo);
// receivedAddr(msg.sender);
// }
// }
//
// contract T {
// event received(address sender, uint amount, bytes memo);
// event receivedAddr(address sender);
// function receive(bytes memo) external payable {
// received(msg.sender, msg.value, memo);
// receivedAddr(msg.sender);
// }
// }
//
// When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt:
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
//
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
func TestUnpackEvent(t *testing.T) {
const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"}]`
abi, err := JSON(strings.NewReader(abiJSON))
Expand Down Expand Up @@ -1089,8 +1093,9 @@ func TestDoubleDuplicateMethodNames(t *testing.T) {
// TestDoubleDuplicateEventNames checks that if send0 already exists, there won't be a name
// conflict and that the second send event will be renamed send1.
// The test runs the abi of the following contract.
// contract DuplicateEvent {
// event send(uint256 a);
//
// contract DuplicateEvent {
// event send(uint256 a);
// event send0();
// event send();
// }
Expand All @@ -1117,7 +1122,8 @@ func TestDoubleDuplicateEventNames(t *testing.T) {
// TestUnnamedEventParam checks that an event with unnamed parameters is
// correctly handled.
// The test runs the abi of the following contract.
// contract TestEvent {
//
// contract TestEvent {
// event send(uint256, uint256);
// }
func TestUnnamedEventParam(t *testing.T) {
Expand Down
23 changes: 12 additions & 11 deletions accounts/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ func TestSimulatedBackend(t *testing.T) {

var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")

// the following is based on this contract:
// contract T {
// event received(address sender, uint amount, bytes memo);
// event receivedAddr(address sender);
// the following is based on this contract:
// contract T {
// event received(address sender, uint amount, bytes memo);
// event receivedAddr(address sender);
//
// function receive(bytes calldata memo) external payable returns (string memory res) {
// emit received(msg.sender, msg.value, memo);
// emit receivedAddr(msg.sender);
// return "hello world";
// }
// }
// function receive(bytes calldata memo) external payable returns (string memory res) {
// emit received(msg.sender, msg.value, memo);
// emit receivedAddr(msg.sender);
// return "hello world";
// }
// }
const abiJSON = `[ { "constant": false, "inputs": [ { "name": "memo", "type": "bytes" } ], "name": "receive", "outputs": [ { "name": "res", "type": "string" } ], "payable": true, "stateMutability": "payable", "type": "function" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "sender", "type": "address" }, { "indexed": false, "name": "amount", "type": "uint256" }, { "indexed": false, "name": "memo", "type": "bytes" } ], "name": "received", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "sender", "type": "address" } ], "name": "receivedAddr", "type": "event" } ]`
const abiBin = `0x608060405234801561001057600080fd5b506102a0806100206000396000f3fe60806040526004361061003b576000357c010000000000000000000000000000000000000000000000000000000090048063a69b6ed014610040575b600080fd5b6100b76004803603602081101561005657600080fd5b810190808035906020019064010000000081111561007357600080fd5b82018360208201111561008557600080fd5b803590602001918460018302840111640100000000831117156100a757600080fd5b9091929391929390505050610132565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f75780820151818401526020810190506100dc565b50505050905090810190601f1680156101245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60607f75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed33348585604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509550505050505060405180910390a17f46923992397eac56cf13058aced2a1871933622717e27b24eabc13bf9dd329c833604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a16040805190810160405280600b81526020017f68656c6c6f20776f726c6400000000000000000000000000000000000000000081525090509291505056fea165627a7a72305820ff0c57dad254cfeda48c9cfb47f1353a558bccb4d1bc31da1dae69315772d29e0029`
const deployedCode = `60806040526004361061003b576000357c010000000000000000000000000000000000000000000000000000000090048063a69b6ed014610040575b600080fd5b6100b76004803603602081101561005657600080fd5b810190808035906020019064010000000081111561007357600080fd5b82018360208201111561008557600080fd5b803590602001918460018302840111640100000000831117156100a757600080fd5b9091929391929390505050610132565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f75780820151818401526020810190506100dc565b50505050905090810190601f1680156101245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60607f75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed33348585604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509550505050505060405180910390a17f46923992397eac56cf13058aced2a1871933622717e27b24eabc13bf9dd329c833604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a16040805190810160405280600b81526020017f68656c6c6f20776f726c6400000000000000000000000000000000000000000081525090509291505056fea165627a7a72305820ff0c57dad254cfeda48c9cfb47f1353a558bccb4d1bc31da1dae69315772d29e0029`
Expand Down Expand Up @@ -1015,7 +1015,8 @@ func TestCodeAt(t *testing.T) {
}

// When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt:
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
//
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
func TestPendingAndCallContract(t *testing.T) {
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
sim := simTestBackend(testAddr)
Expand Down
Loading

0 comments on commit dbb75b5

Please sign in to comment.