Merge remote-tracking branch 'origin/master' into sync-master-to-main

This commit is contained in:
Cal Bera 2025-07-04 11:17:31 -07:00
commit dfea3523b4
99 changed files with 2392 additions and 888 deletions

View file

@ -0,0 +1,10 @@
{
"permissions": {
"allow": [
"Bash(git add:*)",
"Bash(git commit:*)",
"Bash(git push:*)"
],
"deny": []
}
}

View file

@ -0,0 +1,179 @@
on:
push:
branches:
- "master"
tags:
- "v*"
workflow_dispatch:
jobs:
linux-intel:
name: Linux Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.24
cache: false
- name: Install cross toolchain
run: |
apt-get update
apt-get -yq --no-install-suggests --no-install-recommends install gcc-multilib
- name: Build (amd64)
run: |
go run build/ci.go install -static -arch amd64 -dlgo
- name: Create/upload archive (amd64)
run: |
go run build/ci.go archive -arch amd64 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
rm -f build/bin/*
env:
LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }}
AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }}
- name: Build (386)
run: |
go run build/ci.go install -static -arch 386 -dlgo
- name: Create/upload archive (386)
run: |
go run build/ci.go archive -arch 386 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
rm -f build/bin/*
env:
LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }}
AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }}
linux-arm:
name: Linux Build (arm)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.24
cache: false
- name: Install cross toolchain
run: |
apt-get update
apt-get -yq --no-install-suggests --no-install-recommends install gcc-arm-linux-gnueabi libc6-dev-armel-cross gcc-arm-linux-gnueabihf libc6-dev-armhf-cross gcc-aarch64-linux-gnu libc6-dev-arm64-cross
ln -s /usr/include/asm-generic /usr/include/asm
- name: Build (arm64)
run: |
go run build/ci.go install -static -dlgo -arch arm64 -cc aarch64-linux-gnu-gcc
- name: Create/upload archive (arm64)
run: |
go run build/ci.go archive -arch arm64 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
rm -fr build/bin/*
env:
LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }}
AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }}
- name: Run build (arm5)
run: |
go run build/ci.go install -static -dlgo -arch arm -cc arm-linux-gnueabi-gcc
env:
GOARM: "5"
- name: Create/upload archive (arm5)
run: |
go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
env:
GOARM: "5"
LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }}
AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }}
- name: Run build (arm6)
run: |
go run build/ci.go install -static -dlgo -arch arm -cc arm-linux-gnueabi-gcc
env:
GOARM: "6"
- name: Create/upload archive (arm6)
run: |
go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
rm -fr build/bin/*
env:
GOARM: "6"
LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }}
AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }}
- name: Run build (arm7)
run: |
go run build/ci.go install -static -dlgo -arch arm -cc arm-linux-gnueabi-gcc
env:
GOARM: "7"
- name: Create/upload archive (arm7)
run: |
go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
rm -fr build/bin/*
env:
GOARM: "7"
LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }}
AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }}
windows:
name: Windows Build
runs-on: "win-11"
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.24
cache: false
# Note: gcc.exe only works properly if the corresponding bin/ directory is
# contained in PATH.
- name: "Build (amd64)"
shell: cmd
run: |
set PATH=%GETH_MINGW%\bin;%PATH%
go run build/ci.go install -dlgo -arch amd64 -cc %GETH_MINGW%\bin\gcc.exe
env:
GETH_MINGW: 'C:\msys64\mingw64'
- name: "Build (386)"
shell: cmd
run: |
set PATH=%GETH_MINGW%\bin;%PATH%
go run build/ci.go install -dlgo -arch 386 -cc %GETH_MINGW%\bin\gcc.exe
env:
GETH_MINGW: 'C:\msys64\mingw32'
docker:
name: Docker Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.24
cache: false
- name: Run docker build
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
run: |
go run build/ci.go dockerx -platform linux/amd64,linux/arm64,linux/riscv64 -upload

View file

@ -281,7 +281,7 @@ func TestBindingV2ConvertedV1Tests(t *testing.T) {
}
// Set this environment variable to regenerate the test outputs.
if os.Getenv("WRITE_TEST_FILES") != "" {
if err := os.WriteFile((fname), []byte(have), 0666); err != nil {
if err := os.WriteFile(fname, []byte(have), 0666); err != nil {
t.Fatalf("err writing expected output to file: %v\n", err)
}
}

View file

@ -90,7 +90,8 @@ var (
{{range .Calls}}
// Pack{{.Normalized.Name}} is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x{{printf "%x" .Original.ID}}.
// the contract method with ID 0x{{printf "%x" .Original.ID}}. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: {{.Original.String}}
func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) Pack{{.Normalized.Name}}({{range .Normalized.Inputs}} {{.Name}} {{bindtype .Type $structs}}, {{end}}) []byte {
@ -101,6 +102,15 @@ var (
return enc
}
// TryPack{{.Normalized.Name}} is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x{{printf "%x" .Original.ID}}. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: {{.Original.String}}
func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) TryPack{{.Normalized.Name}}({{range .Normalized.Inputs}} {{.Name}} {{bindtype .Type $structs}}, {{end}}) ([]byte, error) {
return {{ decapitalise $contract.Type}}.abi.Pack("{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}})
}
{{/* Unpack method is needed only when there are return args */}}
{{if .Normalized.Outputs }}
{{ if .Structured }}
@ -133,8 +143,7 @@ var (
outstruct.{{capitalise .Name}} = *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}})
{{- end }}
{{- end }}
return *outstruct, err
{{else}}
return *outstruct, nil{{else}}
if err != nil {
return {{range $i, $_ := .Normalized.Outputs}}{{if ispointertype .Type}}new({{underlyingbindtype .Type }}), {{else}}*new({{bindtype .Type $structs}}), {{end}}{{end}} err
}
@ -145,7 +154,7 @@ var (
out{{$i}} := *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}})
{{- end }}
{{- end}}
return {{range $i, $t := .Normalized.Outputs}}out{{$i}}, {{end}} err
return {{range $i, $t := .Normalized.Outputs}}out{{$i}}, {{end}} nil
{{- end}}
}
{{end}}

View file

@ -52,7 +52,8 @@ func (c *CallbackParam) Instance(backend bind.ContractBackend, addr common.Addre
}
// PackTest is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xd7a5aba2.
// the contract method with ID 0xd7a5aba2. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function test(function callback) returns()
func (callbackParam *CallbackParam) PackTest(callback [24]byte) []byte {
@ -62,3 +63,12 @@ func (callbackParam *CallbackParam) PackTest(callback [24]byte) []byte {
}
return enc
}
// TryPackTest is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xd7a5aba2. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function test(function callback) returns()
func (callbackParam *CallbackParam) TryPackTest(callback [24]byte) ([]byte, error) {
return callbackParam.abi.Pack("test", callback)
}

View file

@ -64,7 +64,8 @@ func (crowdsale *Crowdsale) PackConstructor(ifSuccessfulSendTo common.Address, f
}
// PackAmountRaised is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x7b3e5e7b.
// the contract method with ID 0x7b3e5e7b. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function amountRaised() returns(uint256)
func (crowdsale *Crowdsale) PackAmountRaised() []byte {
@ -75,6 +76,15 @@ func (crowdsale *Crowdsale) PackAmountRaised() []byte {
return enc
}
// TryPackAmountRaised is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x7b3e5e7b. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function amountRaised() returns(uint256)
func (crowdsale *Crowdsale) TryPackAmountRaised() ([]byte, error) {
return crowdsale.abi.Pack("amountRaised")
}
// UnpackAmountRaised is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x7b3e5e7b.
//
@ -85,11 +95,12 @@ func (crowdsale *Crowdsale) UnpackAmountRaised(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackBeneficiary is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x38af3eed.
// the contract method with ID 0x38af3eed. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function beneficiary() returns(address)
func (crowdsale *Crowdsale) PackBeneficiary() []byte {
@ -100,6 +111,15 @@ func (crowdsale *Crowdsale) PackBeneficiary() []byte {
return enc
}
// TryPackBeneficiary is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x38af3eed. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function beneficiary() returns(address)
func (crowdsale *Crowdsale) TryPackBeneficiary() ([]byte, error) {
return crowdsale.abi.Pack("beneficiary")
}
// UnpackBeneficiary is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x38af3eed.
//
@ -110,11 +130,12 @@ func (crowdsale *Crowdsale) UnpackBeneficiary(data []byte) (common.Address, erro
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
return out0, nil
}
// PackCheckGoalReached is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x01cb3b20.
// the contract method with ID 0x01cb3b20. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function checkGoalReached() returns()
func (crowdsale *Crowdsale) PackCheckGoalReached() []byte {
@ -125,8 +146,18 @@ func (crowdsale *Crowdsale) PackCheckGoalReached() []byte {
return enc
}
// TryPackCheckGoalReached is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x01cb3b20. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function checkGoalReached() returns()
func (crowdsale *Crowdsale) TryPackCheckGoalReached() ([]byte, error) {
return crowdsale.abi.Pack("checkGoalReached")
}
// PackDeadline is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x29dcb0cf.
// the contract method with ID 0x29dcb0cf. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function deadline() returns(uint256)
func (crowdsale *Crowdsale) PackDeadline() []byte {
@ -137,6 +168,15 @@ func (crowdsale *Crowdsale) PackDeadline() []byte {
return enc
}
// TryPackDeadline is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x29dcb0cf. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function deadline() returns(uint256)
func (crowdsale *Crowdsale) TryPackDeadline() ([]byte, error) {
return crowdsale.abi.Pack("deadline")
}
// UnpackDeadline is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x29dcb0cf.
//
@ -147,11 +187,12 @@ func (crowdsale *Crowdsale) UnpackDeadline(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackFunders is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xdc0d3dff.
// the contract method with ID 0xdc0d3dff. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function funders(uint256 ) returns(address addr, uint256 amount)
func (crowdsale *Crowdsale) PackFunders(arg0 *big.Int) []byte {
@ -162,6 +203,15 @@ func (crowdsale *Crowdsale) PackFunders(arg0 *big.Int) []byte {
return enc
}
// TryPackFunders is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xdc0d3dff. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function funders(uint256 ) returns(address addr, uint256 amount)
func (crowdsale *Crowdsale) TryPackFunders(arg0 *big.Int) ([]byte, error) {
return crowdsale.abi.Pack("funders", arg0)
}
// FundersOutput serves as a container for the return parameters of contract
// method Funders.
type FundersOutput struct {
@ -181,12 +231,12 @@ func (crowdsale *Crowdsale) UnpackFunders(data []byte) (FundersOutput, error) {
}
outstruct.Addr = *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
outstruct.Amount = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
return *outstruct, err
return *outstruct, nil
}
// PackFundingGoal is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x7a3a0e84.
// the contract method with ID 0x7a3a0e84. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function fundingGoal() returns(uint256)
func (crowdsale *Crowdsale) PackFundingGoal() []byte {
@ -197,6 +247,15 @@ func (crowdsale *Crowdsale) PackFundingGoal() []byte {
return enc
}
// TryPackFundingGoal is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x7a3a0e84. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function fundingGoal() returns(uint256)
func (crowdsale *Crowdsale) TryPackFundingGoal() ([]byte, error) {
return crowdsale.abi.Pack("fundingGoal")
}
// UnpackFundingGoal is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x7a3a0e84.
//
@ -207,11 +266,12 @@ func (crowdsale *Crowdsale) UnpackFundingGoal(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackPrice is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xa035b1fe.
// the contract method with ID 0xa035b1fe. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function price() returns(uint256)
func (crowdsale *Crowdsale) PackPrice() []byte {
@ -222,6 +282,15 @@ func (crowdsale *Crowdsale) PackPrice() []byte {
return enc
}
// TryPackPrice is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xa035b1fe. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function price() returns(uint256)
func (crowdsale *Crowdsale) TryPackPrice() ([]byte, error) {
return crowdsale.abi.Pack("price")
}
// UnpackPrice is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xa035b1fe.
//
@ -232,11 +301,12 @@ func (crowdsale *Crowdsale) UnpackPrice(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackTokenReward is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x6e66f6e9.
// the contract method with ID 0x6e66f6e9. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function tokenReward() returns(address)
func (crowdsale *Crowdsale) PackTokenReward() []byte {
@ -247,6 +317,15 @@ func (crowdsale *Crowdsale) PackTokenReward() []byte {
return enc
}
// TryPackTokenReward is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x6e66f6e9. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function tokenReward() returns(address)
func (crowdsale *Crowdsale) TryPackTokenReward() ([]byte, error) {
return crowdsale.abi.Pack("tokenReward")
}
// UnpackTokenReward is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x6e66f6e9.
//
@ -257,7 +336,7 @@ func (crowdsale *Crowdsale) UnpackTokenReward(data []byte) (common.Address, erro
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
return out0, nil
}
// CrowdsaleFundTransfer represents a FundTransfer event raised by the Crowdsale contract.

View file

@ -64,7 +64,8 @@ func (dAO *DAO) PackConstructor(minimumQuorumForProposals *big.Int, minutesForDe
}
// PackChangeMembership is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x9644fcbd.
// the contract method with ID 0x9644fcbd. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function changeMembership(address targetMember, bool canVote, string memberName) returns()
func (dAO *DAO) PackChangeMembership(targetMember common.Address, canVote bool, memberName string) []byte {
@ -75,8 +76,18 @@ func (dAO *DAO) PackChangeMembership(targetMember common.Address, canVote bool,
return enc
}
// TryPackChangeMembership is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x9644fcbd. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function changeMembership(address targetMember, bool canVote, string memberName) returns()
func (dAO *DAO) TryPackChangeMembership(targetMember common.Address, canVote bool, memberName string) ([]byte, error) {
return dAO.abi.Pack("changeMembership", targetMember, canVote, memberName)
}
// PackChangeVotingRules is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xbcca1fd3.
// the contract method with ID 0xbcca1fd3. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function changeVotingRules(uint256 minimumQuorumForProposals, uint256 minutesForDebate, int256 marginOfVotesForMajority) returns()
func (dAO *DAO) PackChangeVotingRules(minimumQuorumForProposals *big.Int, minutesForDebate *big.Int, marginOfVotesForMajority *big.Int) []byte {
@ -87,8 +98,18 @@ func (dAO *DAO) PackChangeVotingRules(minimumQuorumForProposals *big.Int, minute
return enc
}
// TryPackChangeVotingRules is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xbcca1fd3. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function changeVotingRules(uint256 minimumQuorumForProposals, uint256 minutesForDebate, int256 marginOfVotesForMajority) returns()
func (dAO *DAO) TryPackChangeVotingRules(minimumQuorumForProposals *big.Int, minutesForDebate *big.Int, marginOfVotesForMajority *big.Int) ([]byte, error) {
return dAO.abi.Pack("changeVotingRules", minimumQuorumForProposals, minutesForDebate, marginOfVotesForMajority)
}
// PackCheckProposalCode is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xeceb2945.
// the contract method with ID 0xeceb2945. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function checkProposalCode(uint256 proposalNumber, address beneficiary, uint256 etherAmount, bytes transactionBytecode) returns(bool codeChecksOut)
func (dAO *DAO) PackCheckProposalCode(proposalNumber *big.Int, beneficiary common.Address, etherAmount *big.Int, transactionBytecode []byte) []byte {
@ -99,6 +120,15 @@ func (dAO *DAO) PackCheckProposalCode(proposalNumber *big.Int, beneficiary commo
return enc
}
// TryPackCheckProposalCode is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xeceb2945. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function checkProposalCode(uint256 proposalNumber, address beneficiary, uint256 etherAmount, bytes transactionBytecode) returns(bool codeChecksOut)
func (dAO *DAO) TryPackCheckProposalCode(proposalNumber *big.Int, beneficiary common.Address, etherAmount *big.Int, transactionBytecode []byte) ([]byte, error) {
return dAO.abi.Pack("checkProposalCode", proposalNumber, beneficiary, etherAmount, transactionBytecode)
}
// UnpackCheckProposalCode is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xeceb2945.
//
@ -109,11 +139,12 @@ func (dAO *DAO) UnpackCheckProposalCode(data []byte) (bool, error) {
return *new(bool), err
}
out0 := *abi.ConvertType(out[0], new(bool)).(*bool)
return out0, err
return out0, nil
}
// PackDebatingPeriodInMinutes is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x69bd3436.
// the contract method with ID 0x69bd3436. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function debatingPeriodInMinutes() returns(uint256)
func (dAO *DAO) PackDebatingPeriodInMinutes() []byte {
@ -124,6 +155,15 @@ func (dAO *DAO) PackDebatingPeriodInMinutes() []byte {
return enc
}
// TryPackDebatingPeriodInMinutes is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x69bd3436. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function debatingPeriodInMinutes() returns(uint256)
func (dAO *DAO) TryPackDebatingPeriodInMinutes() ([]byte, error) {
return dAO.abi.Pack("debatingPeriodInMinutes")
}
// UnpackDebatingPeriodInMinutes is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x69bd3436.
//
@ -134,11 +174,12 @@ func (dAO *DAO) UnpackDebatingPeriodInMinutes(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackExecuteProposal is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x237e9492.
// the contract method with ID 0x237e9492. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function executeProposal(uint256 proposalNumber, bytes transactionBytecode) returns(int256 result)
func (dAO *DAO) PackExecuteProposal(proposalNumber *big.Int, transactionBytecode []byte) []byte {
@ -149,6 +190,15 @@ func (dAO *DAO) PackExecuteProposal(proposalNumber *big.Int, transactionBytecode
return enc
}
// TryPackExecuteProposal is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x237e9492. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function executeProposal(uint256 proposalNumber, bytes transactionBytecode) returns(int256 result)
func (dAO *DAO) TryPackExecuteProposal(proposalNumber *big.Int, transactionBytecode []byte) ([]byte, error) {
return dAO.abi.Pack("executeProposal", proposalNumber, transactionBytecode)
}
// UnpackExecuteProposal is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x237e9492.
//
@ -159,11 +209,12 @@ func (dAO *DAO) UnpackExecuteProposal(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackMajorityMargin is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xaa02a90f.
// the contract method with ID 0xaa02a90f. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function majorityMargin() returns(int256)
func (dAO *DAO) PackMajorityMargin() []byte {
@ -174,6 +225,15 @@ func (dAO *DAO) PackMajorityMargin() []byte {
return enc
}
// TryPackMajorityMargin is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xaa02a90f. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function majorityMargin() returns(int256)
func (dAO *DAO) TryPackMajorityMargin() ([]byte, error) {
return dAO.abi.Pack("majorityMargin")
}
// UnpackMajorityMargin is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xaa02a90f.
//
@ -184,11 +244,12 @@ func (dAO *DAO) UnpackMajorityMargin(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackMemberId is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x39106821.
// the contract method with ID 0x39106821. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function memberId(address ) returns(uint256)
func (dAO *DAO) PackMemberId(arg0 common.Address) []byte {
@ -199,6 +260,15 @@ func (dAO *DAO) PackMemberId(arg0 common.Address) []byte {
return enc
}
// TryPackMemberId is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x39106821. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function memberId(address ) returns(uint256)
func (dAO *DAO) TryPackMemberId(arg0 common.Address) ([]byte, error) {
return dAO.abi.Pack("memberId", arg0)
}
// UnpackMemberId is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x39106821.
//
@ -209,11 +279,12 @@ func (dAO *DAO) UnpackMemberId(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackMembers is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x5daf08ca.
// the contract method with ID 0x5daf08ca. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function members(uint256 ) returns(address member, bool canVote, string name, uint256 memberSince)
func (dAO *DAO) PackMembers(arg0 *big.Int) []byte {
@ -224,6 +295,15 @@ func (dAO *DAO) PackMembers(arg0 *big.Int) []byte {
return enc
}
// TryPackMembers is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x5daf08ca. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function members(uint256 ) returns(address member, bool canVote, string name, uint256 memberSince)
func (dAO *DAO) TryPackMembers(arg0 *big.Int) ([]byte, error) {
return dAO.abi.Pack("members", arg0)
}
// MembersOutput serves as a container for the return parameters of contract
// method Members.
type MembersOutput struct {
@ -247,12 +327,12 @@ func (dAO *DAO) UnpackMembers(data []byte) (MembersOutput, error) {
outstruct.CanVote = *abi.ConvertType(out[1], new(bool)).(*bool)
outstruct.Name = *abi.ConvertType(out[2], new(string)).(*string)
outstruct.MemberSince = abi.ConvertType(out[3], new(big.Int)).(*big.Int)
return *outstruct, err
return *outstruct, nil
}
// PackMinimumQuorum is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x8160f0b5.
// the contract method with ID 0x8160f0b5. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function minimumQuorum() returns(uint256)
func (dAO *DAO) PackMinimumQuorum() []byte {
@ -263,6 +343,15 @@ func (dAO *DAO) PackMinimumQuorum() []byte {
return enc
}
// TryPackMinimumQuorum is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x8160f0b5. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function minimumQuorum() returns(uint256)
func (dAO *DAO) TryPackMinimumQuorum() ([]byte, error) {
return dAO.abi.Pack("minimumQuorum")
}
// UnpackMinimumQuorum is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x8160f0b5.
//
@ -273,11 +362,12 @@ func (dAO *DAO) UnpackMinimumQuorum(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackNewProposal is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xb1050da5.
// the contract method with ID 0xb1050da5. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function newProposal(address beneficiary, uint256 etherAmount, string JobDescription, bytes transactionBytecode) returns(uint256 proposalID)
func (dAO *DAO) PackNewProposal(beneficiary common.Address, etherAmount *big.Int, jobDescription string, transactionBytecode []byte) []byte {
@ -288,6 +378,15 @@ func (dAO *DAO) PackNewProposal(beneficiary common.Address, etherAmount *big.Int
return enc
}
// TryPackNewProposal is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xb1050da5. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function newProposal(address beneficiary, uint256 etherAmount, string JobDescription, bytes transactionBytecode) returns(uint256 proposalID)
func (dAO *DAO) TryPackNewProposal(beneficiary common.Address, etherAmount *big.Int, jobDescription string, transactionBytecode []byte) ([]byte, error) {
return dAO.abi.Pack("newProposal", beneficiary, etherAmount, jobDescription, transactionBytecode)
}
// UnpackNewProposal is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xb1050da5.
//
@ -298,11 +397,12 @@ func (dAO *DAO) UnpackNewProposal(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackNumProposals is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x400e3949.
// the contract method with ID 0x400e3949. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function numProposals() returns(uint256)
func (dAO *DAO) PackNumProposals() []byte {
@ -313,6 +413,15 @@ func (dAO *DAO) PackNumProposals() []byte {
return enc
}
// TryPackNumProposals is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x400e3949. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function numProposals() returns(uint256)
func (dAO *DAO) TryPackNumProposals() ([]byte, error) {
return dAO.abi.Pack("numProposals")
}
// UnpackNumProposals is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x400e3949.
//
@ -323,11 +432,12 @@ func (dAO *DAO) UnpackNumProposals(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackOwner is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x8da5cb5b.
// the contract method with ID 0x8da5cb5b. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function owner() returns(address)
func (dAO *DAO) PackOwner() []byte {
@ -338,6 +448,15 @@ func (dAO *DAO) PackOwner() []byte {
return enc
}
// TryPackOwner is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x8da5cb5b. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function owner() returns(address)
func (dAO *DAO) TryPackOwner() ([]byte, error) {
return dAO.abi.Pack("owner")
}
// UnpackOwner is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x8da5cb5b.
//
@ -348,11 +467,12 @@ func (dAO *DAO) UnpackOwner(data []byte) (common.Address, error) {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
return out0, nil
}
// PackProposals is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x013cf08b.
// the contract method with ID 0x013cf08b. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function proposals(uint256 ) returns(address recipient, uint256 amount, string description, uint256 votingDeadline, bool executed, bool proposalPassed, uint256 numberOfVotes, int256 currentResult, bytes32 proposalHash)
func (dAO *DAO) PackProposals(arg0 *big.Int) []byte {
@ -363,6 +483,15 @@ func (dAO *DAO) PackProposals(arg0 *big.Int) []byte {
return enc
}
// TryPackProposals is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x013cf08b. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function proposals(uint256 ) returns(address recipient, uint256 amount, string description, uint256 votingDeadline, bool executed, bool proposalPassed, uint256 numberOfVotes, int256 currentResult, bytes32 proposalHash)
func (dAO *DAO) TryPackProposals(arg0 *big.Int) ([]byte, error) {
return dAO.abi.Pack("proposals", arg0)
}
// ProposalsOutput serves as a container for the return parameters of contract
// method Proposals.
type ProposalsOutput struct {
@ -396,12 +525,12 @@ func (dAO *DAO) UnpackProposals(data []byte) (ProposalsOutput, error) {
outstruct.NumberOfVotes = abi.ConvertType(out[6], new(big.Int)).(*big.Int)
outstruct.CurrentResult = abi.ConvertType(out[7], new(big.Int)).(*big.Int)
outstruct.ProposalHash = *abi.ConvertType(out[8], new([32]byte)).(*[32]byte)
return *outstruct, err
return *outstruct, nil
}
// PackTransferOwnership is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xf2fde38b.
// the contract method with ID 0xf2fde38b. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function transferOwnership(address newOwner) returns()
func (dAO *DAO) PackTransferOwnership(newOwner common.Address) []byte {
@ -412,8 +541,18 @@ func (dAO *DAO) PackTransferOwnership(newOwner common.Address) []byte {
return enc
}
// TryPackTransferOwnership is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xf2fde38b. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function transferOwnership(address newOwner) returns()
func (dAO *DAO) TryPackTransferOwnership(newOwner common.Address) ([]byte, error) {
return dAO.abi.Pack("transferOwnership", newOwner)
}
// PackVote is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xd3c0715b.
// the contract method with ID 0xd3c0715b. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function vote(uint256 proposalNumber, bool supportsProposal, string justificationText) returns(uint256 voteID)
func (dAO *DAO) PackVote(proposalNumber *big.Int, supportsProposal bool, justificationText string) []byte {
@ -424,6 +563,15 @@ func (dAO *DAO) PackVote(proposalNumber *big.Int, supportsProposal bool, justifi
return enc
}
// TryPackVote is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xd3c0715b. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function vote(uint256 proposalNumber, bool supportsProposal, string justificationText) returns(uint256 voteID)
func (dAO *DAO) TryPackVote(proposalNumber *big.Int, supportsProposal bool, justificationText string) ([]byte, error) {
return dAO.abi.Pack("vote", proposalNumber, supportsProposal, justificationText)
}
// UnpackVote is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xd3c0715b.
//
@ -434,7 +582,7 @@ func (dAO *DAO) UnpackVote(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// DAOChangeOfRules represents a ChangeOfRules event raised by the DAO contract.

View file

@ -52,7 +52,8 @@ func (c *DeeplyNestedArray) Instance(backend bind.ContractBackend, addr common.A
}
// PackDeepUint64Array is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x98ed1856.
// the contract method with ID 0x98ed1856. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function deepUint64Array(uint256 , uint256 , uint256 ) view returns(uint64)
func (deeplyNestedArray *DeeplyNestedArray) PackDeepUint64Array(arg0 *big.Int, arg1 *big.Int, arg2 *big.Int) []byte {
@ -63,6 +64,15 @@ func (deeplyNestedArray *DeeplyNestedArray) PackDeepUint64Array(arg0 *big.Int, a
return enc
}
// TryPackDeepUint64Array is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x98ed1856. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function deepUint64Array(uint256 , uint256 , uint256 ) view returns(uint64)
func (deeplyNestedArray *DeeplyNestedArray) TryPackDeepUint64Array(arg0 *big.Int, arg1 *big.Int, arg2 *big.Int) ([]byte, error) {
return deeplyNestedArray.abi.Pack("deepUint64Array", arg0, arg1, arg2)
}
// UnpackDeepUint64Array is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x98ed1856.
//
@ -73,11 +83,12 @@ func (deeplyNestedArray *DeeplyNestedArray) UnpackDeepUint64Array(data []byte) (
return *new(uint64), err
}
out0 := *abi.ConvertType(out[0], new(uint64)).(*uint64)
return out0, err
return out0, nil
}
// PackRetrieveDeepArray is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x8ed4573a.
// the contract method with ID 0x8ed4573a. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function retrieveDeepArray() view returns(uint64[3][4][5])
func (deeplyNestedArray *DeeplyNestedArray) PackRetrieveDeepArray() []byte {
@ -88,6 +99,15 @@ func (deeplyNestedArray *DeeplyNestedArray) PackRetrieveDeepArray() []byte {
return enc
}
// TryPackRetrieveDeepArray is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x8ed4573a. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function retrieveDeepArray() view returns(uint64[3][4][5])
func (deeplyNestedArray *DeeplyNestedArray) TryPackRetrieveDeepArray() ([]byte, error) {
return deeplyNestedArray.abi.Pack("retrieveDeepArray")
}
// UnpackRetrieveDeepArray is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x8ed4573a.
//
@ -98,11 +118,12 @@ func (deeplyNestedArray *DeeplyNestedArray) UnpackRetrieveDeepArray(data []byte)
return *new([5][4][3]uint64), err
}
out0 := *abi.ConvertType(out[0], new([5][4][3]uint64)).(*[5][4][3]uint64)
return out0, err
return out0, nil
}
// PackStoreDeepUintArray is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x34424855.
// the contract method with ID 0x34424855. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function storeDeepUintArray(uint64[3][4][5] arr) returns()
func (deeplyNestedArray *DeeplyNestedArray) PackStoreDeepUintArray(arr [5][4][3]uint64) []byte {
@ -112,3 +133,12 @@ func (deeplyNestedArray *DeeplyNestedArray) PackStoreDeepUintArray(arr [5][4][3]
}
return enc
}
// TryPackStoreDeepUintArray is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x34424855. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function storeDeepUintArray(uint64[3][4][5] arr) returns()
func (deeplyNestedArray *DeeplyNestedArray) TryPackStoreDeepUintArray(arr [5][4][3]uint64) ([]byte, error) {
return deeplyNestedArray.abi.Pack("storeDeepUintArray", arr)
}

View file

@ -52,7 +52,8 @@ func (c *Getter) Instance(backend bind.ContractBackend, addr common.Address) *bi
}
// PackGetter is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x993a04b7.
// the contract method with ID 0x993a04b7. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function getter() returns(string, int256, bytes32)
func (getter *Getter) PackGetter() []byte {
@ -63,6 +64,15 @@ func (getter *Getter) PackGetter() []byte {
return enc
}
// TryPackGetter is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x993a04b7. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function getter() returns(string, int256, bytes32)
func (getter *Getter) TryPackGetter() ([]byte, error) {
return getter.abi.Pack("getter")
}
// GetterOutput serves as a container for the return parameters of contract
// method Getter.
type GetterOutput struct {
@ -84,6 +94,5 @@ func (getter *Getter) UnpackGetter(data []byte) (GetterOutput, error) {
outstruct.Arg0 = *abi.ConvertType(out[0], new(string)).(*string)
outstruct.Arg1 = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
outstruct.Arg2 = *abi.ConvertType(out[2], new([32]byte)).(*[32]byte)
return *outstruct, err
return *outstruct, nil
}

View file

@ -52,7 +52,8 @@ func (c *IdentifierCollision) Instance(backend bind.ContractBackend, addr common
}
// PackMyVar is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x4ef1f0ad.
// the contract method with ID 0x4ef1f0ad. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function MyVar() view returns(uint256)
func (identifierCollision *IdentifierCollision) PackMyVar() []byte {
@ -63,6 +64,15 @@ func (identifierCollision *IdentifierCollision) PackMyVar() []byte {
return enc
}
// TryPackMyVar is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x4ef1f0ad. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function MyVar() view returns(uint256)
func (identifierCollision *IdentifierCollision) TryPackMyVar() ([]byte, error) {
return identifierCollision.abi.Pack("MyVar")
}
// UnpackMyVar is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x4ef1f0ad.
//
@ -73,11 +83,12 @@ func (identifierCollision *IdentifierCollision) UnpackMyVar(data []byte) (*big.I
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackPubVar is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x01ad4d87.
// the contract method with ID 0x01ad4d87. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function _myVar() view returns(uint256)
func (identifierCollision *IdentifierCollision) PackPubVar() []byte {
@ -88,6 +99,15 @@ func (identifierCollision *IdentifierCollision) PackPubVar() []byte {
return enc
}
// TryPackPubVar is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x01ad4d87. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function _myVar() view returns(uint256)
func (identifierCollision *IdentifierCollision) TryPackPubVar() ([]byte, error) {
return identifierCollision.abi.Pack("_myVar")
}
// UnpackPubVar is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x01ad4d87.
//
@ -98,5 +118,5 @@ func (identifierCollision *IdentifierCollision) UnpackPubVar(data []byte) (*big.
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}

View file

@ -51,7 +51,8 @@ func (c *InputChecker) Instance(backend bind.ContractBackend, addr common.Addres
}
// PackAnonInput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x3e708e82.
// the contract method with ID 0x3e708e82. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function anonInput(string ) returns()
func (inputChecker *InputChecker) PackAnonInput(arg0 string) []byte {
@ -62,8 +63,18 @@ func (inputChecker *InputChecker) PackAnonInput(arg0 string) []byte {
return enc
}
// TryPackAnonInput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x3e708e82. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function anonInput(string ) returns()
func (inputChecker *InputChecker) TryPackAnonInput(arg0 string) ([]byte, error) {
return inputChecker.abi.Pack("anonInput", arg0)
}
// PackAnonInputs is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x28160527.
// the contract method with ID 0x28160527. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function anonInputs(string , string ) returns()
func (inputChecker *InputChecker) PackAnonInputs(arg0 string, arg1 string) []byte {
@ -74,8 +85,18 @@ func (inputChecker *InputChecker) PackAnonInputs(arg0 string, arg1 string) []byt
return enc
}
// TryPackAnonInputs is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x28160527. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function anonInputs(string , string ) returns()
func (inputChecker *InputChecker) TryPackAnonInputs(arg0 string, arg1 string) ([]byte, error) {
return inputChecker.abi.Pack("anonInputs", arg0, arg1)
}
// PackMixedInputs is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xc689ebdc.
// the contract method with ID 0xc689ebdc. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function mixedInputs(string , string str) returns()
func (inputChecker *InputChecker) PackMixedInputs(arg0 string, str string) []byte {
@ -86,8 +107,18 @@ func (inputChecker *InputChecker) PackMixedInputs(arg0 string, str string) []byt
return enc
}
// TryPackMixedInputs is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xc689ebdc. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function mixedInputs(string , string str) returns()
func (inputChecker *InputChecker) TryPackMixedInputs(arg0 string, str string) ([]byte, error) {
return inputChecker.abi.Pack("mixedInputs", arg0, str)
}
// PackNamedInput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x0d402005.
// the contract method with ID 0x0d402005. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function namedInput(string str) returns()
func (inputChecker *InputChecker) PackNamedInput(str string) []byte {
@ -98,8 +129,18 @@ func (inputChecker *InputChecker) PackNamedInput(str string) []byte {
return enc
}
// TryPackNamedInput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x0d402005. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function namedInput(string str) returns()
func (inputChecker *InputChecker) TryPackNamedInput(str string) ([]byte, error) {
return inputChecker.abi.Pack("namedInput", str)
}
// PackNamedInputs is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x63c796ed.
// the contract method with ID 0x63c796ed. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function namedInputs(string str1, string str2) returns()
func (inputChecker *InputChecker) PackNamedInputs(str1 string, str2 string) []byte {
@ -110,8 +151,18 @@ func (inputChecker *InputChecker) PackNamedInputs(str1 string, str2 string) []by
return enc
}
// TryPackNamedInputs is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x63c796ed. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function namedInputs(string str1, string str2) returns()
func (inputChecker *InputChecker) TryPackNamedInputs(str1 string, str2 string) ([]byte, error) {
return inputChecker.abi.Pack("namedInputs", str1, str2)
}
// PackNoInput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x53539029.
// the contract method with ID 0x53539029. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function noInput() returns()
func (inputChecker *InputChecker) PackNoInput() []byte {
@ -121,3 +172,12 @@ func (inputChecker *InputChecker) PackNoInput() []byte {
}
return enc
}
// TryPackNoInput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x53539029. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function noInput() returns()
func (inputChecker *InputChecker) TryPackNoInput() ([]byte, error) {
return inputChecker.abi.Pack("noInput")
}

View file

@ -64,7 +64,8 @@ func (interactor *Interactor) PackConstructor(str string) []byte {
}
// PackDeployString is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x6874e809.
// the contract method with ID 0x6874e809. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function deployString() returns(string)
func (interactor *Interactor) PackDeployString() []byte {
@ -75,6 +76,15 @@ func (interactor *Interactor) PackDeployString() []byte {
return enc
}
// TryPackDeployString is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x6874e809. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function deployString() returns(string)
func (interactor *Interactor) TryPackDeployString() ([]byte, error) {
return interactor.abi.Pack("deployString")
}
// UnpackDeployString is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x6874e809.
//
@ -85,11 +95,12 @@ func (interactor *Interactor) UnpackDeployString(data []byte) (string, error) {
return *new(string), err
}
out0 := *abi.ConvertType(out[0], new(string)).(*string)
return out0, err
return out0, nil
}
// PackTransact is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xd736c513.
// the contract method with ID 0xd736c513. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function transact(string str) returns()
func (interactor *Interactor) PackTransact(str string) []byte {
@ -100,8 +111,18 @@ func (interactor *Interactor) PackTransact(str string) []byte {
return enc
}
// TryPackTransact is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xd736c513. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function transact(string str) returns()
func (interactor *Interactor) TryPackTransact(str string) ([]byte, error) {
return interactor.abi.Pack("transact", str)
}
// PackTransactString is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x0d86a0e1.
// the contract method with ID 0x0d86a0e1. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function transactString() returns(string)
func (interactor *Interactor) PackTransactString() []byte {
@ -112,6 +133,15 @@ func (interactor *Interactor) PackTransactString() []byte {
return enc
}
// TryPackTransactString is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x0d86a0e1. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function transactString() returns(string)
func (interactor *Interactor) TryPackTransactString() ([]byte, error) {
return interactor.abi.Pack("transactString")
}
// UnpackTransactString is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x0d86a0e1.
//
@ -122,5 +152,5 @@ func (interactor *Interactor) UnpackTransactString(data []byte) (string, error)
return *new(string), err
}
out0 := *abi.ConvertType(out[0], new(string)).(*string)
return out0, err
return out0, nil
}

View file

@ -58,7 +58,8 @@ func (c *NameConflict) Instance(backend bind.ContractBackend, addr common.Addres
}
// PackAddRequest is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xcce7b048.
// the contract method with ID 0xcce7b048. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function addRequest((bytes,bytes) req) pure returns()
func (nameConflict *NameConflict) PackAddRequest(req Oraclerequest) []byte {
@ -69,8 +70,18 @@ func (nameConflict *NameConflict) PackAddRequest(req Oraclerequest) []byte {
return enc
}
// TryPackAddRequest is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xcce7b048. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function addRequest((bytes,bytes) req) pure returns()
func (nameConflict *NameConflict) TryPackAddRequest(req Oraclerequest) ([]byte, error) {
return nameConflict.abi.Pack("addRequest", req)
}
// PackGetRequest is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xc2bb515f.
// the contract method with ID 0xc2bb515f. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function getRequest() pure returns((bytes,bytes))
func (nameConflict *NameConflict) PackGetRequest() []byte {
@ -81,6 +92,15 @@ func (nameConflict *NameConflict) PackGetRequest() []byte {
return enc
}
// TryPackGetRequest is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xc2bb515f. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function getRequest() pure returns((bytes,bytes))
func (nameConflict *NameConflict) TryPackGetRequest() ([]byte, error) {
return nameConflict.abi.Pack("getRequest")
}
// UnpackGetRequest is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xc2bb515f.
//
@ -91,7 +111,7 @@ func (nameConflict *NameConflict) UnpackGetRequest(data []byte) (Oraclerequest,
return *new(Oraclerequest), err
}
out0 := *abi.ConvertType(out[0], new(Oraclerequest)).(*Oraclerequest)
return out0, err
return out0, nil
}
// NameConflictLog represents a log event raised by the NameConflict contract.

View file

@ -52,7 +52,8 @@ func (c *NumericMethodName) Instance(backend bind.ContractBackend, addr common.A
}
// PackE1test is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xffa02795.
// the contract method with ID 0xffa02795. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function _1test() pure returns()
func (numericMethodName *NumericMethodName) PackE1test() []byte {
@ -63,8 +64,18 @@ func (numericMethodName *NumericMethodName) PackE1test() []byte {
return enc
}
// TryPackE1test is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xffa02795. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function _1test() pure returns()
func (numericMethodName *NumericMethodName) TryPackE1test() ([]byte, error) {
return numericMethodName.abi.Pack("_1test")
}
// PackE1test0 is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xd02767c7.
// the contract method with ID 0xd02767c7. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function __1test() pure returns()
func (numericMethodName *NumericMethodName) PackE1test0() []byte {
@ -75,8 +86,18 @@ func (numericMethodName *NumericMethodName) PackE1test0() []byte {
return enc
}
// TryPackE1test0 is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xd02767c7. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function __1test() pure returns()
func (numericMethodName *NumericMethodName) TryPackE1test0() ([]byte, error) {
return numericMethodName.abi.Pack("__1test")
}
// PackE2test is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x9d993132.
// the contract method with ID 0x9d993132. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function __2test() pure returns()
func (numericMethodName *NumericMethodName) PackE2test() []byte {
@ -87,6 +108,15 @@ func (numericMethodName *NumericMethodName) PackE2test() []byte {
return enc
}
// TryPackE2test is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x9d993132. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function __2test() pure returns()
func (numericMethodName *NumericMethodName) TryPackE2test() ([]byte, error) {
return numericMethodName.abi.Pack("__2test")
}
// NumericMethodNameE1TestEvent represents a _1TestEvent event raised by the NumericMethodName contract.
type NumericMethodNameE1TestEvent struct {
Param common.Address

View file

@ -51,7 +51,8 @@ func (c *OutputChecker) Instance(backend bind.ContractBackend, addr common.Addre
}
// PackAnonOutput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x008bda05.
// the contract method with ID 0x008bda05. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function anonOutput() returns(string)
func (outputChecker *OutputChecker) PackAnonOutput() []byte {
@ -62,6 +63,15 @@ func (outputChecker *OutputChecker) PackAnonOutput() []byte {
return enc
}
// TryPackAnonOutput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x008bda05. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function anonOutput() returns(string)
func (outputChecker *OutputChecker) TryPackAnonOutput() ([]byte, error) {
return outputChecker.abi.Pack("anonOutput")
}
// UnpackAnonOutput is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x008bda05.
//
@ -72,11 +82,12 @@ func (outputChecker *OutputChecker) UnpackAnonOutput(data []byte) (string, error
return *new(string), err
}
out0 := *abi.ConvertType(out[0], new(string)).(*string)
return out0, err
return out0, nil
}
// PackAnonOutputs is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x3c401115.
// the contract method with ID 0x3c401115. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function anonOutputs() returns(string, string)
func (outputChecker *OutputChecker) PackAnonOutputs() []byte {
@ -87,6 +98,15 @@ func (outputChecker *OutputChecker) PackAnonOutputs() []byte {
return enc
}
// TryPackAnonOutputs is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x3c401115. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function anonOutputs() returns(string, string)
func (outputChecker *OutputChecker) TryPackAnonOutputs() ([]byte, error) {
return outputChecker.abi.Pack("anonOutputs")
}
// AnonOutputsOutput serves as a container for the return parameters of contract
// method AnonOutputs.
type AnonOutputsOutput struct {
@ -106,12 +126,12 @@ func (outputChecker *OutputChecker) UnpackAnonOutputs(data []byte) (AnonOutputsO
}
outstruct.Arg0 = *abi.ConvertType(out[0], new(string)).(*string)
outstruct.Arg1 = *abi.ConvertType(out[1], new(string)).(*string)
return *outstruct, err
return *outstruct, nil
}
// PackCollidingOutputs is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xeccbc1ee.
// the contract method with ID 0xeccbc1ee. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function collidingOutputs() returns(string str, string Str)
func (outputChecker *OutputChecker) PackCollidingOutputs() []byte {
@ -122,6 +142,15 @@ func (outputChecker *OutputChecker) PackCollidingOutputs() []byte {
return enc
}
// TryPackCollidingOutputs is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xeccbc1ee. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function collidingOutputs() returns(string str, string Str)
func (outputChecker *OutputChecker) TryPackCollidingOutputs() ([]byte, error) {
return outputChecker.abi.Pack("collidingOutputs")
}
// CollidingOutputsOutput serves as a container for the return parameters of contract
// method CollidingOutputs.
type CollidingOutputsOutput struct {
@ -141,12 +170,12 @@ func (outputChecker *OutputChecker) UnpackCollidingOutputs(data []byte) (Collidi
}
outstruct.Str = *abi.ConvertType(out[0], new(string)).(*string)
outstruct.Str0 = *abi.ConvertType(out[1], new(string)).(*string)
return *outstruct, err
return *outstruct, nil
}
// PackMixedOutputs is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x21b77b44.
// the contract method with ID 0x21b77b44. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function mixedOutputs() returns(string, string str)
func (outputChecker *OutputChecker) PackMixedOutputs() []byte {
@ -157,6 +186,15 @@ func (outputChecker *OutputChecker) PackMixedOutputs() []byte {
return enc
}
// TryPackMixedOutputs is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x21b77b44. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function mixedOutputs() returns(string, string str)
func (outputChecker *OutputChecker) TryPackMixedOutputs() ([]byte, error) {
return outputChecker.abi.Pack("mixedOutputs")
}
// MixedOutputsOutput serves as a container for the return parameters of contract
// method MixedOutputs.
type MixedOutputsOutput struct {
@ -176,12 +214,12 @@ func (outputChecker *OutputChecker) UnpackMixedOutputs(data []byte) (MixedOutput
}
outstruct.Arg0 = *abi.ConvertType(out[0], new(string)).(*string)
outstruct.Str = *abi.ConvertType(out[1], new(string)).(*string)
return *outstruct, err
return *outstruct, nil
}
// PackNamedOutput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x5e632bd5.
// the contract method with ID 0x5e632bd5. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function namedOutput() returns(string str)
func (outputChecker *OutputChecker) PackNamedOutput() []byte {
@ -192,6 +230,15 @@ func (outputChecker *OutputChecker) PackNamedOutput() []byte {
return enc
}
// TryPackNamedOutput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x5e632bd5. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function namedOutput() returns(string str)
func (outputChecker *OutputChecker) TryPackNamedOutput() ([]byte, error) {
return outputChecker.abi.Pack("namedOutput")
}
// UnpackNamedOutput is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x5e632bd5.
//
@ -202,11 +249,12 @@ func (outputChecker *OutputChecker) UnpackNamedOutput(data []byte) (string, erro
return *new(string), err
}
out0 := *abi.ConvertType(out[0], new(string)).(*string)
return out0, err
return out0, nil
}
// PackNamedOutputs is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x7970a189.
// the contract method with ID 0x7970a189. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function namedOutputs() returns(string str1, string str2)
func (outputChecker *OutputChecker) PackNamedOutputs() []byte {
@ -217,6 +265,15 @@ func (outputChecker *OutputChecker) PackNamedOutputs() []byte {
return enc
}
// TryPackNamedOutputs is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x7970a189. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function namedOutputs() returns(string str1, string str2)
func (outputChecker *OutputChecker) TryPackNamedOutputs() ([]byte, error) {
return outputChecker.abi.Pack("namedOutputs")
}
// NamedOutputsOutput serves as a container for the return parameters of contract
// method NamedOutputs.
type NamedOutputsOutput struct {
@ -236,12 +293,12 @@ func (outputChecker *OutputChecker) UnpackNamedOutputs(data []byte) (NamedOutput
}
outstruct.Str1 = *abi.ConvertType(out[0], new(string)).(*string)
outstruct.Str2 = *abi.ConvertType(out[1], new(string)).(*string)
return *outstruct, err
return *outstruct, nil
}
// PackNoOutput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x625f0306.
// the contract method with ID 0x625f0306. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function noOutput() returns()
func (outputChecker *OutputChecker) PackNoOutput() []byte {
@ -251,3 +308,12 @@ func (outputChecker *OutputChecker) PackNoOutput() []byte {
}
return enc
}
// TryPackNoOutput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x625f0306. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function noOutput() returns()
func (outputChecker *OutputChecker) TryPackNoOutput() ([]byte, error) {
return outputChecker.abi.Pack("noOutput")
}

View file

@ -52,7 +52,8 @@ func (c *Overload) Instance(backend bind.ContractBackend, addr common.Address) *
}
// PackFoo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x04bc52f8.
// the contract method with ID 0x04bc52f8. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function foo(uint256 i, uint256 j) returns()
func (overload *Overload) PackFoo(i *big.Int, j *big.Int) []byte {
@ -63,8 +64,18 @@ func (overload *Overload) PackFoo(i *big.Int, j *big.Int) []byte {
return enc
}
// TryPackFoo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x04bc52f8. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function foo(uint256 i, uint256 j) returns()
func (overload *Overload) TryPackFoo(i *big.Int, j *big.Int) ([]byte, error) {
return overload.abi.Pack("foo", i, j)
}
// PackFoo0 is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2fbebd38.
// the contract method with ID 0x2fbebd38. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function foo(uint256 i) returns()
func (overload *Overload) PackFoo0(i *big.Int) []byte {
@ -75,6 +86,15 @@ func (overload *Overload) PackFoo0(i *big.Int) []byte {
return enc
}
// TryPackFoo0 is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2fbebd38. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function foo(uint256 i) returns()
func (overload *Overload) TryPackFoo0(i *big.Int) ([]byte, error) {
return overload.abi.Pack("foo0", i)
}
// OverloadBar represents a bar event raised by the Overload contract.
type OverloadBar struct {
I *big.Int

View file

@ -52,7 +52,8 @@ func (c *RangeKeyword) Instance(backend bind.ContractBackend, addr common.Addres
}
// PackFunctionWithKeywordParameter is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x527a119f.
// the contract method with ID 0x527a119f. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function functionWithKeywordParameter(uint256 range) pure returns()
func (rangeKeyword *RangeKeyword) PackFunctionWithKeywordParameter(arg0 *big.Int) []byte {
@ -62,3 +63,12 @@ func (rangeKeyword *RangeKeyword) PackFunctionWithKeywordParameter(arg0 *big.Int
}
return enc
}
// TryPackFunctionWithKeywordParameter is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x527a119f. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function functionWithKeywordParameter(uint256 range) pure returns()
func (rangeKeyword *RangeKeyword) TryPackFunctionWithKeywordParameter(arg0 *big.Int) ([]byte, error) {
return rangeKeyword.abi.Pack("functionWithKeywordParameter", arg0)
}

View file

@ -52,7 +52,8 @@ func (c *Slicer) Instance(backend bind.ContractBackend, addr common.Address) *bi
}
// PackEchoAddresses is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xbe1127a3.
// the contract method with ID 0xbe1127a3. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function echoAddresses(address[] input) returns(address[] output)
func (slicer *Slicer) PackEchoAddresses(input []common.Address) []byte {
@ -63,6 +64,15 @@ func (slicer *Slicer) PackEchoAddresses(input []common.Address) []byte {
return enc
}
// TryPackEchoAddresses is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xbe1127a3. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function echoAddresses(address[] input) returns(address[] output)
func (slicer *Slicer) TryPackEchoAddresses(input []common.Address) ([]byte, error) {
return slicer.abi.Pack("echoAddresses", input)
}
// UnpackEchoAddresses is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xbe1127a3.
//
@ -73,11 +83,12 @@ func (slicer *Slicer) UnpackEchoAddresses(data []byte) ([]common.Address, error)
return *new([]common.Address), err
}
out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address)
return out0, err
return out0, nil
}
// PackEchoBools is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xf637e589.
// the contract method with ID 0xf637e589. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function echoBools(bool[] input) returns(bool[] output)
func (slicer *Slicer) PackEchoBools(input []bool) []byte {
@ -88,6 +99,15 @@ func (slicer *Slicer) PackEchoBools(input []bool) []byte {
return enc
}
// TryPackEchoBools is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xf637e589. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function echoBools(bool[] input) returns(bool[] output)
func (slicer *Slicer) TryPackEchoBools(input []bool) ([]byte, error) {
return slicer.abi.Pack("echoBools", input)
}
// UnpackEchoBools is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xf637e589.
//
@ -98,11 +118,12 @@ func (slicer *Slicer) UnpackEchoBools(data []byte) ([]bool, error) {
return *new([]bool), err
}
out0 := *abi.ConvertType(out[0], new([]bool)).(*[]bool)
return out0, err
return out0, nil
}
// PackEchoFancyInts is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xd88becc0.
// the contract method with ID 0xd88becc0. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function echoFancyInts(uint24[23] input) returns(uint24[23] output)
func (slicer *Slicer) PackEchoFancyInts(input [23]*big.Int) []byte {
@ -113,6 +134,15 @@ func (slicer *Slicer) PackEchoFancyInts(input [23]*big.Int) []byte {
return enc
}
// TryPackEchoFancyInts is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xd88becc0. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function echoFancyInts(uint24[23] input) returns(uint24[23] output)
func (slicer *Slicer) TryPackEchoFancyInts(input [23]*big.Int) ([]byte, error) {
return slicer.abi.Pack("echoFancyInts", input)
}
// UnpackEchoFancyInts is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xd88becc0.
//
@ -123,11 +153,12 @@ func (slicer *Slicer) UnpackEchoFancyInts(data []byte) ([23]*big.Int, error) {
return *new([23]*big.Int), err
}
out0 := *abi.ConvertType(out[0], new([23]*big.Int)).(*[23]*big.Int)
return out0, err
return out0, nil
}
// PackEchoInts is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xe15a3db7.
// the contract method with ID 0xe15a3db7. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function echoInts(int256[] input) returns(int256[] output)
func (slicer *Slicer) PackEchoInts(input []*big.Int) []byte {
@ -138,6 +169,15 @@ func (slicer *Slicer) PackEchoInts(input []*big.Int) []byte {
return enc
}
// TryPackEchoInts is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xe15a3db7. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function echoInts(int256[] input) returns(int256[] output)
func (slicer *Slicer) TryPackEchoInts(input []*big.Int) ([]byte, error) {
return slicer.abi.Pack("echoInts", input)
}
// UnpackEchoInts is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xe15a3db7.
//
@ -148,5 +188,5 @@ func (slicer *Slicer) UnpackEchoInts(data []byte) ([]*big.Int, error) {
return *new([]*big.Int), err
}
out0 := *abi.ConvertType(out[0], new([]*big.Int)).(*[]*big.Int)
return out0, err
return out0, nil
}

View file

@ -57,7 +57,8 @@ func (c *Structs) Instance(backend bind.ContractBackend, addr common.Address) *b
}
// PackF is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x28811f59.
// the contract method with ID 0x28811f59. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function F() view returns((bytes32)[] a, uint256[] c, bool[] d)
func (structs *Structs) PackF() []byte {
@ -68,6 +69,15 @@ func (structs *Structs) PackF() []byte {
return enc
}
// TryPackF is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x28811f59. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function F() view returns((bytes32)[] a, uint256[] c, bool[] d)
func (structs *Structs) TryPackF() ([]byte, error) {
return structs.abi.Pack("F")
}
// FOutput serves as a container for the return parameters of contract
// method F.
type FOutput struct {
@ -89,12 +99,12 @@ func (structs *Structs) UnpackF(data []byte) (FOutput, error) {
outstruct.A = *abi.ConvertType(out[0], new([]Struct0)).(*[]Struct0)
outstruct.C = *abi.ConvertType(out[1], new([]*big.Int)).(*[]*big.Int)
outstruct.D = *abi.ConvertType(out[2], new([]bool)).(*[]bool)
return *outstruct, err
return *outstruct, nil
}
// PackG is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x6fecb623.
// the contract method with ID 0x6fecb623. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function G() view returns((bytes32)[] a)
func (structs *Structs) PackG() []byte {
@ -105,6 +115,15 @@ func (structs *Structs) PackG() []byte {
return enc
}
// TryPackG is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x6fecb623. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function G() view returns((bytes32)[] a)
func (structs *Structs) TryPackG() ([]byte, error) {
return structs.abi.Pack("G")
}
// UnpackG is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x6fecb623.
//
@ -115,5 +134,5 @@ func (structs *Structs) UnpackG(data []byte) ([]Struct0, error) {
return *new([]Struct0), err
}
out0 := *abi.ConvertType(out[0], new([]Struct0)).(*[]Struct0)
return out0, err
return out0, nil
}

View file

@ -64,7 +64,8 @@ func (token *Token) PackConstructor(initialSupply *big.Int, tokenName string, de
}
// PackAllowance is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xdd62ed3e.
// the contract method with ID 0xdd62ed3e. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function allowance(address , address ) returns(uint256)
func (token *Token) PackAllowance(arg0 common.Address, arg1 common.Address) []byte {
@ -75,6 +76,15 @@ func (token *Token) PackAllowance(arg0 common.Address, arg1 common.Address) []by
return enc
}
// TryPackAllowance is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xdd62ed3e. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function allowance(address , address ) returns(uint256)
func (token *Token) TryPackAllowance(arg0 common.Address, arg1 common.Address) ([]byte, error) {
return token.abi.Pack("allowance", arg0, arg1)
}
// UnpackAllowance is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xdd62ed3e.
//
@ -85,11 +95,12 @@ func (token *Token) UnpackAllowance(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackApproveAndCall is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xcae9ca51.
// the contract method with ID 0xcae9ca51. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns(bool success)
func (token *Token) PackApproveAndCall(spender common.Address, value *big.Int, extraData []byte) []byte {
@ -100,6 +111,15 @@ func (token *Token) PackApproveAndCall(spender common.Address, value *big.Int, e
return enc
}
// TryPackApproveAndCall is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xcae9ca51. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns(bool success)
func (token *Token) TryPackApproveAndCall(spender common.Address, value *big.Int, extraData []byte) ([]byte, error) {
return token.abi.Pack("approveAndCall", spender, value, extraData)
}
// UnpackApproveAndCall is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xcae9ca51.
//
@ -110,11 +130,12 @@ func (token *Token) UnpackApproveAndCall(data []byte) (bool, error) {
return *new(bool), err
}
out0 := *abi.ConvertType(out[0], new(bool)).(*bool)
return out0, err
return out0, nil
}
// PackBalanceOf is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x70a08231.
// the contract method with ID 0x70a08231. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function balanceOf(address ) returns(uint256)
func (token *Token) PackBalanceOf(arg0 common.Address) []byte {
@ -125,6 +146,15 @@ func (token *Token) PackBalanceOf(arg0 common.Address) []byte {
return enc
}
// TryPackBalanceOf is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x70a08231. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function balanceOf(address ) returns(uint256)
func (token *Token) TryPackBalanceOf(arg0 common.Address) ([]byte, error) {
return token.abi.Pack("balanceOf", arg0)
}
// UnpackBalanceOf is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x70a08231.
//
@ -135,11 +165,12 @@ func (token *Token) UnpackBalanceOf(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackDecimals is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x313ce567.
// the contract method with ID 0x313ce567. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function decimals() returns(uint8)
func (token *Token) PackDecimals() []byte {
@ -150,6 +181,15 @@ func (token *Token) PackDecimals() []byte {
return enc
}
// TryPackDecimals is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x313ce567. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function decimals() returns(uint8)
func (token *Token) TryPackDecimals() ([]byte, error) {
return token.abi.Pack("decimals")
}
// UnpackDecimals is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x313ce567.
//
@ -160,11 +200,12 @@ func (token *Token) UnpackDecimals(data []byte) (uint8, error) {
return *new(uint8), err
}
out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8)
return out0, err
return out0, nil
}
// PackName is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x06fdde03.
// the contract method with ID 0x06fdde03. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function name() returns(string)
func (token *Token) PackName() []byte {
@ -175,6 +216,15 @@ func (token *Token) PackName() []byte {
return enc
}
// TryPackName is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x06fdde03. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function name() returns(string)
func (token *Token) TryPackName() ([]byte, error) {
return token.abi.Pack("name")
}
// UnpackName is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x06fdde03.
//
@ -185,11 +235,12 @@ func (token *Token) UnpackName(data []byte) (string, error) {
return *new(string), err
}
out0 := *abi.ConvertType(out[0], new(string)).(*string)
return out0, err
return out0, nil
}
// PackSpentAllowance is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xdc3080f2.
// the contract method with ID 0xdc3080f2. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function spentAllowance(address , address ) returns(uint256)
func (token *Token) PackSpentAllowance(arg0 common.Address, arg1 common.Address) []byte {
@ -200,6 +251,15 @@ func (token *Token) PackSpentAllowance(arg0 common.Address, arg1 common.Address)
return enc
}
// TryPackSpentAllowance is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xdc3080f2. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function spentAllowance(address , address ) returns(uint256)
func (token *Token) TryPackSpentAllowance(arg0 common.Address, arg1 common.Address) ([]byte, error) {
return token.abi.Pack("spentAllowance", arg0, arg1)
}
// UnpackSpentAllowance is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xdc3080f2.
//
@ -210,11 +270,12 @@ func (token *Token) UnpackSpentAllowance(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackSymbol is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x95d89b41.
// the contract method with ID 0x95d89b41. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function symbol() returns(string)
func (token *Token) PackSymbol() []byte {
@ -225,6 +286,15 @@ func (token *Token) PackSymbol() []byte {
return enc
}
// TryPackSymbol is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x95d89b41. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function symbol() returns(string)
func (token *Token) TryPackSymbol() ([]byte, error) {
return token.abi.Pack("symbol")
}
// UnpackSymbol is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x95d89b41.
//
@ -235,11 +305,12 @@ func (token *Token) UnpackSymbol(data []byte) (string, error) {
return *new(string), err
}
out0 := *abi.ConvertType(out[0], new(string)).(*string)
return out0, err
return out0, nil
}
// PackTransfer is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xa9059cbb.
// the contract method with ID 0xa9059cbb. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function transfer(address _to, uint256 _value) returns()
func (token *Token) PackTransfer(to common.Address, value *big.Int) []byte {
@ -250,8 +321,18 @@ func (token *Token) PackTransfer(to common.Address, value *big.Int) []byte {
return enc
}
// TryPackTransfer is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xa9059cbb. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function transfer(address _to, uint256 _value) returns()
func (token *Token) TryPackTransfer(to common.Address, value *big.Int) ([]byte, error) {
return token.abi.Pack("transfer", to, value)
}
// PackTransferFrom is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x23b872dd.
// the contract method with ID 0x23b872dd. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function transferFrom(address _from, address _to, uint256 _value) returns(bool success)
func (token *Token) PackTransferFrom(from common.Address, to common.Address, value *big.Int) []byte {
@ -262,6 +343,15 @@ func (token *Token) PackTransferFrom(from common.Address, to common.Address, val
return enc
}
// TryPackTransferFrom is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x23b872dd. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function transferFrom(address _from, address _to, uint256 _value) returns(bool success)
func (token *Token) TryPackTransferFrom(from common.Address, to common.Address, value *big.Int) ([]byte, error) {
return token.abi.Pack("transferFrom", from, to, value)
}
// UnpackTransferFrom is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x23b872dd.
//
@ -272,7 +362,7 @@ func (token *Token) UnpackTransferFrom(data []byte) (bool, error) {
return *new(bool), err
}
out0 := *abi.ConvertType(out[0], new(bool)).(*bool)
return out0, err
return out0, nil
}
// TokenTransfer represents a Transfer event raised by the Token contract.

View file

@ -77,7 +77,8 @@ func (c *Tuple) Instance(backend bind.ContractBackend, addr common.Address) *bin
}
// PackFunc1 is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x443c79b4.
// the contract method with ID 0x443c79b4. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function func1((uint256,uint256[],(uint256,uint256)[]) a, (uint256,uint256)[2][] b, (uint256,uint256)[][2] c, (uint256,uint256[],(uint256,uint256)[])[] d, uint256[] e) pure returns((uint256,uint256[],(uint256,uint256)[]), (uint256,uint256)[2][], (uint256,uint256)[][2], (uint256,uint256[],(uint256,uint256)[])[], uint256[])
func (tuple *Tuple) PackFunc1(a TupleS, b [][2]TupleT, c [2][]TupleT, d []TupleS, e []*big.Int) []byte {
@ -88,6 +89,15 @@ func (tuple *Tuple) PackFunc1(a TupleS, b [][2]TupleT, c [2][]TupleT, d []TupleS
return enc
}
// TryPackFunc1 is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x443c79b4. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function func1((uint256,uint256[],(uint256,uint256)[]) a, (uint256,uint256)[2][] b, (uint256,uint256)[][2] c, (uint256,uint256[],(uint256,uint256)[])[] d, uint256[] e) pure returns((uint256,uint256[],(uint256,uint256)[]), (uint256,uint256)[2][], (uint256,uint256)[][2], (uint256,uint256[],(uint256,uint256)[])[], uint256[])
func (tuple *Tuple) TryPackFunc1(a TupleS, b [][2]TupleT, c [2][]TupleT, d []TupleS, e []*big.Int) ([]byte, error) {
return tuple.abi.Pack("func1", a, b, c, d, e)
}
// Func1Output serves as a container for the return parameters of contract
// method Func1.
type Func1Output struct {
@ -113,12 +123,12 @@ func (tuple *Tuple) UnpackFunc1(data []byte) (Func1Output, error) {
outstruct.Arg2 = *abi.ConvertType(out[2], new([2][]TupleT)).(*[2][]TupleT)
outstruct.Arg3 = *abi.ConvertType(out[3], new([]TupleS)).(*[]TupleS)
outstruct.Arg4 = *abi.ConvertType(out[4], new([]*big.Int)).(*[]*big.Int)
return *outstruct, err
return *outstruct, nil
}
// PackFunc2 is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xd0062cdd.
// the contract method with ID 0xd0062cdd. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function func2((uint256,uint256[],(uint256,uint256)[]) a, (uint256,uint256)[2][] b, (uint256,uint256)[][2] c, (uint256,uint256[],(uint256,uint256)[])[] d, uint256[] e) returns()
func (tuple *Tuple) PackFunc2(a TupleS, b [][2]TupleT, c [2][]TupleT, d []TupleS, e []*big.Int) []byte {
@ -129,8 +139,18 @@ func (tuple *Tuple) PackFunc2(a TupleS, b [][2]TupleT, c [2][]TupleT, d []TupleS
return enc
}
// TryPackFunc2 is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xd0062cdd. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function func2((uint256,uint256[],(uint256,uint256)[]) a, (uint256,uint256)[2][] b, (uint256,uint256)[][2] c, (uint256,uint256[],(uint256,uint256)[])[] d, uint256[] e) returns()
func (tuple *Tuple) TryPackFunc2(a TupleS, b [][2]TupleT, c [2][]TupleT, d []TupleS, e []*big.Int) ([]byte, error) {
return tuple.abi.Pack("func2", a, b, c, d, e)
}
// PackFunc3 is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xe4d9a43b.
// the contract method with ID 0xe4d9a43b. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function func3((uint16,uint16)[] ) pure returns()
func (tuple *Tuple) PackFunc3(arg0 []TupleQ) []byte {
@ -141,6 +161,15 @@ func (tuple *Tuple) PackFunc3(arg0 []TupleQ) []byte {
return enc
}
// TryPackFunc3 is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xe4d9a43b. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function func3((uint16,uint16)[] ) pure returns()
func (tuple *Tuple) TryPackFunc3(arg0 []TupleQ) ([]byte, error) {
return tuple.abi.Pack("func3", arg0)
}
// TupleTupleEvent represents a TupleEvent event raised by the Tuple contract.
type TupleTupleEvent struct {
A TupleS

View file

@ -52,7 +52,8 @@ func (c *Tupler) Instance(backend bind.ContractBackend, addr common.Address) *bi
}
// PackTuple is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x3175aae2.
// the contract method with ID 0x3175aae2. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function tuple() returns(string a, int256 b, bytes32 c)
func (tupler *Tupler) PackTuple() []byte {
@ -63,6 +64,15 @@ func (tupler *Tupler) PackTuple() []byte {
return enc
}
// TryPackTuple is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x3175aae2. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function tuple() returns(string a, int256 b, bytes32 c)
func (tupler *Tupler) TryPackTuple() ([]byte, error) {
return tupler.abi.Pack("tuple")
}
// TupleOutput serves as a container for the return parameters of contract
// method Tuple.
type TupleOutput struct {
@ -84,6 +94,5 @@ func (tupler *Tupler) UnpackTuple(data []byte) (TupleOutput, error) {
outstruct.A = *abi.ConvertType(out[0], new(string)).(*string)
outstruct.B = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
outstruct.C = *abi.ConvertType(out[2], new([32]byte)).(*[32]byte)
return *outstruct, err
return *outstruct, nil
}

View file

@ -52,7 +52,8 @@ func (c *Underscorer) Instance(backend bind.ContractBackend, addr common.Address
}
// PackAllPurelyUnderscoredOutput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xb564b34d.
// the contract method with ID 0xb564b34d. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function AllPurelyUnderscoredOutput() view returns(int256 _, int256 __)
func (underscorer *Underscorer) PackAllPurelyUnderscoredOutput() []byte {
@ -63,6 +64,15 @@ func (underscorer *Underscorer) PackAllPurelyUnderscoredOutput() []byte {
return enc
}
// TryPackAllPurelyUnderscoredOutput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xb564b34d. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function AllPurelyUnderscoredOutput() view returns(int256 _, int256 __)
func (underscorer *Underscorer) TryPackAllPurelyUnderscoredOutput() ([]byte, error) {
return underscorer.abi.Pack("AllPurelyUnderscoredOutput")
}
// AllPurelyUnderscoredOutputOutput serves as a container for the return parameters of contract
// method AllPurelyUnderscoredOutput.
type AllPurelyUnderscoredOutputOutput struct {
@ -82,12 +92,12 @@ func (underscorer *Underscorer) UnpackAllPurelyUnderscoredOutput(data []byte) (A
}
outstruct.Arg0 = abi.ConvertType(out[0], new(big.Int)).(*big.Int)
outstruct.Arg1 = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
return *outstruct, err
return *outstruct, nil
}
// PackLowerLowerCollision is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xe409ca45.
// the contract method with ID 0xe409ca45. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function LowerLowerCollision() view returns(int256 _res, int256 res)
func (underscorer *Underscorer) PackLowerLowerCollision() []byte {
@ -98,6 +108,15 @@ func (underscorer *Underscorer) PackLowerLowerCollision() []byte {
return enc
}
// TryPackLowerLowerCollision is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xe409ca45. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function LowerLowerCollision() view returns(int256 _res, int256 res)
func (underscorer *Underscorer) TryPackLowerLowerCollision() ([]byte, error) {
return underscorer.abi.Pack("LowerLowerCollision")
}
// LowerLowerCollisionOutput serves as a container for the return parameters of contract
// method LowerLowerCollision.
type LowerLowerCollisionOutput struct {
@ -117,12 +136,12 @@ func (underscorer *Underscorer) UnpackLowerLowerCollision(data []byte) (LowerLow
}
outstruct.Res = abi.ConvertType(out[0], new(big.Int)).(*big.Int)
outstruct.Res0 = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
return *outstruct, err
return *outstruct, nil
}
// PackLowerUpperCollision is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x03a59213.
// the contract method with ID 0x03a59213. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function LowerUpperCollision() view returns(int256 _res, int256 Res)
func (underscorer *Underscorer) PackLowerUpperCollision() []byte {
@ -133,6 +152,15 @@ func (underscorer *Underscorer) PackLowerUpperCollision() []byte {
return enc
}
// TryPackLowerUpperCollision is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x03a59213. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function LowerUpperCollision() view returns(int256 _res, int256 Res)
func (underscorer *Underscorer) TryPackLowerUpperCollision() ([]byte, error) {
return underscorer.abi.Pack("LowerUpperCollision")
}
// LowerUpperCollisionOutput serves as a container for the return parameters of contract
// method LowerUpperCollision.
type LowerUpperCollisionOutput struct {
@ -152,12 +180,12 @@ func (underscorer *Underscorer) UnpackLowerUpperCollision(data []byte) (LowerUpp
}
outstruct.Res = abi.ConvertType(out[0], new(big.Int)).(*big.Int)
outstruct.Res0 = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
return *outstruct, err
return *outstruct, nil
}
// PackPurelyUnderscoredOutput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x9df48485.
// the contract method with ID 0x9df48485. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function PurelyUnderscoredOutput() view returns(int256 _, int256 res)
func (underscorer *Underscorer) PackPurelyUnderscoredOutput() []byte {
@ -168,6 +196,15 @@ func (underscorer *Underscorer) PackPurelyUnderscoredOutput() []byte {
return enc
}
// TryPackPurelyUnderscoredOutput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x9df48485. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function PurelyUnderscoredOutput() view returns(int256 _, int256 res)
func (underscorer *Underscorer) TryPackPurelyUnderscoredOutput() ([]byte, error) {
return underscorer.abi.Pack("PurelyUnderscoredOutput")
}
// PurelyUnderscoredOutputOutput serves as a container for the return parameters of contract
// method PurelyUnderscoredOutput.
type PurelyUnderscoredOutputOutput struct {
@ -187,12 +224,12 @@ func (underscorer *Underscorer) UnpackPurelyUnderscoredOutput(data []byte) (Pure
}
outstruct.Arg0 = abi.ConvertType(out[0], new(big.Int)).(*big.Int)
outstruct.Res = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
return *outstruct, err
return *outstruct, nil
}
// PackUnderscoredOutput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x67e6633d.
// the contract method with ID 0x67e6633d. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function UnderscoredOutput() view returns(int256 _int, string _string)
func (underscorer *Underscorer) PackUnderscoredOutput() []byte {
@ -203,6 +240,15 @@ func (underscorer *Underscorer) PackUnderscoredOutput() []byte {
return enc
}
// TryPackUnderscoredOutput is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x67e6633d. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function UnderscoredOutput() view returns(int256 _int, string _string)
func (underscorer *Underscorer) TryPackUnderscoredOutput() ([]byte, error) {
return underscorer.abi.Pack("UnderscoredOutput")
}
// UnderscoredOutputOutput serves as a container for the return parameters of contract
// method UnderscoredOutput.
type UnderscoredOutputOutput struct {
@ -222,12 +268,12 @@ func (underscorer *Underscorer) UnpackUnderscoredOutput(data []byte) (Underscore
}
outstruct.Int = abi.ConvertType(out[0], new(big.Int)).(*big.Int)
outstruct.String = *abi.ConvertType(out[1], new(string)).(*string)
return *outstruct, err
return *outstruct, nil
}
// PackUpperLowerCollision is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xaf7486ab.
// the contract method with ID 0xaf7486ab. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function UpperLowerCollision() view returns(int256 _Res, int256 res)
func (underscorer *Underscorer) PackUpperLowerCollision() []byte {
@ -238,6 +284,15 @@ func (underscorer *Underscorer) PackUpperLowerCollision() []byte {
return enc
}
// TryPackUpperLowerCollision is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xaf7486ab. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function UpperLowerCollision() view returns(int256 _Res, int256 res)
func (underscorer *Underscorer) TryPackUpperLowerCollision() ([]byte, error) {
return underscorer.abi.Pack("UpperLowerCollision")
}
// UpperLowerCollisionOutput serves as a container for the return parameters of contract
// method UpperLowerCollision.
type UpperLowerCollisionOutput struct {
@ -257,12 +312,12 @@ func (underscorer *Underscorer) UnpackUpperLowerCollision(data []byte) (UpperLow
}
outstruct.Res = abi.ConvertType(out[0], new(big.Int)).(*big.Int)
outstruct.Res0 = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
return *outstruct, err
return *outstruct, nil
}
// PackUpperUpperCollision is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xe02ab24d.
// the contract method with ID 0xe02ab24d. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function UpperUpperCollision() view returns(int256 _Res, int256 Res)
func (underscorer *Underscorer) PackUpperUpperCollision() []byte {
@ -273,6 +328,15 @@ func (underscorer *Underscorer) PackUpperUpperCollision() []byte {
return enc
}
// TryPackUpperUpperCollision is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xe02ab24d. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function UpperUpperCollision() view returns(int256 _Res, int256 Res)
func (underscorer *Underscorer) TryPackUpperUpperCollision() ([]byte, error) {
return underscorer.abi.Pack("UpperUpperCollision")
}
// UpperUpperCollisionOutput serves as a container for the return parameters of contract
// method UpperUpperCollision.
type UpperUpperCollisionOutput struct {
@ -292,12 +356,12 @@ func (underscorer *Underscorer) UnpackUpperUpperCollision(data []byte) (UpperUpp
}
outstruct.Res = abi.ConvertType(out[0], new(big.Int)).(*big.Int)
outstruct.Res0 = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
return *outstruct, err
return *outstruct, nil
}
// PackUnderScoredFunc is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x46546dbe.
// the contract method with ID 0x46546dbe. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function _under_scored_func() view returns(int256 _int)
func (underscorer *Underscorer) PackUnderScoredFunc() []byte {
@ -308,6 +372,15 @@ func (underscorer *Underscorer) PackUnderScoredFunc() []byte {
return enc
}
// TryPackUnderScoredFunc is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x46546dbe. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function _under_scored_func() view returns(int256 _int)
func (underscorer *Underscorer) TryPackUnderScoredFunc() ([]byte, error) {
return underscorer.abi.Pack("_under_scored_func")
}
// UnpackUnderScoredFunc is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x46546dbe.
//
@ -318,5 +391,5 @@ func (underscorer *Underscorer) UnpackUnderScoredFunc(data []byte) (*big.Int, er
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}

View file

@ -59,7 +59,8 @@ func (c *DB) Instance(backend bind.ContractBackend, addr common.Address) *bind.B
}
// PackGet is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x9507d39a.
// the contract method with ID 0x9507d39a. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function get(uint256 k) returns(uint256)
func (dB *DB) PackGet(k *big.Int) []byte {
@ -70,6 +71,15 @@ func (dB *DB) PackGet(k *big.Int) []byte {
return enc
}
// TryPackGet is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x9507d39a. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function get(uint256 k) returns(uint256)
func (dB *DB) TryPackGet(k *big.Int) ([]byte, error) {
return dB.abi.Pack("get", k)
}
// UnpackGet is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x9507d39a.
//
@ -80,11 +90,12 @@ func (dB *DB) UnpackGet(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// PackGetNamedStatParams is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xe369ba3b.
// the contract method with ID 0xe369ba3b. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function getNamedStatParams() view returns(uint256 gets, uint256 inserts, uint256 mods)
func (dB *DB) PackGetNamedStatParams() []byte {
@ -95,6 +106,15 @@ func (dB *DB) PackGetNamedStatParams() []byte {
return enc
}
// TryPackGetNamedStatParams is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xe369ba3b. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function getNamedStatParams() view returns(uint256 gets, uint256 inserts, uint256 mods)
func (dB *DB) TryPackGetNamedStatParams() ([]byte, error) {
return dB.abi.Pack("getNamedStatParams")
}
// GetNamedStatParamsOutput serves as a container for the return parameters of contract
// method GetNamedStatParams.
type GetNamedStatParamsOutput struct {
@ -116,12 +136,12 @@ func (dB *DB) UnpackGetNamedStatParams(data []byte) (GetNamedStatParamsOutput, e
outstruct.Gets = abi.ConvertType(out[0], new(big.Int)).(*big.Int)
outstruct.Inserts = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
outstruct.Mods = abi.ConvertType(out[2], new(big.Int)).(*big.Int)
return *outstruct, err
return *outstruct, nil
}
// PackGetStatParams is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x6fcb9c70.
// the contract method with ID 0x6fcb9c70. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function getStatParams() view returns(uint256, uint256, uint256)
func (dB *DB) PackGetStatParams() []byte {
@ -132,6 +152,15 @@ func (dB *DB) PackGetStatParams() []byte {
return enc
}
// TryPackGetStatParams is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x6fcb9c70. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function getStatParams() view returns(uint256, uint256, uint256)
func (dB *DB) TryPackGetStatParams() ([]byte, error) {
return dB.abi.Pack("getStatParams")
}
// GetStatParamsOutput serves as a container for the return parameters of contract
// method GetStatParams.
type GetStatParamsOutput struct {
@ -153,12 +182,12 @@ func (dB *DB) UnpackGetStatParams(data []byte) (GetStatParamsOutput, error) {
outstruct.Arg0 = abi.ConvertType(out[0], new(big.Int)).(*big.Int)
outstruct.Arg1 = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
outstruct.Arg2 = abi.ConvertType(out[2], new(big.Int)).(*big.Int)
return *outstruct, err
return *outstruct, nil
}
// PackGetStatsStruct is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xee8161e0.
// the contract method with ID 0xee8161e0. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function getStatsStruct() view returns((uint256,uint256,uint256))
func (dB *DB) PackGetStatsStruct() []byte {
@ -169,6 +198,15 @@ func (dB *DB) PackGetStatsStruct() []byte {
return enc
}
// TryPackGetStatsStruct is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xee8161e0. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function getStatsStruct() view returns((uint256,uint256,uint256))
func (dB *DB) TryPackGetStatsStruct() ([]byte, error) {
return dB.abi.Pack("getStatsStruct")
}
// UnpackGetStatsStruct is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xee8161e0.
//
@ -179,11 +217,12 @@ func (dB *DB) UnpackGetStatsStruct(data []byte) (DBStats, error) {
return *new(DBStats), err
}
out0 := *abi.ConvertType(out[0], new(DBStats)).(*DBStats)
return out0, err
return out0, nil
}
// PackInsert is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x1d834a1b.
// the contract method with ID 0x1d834a1b. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function insert(uint256 k, uint256 v) returns(uint256)
func (dB *DB) PackInsert(k *big.Int, v *big.Int) []byte {
@ -194,6 +233,15 @@ func (dB *DB) PackInsert(k *big.Int, v *big.Int) []byte {
return enc
}
// TryPackInsert is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x1d834a1b. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function insert(uint256 k, uint256 v) returns(uint256)
func (dB *DB) TryPackInsert(k *big.Int, v *big.Int) ([]byte, error) {
return dB.abi.Pack("insert", k, v)
}
// UnpackInsert is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x1d834a1b.
//
@ -204,7 +252,7 @@ func (dB *DB) UnpackInsert(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// DBInsert represents a Insert event raised by the DB contract.

View file

@ -52,7 +52,8 @@ func (c *C) Instance(backend bind.ContractBackend, addr common.Address) *bind.Bo
}
// PackEmitMulti is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xcb493749.
// the contract method with ID 0xcb493749. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function EmitMulti() returns()
func (c *C) PackEmitMulti() []byte {
@ -63,8 +64,18 @@ func (c *C) PackEmitMulti() []byte {
return enc
}
// TryPackEmitMulti is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xcb493749. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function EmitMulti() returns()
func (c *C) TryPackEmitMulti() ([]byte, error) {
return c.abi.Pack("EmitMulti")
}
// PackEmitOne is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xe8e49a71.
// the contract method with ID 0xe8e49a71. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function EmitOne() returns()
func (c *C) PackEmitOne() []byte {
@ -75,6 +86,15 @@ func (c *C) PackEmitOne() []byte {
return enc
}
// TryPackEmitOne is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xe8e49a71. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function EmitOne() returns()
func (c *C) TryPackEmitOne() ([]byte, error) {
return c.abi.Pack("EmitOne")
}
// CBasic1 represents a basic1 event raised by the C contract.
type CBasic1 struct {
Id *big.Int

View file

@ -68,7 +68,8 @@ func (c1 *C1) PackConstructor(v1 *big.Int, v2 *big.Int) []byte {
}
// PackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272.
// the contract method with ID 0x2ad11272. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function Do(uint256 val) pure returns(uint256 res)
func (c1 *C1) PackDo(val *big.Int) []byte {
@ -79,6 +80,15 @@ func (c1 *C1) PackDo(val *big.Int) []byte {
return enc
}
// TryPackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function Do(uint256 val) pure returns(uint256 res)
func (c1 *C1) TryPackDo(val *big.Int) ([]byte, error) {
return c1.abi.Pack("Do", val)
}
// UnpackDo is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x2ad11272.
//
@ -89,7 +99,7 @@ func (c1 *C1) UnpackDo(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// C2MetaData contains all meta data concerning the C2 contract.
@ -136,7 +146,8 @@ func (c2 *C2) PackConstructor(v1 *big.Int, v2 *big.Int) []byte {
}
// PackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272.
// the contract method with ID 0x2ad11272. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function Do(uint256 val) pure returns(uint256 res)
func (c2 *C2) PackDo(val *big.Int) []byte {
@ -147,6 +158,15 @@ func (c2 *C2) PackDo(val *big.Int) []byte {
return enc
}
// TryPackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function Do(uint256 val) pure returns(uint256 res)
func (c2 *C2) TryPackDo(val *big.Int) ([]byte, error) {
return c2.abi.Pack("Do", val)
}
// UnpackDo is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x2ad11272.
//
@ -157,7 +177,7 @@ func (c2 *C2) UnpackDo(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// L1MetaData contains all meta data concerning the L1 contract.
@ -188,7 +208,8 @@ func (c *L1) Instance(backend bind.ContractBackend, addr common.Address) *bind.B
}
// PackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272.
// the contract method with ID 0x2ad11272. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function Do(uint256 val) pure returns(uint256)
func (l1 *L1) PackDo(val *big.Int) []byte {
@ -199,6 +220,15 @@ func (l1 *L1) PackDo(val *big.Int) []byte {
return enc
}
// TryPackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function Do(uint256 val) pure returns(uint256)
func (l1 *L1) TryPackDo(val *big.Int) ([]byte, error) {
return l1.abi.Pack("Do", val)
}
// UnpackDo is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x2ad11272.
//
@ -209,7 +239,7 @@ func (l1 *L1) UnpackDo(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// L2MetaData contains all meta data concerning the L2 contract.
@ -243,7 +273,8 @@ func (c *L2) Instance(backend bind.ContractBackend, addr common.Address) *bind.B
}
// PackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272.
// the contract method with ID 0x2ad11272. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function Do(uint256 val) pure returns(uint256)
func (l2 *L2) PackDo(val *big.Int) []byte {
@ -254,6 +285,15 @@ func (l2 *L2) PackDo(val *big.Int) []byte {
return enc
}
// TryPackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function Do(uint256 val) pure returns(uint256)
func (l2 *L2) TryPackDo(val *big.Int) ([]byte, error) {
return l2.abi.Pack("Do", val)
}
// UnpackDo is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x2ad11272.
//
@ -264,7 +304,7 @@ func (l2 *L2) UnpackDo(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// L2bMetaData contains all meta data concerning the L2b contract.
@ -298,7 +338,8 @@ func (c *L2b) Instance(backend bind.ContractBackend, addr common.Address) *bind.
}
// PackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272.
// the contract method with ID 0x2ad11272. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function Do(uint256 val) pure returns(uint256)
func (l2b *L2b) PackDo(val *big.Int) []byte {
@ -309,6 +350,15 @@ func (l2b *L2b) PackDo(val *big.Int) []byte {
return enc
}
// TryPackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function Do(uint256 val) pure returns(uint256)
func (l2b *L2b) TryPackDo(val *big.Int) ([]byte, error) {
return l2b.abi.Pack("Do", val)
}
// UnpackDo is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x2ad11272.
//
@ -319,7 +369,7 @@ func (l2b *L2b) UnpackDo(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// L3MetaData contains all meta data concerning the L3 contract.
@ -350,7 +400,8 @@ func (c *L3) Instance(backend bind.ContractBackend, addr common.Address) *bind.B
}
// PackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272.
// the contract method with ID 0x2ad11272. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function Do(uint256 val) pure returns(uint256)
func (l3 *L3) PackDo(val *big.Int) []byte {
@ -361,6 +412,15 @@ func (l3 *L3) PackDo(val *big.Int) []byte {
return enc
}
// TryPackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function Do(uint256 val) pure returns(uint256)
func (l3 *L3) TryPackDo(val *big.Int) ([]byte, error) {
return l3.abi.Pack("Do", val)
}
// UnpackDo is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x2ad11272.
//
@ -371,7 +431,7 @@ func (l3 *L3) UnpackDo(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// L4MetaData contains all meta data concerning the L4 contract.
@ -406,7 +466,8 @@ func (c *L4) Instance(backend bind.ContractBackend, addr common.Address) *bind.B
}
// PackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272.
// the contract method with ID 0x2ad11272. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function Do(uint256 val) pure returns(uint256)
func (l4 *L4) PackDo(val *big.Int) []byte {
@ -417,6 +478,15 @@ func (l4 *L4) PackDo(val *big.Int) []byte {
return enc
}
// TryPackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function Do(uint256 val) pure returns(uint256)
func (l4 *L4) TryPackDo(val *big.Int) ([]byte, error) {
return l4.abi.Pack("Do", val)
}
// UnpackDo is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x2ad11272.
//
@ -427,7 +497,7 @@ func (l4 *L4) UnpackDo(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}
// L4bMetaData contains all meta data concerning the L4b contract.
@ -461,7 +531,8 @@ func (c *L4b) Instance(backend bind.ContractBackend, addr common.Address) *bind.
}
// PackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272.
// the contract method with ID 0x2ad11272. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function Do(uint256 val) pure returns(uint256)
func (l4b *L4b) PackDo(val *big.Int) []byte {
@ -472,6 +543,15 @@ func (l4b *L4b) PackDo(val *big.Int) []byte {
return enc
}
// TryPackDo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0x2ad11272. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function Do(uint256 val) pure returns(uint256)
func (l4b *L4b) TryPackDo(val *big.Int) ([]byte, error) {
return l4b.abi.Pack("Do", val)
}
// UnpackDo is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0x2ad11272.
//
@ -482,5 +562,5 @@ func (l4b *L4b) UnpackDo(data []byte) (*big.Int, error) {
return new(big.Int), err
}
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
return out0, err
return out0, nil
}

View file

@ -52,7 +52,8 @@ func (c *C) Instance(backend bind.ContractBackend, addr common.Address) *bind.Bo
}
// PackBar is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xb0a378b0.
// the contract method with ID 0xb0a378b0. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function Bar() pure returns()
func (c *C) PackBar() []byte {
@ -63,8 +64,18 @@ func (c *C) PackBar() []byte {
return enc
}
// TryPackBar is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xb0a378b0. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function Bar() pure returns()
func (c *C) TryPackBar() ([]byte, error) {
return c.abi.Pack("Bar")
}
// PackFoo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xbfb4ebcf.
// the contract method with ID 0xbfb4ebcf. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function Foo() pure returns()
func (c *C) PackFoo() []byte {
@ -75,6 +86,15 @@ func (c *C) PackFoo() []byte {
return enc
}
// TryPackFoo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xbfb4ebcf. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function Foo() pure returns()
func (c *C) TryPackFoo() ([]byte, error) {
return c.abi.Pack("Foo")
}
// UnpackError attempts to decode the provided error data using user-defined
// error definitions.
func (c *C) UnpackError(raw []byte) (any, error) {
@ -169,7 +189,8 @@ func (c *C2) Instance(backend bind.ContractBackend, addr common.Address) *bind.B
}
// PackFoo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xbfb4ebcf.
// the contract method with ID 0xbfb4ebcf. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function Foo() pure returns()
func (c2 *C2) PackFoo() []byte {
@ -180,6 +201,15 @@ func (c2 *C2) PackFoo() []byte {
return enc
}
// TryPackFoo is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xbfb4ebcf. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function Foo() pure returns()
func (c2 *C2) TryPackFoo() ([]byte, error) {
return c2.abi.Pack("Foo")
}
// UnpackError attempts to decode the provided error data using user-defined
// error definitions.
func (c2 *C2) UnpackError(raw []byte) (any, error) {

View file

@ -52,7 +52,8 @@ func (c *MyContract) Instance(backend bind.ContractBackend, addr common.Address)
}
// PackGetNums is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xbd6d1007.
// the contract method with ID 0xbd6d1007. This method will panic if any
// invalid/nil inputs are passed.
//
// Solidity: function GetNums() pure returns(uint256[5])
func (myContract *MyContract) PackGetNums() []byte {
@ -63,6 +64,15 @@ func (myContract *MyContract) PackGetNums() []byte {
return enc
}
// TryPackGetNums is the Go binding used to pack the parameters required for calling
// the contract method with ID 0xbd6d1007. This method will return an error
// if any inputs are invalid/nil.
//
// Solidity: function GetNums() pure returns(uint256[5])
func (myContract *MyContract) TryPackGetNums() ([]byte, error) {
return myContract.abi.Pack("GetNums")
}
// UnpackGetNums is the Go binding that unpacks the parameters returned
// from invoking the contract method with ID 0xbd6d1007.
//
@ -73,5 +83,5 @@ func (myContract *MyContract) UnpackGetNums(data []byte) ([5]*big.Int, error) {
return *new([5]*big.Int), err
}
out0 := *abi.ConvertType(out[0], new([5]*big.Int)).(*[5]*big.Int)
return out0, err
return out0, nil
}

View file

@ -272,7 +272,7 @@ var (
}
GCModeFlag = &cli.StringFlag{
Name: "gcmode",
Usage: `Blockchain garbage collection mode, only relevant in state.scheme=hash ("full", "archive")`,
Usage: `Blockchain garbage collection mode ("full", "archive")`,
Value: "full",
Category: flags.StateCategory,
}
@ -1390,13 +1390,13 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
cfg.UseLightweightKDF = ctx.Bool(LightKDFFlag.Name)
}
if ctx.IsSet(NoUSBFlag.Name) || cfg.NoUSB {
log.Warn("Option nousb is deprecated and USB is deactivated by default. Use --usb to enable")
log.Warn("Option --nousb is deprecated and USB is deactivated by default. Use --usb to enable")
}
if ctx.IsSet(USBFlag.Name) {
cfg.USB = ctx.Bool(USBFlag.Name)
}
if ctx.IsSet(InsecureUnlockAllowedFlag.Name) {
log.Warn(fmt.Sprintf("Option %q is deprecated and has no effect", InsecureUnlockAllowedFlag.Name))
log.Warn(fmt.Sprintf("Option --%s is deprecated and has no effect", InsecureUnlockAllowedFlag.Name))
}
if ctx.IsSet(DBEngineFlag.Name) {
dbEngine := ctx.String(DBEngineFlag.Name)
@ -1408,10 +1408,10 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
}
// deprecation notice for log debug flags (TODO: find a more appropriate place to put these?)
if ctx.IsSet(LogBacktraceAtFlag.Name) {
log.Warn("log.backtrace flag is deprecated")
log.Warn("Option --log.backtrace flag is deprecated")
}
if ctx.IsSet(LogDebugFlag.Name) {
log.Warn("log.debug flag is deprecated")
log.Warn("Option --log.debug flag is deprecated")
}
}

View file

@ -44,40 +44,50 @@ var DeprecatedFlags = []cli.Flag{
MinerNewPayloadTimeoutFlag,
MinerEtherbaseFlag,
MiningEnabledFlag,
MetricsEnabledExpensiveFlag,
EnablePersonal,
UnlockedAccountFlag,
InsecureUnlockAllowedFlag,
}
var (
// Deprecated May 2020, shown in aliased flags section
NoUSBFlag = &cli.BoolFlag{
Name: "nousb",
Hidden: true,
Usage: "Disables monitoring for and managing USB hardware wallets (deprecated)",
Category: flags.DeprecatedCategory,
}
// Deprecated March 2022
LegacyWhitelistFlag = &cli.StringFlag{
Name: "whitelist",
Hidden: true,
Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>) (deprecated in favor of --eth.requiredblocks)",
Category: flags.DeprecatedCategory,
}
// Deprecated July 2023
CacheTrieJournalFlag = &cli.StringFlag{
Name: "cache.trie.journal",
Hidden: true,
Usage: "Disk journal directory for trie cache to survive node restarts",
Category: flags.DeprecatedCategory,
}
CacheTrieRejournalFlag = &cli.DurationFlag{
Name: "cache.trie.rejournal",
Hidden: true,
Usage: "Time interval to regenerate the trie cache journal",
Category: flags.DeprecatedCategory,
}
LegacyDiscoveryV5Flag = &cli.BoolFlag{
Name: "v5disc",
Hidden: true,
Usage: "Enables the experimental RLPx V5 (Topic Discovery) mechanism (deprecated, use --discv5 instead)",
Category: flags.DeprecatedCategory,
}
// Deprecated August 2023
TxLookupLimitFlag = &cli.Uint64Flag{
Name: "txlookuplimit",
Hidden: true,
Usage: "Number of recent blocks to maintain transactions index for (default = about one year, 0 = entire chain) (deprecated, use history.transactions instead)",
Value: ethconfig.Defaults.TransactionHistory,
Category: flags.DeprecatedCategory,
@ -85,51 +95,60 @@ var (
// Deprecated November 2023
LogBacktraceAtFlag = &cli.StringFlag{
Name: "log.backtrace",
Hidden: true,
Usage: "Request a stack trace at a specific logging statement (deprecated)",
Value: "",
Category: flags.DeprecatedCategory,
}
LogDebugFlag = &cli.BoolFlag{
Name: "log.debug",
Hidden: true,
Usage: "Prepends log messages with call-site location (deprecated)",
Category: flags.DeprecatedCategory,
}
// Deprecated February 2024
MinerNewPayloadTimeoutFlag = &cli.DurationFlag{
Name: "miner.newpayload-timeout",
Hidden: true,
Usage: "Specify the maximum time allowance for creating a new payload (deprecated)",
Value: ethconfig.Defaults.Miner.Recommit,
Category: flags.DeprecatedCategory,
}
MinerEtherbaseFlag = &cli.StringFlag{
Name: "miner.etherbase",
Hidden: true,
Usage: "0x prefixed public address for block mining rewards (deprecated)",
Category: flags.DeprecatedCategory,
}
MiningEnabledFlag = &cli.BoolFlag{
Name: "mine",
Hidden: true,
Usage: "Enable mining (deprecated)",
Category: flags.DeprecatedCategory,
}
MetricsEnabledExpensiveFlag = &cli.BoolFlag{
Name: "metrics.expensive",
Hidden: true,
Usage: "Enable expensive metrics collection and reporting (deprecated)",
Category: flags.DeprecatedCategory,
}
// Deprecated Oct 2024
EnablePersonal = &cli.BoolFlag{
Name: "rpc.enabledeprecatedpersonal",
Hidden: true,
Usage: "This used to enable the 'personal' namespace.",
Category: flags.DeprecatedCategory,
}
UnlockedAccountFlag = &cli.StringFlag{
Name: "unlock",
Hidden: true,
Usage: "Comma separated list of accounts to unlock (deprecated)",
Value: "",
Category: flags.DeprecatedCategory,
}
InsecureUnlockAllowedFlag = &cli.BoolFlag{
Name: "allow-insecure-unlock",
Hidden: true,
Usage: "Allow insecure account unlocking when account-related RPCs are exposed by http (deprecated)",
Category: flags.DeprecatedCategory,
}

View file

@ -17,6 +17,13 @@ and `eth_getBlockByNumber`, use this command:
> ./workload test --sepolia --run History/getBlockBy http://host:8545
```
Notably, trace tests require archive which keeps all the historical states for tracing.
The additional flag is required to activate the trace tests.
```
> ./workload test --sepolia --archive --run Trace/Block http://host:8545
```
### Regenerating tests
There is a facility for updating the tests from the chain. This can also be used to
@ -26,5 +33,5 @@ the following commands (in this directory) against a synced mainnet node:
```shell
> go run . filtergen --queries queries/filter_queries_mainnet.json http://host:8545
> go run . historygen --history-tests queries/history_mainnet.json http://host:8545
> go run . tracegen --trace-tests queries/trace_mainnet.json http://host:8545
> go run . tracegen --trace-tests queries/trace_mainnet.json --trace-start 4000000 --trace-end 4000100 http://host:8545
```

View file

@ -21,6 +21,7 @@ import (
"encoding/json"
"fmt"
"math/big"
"os"
"time"
"github.com/ethereum/go-ethereum"
@ -152,9 +153,16 @@ func (s *filterTestSuite) fullRangeQueryAndCheck(t *utesting.T, query *filterQue
func (s *filterTestSuite) loadQueries() error {
file, err := s.cfg.fsys.Open(s.cfg.filterQueryFile)
if err != nil {
// If not found in embedded FS, try to load it from disk
if !os.IsNotExist(err) {
return err
}
file, err = os.OpenFile(s.cfg.filterQueryFile, os.O_RDONLY, 0666)
if err != nil {
return fmt.Errorf("can't open filterQueryFile: %v", err)
}
}
defer file.Close()
var queries [][]*filterQuery

View file

@ -20,6 +20,7 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
@ -51,9 +52,16 @@ func newHistoryTestSuite(cfg testConfig) *historyTestSuite {
func (s *historyTestSuite) loadTests() error {
file, err := s.cfg.fsys.Open(s.cfg.historyTestFile)
if err != nil {
// If not found in embedded FS, try to load it from disk
if !os.IsNotExist(err) {
return err
}
file, err = os.OpenFile(s.cfg.historyTestFile, os.O_RDONLY, 0666)
if err != nil {
return fmt.Errorf("can't open historyTestFile: %v", err)
}
}
defer file.Close()
if err := json.NewDecoder(file).Decode(&s.tests); err != nil {
return fmt.Errorf("invalid JSON in %s: %v", s.cfg.historyTestFile, err)

View file

@ -22,6 +22,7 @@ import (
"fmt"
"math/big"
"os"
"path/filepath"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
@ -137,11 +138,17 @@ func calcReceiptsHash(rcpt []*types.Receipt) common.Hash {
}
func writeJSON(fileName string, value any) {
// Ensure the directory exists
dir := filepath.Dir(fileName)
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
exit(fmt.Errorf("failed to create directories: %w", err))
}
file, err := os.Create(fileName)
if err != nil {
exit(fmt.Errorf("error creating %s: %v", fileName, err))
return
}
defer file.Close()
json.NewEncoder(file).Encode(value)
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -143,32 +143,80 @@ func testConfigFromCLI(ctx *cli.Context) (cfg testConfig) {
switch {
case ctx.Bool(testMainnetFlag.Name):
cfg.fsys = builtinTestFiles
if ctx.IsSet(filterQueryFileFlag.Name) {
cfg.filterQueryFile = ctx.String(filterQueryFileFlag.Name)
} else {
cfg.filterQueryFile = "queries/filter_queries_mainnet.json"
}
if ctx.IsSet(historyTestFileFlag.Name) {
cfg.historyTestFile = ctx.String(historyTestFileFlag.Name)
} else {
cfg.historyTestFile = "queries/history_mainnet.json"
}
if ctx.IsSet(traceTestFileFlag.Name) {
cfg.traceTestFile = ctx.String(traceTestFileFlag.Name)
} else {
cfg.traceTestFile = "queries/trace_mainnet.json"
}
cfg.historyPruneBlock = new(uint64)
*cfg.historyPruneBlock = history.PrunePoints[params.MainnetGenesisHash].BlockNumber
cfg.traceTestFile = "queries/trace_mainnet.json"
case ctx.Bool(testSepoliaFlag.Name):
cfg.fsys = builtinTestFiles
if ctx.IsSet(filterQueryFileFlag.Name) {
cfg.filterQueryFile = ctx.String(filterQueryFileFlag.Name)
} else {
cfg.filterQueryFile = "queries/filter_queries_sepolia.json"
}
if ctx.IsSet(historyTestFileFlag.Name) {
cfg.historyTestFile = ctx.String(historyTestFileFlag.Name)
} else {
cfg.historyTestFile = "queries/history_sepolia.json"
}
if ctx.IsSet(traceTestFileFlag.Name) {
cfg.traceTestFile = ctx.String(traceTestFileFlag.Name)
} else {
cfg.traceTestFile = "queries/trace_sepolia.json"
}
cfg.historyPruneBlock = new(uint64)
*cfg.historyPruneBlock = history.PrunePoints[params.SepoliaGenesisHash].BlockNumber
cfg.traceTestFile = "queries/trace_sepolia.json"
case ctx.Bool(testBerachainFlag.Name):
cfg.fsys = builtinTestFiles
if ctx.IsSet(filterQueryFileFlag.Name) {
cfg.filterQueryFile = ctx.String(filterQueryFileFlag.Name)
} else {
cfg.filterQueryFile = "queries/filter_queries_berachain.json"
}
if ctx.IsSet(historyTestFileFlag.Name) {
cfg.historyTestFile = ctx.String(historyTestFileFlag.Name)
} else {
cfg.historyTestFile = "queries/history_berachain.json"
}
if ctx.IsSet(traceTestFileFlag.Name) {
cfg.traceTestFile = ctx.String(traceTestFileFlag.Name)
} else {
cfg.traceTestFile = "queries/trace_berachain.json"
}
cfg.historyPruneBlock = new(uint64)
*cfg.historyPruneBlock = history.PrunePoints[params.BerachainGenesisHash].BlockNumber
cfg.traceTestFile = "queries/trace_berachain.json"
case ctx.Bool(testBepoliaFlag.Name):
cfg.fsys = builtinTestFiles
if ctx.IsSet(filterQueryFileFlag.Name) {
cfg.filterQueryFile = ctx.String(filterQueryFileFlag.Name)
} else {
cfg.filterQueryFile = "queries/filter_queries_bepolia.json"
}
if ctx.IsSet(historyTestFileFlag.Name) {
cfg.historyTestFile = ctx.String(historyTestFileFlag.Name)
} else {
cfg.historyTestFile = "queries/history_bepolia.json"
}
if ctx.IsSet(traceTestFileFlag.Name) {
cfg.traceTestFile = ctx.String(traceTestFileFlag.Name)
} else {
cfg.traceTestFile = "queries/trace_bepolia.json"
}
cfg.historyPruneBlock = new(uint64)
*cfg.historyPruneBlock = history.PrunePoints[params.BepoliaGenesisHash].BlockNumber
cfg.traceTestFile = "queries/trace_bepolia.json"
default:
cfg.fsys = os.DirFS(".")
cfg.filterQueryFile = ctx.String(filterQueryFileFlag.Name)

View file

@ -33,7 +33,7 @@ import (
// traceTest is the content of a history test.
type traceTest struct {
TxHashes []common.Hash `json:"txHashes"`
BlockHashes []common.Hash `json:"blockHashes"`
TraceConfigs []tracers.TraceConfig `json:"traceConfigs"`
ResultHashes []common.Hash `json:"resultHashes"`
}
@ -57,15 +57,21 @@ func newTraceTestSuite(cfg testConfig, ctx *cli.Context) *traceTestSuite {
func (s *traceTestSuite) loadTests() error {
file, err := s.cfg.fsys.Open(s.cfg.traceTestFile)
if err != nil {
// If not found in embedded FS, try to load it from disk
if !os.IsNotExist(err) {
return err
}
file, err = os.OpenFile(s.cfg.traceTestFile, os.O_RDONLY, 0666)
if err != nil {
return fmt.Errorf("can't open traceTestFile: %v", err)
}
}
defer file.Close()
if err := json.NewDecoder(file).Decode(&s.tests); err != nil {
return fmt.Errorf("invalid JSON in %s: %v", s.cfg.traceTestFile, err)
}
if len(s.tests.TxHashes) == 0 {
if len(s.tests.BlockHashes) == 0 {
return fmt.Errorf("traceTestFile %s has no test data", s.cfg.traceTestFile)
}
return nil
@ -73,17 +79,17 @@ func (s *traceTestSuite) loadTests() error {
func (s *traceTestSuite) allTests() []workloadTest {
return []workloadTest{
newArchiveWorkloadTest("Trace/Transaction", s.traceTransaction),
newArchiveWorkloadTest("Trace/Block", s.traceBlock),
}
}
// traceTransaction runs all transaction tracing tests
func (s *traceTestSuite) traceTransaction(t *utesting.T) {
// traceBlock runs all block tracing tests
func (s *traceTestSuite) traceBlock(t *utesting.T) {
ctx := context.Background()
for i, hash := range s.tests.TxHashes {
for i, hash := range s.tests.BlockHashes {
config := s.tests.TraceConfigs[i]
result, err := s.cfg.client.Geth.TraceTransaction(ctx, hash, &config)
result, err := s.cfg.client.Geth.TraceBlock(ctx, hash, &config)
if err != nil {
t.Fatalf("Transaction %d (hash %v): error %v", i, hash, err)
}

View file

@ -36,8 +36,6 @@ import (
)
var (
defaultBlocksToTrace = 64 // the number of states assumed to be available
traceGenerateCommand = &cli.Command{
Name: "tracegen",
Usage: "Generates tests for state tracing",
@ -46,7 +44,8 @@ var (
Flags: []cli.Flag{
traceTestFileFlag,
traceTestResultOutputFlag,
traceTestBlockFlag,
traceTestStartBlockFlag,
traceTestEndBlockFlag,
},
}
@ -58,14 +57,18 @@ var (
}
traceTestResultOutputFlag = &cli.StringFlag{
Name: "trace-output",
Usage: "Folder containing the trace output files",
Usage: "Folder containing detailed trace output files",
Value: "",
Category: flags.TestingCategory,
}
traceTestBlockFlag = &cli.IntFlag{
Name: "trace-blocks",
Usage: "The number of blocks for tracing",
Value: defaultBlocksToTrace,
traceTestStartBlockFlag = &cli.IntFlag{
Name: "trace-start",
Usage: "The number of starting block for tracing (included)",
Category: flags.TestingCategory,
}
traceTestEndBlockFlag = &cli.IntFlag{
Name: "trace-end",
Usage: "The number of ending block for tracing (excluded)",
Category: flags.TestingCategory,
}
traceTestInvalidOutputFlag = &cli.StringFlag{
@ -81,21 +84,22 @@ func generateTraceTests(clictx *cli.Context) error {
client = makeClient(clictx)
outputFile = clictx.String(traceTestFileFlag.Name)
outputDir = clictx.String(traceTestResultOutputFlag.Name)
blocks = clictx.Int(traceTestBlockFlag.Name)
startBlock = clictx.Int(traceTestStartBlockFlag.Name)
endBlock = clictx.Int(traceTestEndBlockFlag.Name)
ctx = context.Background()
test = new(traceTest)
)
if outputDir != "" {
err := os.MkdirAll(outputDir, os.ModePerm)
if err != nil {
return err
}
}
latest, err := client.Eth.BlockNumber(ctx)
if err != nil {
exit(err)
}
if latest < uint64(blocks) {
if startBlock > endBlock {
exit(fmt.Errorf("invalid block range for tracing, start: %d, end: %d", startBlock, endBlock))
}
if endBlock-startBlock == 0 {
exit(fmt.Errorf("invalid block range for tracing, start: %d, end: %d", startBlock, endBlock))
}
if latest < uint64(startBlock) || latest < uint64(endBlock) {
exit(fmt.Errorf("node seems not synced, latest block is %d", latest))
}
// Get blocks and assign block info into the test
@ -104,37 +108,35 @@ func generateTraceTests(clictx *cli.Context) error {
logged = time.Now()
failed int
)
log.Info("Trace transactions around the chain tip", "head", latest, "blocks", blocks)
log.Info("Trace transactions around the chain tip", "head", latest, "start", startBlock, "end", endBlock)
for i := 0; i < blocks; i++ {
number := latest - uint64(i)
block, err := client.Eth.BlockByNumber(ctx, big.NewInt(int64(number)))
for i := startBlock; i < endBlock; i++ {
header, err := client.Eth.HeaderByNumber(ctx, big.NewInt(int64(i)))
if err != nil {
exit(err)
}
for _, tx := range block.Transactions() {
config, configName := randomTraceOption()
result, err := client.Geth.TraceTransaction(ctx, tx.Hash(), config)
result, err := client.Geth.TraceBlock(ctx, header.Hash(), config)
if err != nil {
failed += 1
break
continue
}
blob, err := json.Marshal(result)
if err != nil {
failed += 1
break
continue
}
test.TxHashes = append(test.TxHashes, tx.Hash())
test.BlockHashes = append(test.BlockHashes, header.Hash())
test.TraceConfigs = append(test.TraceConfigs, *config)
test.ResultHashes = append(test.ResultHashes, crypto.Keccak256Hash(blob))
writeTraceResult(outputDir, tx.Hash(), result, configName)
}
writeTraceResult(outputDir, header.Hash(), result, configName)
if time.Since(logged) > time.Second*8 {
logged = time.Now()
log.Info("Tracing transactions", "executed", len(test.TxHashes), "failed", failed, "elapsed", common.PrettyDuration(time.Since(start)))
log.Info("Tracing blocks", "executed", len(test.BlockHashes), "failed", failed, "elapsed", common.PrettyDuration(time.Since(start)))
}
}
log.Info("Traced transactions", "executed", len(test.TxHashes), "failed", failed, "elapsed", common.PrettyDuration(time.Since(start)))
log.Info("Traced blocks", "executed", len(test.BlockHashes), "failed", failed, "elapsed", common.PrettyDuration(time.Since(start)))
// Write output file.
writeJSON(outputFile, test)
@ -142,24 +144,15 @@ func generateTraceTests(clictx *cli.Context) error {
}
func randomTraceOption() (*tracers.TraceConfig, string) {
x := rand.Intn(11)
x := rand.Intn(10)
if x == 0 {
// struct-logger, with all fields enabled, very heavy
return &tracers.TraceConfig{
Config: &logger.Config{
EnableMemory: true,
EnableReturnData: true,
},
}, "structAll"
}
if x == 1 {
// default options for struct-logger, with stack and storage capture
// enabled
return &tracers.TraceConfig{
Config: &logger.Config{},
}, "structDefault"
}
if x == 2 || x == 3 || x == 4 {
if x >= 1 && x <= 3 {
// struct-logger with storage capture enabled
return &tracers.TraceConfig{
Config: &logger.Config{
@ -170,14 +163,18 @@ func randomTraceOption() (*tracers.TraceConfig, string) {
// Native tracer
loggers := []string{"callTracer", "4byteTracer", "flatCallTracer", "muxTracer", "noopTracer", "prestateTracer"}
return &tracers.TraceConfig{
Tracer: &loggers[x-5],
}, loggers[x-5]
Tracer: &loggers[x-4],
}, loggers[x-4]
}
func writeTraceResult(dir string, hash common.Hash, result any, configName string) {
if dir == "" {
return
}
// Ensure the directory exists
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
exit(fmt.Errorf("failed to create directories: %w", err))
}
name := filepath.Join(dir, configName+"_"+hash.String())
file, err := os.Create(name)
if err != nil {

View file

@ -314,7 +314,7 @@ type BlockChain struct {
bodyCache *lru.Cache[common.Hash, *types.Body]
bodyRLPCache *lru.Cache[common.Hash, rlp.RawValue]
receiptsCache *lru.Cache[common.Hash, []*types.Receipt]
receiptsCache *lru.Cache[common.Hash, []*types.Receipt] // Receipts cache with all fields derived
blockCache *lru.Cache[common.Hash, *types.Block]
txLookupLock sync.RWMutex

View file

@ -18,9 +18,12 @@ package core
import (
"errors"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state/snapshot"
@ -213,6 +216,44 @@ func (bc *BlockChain) GetBlocksFromHash(hash common.Hash, n int) (blocks []*type
return
}
// GetCanonicalReceipt allows fetching a receipt for a transaction that was
// already looked up on the index. Notably, only receipt in canonical chain
// is visible.
func (bc *BlockChain) GetCanonicalReceipt(tx *types.Transaction, blockHash common.Hash, blockNumber, txIndex uint64) (*types.Receipt, error) {
// The receipt retrieved from the cache contains all previously derived fields
if receipts, ok := bc.receiptsCache.Get(blockHash); ok {
if int(txIndex) >= len(receipts) {
return nil, fmt.Errorf("receipt out of index, length: %d, index: %d", len(receipts), txIndex)
}
return receipts[int(txIndex)], nil
}
header := bc.GetHeader(blockHash, blockNumber)
if header == nil {
return nil, fmt.Errorf("block header is not found, %d, %x", blockNumber, blockHash)
}
var blobGasPrice *big.Int
if header.ExcessBlobGas != nil {
blobGasPrice = eip4844.CalcBlobFee(bc.chainConfig, header)
}
receipt, ctx, err := rawdb.ReadCanonicalRawReceipt(bc.db, blockHash, blockNumber, txIndex)
if err != nil {
return nil, err
}
signer := types.MakeSigner(bc.chainConfig, new(big.Int).SetUint64(blockNumber), header.Time)
receipt.DeriveFields(signer, types.DeriveReceiptContext{
BlockHash: blockHash,
BlockNumber: blockNumber,
BlockTime: header.Time,
BaseFee: header.BaseFee,
BlobGasPrice: blobGasPrice,
GasUsed: ctx.GasUsed,
LogIndex: ctx.LogIndex,
Tx: tx,
TxIndex: uint(txIndex),
})
return receipt, nil
}
// GetReceiptsByHash retrieves the receipts for all transactions in a given block.
func (bc *BlockChain) GetReceiptsByHash(hash common.Hash) types.Receipts {
if receipts, ok := bc.receiptsCache.Get(hash); ok {
@ -277,13 +318,15 @@ func (bc *BlockChain) GetAncestor(hash common.Hash, number, ancestor uint64, max
return bc.hc.GetAncestor(hash, number, ancestor, maxNonCanonical)
}
// GetTransactionLookup retrieves the lookup along with the transaction
// GetCanonicalTransaction retrieves the lookup along with the transaction
// itself associate with the given transaction hash.
//
// A null will be returned if the transaction is not found. This can be due to
// the transaction indexer not being finished. The caller must explicitly check
// the indexer progress.
func (bc *BlockChain) GetTransactionLookup(hash common.Hash) (*rawdb.LegacyTxLookupEntry, *types.Transaction) {
//
// Notably, only the transaction in the canonical chain is visible.
func (bc *BlockChain) GetCanonicalTransaction(hash common.Hash) (*rawdb.LegacyTxLookupEntry, *types.Transaction) {
bc.txLookupLock.RLock()
defer bc.txLookupLock.RUnlock()
@ -291,7 +334,7 @@ func (bc *BlockChain) GetTransactionLookup(hash common.Hash) (*rawdb.LegacyTxLoo
if item, exist := bc.txLookupCache.Get(hash); exist {
return item.lookup, item.transaction
}
tx, blockHash, blockNumber, txIndex := rawdb.ReadTransaction(bc.db, hash)
tx, blockHash, blockNumber, txIndex := rawdb.ReadCanonicalTransaction(bc.db, hash)
if tx == nil {
return nil, nil
}

View file

@ -25,10 +25,12 @@ import (
"math/rand"
"os"
"path"
"reflect"
"sync"
"testing"
"time"
"github.com/davecgh/go-spew/spew"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/beacon"
@ -46,6 +48,7 @@ import (
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie"
"github.com/holiman/uint256"
"github.com/stretchr/testify/assert"
)
// So we can deterministically seed different blockchains
@ -1004,29 +1007,47 @@ func testChainTxReorgs(t *testing.T, scheme string) {
// removed tx
for i, tx := range (types.Transactions{pastDrop, freshDrop}) {
if txn, _, _, _ := rawdb.ReadTransaction(db, tx.Hash()); txn != nil {
if txn, _, _, _ := rawdb.ReadCanonicalTransaction(db, tx.Hash()); txn != nil {
t.Errorf("drop %d: tx %v found while shouldn't have been", i, txn)
}
if rcpt, _, _, _ := rawdb.ReadReceipt(db, tx.Hash(), blockchain.Config()); rcpt != nil {
if rcpt, _, _, _ := rawdb.ReadCanonicalReceipt(db, tx.Hash(), blockchain.Config()); rcpt != nil {
t.Errorf("drop %d: receipt %v found while shouldn't have been", i, rcpt)
}
}
// added tx
for i, tx := range (types.Transactions{pastAdd, freshAdd, futureAdd}) {
if txn, _, _, _ := rawdb.ReadTransaction(db, tx.Hash()); txn == nil {
if txn, _, _, _ := rawdb.ReadCanonicalTransaction(db, tx.Hash()); txn == nil {
t.Errorf("add %d: expected tx to be found", i)
}
if rcpt, _, _, _ := rawdb.ReadReceipt(db, tx.Hash(), blockchain.Config()); rcpt == nil {
if rcpt, _, _, index := rawdb.ReadCanonicalReceipt(db, tx.Hash(), blockchain.Config()); rcpt == nil {
t.Errorf("add %d: expected receipt to be found", i)
} else if rawRcpt, ctx, _ := rawdb.ReadCanonicalRawReceipt(db, rcpt.BlockHash, rcpt.BlockNumber.Uint64(), index); rawRcpt == nil {
t.Errorf("add %d: expected raw receipt to be found", i)
} else {
if rcpt.GasUsed != ctx.GasUsed {
t.Errorf("add %d, raw gasUsedSoFar doesn't make sense", i)
}
if len(rcpt.Logs) > 0 && rcpt.Logs[0].Index != ctx.LogIndex {
t.Errorf("add %d, raw startingLogIndex doesn't make sense", i)
}
}
}
// shared tx
for i, tx := range (types.Transactions{postponed, swapped}) {
if txn, _, _, _ := rawdb.ReadTransaction(db, tx.Hash()); txn == nil {
if txn, _, _, _ := rawdb.ReadCanonicalTransaction(db, tx.Hash()); txn == nil {
t.Errorf("share %d: expected tx to be found", i)
}
if rcpt, _, _, _ := rawdb.ReadReceipt(db, tx.Hash(), blockchain.Config()); rcpt == nil {
if rcpt, _, _, index := rawdb.ReadCanonicalReceipt(db, tx.Hash(), blockchain.Config()); rcpt == nil {
t.Errorf("share %d: expected receipt to be found", i)
} else if rawRcpt, ctx, _ := rawdb.ReadCanonicalRawReceipt(db, rcpt.BlockHash, rcpt.BlockNumber.Uint64(), index); rawRcpt == nil {
t.Errorf("add %d: expected raw receipt to be found", i)
} else {
if rcpt.GasUsed != ctx.GasUsed {
t.Errorf("add %d, raw gasUsedSoFar doesn't make sense", i)
}
if len(rcpt.Logs) > 0 && rcpt.Logs[0].Index != ctx.LogIndex {
t.Errorf("add %d, raw startingLogIndex doesn't make sense", i)
}
}
}
}
@ -4404,6 +4425,93 @@ func testInsertChainWithCutoff(t *testing.T, cutoff uint64, ancientLimit uint64,
if receipts == nil || len(receipts) != 1 {
t.Fatalf("Missed block receipts: %d, cutoff: %d", num, cutoffBlock.NumberU64())
}
for indx, receipt := range receipts {
receiptByLookup, err := chain.GetCanonicalReceipt(body.Transactions[indx], receipt.BlockHash,
receipt.BlockNumber.Uint64(), uint64(indx))
assert.NoError(t, err)
assert.Equal(t, receipt, receiptByLookup)
}
}
}
}
func TestGetCanonicalReceipt(t *testing.T) {
const chainLength = 64
// Configure and generate a sample block chain
var (
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
address = crypto.PubkeyToAddress(key.PublicKey)
funds = big.NewInt(1000000000000000000)
gspec = &Genesis{
Config: params.MergedTestChainConfig,
Alloc: types.GenesisAlloc{address: {Balance: funds}},
BaseFee: big.NewInt(params.InitialBaseFee),
}
signer = types.LatestSigner(gspec.Config)
engine = beacon.New(ethash.NewFaker())
codeBin = common.FromHex("0x608060405234801561000f575f5ffd5b507f8ae1c8c6e5f91159d0bc1c4b9a47ce45301753843012cbe641e4456bfc73538b33426040516100419291906100ff565b60405180910390a1610139565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100778261004e565b9050919050565b6100878161006d565b82525050565b5f819050919050565b61009f8161008d565b82525050565b5f82825260208201905092915050565b7f436f6e7374727563746f72207761732063616c6c6564000000000000000000005f82015250565b5f6100e96016836100a5565b91506100f4826100b5565b602082019050919050565b5f6060820190506101125f83018561007e565b61011f6020830184610096565b8181036040830152610130816100dd565b90509392505050565b603e806101455f395ff3fe60806040525f5ffdfea2646970667358221220e8bc3c31e3ac337eab702e8fdfc1c71894f4df1af4221bcde4a2823360f403fb64736f6c634300081e0033")
)
_, blocks, receipts := GenerateChainWithGenesis(gspec, engine, chainLength, func(i int, block *BlockGen) {
// SPDX-License-Identifier: MIT
// pragma solidity ^0.8.0;
//
// contract ConstructorLogger {
// event ConstructorLog(address sender, uint256 timestamp, string message);
//
// constructor() {
// emit ConstructorLog(msg.sender, block.timestamp, "Constructor was called");
// }
// }
//
// 608060405234801561000f575f5ffd5b507f8ae1c8c6e5f91159d0bc1c4b9a47ce45301753843012cbe641e4456bfc73538b33426040516100419291906100ff565b60405180910390a1610139565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100778261004e565b9050919050565b6100878161006d565b82525050565b5f819050919050565b61009f8161008d565b82525050565b5f82825260208201905092915050565b7f436f6e7374727563746f72207761732063616c6c6564000000000000000000005f82015250565b5f6100e96016836100a5565b91506100f4826100b5565b602082019050919050565b5f6060820190506101125f83018561007e565b61011f6020830184610096565b8181036040830152610130816100dd565b90509392505050565b603e806101455f395ff3fe60806040525f5ffdfea2646970667358221220e8bc3c31e3ac337eab702e8fdfc1c71894f4df1af4221bcde4a2823360f403fb64736f6c634300081e0033
nonce := block.TxNonce(address)
tx, err := types.SignTx(types.NewContractCreation(nonce, big.NewInt(0), 100_000, block.header.BaseFee, codeBin), signer, key)
if err != nil {
panic(err)
}
block.AddTx(tx)
tx2, err := types.SignTx(types.NewContractCreation(nonce+1, big.NewInt(0), 100_000, block.header.BaseFee, codeBin), signer, key)
if err != nil {
panic(err)
}
block.AddTx(tx2)
tx3, err := types.SignTx(types.NewContractCreation(nonce+2, big.NewInt(0), 100_000, block.header.BaseFee, codeBin), signer, key)
if err != nil {
panic(err)
}
block.AddTx(tx3)
})
db, _ := rawdb.Open(rawdb.NewMemoryDatabase(), rawdb.OpenOptions{})
defer db.Close()
options := DefaultConfig().WithStateScheme(rawdb.PathScheme)
chain, _ := NewBlockChain(db, gspec, beacon.New(ethash.NewFaker()), options)
defer chain.Stop()
chain.InsertReceiptChain(blocks, types.EncodeBlockReceiptLists(receipts), 0)
for i := 0; i < chainLength; i++ {
block := blocks[i]
blockReceipts := chain.GetReceiptsByHash(block.Hash())
chain.receiptsCache.Purge() // ugly hack
for txIndex, tx := range block.Body().Transactions {
receipt, err := chain.GetCanonicalReceipt(tx, block.Hash(), block.NumberU64(), uint64(txIndex))
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
if !reflect.DeepEqual(receipts[i][txIndex], receipt) {
want := spew.Sdump(receipts[i][txIndex])
got := spew.Sdump(receipt)
t.Fatalf("Receipt is not matched, want %s, got: %s", want, got)
}
if !reflect.DeepEqual(blockReceipts[txIndex], receipt) {
want := spew.Sdump(blockReceipts[txIndex])
got := spew.Sdump(receipt)
t.Fatalf("Receipt is not matched, want %s, got: %s", want, got)
}
}
}
}

View file

@ -55,7 +55,9 @@ func NewChainView(chain blockchain, number uint64, hash common.Hash) *ChainView
headNumber: number,
hashes: []common.Hash{hash},
}
cv.extendNonCanonical()
if !cv.extendNonCanonical() {
return nil
}
return cv
}
@ -129,7 +131,11 @@ func (cv *ChainView) SharedRange(cv2 *ChainView) common.Range[uint64] {
return common.Range[uint64]{}
}
var sharedLen uint64
for n := min(cv.headNumber+1-uint64(len(cv.hashes)), cv2.headNumber+1-uint64(len(cv2.hashes))); n <= cv.headNumber && n <= cv2.headNumber && cv.blockHash(n) == cv2.blockHash(n); n++ {
for n := min(cv.headNumber+1-uint64(len(cv.hashes)), cv2.headNumber+1-uint64(len(cv2.hashes))); n <= cv.headNumber && n <= cv2.headNumber; n++ {
h1, h2 := cv.blockHash(n), cv2.blockHash(n)
if h1 != h2 || h1 == (common.Hash{}) {
break
}
sharedLen = n + 1
}
return common.NewRange(0, sharedLen)
@ -153,10 +159,13 @@ func matchViews(cv1, cv2 *ChainView, number uint64) bool {
if cv1.headNumber < number || cv2.headNumber < number {
return false
}
var h1, h2 common.Hash
if number == cv1.headNumber || number == cv2.headNumber {
return cv1.BlockId(number) == cv2.BlockId(number)
h1, h2 = cv1.BlockId(number), cv2.BlockId(number)
} else {
h1, h2 = cv1.BlockHash(number), cv2.BlockHash(number)
}
return cv1.BlockHash(number) == cv2.BlockHash(number)
return h1 == h2 && h1 != common.Hash{}
}
// extendNonCanonical checks whether the previously known reverse list of head
@ -175,7 +184,10 @@ func (cv *ChainView) extendNonCanonical() bool {
}
header := cv.chain.GetHeader(hash, number)
if header == nil {
log.Error("Header not found", "number", number, "hash", hash)
// Header not found - this can happen after debug_setHead operations
// where blocks have been deleted. Return false to indicate the chain view
// is no longer valid rather than logging repeated errors.
log.Debug("Header not found during chain view extension", "number", number, "hash", hash)
return false
}
cv.hashes = append(cv.hashes, header.ParentHash)

View file

@ -185,11 +185,14 @@ type filterMapsRange struct {
initialized bool
headIndexed bool
headDelimiter uint64 // zero if headIndexed is false
// if initialized then all maps are rendered in the maps range
maps common.Range[uint32]
// if tailPartialEpoch > 0 then maps between firstRenderedMap-mapsPerEpoch and
// firstRenderedMap-mapsPerEpoch+tailPartialEpoch-1 are rendered
tailPartialEpoch uint32
// if initialized then all log values in the blocks range are fully
// rendered
// blockLvPointers are available in the blocks range
@ -223,13 +226,15 @@ type Config struct {
}
// NewFilterMaps creates a new FilterMaps and starts the indexer.
func NewFilterMaps(db ethdb.KeyValueStore, initView *ChainView, historyCutoff, finalBlock uint64, params Params, config Config) *FilterMaps {
func NewFilterMaps(db ethdb.KeyValueStore, initView *ChainView, historyCutoff, finalBlock uint64, params Params, config Config) (*FilterMaps, error) {
rs, initialized, err := rawdb.ReadFilterMapsRange(db)
if err != nil || (initialized && rs.Version != databaseVersion) {
rs, initialized = rawdb.FilterMapsRange{}, false
log.Warn("Invalid log index database version; resetting log index")
}
params.deriveFields()
if err := params.sanitize(); err != nil {
return nil, err
}
f := &FilterMaps{
db: db,
closeCh: make(chan struct{}),
@ -254,7 +259,6 @@ func NewFilterMaps(db ethdb.KeyValueStore, initView *ChainView, historyCutoff, f
},
// deleting last unindexed epoch might have been interrupted by shutdown
cleanedEpochsBefore: max(rs.MapsFirst>>params.logMapsPerEpoch, 1) - 1,
historyCutoff: historyCutoff,
finalBlock: finalBlock,
matcherSyncCh: make(chan *FilterMapsMatcherBackend),
@ -272,7 +276,7 @@ func NewFilterMaps(db ethdb.KeyValueStore, initView *ChainView, historyCutoff, f
"firstmap", f.indexedRange.maps.First(), "lastmap", f.indexedRange.maps.Last(),
"headindexed", f.indexedRange.headIndexed)
}
return f
return f, nil
}
// Start starts the indexer.
@ -399,7 +403,7 @@ func (f *FilterMaps) init() error {
batch := f.db.NewBatch()
for epoch := range bestLen {
cp := checkpoints[bestIdx][epoch]
f.storeLastBlockOfMap(batch, (uint32(epoch+1)<<f.logMapsPerEpoch)-1, cp.BlockNumber, cp.BlockId)
f.storeLastBlockOfMap(batch, f.lastEpochMap(uint32(epoch)), cp.BlockNumber, cp.BlockId)
f.storeBlockLvPointer(batch, cp.BlockNumber, cp.FirstIndex)
}
fmr := filterMapsRange{
@ -408,7 +412,7 @@ func (f *FilterMaps) init() error {
if bestLen > 0 {
cp := checkpoints[bestIdx][bestLen-1]
fmr.blocks = common.NewRange(cp.BlockNumber+1, 0)
fmr.maps = common.NewRange(uint32(bestLen)<<f.logMapsPerEpoch, 0)
fmr.maps = common.NewRange(f.firstEpochMap(uint32(bestLen)), 0)
}
f.setRange(batch, f.targetView, fmr, false)
return batch.Write()
@ -578,9 +582,11 @@ func (f *FilterMaps) getFilterMapRows(mapIndices []uint32, rowIndex uint32, base
rows := make([]FilterRow, len(mapIndices))
var ptr int
for len(mapIndices) > ptr {
baseRowGroup := mapIndices[ptr] / f.baseRowGroupLength
groupLength := 1
for ptr+groupLength < len(mapIndices) && mapIndices[ptr+groupLength]/f.baseRowGroupLength == baseRowGroup {
var (
groupIndex = f.mapGroupIndex(mapIndices[ptr])
groupLength = 1
)
for ptr+groupLength < len(mapIndices) && f.mapGroupIndex(mapIndices[ptr+groupLength]) == groupIndex {
groupLength++
}
if err := f.getFilterMapRowsOfGroup(rows[ptr:ptr+groupLength], mapIndices[ptr:ptr+groupLength], rowIndex, baseLayerOnly); err != nil {
@ -594,17 +600,19 @@ func (f *FilterMaps) getFilterMapRows(mapIndices []uint32, rowIndex uint32, base
// getFilterMapRowsOfGroup fetches a set of filter map rows at map indices
// belonging to the same base row group.
func (f *FilterMaps) getFilterMapRowsOfGroup(target []FilterRow, mapIndices []uint32, rowIndex uint32, baseLayerOnly bool) error {
baseRowGroup := mapIndices[0] / f.baseRowGroupLength
baseMapRowIndex := f.mapRowIndex(baseRowGroup*f.baseRowGroupLength, rowIndex)
baseRows, err := rawdb.ReadFilterMapBaseRows(f.db, baseMapRowIndex, f.baseRowGroupLength, f.logMapWidth)
var (
groupIndex = f.mapGroupIndex(mapIndices[0])
mapRowIndex = f.mapRowIndex(groupIndex, rowIndex)
)
baseRows, err := rawdb.ReadFilterMapBaseRows(f.db, mapRowIndex, f.baseRowGroupSize, f.logMapWidth)
if err != nil {
return fmt.Errorf("failed to retrieve base row group %d of row %d: %v", baseRowGroup, rowIndex, err)
return fmt.Errorf("failed to retrieve base row group %d of row %d: %v", groupIndex, rowIndex, err)
}
for i, mapIndex := range mapIndices {
if mapIndex/f.baseRowGroupLength != baseRowGroup {
panic("mapIndices are not in the same base row group")
if f.mapGroupIndex(mapIndex) != groupIndex {
return fmt.Errorf("maps are not in the same base row group, index: %d, group: %d", mapIndex, groupIndex)
}
row := baseRows[mapIndex&(f.baseRowGroupLength-1)]
row := baseRows[f.mapGroupOffset(mapIndex)]
if !baseLayerOnly {
extRow, err := rawdb.ReadFilterMapExtRow(f.db, f.mapRowIndex(mapIndex, rowIndex), f.logMapWidth)
if err != nil {
@ -621,15 +629,17 @@ func (f *FilterMaps) getFilterMapRowsOfGroup(target []FilterRow, mapIndices []ui
// indices and a shared row index.
func (f *FilterMaps) storeFilterMapRows(batch ethdb.Batch, mapIndices []uint32, rowIndex uint32, rows []FilterRow) error {
for len(mapIndices) > 0 {
baseRowGroup := mapIndices[0] / f.baseRowGroupLength
groupLength := 1
for groupLength < len(mapIndices) && mapIndices[groupLength]/f.baseRowGroupLength == baseRowGroup {
groupLength++
var (
pos = 1
groupIndex = f.mapGroupIndex(mapIndices[0])
)
for pos < len(mapIndices) && f.mapGroupIndex(mapIndices[pos]) == groupIndex {
pos++
}
if err := f.storeFilterMapRowsOfGroup(batch, mapIndices[:groupLength], rowIndex, rows[:groupLength]); err != nil {
if err := f.storeFilterMapRowsOfGroup(batch, mapIndices[:pos], rowIndex, rows[:pos]); err != nil {
return err
}
mapIndices, rows = mapIndices[groupLength:], rows[groupLength:]
mapIndices, rows = mapIndices[pos:], rows[pos:]
}
return nil
}
@ -637,21 +647,23 @@ func (f *FilterMaps) storeFilterMapRows(batch ethdb.Batch, mapIndices []uint32,
// storeFilterMapRowsOfGroup stores a set of filter map rows at map indices
// belonging to the same base row group.
func (f *FilterMaps) storeFilterMapRowsOfGroup(batch ethdb.Batch, mapIndices []uint32, rowIndex uint32, rows []FilterRow) error {
baseRowGroup := mapIndices[0] / f.baseRowGroupLength
baseMapRowIndex := f.mapRowIndex(baseRowGroup*f.baseRowGroupLength, rowIndex)
var baseRows [][]uint32
if uint32(len(mapIndices)) != f.baseRowGroupLength { // skip base rows read if all rows are replaced
var (
baseRows [][]uint32
groupIndex = f.mapGroupIndex(mapIndices[0])
mapRowIndex = f.mapRowIndex(groupIndex, rowIndex)
)
if uint32(len(mapIndices)) != f.baseRowGroupSize { // skip base rows read if all rows are replaced
var err error
baseRows, err = rawdb.ReadFilterMapBaseRows(f.db, baseMapRowIndex, f.baseRowGroupLength, f.logMapWidth)
baseRows, err = rawdb.ReadFilterMapBaseRows(f.db, mapRowIndex, f.baseRowGroupSize, f.logMapWidth)
if err != nil {
return fmt.Errorf("failed to retrieve base row group %d of row %d for modification: %v", baseRowGroup, rowIndex, err)
return fmt.Errorf("failed to retrieve filter map %d base rows %d for modification: %v", groupIndex, rowIndex, err)
}
} else {
baseRows = make([][]uint32, f.baseRowGroupLength)
baseRows = make([][]uint32, f.baseRowGroupSize)
}
for i, mapIndex := range mapIndices {
if mapIndex/f.baseRowGroupLength != baseRowGroup {
panic("mapIndices are not in the same base row group")
if f.mapGroupIndex(mapIndex) != groupIndex {
return fmt.Errorf("maps are not in the same base row group, index: %d, group: %d", mapIndex, groupIndex)
}
baseRow := []uint32(rows[i])
var extRow FilterRow
@ -659,10 +671,10 @@ func (f *FilterMaps) storeFilterMapRowsOfGroup(batch ethdb.Batch, mapIndices []u
extRow = baseRow[f.baseRowLength:]
baseRow = baseRow[:f.baseRowLength]
}
baseRows[mapIndex&(f.baseRowGroupLength-1)] = baseRow
baseRows[f.mapGroupOffset(mapIndex)] = baseRow
rawdb.WriteFilterMapExtRow(batch, f.mapRowIndex(mapIndex, rowIndex), extRow, f.logMapWidth)
}
rawdb.WriteFilterMapBaseRows(batch, baseMapRowIndex, baseRows, f.logMapWidth)
rawdb.WriteFilterMapBaseRows(batch, mapRowIndex, baseRows, f.logMapWidth)
return nil
}
@ -747,12 +759,12 @@ func (f *FilterMaps) deleteTailEpoch(epoch uint32) (bool, error) {
defer f.indexLock.Unlock()
// determine epoch boundaries
firstMap := epoch << f.logMapsPerEpoch
lastBlock, _, err := f.getLastBlockOfMap(firstMap + f.mapsPerEpoch - 1)
lastBlock, _, err := f.getLastBlockOfMap(f.lastEpochMap(epoch))
if err != nil {
return false, fmt.Errorf("failed to retrieve last block of deleted epoch %d: %v", epoch, err)
}
var firstBlock uint64
firstMap := f.firstEpochMap(epoch)
if epoch > 0 {
firstBlock, _, err = f.getLastBlockOfMap(firstMap - 1)
if err != nil {
@ -763,8 +775,8 @@ func (f *FilterMaps) deleteTailEpoch(epoch uint32) (bool, error) {
// update rendered range if necessary
var (
fmr = f.indexedRange
firstEpoch = f.indexedRange.maps.First() >> f.logMapsPerEpoch
afterLastEpoch = (f.indexedRange.maps.AfterLast() + f.mapsPerEpoch - 1) >> f.logMapsPerEpoch
firstEpoch = f.mapEpoch(f.indexedRange.maps.First())
afterLastEpoch = f.mapEpoch(f.indexedRange.maps.AfterLast() + f.mapsPerEpoch - 1)
)
if f.indexedRange.tailPartialEpoch != 0 && firstEpoch > 0 {
firstEpoch--
@ -776,7 +788,7 @@ func (f *FilterMaps) deleteTailEpoch(epoch uint32) (bool, error) {
// first fully or partially rendered epoch and there is at least one
// rendered map in the next epoch; remove from indexed range
fmr.tailPartialEpoch = 0
fmr.maps.SetFirst((epoch + 1) << f.logMapsPerEpoch)
fmr.maps.SetFirst(f.firstEpochMap(epoch + 1))
fmr.blocks.SetFirst(lastBlock + 1)
f.setRange(f.db, f.indexedView, fmr, false)
default:
@ -857,7 +869,7 @@ func (f *FilterMaps) exportCheckpoints() {
w.WriteString("[\n")
comma := ","
for epoch := uint32(0); epoch < epochCount; epoch++ {
lastBlock, lastBlockId, err := f.getLastBlockOfMap((epoch+1)<<f.logMapsPerEpoch - 1)
lastBlock, lastBlockId, err := f.getLastBlockOfMap(f.lastEpochMap(epoch))
if err != nil {
log.Error("Error fetching last block of epoch", "epoch", epoch, "error", err)
return

View file

@ -281,7 +281,7 @@ func (f *FilterMaps) tryIndexHead() error {
// is changed.
func (f *FilterMaps) tryIndexTail() (bool, error) {
for {
firstEpoch := f.indexedRange.maps.First() >> f.logMapsPerEpoch
firstEpoch := f.mapEpoch(f.indexedRange.maps.First())
if firstEpoch == 0 || !f.needTailEpoch(firstEpoch-1) {
break
}
@ -359,7 +359,7 @@ func (f *FilterMaps) tryIndexTail() (bool, error) {
// Note that unindexing is very quick as it only removes continuous ranges of
// data from the database and is also called while running head indexing.
func (f *FilterMaps) tryUnindexTail() (bool, error) {
firstEpoch := f.indexedRange.maps.First() >> f.logMapsPerEpoch
firstEpoch := f.mapEpoch(f.indexedRange.maps.First())
if f.indexedRange.tailPartialEpoch > 0 && firstEpoch > 0 {
firstEpoch--
}
@ -392,11 +392,11 @@ func (f *FilterMaps) tryUnindexTail() (bool, error) {
// needTailEpoch returns true if the given tail epoch needs to be kept
// according to the current tail target, false if it can be removed.
func (f *FilterMaps) needTailEpoch(epoch uint32) bool {
firstEpoch := f.indexedRange.maps.First() >> f.logMapsPerEpoch
firstEpoch := f.mapEpoch(f.indexedRange.maps.First())
if epoch > firstEpoch {
return true
}
if (epoch+1)<<f.logMapsPerEpoch >= f.indexedRange.maps.AfterLast() {
if f.firstEpochMap(epoch+1) >= f.indexedRange.maps.AfterLast() {
return true
}
if epoch+1 < firstEpoch {
@ -405,7 +405,7 @@ func (f *FilterMaps) needTailEpoch(epoch uint32) bool {
var lastBlockOfPrevEpoch uint64
if epoch > 0 {
var err error
lastBlockOfPrevEpoch, _, err = f.getLastBlockOfMap(epoch<<f.logMapsPerEpoch - 1)
lastBlockOfPrevEpoch, _, err = f.getLastBlockOfMap(f.lastEpochMap(epoch - 1))
if err != nil {
log.Error("Could not get last block of previous epoch", "epoch", epoch-1, "error", err)
return epoch >= firstEpoch
@ -414,7 +414,7 @@ func (f *FilterMaps) needTailEpoch(epoch uint32) bool {
if f.historyCutoff > lastBlockOfPrevEpoch {
return false
}
lastBlockOfEpoch, _, err := f.getLastBlockOfMap((epoch+1)<<f.logMapsPerEpoch - 1)
lastBlockOfEpoch, _, err := f.getLastBlockOfMap(f.lastEpochMap(epoch))
if err != nil {
log.Error("Could not get last block of epoch", "epoch", epoch, "error", err)
return epoch >= firstEpoch

View file

@ -41,7 +41,7 @@ var testParams = Params{
logMapWidth: 24,
logMapsPerEpoch: 4,
logValuesPerMap: 4,
baseRowGroupLength: 4,
baseRowGroupSize: 4,
baseRowLengthRatio: 2,
logLayerDiff: 2,
}
@ -370,7 +370,7 @@ func (ts *testSetup) setHistory(history uint64, noHistory bool) {
History: history,
Disabled: noHistory,
}
ts.fm = NewFilterMaps(ts.db, view, 0, 0, ts.params, config)
ts.fm, _ = NewFilterMaps(ts.db, view, 0, 0, ts.params, config)
ts.fm.testDisableSnapshots = ts.testDisableSnapshots
ts.fm.Start()
}

View file

@ -284,7 +284,7 @@ func (r *mapRenderer) run(stopCb func() bool, writeCb func()) (bool, error) {
// map finished
r.finishedMaps[r.currentMap.mapIndex] = r.currentMap
r.finished.SetLast(r.finished.AfterLast())
if len(r.finishedMaps) >= maxMapsPerBatch || r.finished.AfterLast()&(r.f.baseRowGroupLength-1) == 0 {
if len(r.finishedMaps) >= maxMapsPerBatch || r.f.mapGroupOffset(r.finished.AfterLast()) == 0 {
if err := r.writeFinishedMaps(stopCb); err != nil {
return false, err
}

View file

@ -844,7 +844,7 @@ func (m *matchSequenceInstance) dropNext(mapIndex uint32) bool {
// results at mapIndex and mapIndex+1. Note that acquiring nextNextRes may be
// skipped and it can be substituted with an empty list if baseRes has no potential
// matches that could be sequence matched with anything that could be in nextNextRes.
func (params *Params) matchResults(mapIndex uint32, offset uint64, baseRes, nextRes potentialMatches) potentialMatches {
func (p *Params) matchResults(mapIndex uint32, offset uint64, baseRes, nextRes potentialMatches) potentialMatches {
if nextRes == nil || (baseRes != nil && len(baseRes) == 0) {
// if nextRes is a wild card or baseRes is empty then the sequence matcher
// result equals baseRes.
@ -854,7 +854,7 @@ func (params *Params) matchResults(mapIndex uint32, offset uint64, baseRes, next
// if baseRes is a wild card or nextRes is empty then the sequence matcher
// result is the items of nextRes with a negative offset applied.
result := make(potentialMatches, 0, len(nextRes))
min := (uint64(mapIndex) << params.logValuesPerMap) + offset
min := (uint64(mapIndex) << p.logValuesPerMap) + offset
for _, v := range nextRes {
if v >= min {
result = append(result, v-offset)

View file

@ -19,6 +19,7 @@ package filtermaps
import (
"crypto/sha256"
"encoding/binary"
"fmt"
"hash/fnv"
"math"
"sort"
@ -28,19 +29,36 @@ import (
// Params defines the basic parameters of the log index structure.
type Params struct {
logMapHeight uint // log2(mapHeight)
logMapWidth uint // log2(mapWidth)
logMapsPerEpoch uint // log2(mapsPerEpoch)
logValuesPerMap uint // log2(logValuesPerMap)
baseRowLengthRatio uint // baseRowLength / average row length
logLayerDiff uint // maxRowLength log2 growth per layer
// derived fields
mapHeight uint32 // filter map height (number of rows)
mapsPerEpoch uint32 // number of maps in an epoch
logMapHeight uint // The number of bits required to represent the map height
logMapWidth uint // The number of bits required to represent the map width
logMapsPerEpoch uint // The number of bits required to represent the number of maps per epoch
logValuesPerMap uint // The number of bits required to represent the number of log values per map
// baseRowLengthRatio represents the ratio of base row length
// to the average row length.
baseRowLengthRatio uint
// logLayerDiff defines the logarithmic growth factor (base 2) of
// the maximum row length per layer. It indicates how much the maximum
// row length increases as the layer depth increases.
//
// Specifically:
// - the row length in base layer (layer == 0) is baseRowLength
// - the row length in layer x is baseRowLength << (logLayerDiff * x)
logLayerDiff uint
// These fields can be derived with the information above
mapHeight uint32 // The number of rows in the filter map
mapsPerEpoch uint32 // The number of maps in an epoch
valuesPerMap uint64 // The number of log values marked on each filter map
baseRowLength uint32 // maximum number of log values per row on layer 0
valuesPerMap uint64 // number of log values marked on each filter map
// not affecting consensus
baseRowGroupLength uint32 // length of base row groups in local database
// baseRowGroupSize defines the number of base row entries grouped together
// as a single database entry in the local database to optimize storage
// and retrieval efficiency.
//
// This value can be configured based on the specific implementation.
baseRowGroupSize uint32
}
// DefaultParams is the set of parameters used on mainnet.
@ -49,7 +67,7 @@ var DefaultParams = Params{
logMapWidth: 24,
logMapsPerEpoch: 10,
logValuesPerMap: 16,
baseRowGroupLength: 32,
baseRowGroupSize: 32,
baseRowLengthRatio: 8,
logLayerDiff: 4,
}
@ -60,7 +78,7 @@ var RangeTestParams = Params{
logMapWidth: 24,
logMapsPerEpoch: 0,
logValuesPerMap: 0,
baseRowGroupLength: 32,
baseRowGroupSize: 32,
baseRowLengthRatio: 16, // baseRowLength >= 1
logLayerDiff: 4,
}
@ -91,6 +109,44 @@ func topicValue(topic common.Hash) common.Hash {
return result
}
// sanitize derives any missing fields and validates the parameter values.
func (p *Params) sanitize() error {
p.deriveFields()
if p.logMapWidth%8 != 0 {
return fmt.Errorf("invalid configuration: logMapWidth (%d) must be a multiple of 8", p.logMapWidth)
}
if p.baseRowGroupSize == 0 || (p.baseRowGroupSize&(p.baseRowGroupSize-1)) != 0 {
return fmt.Errorf("invalid configuration: baseRowGroupSize (%d) must be a power of 2", p.baseRowGroupSize)
}
return nil
}
// mapGroupIndex returns the start index of the base row group that contains the
// given map index. Assumes baseRowGroupSize is a power of 2.
func (p *Params) mapGroupIndex(index uint32) uint32 {
return index & ^(p.baseRowGroupSize - 1)
}
// mapGroupOffset returns the offset of the given map index within its base row group.
func (p *Params) mapGroupOffset(index uint32) uint32 {
return index & (p.baseRowGroupSize - 1)
}
// mapEpoch returns the epoch number that the given map index belongs to.
func (p *Params) mapEpoch(index uint32) uint32 {
return index >> p.logMapsPerEpoch
}
// firstEpochMap returns the index of the first map in the specified epoch.
func (p *Params) firstEpochMap(epoch uint32) uint32 {
return epoch << p.logMapsPerEpoch
}
// lastEpochMap returns the index of the last map in the specified epoch.
func (p *Params) lastEpochMap(epoch uint32) uint32 {
return (epoch+1)<<p.logMapsPerEpoch - 1
}
// rowIndex returns the row index in which the given log value should be marked
// on the given map and mapping layer. Note that row assignments are re-shuffled
// with a different frequency on each mapping layer, allowing efficient disk
@ -125,17 +181,20 @@ func (p *Params) columnIndex(lvIndex uint64, logValue *common.Hash) uint32 {
return uint32(lvIndex%p.valuesPerMap)<<hashBits + (uint32(hash>>(64-hashBits)) ^ uint32(hash)>>(32-hashBits))
}
// maxRowLength returns the maximum length filter rows are populated up to
// when using the given mapping layer. A log value can be marked on the map
// according to a given mapping layer if the row mapping on that layer points
// to a row that has not yet reached the maxRowLength belonging to that layer.
// maxRowLength returns the maximum length filter rows are populated up to when
// using the given mapping layer.
//
// A log value can be marked on the map according to a given mapping layer if
// the row mapping on that layer points to a row that has not yet reached the
// maxRowLength belonging to that layer.
//
// This means that a row that is considered full on a given layer may still be
// extended further on a higher order layer.
//
// Each value is marked on the lowest order layer possible, assuming that marks
// are added in ascending log value index order.
// When searching for a log value one should consider all layers and process
// corresponding rows up until the first one where the row mapped to the given
// layer is not full.
// are added in ascending log value index order. When searching for a log value
// one should consider all layers and process corresponding rows up until the
// first one where the row mapped to the given layer is not full.
func (p *Params) maxRowLength(layerIndex uint32) uint32 {
logLayerDiff := uint(layerIndex) * p.logLayerDiff
if logLayerDiff > p.logMapsPerEpoch {

View file

@ -449,9 +449,10 @@ func ReadBodyRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue
return data
}
// ReadCanonicalBodyRLP retrieves the block body (transactions and uncles) for the canonical
// block at number, in RLP encoding.
func ReadCanonicalBodyRLP(db ethdb.Reader, number uint64) rlp.RawValue {
// ReadCanonicalBodyRLP retrieves the block body (transactions and uncles) for the
// canonical block at number, in RLP encoding. Optionally it takes the block hash
// to avoid looking it up
func ReadCanonicalBodyRLP(db ethdb.Reader, number uint64, hash *common.Hash) rlp.RawValue {
var data []byte
db.ReadAncients(func(reader ethdb.AncientReaderOp) error {
data, _ = reader.Ancient(ChainFreezerBodiesTable, number)
@ -459,10 +460,14 @@ func ReadCanonicalBodyRLP(db ethdb.Reader, number uint64) rlp.RawValue {
return nil
}
// Block is not in ancients, read from leveldb by hash and number.
if hash != nil {
data, _ = db.Get(blockBodyKey(number, *hash))
} else {
// Note: ReadCanonicalHash cannot be used here because it also
// calls ReadAncients internally.
hash, _ := db.Get(headerHashKey(number))
data, _ = db.Get(blockBodyKey(number, common.BytesToHash(hash)))
hashBytes, _ := db.Get(headerHashKey(number))
data, _ = db.Get(blockBodyKey(number, common.BytesToHash(hashBytes)))
}
return nil
})
return data
@ -544,6 +549,29 @@ func ReadReceiptsRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawVa
return data
}
// ReadCanonicalReceiptsRLP retrieves the receipts RLP for the canonical block at
// number, in RLP encoding. Optionally it takes the block hash to avoid looking it up.
func ReadCanonicalReceiptsRLP(db ethdb.Reader, number uint64, hash *common.Hash) rlp.RawValue {
var data []byte
db.ReadAncients(func(reader ethdb.AncientReaderOp) error {
data, _ = reader.Ancient(ChainFreezerReceiptTable, number)
if len(data) > 0 {
return nil
}
// Block is not in ancients, read from leveldb by hash and number.
if hash != nil {
data, _ = db.Get(blockReceiptsKey(number, *hash))
} else {
// Note: ReadCanonicalHash cannot be used here because it also
// calls ReadAncients internally.
hashBytes, _ := db.Get(headerHashKey(number))
data, _ = db.Get(blockReceiptsKey(number, common.BytesToHash(hashBytes)))
}
return nil
})
return data
}
// ReadRawReceipts retrieves all the transaction receipts belonging to a block.
// The receipt metadata fields and the Bloom are not guaranteed to be populated,
// so they should not be used. Use ReadReceipts instead if the metadata is needed.

View file

@ -441,6 +441,9 @@ func TestAncientStorage(t *testing.T) {
if blob := ReadReceiptsRLP(db, hash, number); len(blob) > 0 {
t.Fatalf("non existent receipts returned")
}
if blob := ReadCanonicalReceiptsRLP(db, number, &hash); len(blob) > 0 {
t.Fatalf("non existent receipts returned")
}
// Write and verify the header in the database
WriteAncientBlocks(db, []*types.Block{block}, types.EncodeBlockReceiptLists([]types.Receipts{nil}))
@ -454,6 +457,9 @@ func TestAncientStorage(t *testing.T) {
if blob := ReadReceiptsRLP(db, hash, number); len(blob) == 0 {
t.Fatalf("no receipts returned")
}
if blob := ReadCanonicalReceiptsRLP(db, number, &hash); len(blob) == 0 {
t.Fatalf("no receipts returned")
}
// Use a fake hash for data retrieval, nothing should be returned.
fakeHash := common.BytesToHash([]byte{0x01, 0x02, 0x03})

View file

@ -20,6 +20,7 @@ import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
@ -169,9 +170,10 @@ func findTxInBlockBody(blockbody rlp.RawValue, target common.Hash) (*types.Trans
return nil, 0, errors.New("transaction not found")
}
// ReadTransaction retrieves a specific transaction from the database, along with
// its added positional metadata.
func ReadTransaction(db ethdb.Reader, hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64) {
// ReadCanonicalTransaction retrieves a specific transaction from the database, along
// with its added positional metadata. Notably, only the transaction in the canonical
// chain is visible.
func ReadCanonicalTransaction(db ethdb.Reader, hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64) {
blockNumber := ReadTxLookupEntry(db, hash)
if blockNumber == nil {
return nil, common.Hash{}, 0, 0
@ -180,7 +182,7 @@ func ReadTransaction(db ethdb.Reader, hash common.Hash) (*types.Transaction, com
if blockHash == (common.Hash{}) {
return nil, common.Hash{}, 0, 0
}
bodyRLP := ReadBodyRLP(db, blockHash, *blockNumber)
bodyRLP := ReadCanonicalBodyRLP(db, *blockNumber, &blockHash)
if bodyRLP == nil {
log.Error("Transaction referenced missing", "number", *blockNumber, "hash", blockHash)
return nil, common.Hash{}, 0, 0
@ -193,9 +195,10 @@ func ReadTransaction(db ethdb.Reader, hash common.Hash) (*types.Transaction, com
return tx, blockHash, *blockNumber, txIndex
}
// ReadReceipt retrieves a specific transaction receipt from the database, along with
// its added positional metadata.
func ReadReceipt(db ethdb.Reader, hash common.Hash, config *params.ChainConfig) (*types.Receipt, common.Hash, uint64, uint64) {
// ReadCanonicalReceipt retrieves a specific transaction receipt from the database,
// along with its added positional metadata. Notably, only the receipt in the canonical
// chain is visible.
func ReadCanonicalReceipt(db ethdb.Reader, hash common.Hash, config *params.ChainConfig) (*types.Receipt, common.Hash, uint64, uint64) {
// Retrieve the context of the receipt based on the transaction hash
blockNumber := ReadTxLookupEntry(db, hash)
if blockNumber == nil {
@ -220,7 +223,91 @@ func ReadReceipt(db ethdb.Reader, hash common.Hash, config *params.ChainConfig)
return nil, common.Hash{}, 0, 0
}
// ReadFilterMapRow retrieves a filter map row at the given mapRowIndex
// extractReceiptFields takes a raw RLP-encoded receipt blob and extracts
// specific fields from it.
func extractReceiptFields(receiptRLP rlp.RawValue) (uint64, uint, error) {
receiptList, _, err := rlp.SplitList(receiptRLP)
if err != nil {
return 0, 0, err
}
// Decode the field: receipt status
// for receipt before the byzantium fork:
// - bytes: post state root
// for receipt after the byzantium fork:
// - bytes: receipt status flag
_, _, rest, err := rlp.Split(receiptList)
if err != nil {
return 0, 0, err
}
// Decode the field: cumulative gas used (type: uint64)
gasUsed, rest, err := rlp.SplitUint64(rest)
if err != nil {
return 0, 0, err
}
// Decode the field: logs (type: rlp list)
logList, _, err := rlp.SplitList(rest)
if err != nil {
return 0, 0, err
}
logCount, err := rlp.CountValues(logList)
if err != nil {
return 0, 0, err
}
return gasUsed, uint(logCount), nil
}
// RawReceiptContext carries the contextual information that is needed to derive
// a complete receipt from a raw one.
type RawReceiptContext struct {
GasUsed uint64 // Amount of gas used by the associated transaction
LogIndex uint // Starting index of the logs within the block
}
// ReadCanonicalRawReceipt reads a raw receipt at the specified position. It also
// returns the gas used by the associated transaction and the starting index of
// the logs within the block. The main difference with ReadCanonicalReceipt is
// that the additional positional fields are not directly included in the receipt.
// Notably, only receipts from the canonical chain are visible.
func ReadCanonicalRawReceipt(db ethdb.Reader, blockHash common.Hash, blockNumber, txIndex uint64) (*types.Receipt, RawReceiptContext, error) {
receiptIt, err := rlp.NewListIterator(ReadCanonicalReceiptsRLP(db, blockNumber, &blockHash))
if err != nil {
return nil, RawReceiptContext{}, err
}
var (
cumulativeGasUsed uint64
logIndex uint
)
for i := uint64(0); i <= txIndex; i++ {
// Unexpected iteration error
if receiptIt.Err() != nil {
return nil, RawReceiptContext{}, receiptIt.Err()
}
// Unexpected end of iteration
if !receiptIt.Next() {
return nil, RawReceiptContext{}, fmt.Errorf("receipt not found, %d, %x, %d", blockNumber, blockHash, txIndex)
}
if i == txIndex {
var stored types.ReceiptForStorage
if err := rlp.DecodeBytes(receiptIt.Value(), &stored); err != nil {
return nil, RawReceiptContext{}, err
}
return (*types.Receipt)(&stored), RawReceiptContext{
GasUsed: stored.CumulativeGasUsed - cumulativeGasUsed,
LogIndex: logIndex,
}, nil
} else {
gas, logs, err := extractReceiptFields(receiptIt.Value())
if err != nil {
return nil, RawReceiptContext{}, err
}
cumulativeGasUsed = gas
logIndex += logs
}
}
return nil, RawReceiptContext{}, fmt.Errorf("receipt not found, %d, %x, %d", blockNumber, blockHash, txIndex)
}
// ReadFilterMapExtRow retrieves a filter map row at the given mapRowIndex
// (see filtermaps.mapRowIndex for the storage index encoding).
// Note that zero length rows are not stored in the database and therefore all
// non-existent entries are interpreted as empty rows and return no error.
@ -247,7 +334,7 @@ func ReadFilterMapExtRow(db ethdb.KeyValueReader, mapRowIndex uint64, bitLength
return nil, err
}
if len(encRow)%byteLength != 0 {
return nil, errors.New("Invalid encoded extended filter row length")
return nil, errors.New("invalid encoded extended filter row length")
}
row := make([]uint32, len(encRow)/byteLength)
var b [4]byte
@ -301,7 +388,7 @@ func ReadFilterMapBaseRows(db ethdb.KeyValueReader, mapRowIndex uint64, rowCount
headerBits--
}
if headerLen+byteLength*entryCount > encLen {
return nil, errors.New("Invalid encoded base filter rows length")
return nil, errors.New("invalid encoded base filter rows length")
}
if entriesInRow > 0 {
rows[rowIndex] = make([]uint32, entriesInRow)
@ -318,8 +405,8 @@ func ReadFilterMapBaseRows(db ethdb.KeyValueReader, mapRowIndex uint64, rowCount
return rows, nil
}
// WriteFilterMapRow stores a filter map row at the given mapRowIndex or deletes
// any existing entry if the row is empty.
// WriteFilterMapExtRow stores an extended filter map row at the given mapRowIndex
// or deletes any existing entry if the row is empty.
func WriteFilterMapExtRow(db ethdb.KeyValueWriter, mapRowIndex uint64, row []uint32, bitLength uint) {
byteLength := int(bitLength) / 8
if int(bitLength) != byteLength*8 {

View file

@ -17,6 +17,7 @@
package rawdb
import (
"errors"
"math/big"
"testing"
@ -88,7 +89,7 @@ func TestLookupStorage(t *testing.T) {
// Check that no transactions entries are in a pristine database
for i, tx := range txs {
if txn, _, _, _ := ReadTransaction(db, tx.Hash()); txn != nil {
if txn, _, _, _ := ReadCanonicalTransaction(db, tx.Hash()); txn != nil {
t.Fatalf("tx #%d [%x]: non existent transaction returned: %v", i, tx.Hash(), txn)
}
}
@ -98,7 +99,7 @@ func TestLookupStorage(t *testing.T) {
tc.writeTxLookupEntriesByBlock(db, block)
for i, tx := range txs {
if txn, hash, number, index := ReadTransaction(db, tx.Hash()); txn == nil {
if txn, hash, number, index := ReadCanonicalTransaction(db, tx.Hash()); txn == nil {
t.Fatalf("tx #%d [%x]: transaction not found", i, tx.Hash())
} else {
if hash != block.Hash() || number != block.NumberU64() || index != uint64(i) {
@ -112,7 +113,7 @@ func TestLookupStorage(t *testing.T) {
// Delete the transactions and check purge
for i, tx := range txs {
DeleteTxLookupEntry(db, tx.Hash())
if txn, _, _, _ := ReadTransaction(db, tx.Hash()); txn != nil {
if txn, _, _, _ := ReadCanonicalTransaction(db, tx.Hash()); txn != nil {
t.Fatalf("tx #%d [%x]: deleted transaction returned: %v", i, tx.Hash(), txn)
}
}
@ -219,3 +220,80 @@ func TestFindTxInBlockBody(t *testing.T) {
}
}
}
func TestExtractReceiptFields(t *testing.T) {
receiptWithPostState := types.ReceiptForStorage(types.Receipt{
Type: types.LegacyTxType,
PostState: []byte{0x1, 0x2, 0x3},
CumulativeGasUsed: 100,
})
receiptWithPostStateBlob, _ := rlp.EncodeToBytes(&receiptWithPostState)
receiptNoLogs := types.ReceiptForStorage(types.Receipt{
Type: types.LegacyTxType,
Status: types.ReceiptStatusSuccessful,
CumulativeGasUsed: 100,
})
receiptNoLogBlob, _ := rlp.EncodeToBytes(&receiptNoLogs)
receiptWithLogs := types.ReceiptForStorage(types.Receipt{
Type: types.LegacyTxType,
Status: types.ReceiptStatusSuccessful,
CumulativeGasUsed: 100,
Logs: []*types.Log{
{
Address: common.BytesToAddress([]byte{0x1}),
Topics: []common.Hash{
common.BytesToHash([]byte{0x1}),
},
Data: []byte{0x1},
},
{
Address: common.BytesToAddress([]byte{0x2}),
Topics: []common.Hash{
common.BytesToHash([]byte{0x2}),
},
Data: []byte{0x2},
},
},
})
receiptWithLogBlob, _ := rlp.EncodeToBytes(&receiptWithLogs)
invalidReceipt := types.ReceiptForStorage(types.Receipt{
Type: types.LegacyTxType,
Status: types.ReceiptStatusSuccessful,
CumulativeGasUsed: 100,
})
invalidReceiptBlob, _ := rlp.EncodeToBytes(&invalidReceipt)
invalidReceiptBlob[len(invalidReceiptBlob)-1] = 0xf
var cases = []struct {
logs rlp.RawValue
expErr error
expGasUsed uint64
expLogs uint
}{
{receiptWithPostStateBlob, nil, 100, 0},
{receiptNoLogBlob, nil, 100, 0},
{receiptWithLogBlob, nil, 100, 2},
{invalidReceiptBlob, rlp.ErrExpectedList, 100, 0},
}
for _, c := range cases {
gasUsed, logs, err := extractReceiptFields(c.logs)
if c.expErr != nil {
if !errors.Is(err, c.expErr) {
t.Fatalf("Unexpected error, want: %v, got: %v", c.expErr, err)
}
} else {
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
if gasUsed != c.expGasUsed {
t.Fatalf("Unexpected gas used, want %d, got %d", c.expGasUsed, gasUsed)
}
if logs != c.expLogs {
t.Fatalf("Unexpected logs, want %d, got %d", c.expLogs, logs)
}
}
}
}

View file

@ -118,7 +118,7 @@ func iterateTransactions(db ethdb.Database, from uint64, to uint64, reverse bool
}
defer close(rlpCh)
for n != end {
data := ReadCanonicalBodyRLP(db, n)
data := ReadCanonicalBodyRLP(db, n, nil)
// Feed the block to the aggregator, or abort on interrupt
select {
case rlpCh <- &numberRlp{n, data}:

View file

@ -125,8 +125,8 @@ var (
StateHistoryIndexPrefix = []byte("m") // The global prefix of state history index data
StateHistoryAccountMetadataPrefix = []byte("ma") // StateHistoryAccountMetadataPrefix + account address hash => account metadata
StateHistoryStorageMetadataPrefix = []byte("ms") // StateHistoryStorageMetadataPrefix + account address hash + storage slot hash => slot metadata
StateHistoryAccountBlockPrefix = []byte("mba") // StateHistoryAccountBlockPrefix + account address hash + block_number => account block
StateHistoryStorageBlockPrefix = []byte("mbs") // StateHistoryStorageBlockPrefix + account address hash + storage slot hash + block_number => slot block
StateHistoryAccountBlockPrefix = []byte("mba") // StateHistoryAccountBlockPrefix + account address hash + blockID => account block
StateHistoryStorageBlockPrefix = []byte("mbs") // StateHistoryStorageBlockPrefix + account address hash + storage slot hash + blockID => slot block
// VerklePrefix is the database prefix for Verkle trie data, which includes:
// (a) Trie nodes

View file

@ -389,6 +389,15 @@ func (s *StateDB) GetCommittedState(addr common.Address, hash common.Hash) commo
return common.Hash{}
}
// GetStateAndCommittedState returns the current value and the original value.
func (s *StateDB) GetStateAndCommittedState(addr common.Address, hash common.Hash) (common.Hash, common.Hash) {
stateObject := s.getStateObject(addr)
if stateObject != nil {
return stateObject.getState(hash)
}
return common.Hash{}, common.Hash{}
}
// Database retrieves the low level database supporting the lower level trie ops.
func (s *StateDB) Database() Database {
return s.db

View file

@ -85,8 +85,8 @@ func (s *hookedStateDB) GetRefund() uint64 {
return s.inner.GetRefund()
}
func (s *hookedStateDB) GetCommittedState(addr common.Address, hash common.Hash) common.Hash {
return s.inner.GetCommittedState(addr, hash)
func (s *hookedStateDB) GetStateAndCommittedState(addr common.Address, hash common.Hash) (common.Hash, common.Hash) {
return s.inner.GetStateAndCommittedState(addr, hash)
}
func (s *hookedStateDB) GetState(addr common.Address, hash common.Hash) common.Hash {

View file

@ -22,7 +22,7 @@ func (l Log) MarshalJSON() ([]byte, error) {
TxHash common.Hash `json:"transactionHash" gencodec:"required" rlp:"-"`
TxIndex hexutil.Uint `json:"transactionIndex" rlp:"-"`
BlockHash common.Hash `json:"blockHash" rlp:"-"`
BlockTimestamp uint64 `json:"blockTimestamp" rlp:"-"`
BlockTimestamp hexutil.Uint64 `json:"blockTimestamp" rlp:"-"`
Index hexutil.Uint `json:"logIndex" rlp:"-"`
Removed bool `json:"removed" rlp:"-"`
}
@ -34,7 +34,7 @@ func (l Log) MarshalJSON() ([]byte, error) {
enc.TxHash = l.TxHash
enc.TxIndex = hexutil.Uint(l.TxIndex)
enc.BlockHash = l.BlockHash
enc.BlockTimestamp = l.BlockTimestamp
enc.BlockTimestamp = hexutil.Uint64(l.BlockTimestamp)
enc.Index = hexutil.Uint(l.Index)
enc.Removed = l.Removed
return json.Marshal(&enc)
@ -50,7 +50,7 @@ func (l *Log) UnmarshalJSON(input []byte) error {
TxHash *common.Hash `json:"transactionHash" gencodec:"required" rlp:"-"`
TxIndex *hexutil.Uint `json:"transactionIndex" rlp:"-"`
BlockHash *common.Hash `json:"blockHash" rlp:"-"`
BlockTimestamp *uint64 `json:"blockTimestamp" rlp:"-"`
BlockTimestamp *hexutil.Uint64 `json:"blockTimestamp" rlp:"-"`
Index *hexutil.Uint `json:"logIndex" rlp:"-"`
Removed *bool `json:"removed" rlp:"-"`
}
@ -84,7 +84,7 @@ func (l *Log) UnmarshalJSON(input []byte) error {
l.BlockHash = *dec.BlockHash
}
if dec.BlockTimestamp != nil {
l.BlockTimestamp = *dec.BlockTimestamp
l.BlockTimestamp = uint64(*dec.BlockTimestamp)
}
if dec.Index != nil {
l.Index = uint(*dec.Index)

View file

@ -59,5 +59,6 @@ type logMarshaling struct {
Data hexutil.Bytes
BlockNumber hexutil.Uint64
TxIndex hexutil.Uint
BlockTimestamp hexutil.Uint64
Index hexutil.Uint
}

View file

@ -258,6 +258,62 @@ func (r *Receipt) Size() common.StorageSize {
return size
}
// DeriveReceiptContext holds the contextual information needed to derive a receipt
type DeriveReceiptContext struct {
BlockHash common.Hash
BlockNumber uint64
BlockTime uint64
BaseFee *big.Int
BlobGasPrice *big.Int
GasUsed uint64
LogIndex uint // Number of logs in the block until this receipt
Tx *Transaction
TxIndex uint
}
// DeriveFields fills the receipt with computed fields based on consensus
// data and contextual infos like containing block and transactions.
func (r *Receipt) DeriveFields(signer Signer, context DeriveReceiptContext) {
// The transaction type and hash can be retrieved from the transaction itself
r.Type = context.Tx.Type()
r.TxHash = context.Tx.Hash()
r.GasUsed = context.GasUsed
r.EffectiveGasPrice = context.Tx.inner.effectiveGasPrice(new(big.Int), context.BaseFee)
// EIP-4844 blob transaction fields
if context.Tx.Type() == BlobTxType {
r.BlobGasUsed = context.Tx.BlobGas()
r.BlobGasPrice = context.BlobGasPrice
}
// Block location fields
r.BlockHash = context.BlockHash
r.BlockNumber = new(big.Int).SetUint64(context.BlockNumber)
r.TransactionIndex = context.TxIndex
// The contract address can be derived from the transaction itself
if context.Tx.To() == nil {
// Deriving the signer is expensive, only do if it's actually needed
from, _ := Sender(signer, context.Tx)
r.ContractAddress = crypto.CreateAddress(from, context.Tx.Nonce())
} else {
r.ContractAddress = common.Address{}
}
// The derived log fields can simply be set from the block and transaction
logIndex := context.LogIndex
for j := 0; j < len(r.Logs); j++ {
r.Logs[j].BlockNumber = context.BlockNumber
r.Logs[j].BlockHash = context.BlockHash
r.Logs[j].BlockTimestamp = context.BlockTime
r.Logs[j].TxHash = r.TxHash
r.Logs[j].TxIndex = context.TxIndex
r.Logs[j].Index = logIndex
logIndex++
}
// Also derive the Bloom if not derived yet
r.Bloom = CreateBloom(r)
}
// ReceiptForStorage is a wrapper around a Receipt with RLP serialization
// that omits the Bloom field. The Bloom field is recomputed by DeriveFields.
type ReceiptForStorage Receipt
@ -323,58 +379,30 @@ func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer) {
// DeriveFields fills the receipts with their computed fields based on consensus
// data and contextual infos like containing block and transactions.
func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, number uint64, time uint64, baseFee *big.Int, blobGasPrice *big.Int, txs []*Transaction) error {
signer := MakeSigner(config, new(big.Int).SetUint64(number), time)
func (rs Receipts) DeriveFields(config *params.ChainConfig, blockHash common.Hash, blockNumber uint64, blockTime uint64, baseFee *big.Int, blobGasPrice *big.Int, txs []*Transaction) error {
signer := MakeSigner(config, new(big.Int).SetUint64(blockNumber), blockTime)
logIndex := uint(0)
if len(txs) != len(rs) {
return errors.New("transaction and receipt count mismatch")
}
for i := 0; i < len(rs); i++ {
// The transaction type and hash can be retrieved from the transaction itself
rs[i].Type = txs[i].Type()
rs[i].TxHash = txs[i].Hash()
rs[i].EffectiveGasPrice = txs[i].inner.effectiveGasPrice(new(big.Int), baseFee)
// EIP-4844 blob transaction fields
if txs[i].Type() == BlobTxType {
rs[i].BlobGasUsed = txs[i].BlobGas()
rs[i].BlobGasPrice = blobGasPrice
var cumulativeGasUsed uint64
if i > 0 {
cumulativeGasUsed = rs[i-1].CumulativeGasUsed
}
// block location fields
rs[i].BlockHash = hash
rs[i].BlockNumber = new(big.Int).SetUint64(number)
rs[i].TransactionIndex = uint(i)
// The contract address can be derived from the transaction itself
if txs[i].To() == nil {
// Deriving the signer is expensive, only do if it's actually needed
from, _ := Sender(signer, txs[i])
rs[i].ContractAddress = crypto.CreateAddress(from, txs[i].Nonce())
} else {
rs[i].ContractAddress = common.Address{}
}
// The used gas can be calculated based on previous r
if i == 0 {
rs[i].GasUsed = rs[i].CumulativeGasUsed
} else {
rs[i].GasUsed = rs[i].CumulativeGasUsed - rs[i-1].CumulativeGasUsed
}
// The derived log fields can simply be set from the block and transaction
for j := 0; j < len(rs[i].Logs); j++ {
rs[i].Logs[j].BlockNumber = number
rs[i].Logs[j].BlockHash = hash
rs[i].Logs[j].BlockTimestamp = time
rs[i].Logs[j].TxHash = rs[i].TxHash
rs[i].Logs[j].TxIndex = uint(i)
rs[i].Logs[j].Index = logIndex
logIndex++
}
// also derive the Bloom if not derived yet
rs[i].Bloom = CreateBloom(rs[i])
rs[i].DeriveFields(signer, DeriveReceiptContext{
BlockHash: blockHash,
BlockNumber: blockNumber,
BlockTime: blockTime,
BaseFee: baseFee,
BlobGasPrice: blobGasPrice,
GasUsed: rs[i].CumulativeGasUsed - cumulativeGasUsed,
LogIndex: logIndex,
Tx: txs[i],
TxIndex: uint(i),
})
logIndex += uint(len(rs[i].Logs))
}
return nil
}

View file

@ -99,7 +99,7 @@ var (
func gasSStore(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
var (
y, x = stack.Back(1), stack.Back(0)
current = evm.StateDB.GetState(contract.Address(), x.Bytes32())
current, original = evm.StateDB.GetStateAndCommittedState(contract.Address(), x.Bytes32())
)
// The legacy gas metering only takes into consideration the current state
// Legacy rules should be applied if we are in Petersburg (removal of EIP-1283)
@ -139,7 +139,6 @@ func gasSStore(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySi
if current == value { // noop (1)
return params.NetSstoreNoopGas, nil
}
original := evm.StateDB.GetCommittedState(contract.Address(), x.Bytes32())
if original == current {
if original == (common.Hash{}) { // create slot (2.1.1)
return params.NetSstoreInitGas, nil
@ -189,14 +188,13 @@ func gasSStoreEIP2200(evm *EVM, contract *Contract, stack *Stack, mem *Memory, m
// Gas sentry honoured, do the actual gas calculation based on the stored value
var (
y, x = stack.Back(1), stack.Back(0)
current = evm.StateDB.GetState(contract.Address(), x.Bytes32())
current, original = evm.StateDB.GetStateAndCommittedState(contract.Address(), x.Bytes32())
)
value := common.Hash(y.Bytes32())
if current == value { // noop (1)
return params.SloadGasEIP2200, nil
}
original := evm.StateDB.GetCommittedState(contract.Address(), x.Bytes32())
if original == current {
if original == (common.Hash{}) { // create slot (2.1.1)
return params.SstoreSetGasEIP2200, nil

View file

@ -50,7 +50,7 @@ type StateDB interface {
SubRefund(uint64)
GetRefund() uint64
GetCommittedState(common.Address, common.Hash) common.Hash
GetStateAndCommittedState(common.Address, common.Hash) (common.Hash, common.Hash)
GetState(common.Address, common.Hash) common.Hash
SetState(common.Address, common.Hash, common.Hash) common.Hash
GetStorageRoot(addr common.Address) common.Hash

View file

@ -18,6 +18,7 @@ package vm
import (
"math"
"math/big"
"testing"
"time"
@ -74,3 +75,22 @@ func TestLoopInterrupt(t *testing.T) {
}
}
}
func BenchmarkInterpreter(b *testing.B) {
var (
statedb, _ = state.New(types.EmptyRootHash, state.NewDatabaseForTesting())
evm = NewEVM(BlockContext{BlockNumber: big.NewInt(1), Time: 1, Random: &common.Hash{}}, statedb, params.MergedTestChainConfig, Config{})
startGas uint64 = 100_000_000
value = uint256.NewInt(0)
stack = newstack()
mem = NewMemory()
contract = NewContract(common.Address{}, common.Address{}, value, startGas, nil)
)
stack.push(uint256.NewInt(123))
stack.push(uint256.NewInt(123))
gasSStoreEIP3529 = makeGasSStoreFunc(params.SstoreClearsScheduleRefundEIP3529)
b.ResetTimer()
for i := 0; i < b.N; i++ {
gasSStoreEIP3529(evm, contract, stack, mem, 1234)
}
}

View file

@ -36,7 +36,7 @@ func makeGasSStoreFunc(clearingRefund uint64) gasFunc {
var (
y, x = stack.Back(1), stack.peek()
slot = common.Hash(x.Bytes32())
current = evm.StateDB.GetState(contract.Address(), slot)
current, original = evm.StateDB.GetStateAndCommittedState(contract.Address(), slot)
cost = uint64(0)
)
// Check slot presence in the access list
@ -52,7 +52,6 @@ func makeGasSStoreFunc(clearingRefund uint64) gasFunc {
// return params.SloadGasEIP2200, nil
return cost + params.WarmStorageReadCostEIP2929, nil // SLOAD_GAS
}
original := evm.StateDB.GetCommittedState(contract.Address(), x.Bytes32())
if original == current {
if original == (common.Hash{}) { // create slot (2.1.1)
return cost + params.SstoreSetGasEIP2200, nil

View file

@ -282,6 +282,10 @@ func (b *EthAPIBackend) GetReceipts(ctx context.Context, hash common.Hash) (type
return b.eth.blockchain.GetReceiptsByHash(hash), nil
}
func (b *EthAPIBackend) GetCanonicalReceipt(tx *types.Transaction, blockHash common.Hash, blockNumber, blockIndex uint64) (*types.Receipt, error) {
return b.eth.blockchain.GetCanonicalReceipt(tx, blockHash, blockNumber, blockIndex)
}
func (b *EthAPIBackend) GetLogs(ctx context.Context, hash common.Hash, number uint64) ([][]*types.Log, error) {
return rawdb.ReadLogs(b.eth.chainDb, hash, number), nil
}
@ -354,14 +358,16 @@ func (b *EthAPIBackend) GetPoolTransaction(hash common.Hash) *types.Transaction
return b.eth.txPool.Get(hash)
}
// GetTransaction retrieves the lookup along with the transaction itself associate
// with the given transaction hash.
// GetCanonicalTransaction retrieves the lookup along with the transaction itself
// associate with the given transaction hash.
//
// A null will be returned if the transaction is not found. The transaction is not
// existent from the node's perspective. This can be due to the transaction indexer
// not being finished. The caller must explicitly check the indexer progress.
func (b *EthAPIBackend) GetTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64) {
lookup, tx := b.eth.blockchain.GetTransactionLookup(txHash)
//
// Notably, only the transaction in the canonical chain is visible.
func (b *EthAPIBackend) GetCanonicalTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64) {
lookup, tx := b.eth.blockchain.GetCanonicalTransaction(txHash)
if lookup == nil || tx == nil {
return false, nil, common.Hash{}, 0, 0
}

View file

@ -278,7 +278,11 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if fb := eth.blockchain.CurrentFinalBlock(); fb != nil {
finalBlock = fb.Number.Uint64()
}
eth.filterMaps = filtermaps.NewFilterMaps(chainDb, chainView, historyCutoff, finalBlock, filtermaps.DefaultParams, fmConfig)
filterMaps, err := filtermaps.NewFilterMaps(chainDb, chainView, historyCutoff, finalBlock, filtermaps.DefaultParams, fmConfig)
if err != nil {
return nil, err
}
eth.filterMaps = filterMaps
eth.closeFilterMaps = make(chan chan struct{})
// TxPool

View file

@ -648,7 +648,7 @@ func (api *ConsensusAPI) NewPayloadV4(params engine.ExecutableData, versionedHas
case executionRequests == nil:
return invalidStatus, paramsErr("nil executionRequests post-prague")
case !api.checkFork(params.Timestamp, forks.Prague, forks.Osaka):
return invalidStatus, unsupportedForkErr("newPayloadV3 must only be called for cancun payloads")
return invalidStatus, unsupportedForkErr("newPayloadV4 must only be called for prague payloads")
}
requests := convertRequests(executionRequests)
if err := validateRequests(requests); err != nil {

View file

@ -208,6 +208,12 @@ func (c *SimulatedBeacon) sealBlock(withdrawals []*types.Withdrawal, timestamp u
return errors.New("chain rewind prevented invocation of payload creation")
}
// If the payload was already known, we can skip the rest of the process.
// This edge case is possible due to a race condition between seal and debug.setHead.
if fcResponse.PayloadStatus.Status == engine.VALID && fcResponse.PayloadID == nil {
return nil
}
envelope, err := c.engineAPI.getPayload(*fcResponse.PayloadID, true)
if err != nil {
return err

View file

@ -152,7 +152,7 @@ func (api *ConsensusAPI) NewPayloadWithWitnessV4(params engine.ExecutableData, v
case executionRequests == nil:
return invalidStatus, paramsErr("nil executionRequests post-prague")
case !api.checkFork(params.Timestamp, forks.Prague):
return invalidStatus, unsupportedForkErr("newPayloadV3 must only be called for cancun payloads")
return invalidStatus, unsupportedForkErr("newPayloadV4 must only be called for prague payloads")
}
requests := convertRequests(executionRequests)
if err := validateRequests(requests); err != nil {

View file

@ -384,7 +384,7 @@ func (s *skeleton) sync(head *types.Header) (*types.Header, error) {
defer close(done)
filled := s.filler.suspend()
if filled == nil {
log.Error("Latest filled block is not available")
log.Warn("Latest filled block is not available")
return
}
// If something was filled, try to delete stale sync helpers. If

View file

@ -40,13 +40,17 @@ var (
errInvalidBlockRange = errors.New("invalid block range params")
errPendingLogsUnsupported = errors.New("pending logs are not supported")
errExceedMaxTopics = errors.New("exceed max topics")
errExceedMaxAddresses = errors.New("exceed max addresses")
)
const (
// The maximum number of addresses allowed in a filter criteria
maxAddresses = 1000
// The maximum number of topic criteria allowed, vm.LOG4 - vm.LOG0
const maxTopics = 4
maxTopics = 4
// The maximum number of allowed topics within a topic criteria
const maxSubTopics = 1000
maxSubTopics = 1000
)
// filter is a helper struct that holds meta information over the filter type
// and associated subscription in the event system.
@ -341,6 +345,9 @@ func (api *FilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]*type
if len(crit.Topics) > maxTopics {
return nil, errExceedMaxTopics
}
if len(crit.Addresses) > maxAddresses {
return nil, errExceedMaxAddresses
}
var filter *Filter
if crit.BlockHash != nil {
// Block filter requested, construct a single-shot filter
@ -530,6 +537,9 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
// raw.Address can contain a single address or an array of addresses
switch rawAddr := raw.Addresses.(type) {
case []interface{}:
if len(rawAddr) > maxAddresses {
return errExceedMaxAddresses
}
for i, addr := range rawAddr {
if strAddr, ok := addr.(string); ok {
addr, err := decodeAddress(strAddr)

View file

@ -19,6 +19,7 @@ package filters
import (
"encoding/json"
"fmt"
"strings"
"testing"
"github.com/ethereum/go-ethereum/common"
@ -182,4 +183,15 @@ func TestUnmarshalJSONNewFilterArgs(t *testing.T) {
if len(test7.Topics[2]) != 0 {
t.Fatalf("expected 0 topics, got %d topics", len(test7.Topics[2]))
}
// multiple address exceeding max
var test8 FilterCriteria
addresses := make([]string, maxAddresses+1)
for i := 0; i < maxAddresses+1; i++ {
addresses[i] = fmt.Sprintf(`"%s"`, common.HexToAddress(fmt.Sprintf("0x%x", i)).Hex())
}
vector = fmt.Sprintf(`{"address": [%s]}`, strings.Join(addresses, ", "))
if err := json.Unmarshal([]byte(vector), &test8); err != errExceedMaxAddresses {
t.Fatal("expected errExceedMaxAddresses, got", err)
}
}

View file

@ -291,6 +291,9 @@ func (es *EventSystem) SubscribeLogs(crit ethereum.FilterQuery, logs chan []*typ
if len(crit.Topics) > maxTopics {
return nil, errExceedMaxTopics
}
if len(crit.Addresses) > maxAddresses {
return nil, errExceedMaxAddresses
}
var from, to rpc.BlockNumber
if crit.FromBlock == nil {
from = rpc.LatestBlockNumber

View file

@ -175,7 +175,7 @@ func (b *testBackend) startFilterMaps(history uint64, disabled bool, params filt
Disabled: disabled,
ExportFileName: "",
}
b.fm = filtermaps.NewFilterMaps(b.db, chainView, 0, 0, params, config)
b.fm, _ = filtermaps.NewFilterMaps(b.db, chainView, 0, 0, params, config)
b.fm.Start()
b.fm.WaitIdle()
}
@ -435,6 +435,7 @@ func TestInvalidLogFilterCreation(t *testing.T) {
1: {FromBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), ToBlock: big.NewInt(100)},
2: {FromBlock: big.NewInt(rpc.LatestBlockNumber.Int64()), ToBlock: big.NewInt(100)},
3: {Topics: [][]common.Hash{{}, {}, {}, {}, {}}},
4: {Addresses: make([]common.Address, maxAddresses+1)},
}
for i, test := range testCases {
@ -461,6 +462,7 @@ func TestInvalidGetLogsRequest(t *testing.T) {
1: {BlockHash: &blockHash, ToBlock: big.NewInt(500)},
2: {BlockHash: &blockHash, FromBlock: big.NewInt(rpc.LatestBlockNumber.Int64())},
3: {BlockHash: &blockHash, Topics: [][]common.Hash{{}, {}, {}, {}, {}}},
4: {BlockHash: &blockHash, Addresses: make([]common.Address, maxAddresses+1)},
}
for i, test := range testCases {

View file

@ -317,26 +317,26 @@ func testFilters(t *testing.T, history uint64, noHistory bool) {
}{
{
f: sys.NewBlockFilter(chain[2].Hash(), []common.Address{contract}, nil),
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696332","0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x3","transactionHash":"0xdefe471992a07a02acdfbe33edaae22fbb86d7d3cec3f1b8e4e77702fb3acc1d","transactionIndex":"0x0","blockHash":"0x7a7556792ca7d37882882e2b001fe14833eaf81c2c7f865c9c771ec37a024f6b","blockTimestamp":30,"logIndex":"0x0","removed":false}]`,
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696332","0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x3","transactionHash":"0xdefe471992a07a02acdfbe33edaae22fbb86d7d3cec3f1b8e4e77702fb3acc1d","transactionIndex":"0x0","blockHash":"0x7a7556792ca7d37882882e2b001fe14833eaf81c2c7f865c9c771ec37a024f6b","blockTimestamp":"0x1e","logIndex":"0x0","removed":false}]`,
},
{
f: sys.NewRangeFilter(0, int64(rpc.LatestBlockNumber), []common.Address{contract}, [][]common.Hash{{hash1, hash2, hash3, hash4}}),
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x2","transactionHash":"0xa8028c655b6423204c8edfbc339f57b042d6bec2b6a61145d76b7c08b4cccd42","transactionIndex":"0x0","blockHash":"0x24417bb49ce44cfad65da68f33b510bf2a129c0d89ccf06acb6958b8585ccf34","blockTimestamp":20,"logIndex":"0x0","removed":false},{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696332","0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x3","transactionHash":"0xdefe471992a07a02acdfbe33edaae22fbb86d7d3cec3f1b8e4e77702fb3acc1d","transactionIndex":"0x0","blockHash":"0x7a7556792ca7d37882882e2b001fe14833eaf81c2c7f865c9c771ec37a024f6b","blockTimestamp":30,"logIndex":"0x0","removed":false},{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696334"],"data":"0x","blockNumber":"0x3e8","transactionHash":"0x9a87842100a638dfa5da8842b4beda691d2fd77b0c84b57f24ecfa9fb208f747","transactionIndex":"0x0","blockHash":"0xb360bad5265261c075ece02d3bf0e39498a6a76310482cdfd90588748e6c5ee0","blockTimestamp":10000,"logIndex":"0x0","removed":false}]`,
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x2","transactionHash":"0xa8028c655b6423204c8edfbc339f57b042d6bec2b6a61145d76b7c08b4cccd42","transactionIndex":"0x0","blockHash":"0x24417bb49ce44cfad65da68f33b510bf2a129c0d89ccf06acb6958b8585ccf34","blockTimestamp":"0x14","logIndex":"0x0","removed":false},{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696332","0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x3","transactionHash":"0xdefe471992a07a02acdfbe33edaae22fbb86d7d3cec3f1b8e4e77702fb3acc1d","transactionIndex":"0x0","blockHash":"0x7a7556792ca7d37882882e2b001fe14833eaf81c2c7f865c9c771ec37a024f6b","blockTimestamp":"0x1e","logIndex":"0x0","removed":false},{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696334"],"data":"0x","blockNumber":"0x3e8","transactionHash":"0x9a87842100a638dfa5da8842b4beda691d2fd77b0c84b57f24ecfa9fb208f747","transactionIndex":"0x0","blockHash":"0xb360bad5265261c075ece02d3bf0e39498a6a76310482cdfd90588748e6c5ee0","blockTimestamp":"0x2710","logIndex":"0x0","removed":false}]`,
},
{
f: sys.NewRangeFilter(900, 999, []common.Address{contract}, [][]common.Hash{{hash3}}),
},
{
f: sys.NewRangeFilter(990, int64(rpc.LatestBlockNumber), []common.Address{contract2}, [][]common.Hash{{hash3}}),
want: `[{"address":"0xff00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696333"],"data":"0x","blockNumber":"0x3e7","transactionHash":"0x53e3675800c6908424b61b35a44e51ca4c73ca603e58a65b32c67968b4f42200","transactionIndex":"0x0","blockHash":"0x2e4620a2b426b0612ec6cad9603f466723edaed87f98c9137405dd4f7a2409ff","blockTimestamp":9990,"logIndex":"0x0","removed":false}]`,
want: `[{"address":"0xff00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696333"],"data":"0x","blockNumber":"0x3e7","transactionHash":"0x53e3675800c6908424b61b35a44e51ca4c73ca603e58a65b32c67968b4f42200","transactionIndex":"0x0","blockHash":"0x2e4620a2b426b0612ec6cad9603f466723edaed87f98c9137405dd4f7a2409ff","blockTimestamp":"0x2706","logIndex":"0x0","removed":false}]`,
},
{
f: sys.NewRangeFilter(1, 10, []common.Address{contract}, [][]common.Hash{{hash2}, {hash1}}),
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696332","0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x3","transactionHash":"0xdefe471992a07a02acdfbe33edaae22fbb86d7d3cec3f1b8e4e77702fb3acc1d","transactionIndex":"0x0","blockHash":"0x7a7556792ca7d37882882e2b001fe14833eaf81c2c7f865c9c771ec37a024f6b","blockTimestamp":30,"logIndex":"0x0","removed":false}]`,
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696332","0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x3","transactionHash":"0xdefe471992a07a02acdfbe33edaae22fbb86d7d3cec3f1b8e4e77702fb3acc1d","transactionIndex":"0x0","blockHash":"0x7a7556792ca7d37882882e2b001fe14833eaf81c2c7f865c9c771ec37a024f6b","blockTimestamp":"0x1e","logIndex":"0x0","removed":false}]`,
},
{
f: sys.NewRangeFilter(1, 10, nil, [][]common.Hash{{hash1, hash2}}),
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x2","transactionHash":"0xa8028c655b6423204c8edfbc339f57b042d6bec2b6a61145d76b7c08b4cccd42","transactionIndex":"0x0","blockHash":"0x24417bb49ce44cfad65da68f33b510bf2a129c0d89ccf06acb6958b8585ccf34","blockTimestamp":20,"logIndex":"0x0","removed":false},{"address":"0xff00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x2","transactionHash":"0xdba3e2ea9a7d690b722d70ee605fd67ba4c00d1d3aecd5cf187a7b92ad8eb3df","transactionIndex":"0x1","blockHash":"0x24417bb49ce44cfad65da68f33b510bf2a129c0d89ccf06acb6958b8585ccf34","blockTimestamp":20,"logIndex":"0x1","removed":false},{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696332","0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x3","transactionHash":"0xdefe471992a07a02acdfbe33edaae22fbb86d7d3cec3f1b8e4e77702fb3acc1d","transactionIndex":"0x0","blockHash":"0x7a7556792ca7d37882882e2b001fe14833eaf81c2c7f865c9c771ec37a024f6b","blockTimestamp":30,"logIndex":"0x0","removed":false}]`,
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x2","transactionHash":"0xa8028c655b6423204c8edfbc339f57b042d6bec2b6a61145d76b7c08b4cccd42","transactionIndex":"0x0","blockHash":"0x24417bb49ce44cfad65da68f33b510bf2a129c0d89ccf06acb6958b8585ccf34","blockTimestamp":"0x14","logIndex":"0x0","removed":false},{"address":"0xff00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x2","transactionHash":"0xdba3e2ea9a7d690b722d70ee605fd67ba4c00d1d3aecd5cf187a7b92ad8eb3df","transactionIndex":"0x1","blockHash":"0x24417bb49ce44cfad65da68f33b510bf2a129c0d89ccf06acb6958b8585ccf34","blockTimestamp":"0x14","logIndex":"0x1","removed":false},{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696332","0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x3","transactionHash":"0xdefe471992a07a02acdfbe33edaae22fbb86d7d3cec3f1b8e4e77702fb3acc1d","transactionIndex":"0x0","blockHash":"0x7a7556792ca7d37882882e2b001fe14833eaf81c2c7f865c9c771ec37a024f6b","blockTimestamp":"0x1e","logIndex":"0x0","removed":false}]`,
},
{
f: sys.NewRangeFilter(0, int64(rpc.LatestBlockNumber), nil, [][]common.Hash{{common.BytesToHash([]byte("fail"))}}),
@ -349,15 +349,15 @@ func testFilters(t *testing.T, history uint64, noHistory bool) {
},
{
f: sys.NewRangeFilter(int64(rpc.LatestBlockNumber), int64(rpc.LatestBlockNumber), nil, nil),
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696334"],"data":"0x","blockNumber":"0x3e8","transactionHash":"0x9a87842100a638dfa5da8842b4beda691d2fd77b0c84b57f24ecfa9fb208f747","transactionIndex":"0x0","blockHash":"0xb360bad5265261c075ece02d3bf0e39498a6a76310482cdfd90588748e6c5ee0","blockTimestamp":10000,"logIndex":"0x0","removed":false}]`,
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696334"],"data":"0x","blockNumber":"0x3e8","transactionHash":"0x9a87842100a638dfa5da8842b4beda691d2fd77b0c84b57f24ecfa9fb208f747","transactionIndex":"0x0","blockHash":"0xb360bad5265261c075ece02d3bf0e39498a6a76310482cdfd90588748e6c5ee0","blockTimestamp":"0x2710","logIndex":"0x0","removed":false}]`,
},
{
f: sys.NewRangeFilter(int64(rpc.FinalizedBlockNumber), int64(rpc.LatestBlockNumber), nil, nil),
want: `[{"address":"0xff00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696333"],"data":"0x","blockNumber":"0x3e7","transactionHash":"0x53e3675800c6908424b61b35a44e51ca4c73ca603e58a65b32c67968b4f42200","transactionIndex":"0x0","blockHash":"0x2e4620a2b426b0612ec6cad9603f466723edaed87f98c9137405dd4f7a2409ff","blockTimestamp":9990,"logIndex":"0x0","removed":false},{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696334"],"data":"0x","blockNumber":"0x3e8","transactionHash":"0x9a87842100a638dfa5da8842b4beda691d2fd77b0c84b57f24ecfa9fb208f747","transactionIndex":"0x0","blockHash":"0xb360bad5265261c075ece02d3bf0e39498a6a76310482cdfd90588748e6c5ee0","blockTimestamp":10000,"logIndex":"0x0","removed":false}]`,
want: `[{"address":"0xff00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696333"],"data":"0x","blockNumber":"0x3e7","transactionHash":"0x53e3675800c6908424b61b35a44e51ca4c73ca603e58a65b32c67968b4f42200","transactionIndex":"0x0","blockHash":"0x2e4620a2b426b0612ec6cad9603f466723edaed87f98c9137405dd4f7a2409ff","blockTimestamp":"0x2706","logIndex":"0x0","removed":false},{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696334"],"data":"0x","blockNumber":"0x3e8","transactionHash":"0x9a87842100a638dfa5da8842b4beda691d2fd77b0c84b57f24ecfa9fb208f747","transactionIndex":"0x0","blockHash":"0xb360bad5265261c075ece02d3bf0e39498a6a76310482cdfd90588748e6c5ee0","blockTimestamp":"0x2710","logIndex":"0x0","removed":false}]`,
},
{
f: sys.NewRangeFilter(int64(rpc.FinalizedBlockNumber), int64(rpc.FinalizedBlockNumber), nil, nil),
want: `[{"address":"0xff00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696333"],"data":"0x","blockNumber":"0x3e7","transactionHash":"0x53e3675800c6908424b61b35a44e51ca4c73ca603e58a65b32c67968b4f42200","transactionIndex":"0x0","blockHash":"0x2e4620a2b426b0612ec6cad9603f466723edaed87f98c9137405dd4f7a2409ff","blockTimestamp":9990,"logIndex":"0x0","removed":false}]`,
want: `[{"address":"0xff00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696333"],"data":"0x","blockNumber":"0x3e7","transactionHash":"0x53e3675800c6908424b61b35a44e51ca4c73ca603e58a65b32c67968b4f42200","transactionIndex":"0x0","blockHash":"0x2e4620a2b426b0612ec6cad9603f466723edaed87f98c9137405dd4f7a2409ff","blockTimestamp":"0x2706","logIndex":"0x0","removed":false}]`,
},
{
f: sys.NewRangeFilter(int64(rpc.LatestBlockNumber), int64(rpc.FinalizedBlockNumber), nil, nil),

View file

@ -82,7 +82,7 @@ type Backend interface {
HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)
BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error)
GetTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64)
GetCanonicalTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64)
TxIndexDone() bool
RPCGasCap() uint64
ChainConfig() *params.ChainConfig
@ -863,7 +863,7 @@ func containsTx(block *types.Block, hash common.Hash) bool {
// TraceTransaction returns the structured logs created during the execution of EVM
// and returns them as a JSON object.
func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
found, _, blockHash, blockNumber, index := api.backend.GetTransaction(hash)
found, _, blockHash, blockNumber, index := api.backend.GetCanonicalTransaction(hash)
if !found {
// Warn in case tx indexer is not done.
if !api.backend.TxIndexDone() {

View file

@ -117,8 +117,8 @@ func (b *testBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumber)
return b.chain.GetBlockByNumber(uint64(number)), nil
}
func (b *testBackend) GetTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64) {
tx, hash, blockNumber, index := rawdb.ReadTransaction(b.chaindb, txHash)
func (b *testBackend) GetCanonicalTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64) {
tx, hash, blockNumber, index := rawdb.ReadCanonicalTransaction(b.chaindb, txHash)
return tx != nil, tx, hash, blockNumber, index
}

View file

@ -39,6 +39,10 @@ func (*dummyStatedb) SetState(_ common.Address, _ common.Hash, _ common.Hash) co
return common.Hash{}
}
func (*dummyStatedb) GetStateAndCommittedState(common.Address, common.Hash) (common.Hash, common.Hash) {
return common.Hash{}, common.Hash{}
}
func TestStoreCapture(t *testing.T) {
var (
logger = NewStructLogger(nil)

View file

@ -216,6 +216,17 @@ func (ec *Client) TraceTransaction(ctx context.Context, hash common.Hash, config
return result, nil
}
// TraceBlock returns the structured logs created during the execution of EVM
// and returns them as a JSON object.
func (ec *Client) TraceBlock(ctx context.Context, hash common.Hash, config *tracers.TraceConfig) (any, error) {
var result any
err := ec.c.CallContext(ctx, &result, "debug_traceBlockByHash", hash, config)
if err != nil {
return nil, err
}
return result, nil
}
func toBlockNumArg(number *big.Int) string {
if number == nil {
return "latest"

View file

@ -229,7 +229,7 @@ func (t *Transaction) resolve(ctx context.Context) (*types.Transaction, *Block)
return t.tx, t.block
}
// Try to return an already finalized transaction
found, tx, blockHash, _, index := t.r.backend.GetTransaction(t.hash)
found, tx, blockHash, _, index := t.r.backend.GetCanonicalTransaction(t.hash)
if found {
t.tx = tx
blockNrOrHash := rpc.BlockNumberOrHashWithHash(blockHash, false)

View file

@ -55,13 +55,13 @@ var (
Usage: "Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=5,p2p=4)",
Value: "",
Hidden: true,
Category: flags.LoggingCategory,
Category: flags.DeprecatedCategory,
}
logjsonFlag = &cli.BoolFlag{
Name: "log.json",
Usage: "Format logs with JSON",
Hidden: true,
Category: flags.LoggingCategory,
Category: flags.DeprecatedCategory,
}
logFormatFlag = &cli.StringFlag{
Name: "log.format",

View file

@ -186,15 +186,15 @@ func NewTxPoolAPI(b Backend) *TxPoolAPI {
// Content returns the transactions contained within the transaction pool.
func (api *TxPoolAPI) Content() map[string]map[string]map[string]*RPCTransaction {
content := map[string]map[string]map[string]*RPCTransaction{
"pending": make(map[string]map[string]*RPCTransaction),
"queued": make(map[string]map[string]*RPCTransaction),
}
pending, queue := api.b.TxPoolContent()
content := map[string]map[string]map[string]*RPCTransaction{
"pending": make(map[string]map[string]*RPCTransaction, len(pending)),
"queued": make(map[string]map[string]*RPCTransaction, len(queue)),
}
curHeader := api.b.CurrentHeader()
// Flatten the pending transactions
for account, txs := range pending {
dump := make(map[string]*RPCTransaction)
dump := make(map[string]*RPCTransaction, len(txs))
for _, tx := range txs {
dump[fmt.Sprintf("%d", tx.Nonce())] = NewRPCPendingTransaction(tx, curHeader, api.b.ChainConfig())
}
@ -202,7 +202,7 @@ func (api *TxPoolAPI) Content() map[string]map[string]map[string]*RPCTransaction
}
// Flatten the queued transactions
for account, txs := range queue {
dump := make(map[string]*RPCTransaction)
dump := make(map[string]*RPCTransaction, len(txs))
for _, tx := range txs {
dump[fmt.Sprintf("%d", tx.Nonce())] = NewRPCPendingTransaction(tx, curHeader, api.b.ChainConfig())
}
@ -246,11 +246,11 @@ func (api *TxPoolAPI) Status() map[string]hexutil.Uint {
// Inspect retrieves the content of the transaction pool and flattens it into an
// easily inspectable list.
func (api *TxPoolAPI) Inspect() map[string]map[string]map[string]string {
content := map[string]map[string]map[string]string{
"pending": make(map[string]map[string]string),
"queued": make(map[string]map[string]string),
}
pending, queue := api.b.TxPoolContent()
content := map[string]map[string]map[string]string{
"pending": make(map[string]map[string]string, len(pending)),
"queued": make(map[string]map[string]string, len(queue)),
}
// Define a formatter to flatten a transaction into a string
format := func(tx *types.Transaction) string {
@ -261,7 +261,7 @@ func (api *TxPoolAPI) Inspect() map[string]map[string]map[string]string {
}
// Flatten the pending transactions
for account, txs := range pending {
dump := make(map[string]string)
dump := make(map[string]string, len(txs))
for _, tx := range txs {
dump[fmt.Sprintf("%d", tx.Nonce())] = format(tx)
}
@ -269,7 +269,7 @@ func (api *TxPoolAPI) Inspect() map[string]map[string]map[string]string {
}
// Flatten the queued transactions
for account, txs := range queue {
dump := make(map[string]string)
dump := make(map[string]string, len(txs))
for _, tx := range txs {
dump[fmt.Sprintf("%d", tx.Nonce())] = format(tx)
}
@ -1334,7 +1334,7 @@ func (api *TransactionAPI) GetTransactionCount(ctx context.Context, address comm
// GetTransactionByHash returns the transaction for the given hash
func (api *TransactionAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error) {
// Try to return an already finalized transaction
found, tx, blockHash, blockNumber, index := api.b.GetTransaction(hash)
found, tx, blockHash, blockNumber, index := api.b.GetCanonicalTransaction(hash)
if !found {
// No finalized transaction, try to retrieve it from the pool
if tx := api.b.GetPoolTransaction(hash); tx != nil {
@ -1357,7 +1357,7 @@ func (api *TransactionAPI) GetTransactionByHash(ctx context.Context, hash common
// GetRawTransactionByHash returns the bytes of the transaction for the given hash.
func (api *TransactionAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) {
// Retrieve a finalized transaction, or a pooled otherwise
found, tx, _, _, _ := api.b.GetTransaction(hash)
found, tx, _, _, _ := api.b.GetCanonicalTransaction(hash)
if !found {
if tx = api.b.GetPoolTransaction(hash); tx != nil {
return tx.MarshalBinary()
@ -1374,7 +1374,7 @@ func (api *TransactionAPI) GetRawTransactionByHash(ctx context.Context, hash com
// GetTransactionReceipt returns the transaction receipt for the given transaction hash.
func (api *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) {
found, tx, blockHash, blockNumber, index := api.b.GetTransaction(hash)
found, tx, blockHash, blockNumber, index := api.b.GetCanonicalTransaction(hash)
if !found {
// Make sure indexer is done.
if !api.b.TxIndexDone() {
@ -1383,22 +1383,12 @@ func (api *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash commo
// No such tx.
return nil, nil
}
header, err := api.b.HeaderByHash(ctx, blockHash)
receipt, err := api.b.GetCanonicalReceipt(tx, blockHash, blockNumber, index)
if err != nil {
return nil, err
}
receipts, err := api.b.GetReceipts(ctx, blockHash)
if err != nil {
return nil, err
}
if uint64(len(receipts)) <= index {
return nil, nil
}
receipt := receipts[index]
// Derive the sender.
signer := types.MakeSigner(api.b.ChainConfig(), header.Number, header.Time)
return marshalReceipt(receipt, blockHash, blockNumber, signer, tx, int(index)), nil
return marshalReceipt(receipt, blockHash, blockNumber, api.signer, tx, int(index)), nil
}
// marshalReceipt marshals a transaction receipt into a JSON object.
@ -1781,7 +1771,7 @@ func (api *DebugAPI) GetRawReceipts(ctx context.Context, blockNrOrHash rpc.Block
// GetRawTransaction returns the bytes of the transaction for the given hash.
func (api *DebugAPI) GetRawTransaction(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) {
// Retrieve a finalized transaction, or a pooled otherwise
found, tx, _, _, _ := api.b.GetTransaction(hash)
found, tx, _, _, _ := api.b.GetCanonicalTransaction(hash)
if !found {
if tx = api.b.GetPoolTransaction(hash); tx != nil {
return tx.MarshalBinary()

View file

@ -586,9 +586,12 @@ func (b testBackend) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) even
func (b testBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error {
panic("implement me")
}
func (b testBackend) GetTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64) {
tx, blockHash, blockNumber, index := rawdb.ReadTransaction(b.db, txHash)
return true, tx, blockHash, blockNumber, index
func (b testBackend) GetCanonicalTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64) {
tx, blockHash, blockNumber, index := rawdb.ReadCanonicalTransaction(b.db, txHash)
return tx != nil, tx, blockHash, blockNumber, index
}
func (b testBackend) GetCanonicalReceipt(tx *types.Transaction, blockHash common.Hash, blockNumber, blockIndex uint64) (*types.Receipt, error) {
return b.chain.GetCanonicalReceipt(tx, blockHash, blockNumber, blockIndex)
}
func (b testBackend) TxIndexDone() bool {
return true

View file

@ -68,13 +68,14 @@ type Backend interface {
StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error)
Pending() (*types.Block, types.Receipts, *state.StateDB)
GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error)
GetCanonicalReceipt(tx *types.Transaction, blockHash common.Hash, blockNumber, blockIndex uint64) (*types.Receipt, error)
GetEVM(ctx context.Context, state *state.StateDB, header *types.Header, vmConfig *vm.Config, blockCtx *vm.BlockContext) *vm.EVM
SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription
SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
// Transaction pool API
SendTx(ctx context.Context, signedTx *types.Transaction) error
GetTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64)
GetCanonicalTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64)
TxIndexDone() bool
GetPoolTransactions() (types.Transactions, error)
GetPoolTransaction(txHash common.Hash) *types.Transaction

View file

@ -20,7 +20,7 @@
"transactionHash": "0xeaf3921cbf03ba45bad4e6ab807b196ce3b2a0b5bacc355b6272fa96b11b4287",
"transactionIndex": "0x0",
"blockHash": "0xcc6225bf39327429a3d869af71182d619a354155187d0b5a8ecd6a9309cffcaa",
"blockTimestamp": 30,
"blockTimestamp": "0x1e",
"logIndex": "0x0",
"removed": false
}

View file

@ -19,7 +19,7 @@
"transactionHash": "0xeaf3921cbf03ba45bad4e6ab807b196ce3b2a0b5bacc355b6272fa96b11b4287",
"transactionIndex": "0x0",
"blockHash": "0xcc6225bf39327429a3d869af71182d619a354155187d0b5a8ecd6a9309cffcaa",
"blockTimestamp": 30,
"blockTimestamp": "0x1e",
"logIndex": "0x0",
"removed": false
}

View file

@ -369,6 +369,9 @@ func (b *backendMock) Pending() (*types.Block, types.Receipts, *state.StateDB) {
func (b *backendMock) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
return nil, nil
}
func (b *backendMock) GetCanonicalReceipt(tx *types.Transaction, blockHash common.Hash, blockNumber, blockIndex uint64) (*types.Receipt, error) {
return nil, nil
}
func (b *backendMock) GetLogs(ctx context.Context, blockHash common.Hash, number uint64) ([][]*types.Log, error) {
return nil, nil
}
@ -380,7 +383,7 @@ func (b *backendMock) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) eve
return nil
}
func (b *backendMock) SendTx(ctx context.Context, signedTx *types.Transaction) error { return nil }
func (b *backendMock) GetTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64) {
func (b *backendMock) GetCanonicalTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64) {
return false, nil, [32]byte{}, 0, 0
}
func (b *backendMock) TxIndexDone() bool { return true }

View file

@ -2510,10 +2510,8 @@ var RequestManager = require('./web3/requestmanager');
var Iban = require('./web3/iban');
var Eth = require('./web3/methods/eth');
var DB = require('./web3/methods/db');
var Shh = require('./web3/methods/shh');
var Net = require('./web3/methods/net');
var Personal = require('./web3/methods/personal');
var Swarm = require('./web3/methods/swarm');
var Settings = require('./web3/settings');
var version = require('./version.json');
var utils = require('./utils/utils');
@ -2532,10 +2530,8 @@ function Web3 (provider) {
this.currentProvider = provider;
this.eth = new Eth(this);
this.db = new DB(this);
this.shh = new Shh(this);
this.net = new Net(this);
this.personal = new Personal(this);
this.bzz = new Swarm(this);
this.settings = new Settings();
this.version = {
api: version.version
@ -2612,11 +2608,6 @@ var properties = function () {
name: 'version.ethereum',
getter: 'eth_protocolVersion',
inputFormatter: utils.toDecimal
}),
new Property({
name: 'version.whisper',
getter: 'shh_version',
inputFormatter: utils.toDecimal
})
];
};
@ -2632,7 +2623,7 @@ Web3.prototype.createBatch = function () {
module.exports = Web3;
},{"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/extend":28,"./web3/httpprovider":32,"./web3/iban":33,"./web3/ipcprovider":34,"./web3/methods/db":37,"./web3/methods/eth":38,"./web3/methods/net":39,"./web3/methods/personal":40,"./web3/methods/shh":41,"./web3/methods/swarm":42,"./web3/property":45,"./web3/requestmanager":46,"./web3/settings":47,"bignumber.js":"bignumber.js"}],23:[function(require,module,exports){
},{"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/extend":28,"./web3/httpprovider":32,"./web3/iban":33,"./web3/ipcprovider":34,"./web3/methods/db":37,"./web3/methods/eth":38,"./web3/methods/net":39,"./web3/methods/personal":40,"./web3/property":45,"./web3/requestmanager":46,"./web3/settings":47,"bignumber.js":"bignumber.js"}],23:[function(require,module,exports){
/*
This file is part of web3.js.
@ -3486,8 +3477,6 @@ var getOptions = function (options, type) {
fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
};
case 'shh':
return options;
}
};
@ -5699,300 +5688,7 @@ var properties = function () {
module.exports = Personal;
},{"../formatters":30,"../method":36,"../property":45}],41:[function(require,module,exports){
/*
This file is part of web3.js.
web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file shh.js
* @authors:
* Fabian Vogelsteller <fabian@ethereum.org>
* Marek Kotewicz <marek@ethcore.io>
* @date 2017
*/
var Method = require('../method');
var Filter = require('../filter');
var watches = require('./watches');
var Shh = function (web3) {
this._requestManager = web3._requestManager;
var self = this;
methods().forEach(function(method) {
method.attachToObject(self);
method.setRequestManager(self._requestManager);
});
};
Shh.prototype.newMessageFilter = function (options, callback, filterCreationErrorCallback) {
return new Filter(options, 'shh', this._requestManager, watches.shh(), null, callback, filterCreationErrorCallback);
};
var methods = function () {
return [
new Method({
name: 'version',
call: 'shh_version',
params: 0
}),
new Method({
name: 'info',
call: 'shh_info',
params: 0
}),
new Method({
name: 'setMaxMessageSize',
call: 'shh_setMaxMessageSize',
params: 1
}),
new Method({
name: 'setMinPoW',
call: 'shh_setMinPoW',
params: 1
}),
new Method({
name: 'markTrustedPeer',
call: 'shh_markTrustedPeer',
params: 1
}),
new Method({
name: 'newKeyPair',
call: 'shh_newKeyPair',
params: 0
}),
new Method({
name: 'addPrivateKey',
call: 'shh_addPrivateKey',
params: 1
}),
new Method({
name: 'deleteKeyPair',
call: 'shh_deleteKeyPair',
params: 1
}),
new Method({
name: 'hasKeyPair',
call: 'shh_hasKeyPair',
params: 1
}),
new Method({
name: 'getPublicKey',
call: 'shh_getPublicKey',
params: 1
}),
new Method({
name: 'getPrivateKey',
call: 'shh_getPrivateKey',
params: 1
}),
new Method({
name: 'newSymKey',
call: 'shh_newSymKey',
params: 0
}),
new Method({
name: 'addSymKey',
call: 'shh_addSymKey',
params: 1
}),
new Method({
name: 'generateSymKeyFromPassword',
call: 'shh_generateSymKeyFromPassword',
params: 1
}),
new Method({
name: 'hasSymKey',
call: 'shh_hasSymKey',
params: 1
}),
new Method({
name: 'getSymKey',
call: 'shh_getSymKey',
params: 1
}),
new Method({
name: 'deleteSymKey',
call: 'shh_deleteSymKey',
params: 1
}),
// subscribe and unsubscribe missing
new Method({
name: 'post',
call: 'shh_post',
params: 1,
inputFormatter: [null]
})
];
};
module.exports = Shh;
},{"../filter":29,"../method":36,"./watches":43}],42:[function(require,module,exports){
/*
This file is part of web3.js.
web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file bzz.js
* @author Alex Beregszaszi <alex@rtfs.hu>
* @date 2016
*
* Reference: https://github.com/ethereum/go-ethereum/blob/swarm/internal/web3ext/web3ext.go#L33
*/
"use strict";
var Method = require('../method');
var Property = require('../property');
function Swarm(web3) {
this._requestManager = web3._requestManager;
var self = this;
methods().forEach(function(method) {
method.attachToObject(self);
method.setRequestManager(self._requestManager);
});
properties().forEach(function(p) {
p.attachToObject(self);
p.setRequestManager(self._requestManager);
});
}
var methods = function () {
var blockNetworkRead = new Method({
name: 'blockNetworkRead',
call: 'bzz_blockNetworkRead',
params: 1,
inputFormatter: [null]
});
var syncEnabled = new Method({
name: 'syncEnabled',
call: 'bzz_syncEnabled',
params: 1,
inputFormatter: [null]
});
var swapEnabled = new Method({
name: 'swapEnabled',
call: 'bzz_swapEnabled',
params: 1,
inputFormatter: [null]
});
var download = new Method({
name: 'download',
call: 'bzz_download',
params: 2,
inputFormatter: [null, null]
});
var upload = new Method({
name: 'upload',
call: 'bzz_upload',
params: 2,
inputFormatter: [null, null]
});
var retrieve = new Method({
name: 'retrieve',
call: 'bzz_retrieve',
params: 1,
inputFormatter: [null]
});
var store = new Method({
name: 'store',
call: 'bzz_store',
params: 2,
inputFormatter: [null, null]
});
var get = new Method({
name: 'get',
call: 'bzz_get',
params: 1,
inputFormatter: [null]
});
var put = new Method({
name: 'put',
call: 'bzz_put',
params: 2,
inputFormatter: [null, null]
});
var modify = new Method({
name: 'modify',
call: 'bzz_modify',
params: 4,
inputFormatter: [null, null, null, null]
});
return [
blockNetworkRead,
syncEnabled,
swapEnabled,
download,
upload,
retrieve,
store,
get,
put,
modify
];
};
var properties = function () {
return [
new Property({
name: 'hive',
getter: 'bzz_hive'
}),
new Property({
name: 'info',
getter: 'bzz_info'
})
];
};
module.exports = Swarm;
},{"../method":36,"../property":45}],43:[function(require,module,exports){
},{"../formatters":30,"../method":36,"../property":45}],43:[function(require,module,exports){
/*
This file is part of web3.js.
@ -6068,36 +5764,8 @@ var eth = function () {
];
};
/// @returns an array of objects describing web3.shh.watch api methods
var shh = function () {
return [
new Method({
name: 'newFilter',
call: 'shh_newMessageFilter',
params: 1
}),
new Method({
name: 'uninstallFilter',
call: 'shh_deleteMessageFilter',
params: 1
}),
new Method({
name: 'getLogs',
call: 'shh_getFilterMessages',
params: 1
}),
new Method({
name: 'poll',
call: 'shh_getFilterMessages',
params: 1
})
];
};
module.exports = {
eth: eth,
shh: shh
eth: eth
};

View file

@ -487,12 +487,6 @@ func (c *Client) EthSubscribe(ctx context.Context, channel interface{}, args ...
return c.Subscribe(ctx, "eth", channel, args...)
}
// ShhSubscribe registers a subscription under the "shh" namespace.
// Deprecated: use Subscribe(ctx, "shh", ...).
func (c *Client) ShhSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (*ClientSubscription, error) {
return c.Subscribe(ctx, "shh", channel, args...)
}
// Subscribe calls the "<namespace>_subscribe" method with the given arguments,
// registering a subscription. Server notifications for the subscription are
// sent to the given channel. The element type of the channel must match the

View file

@ -59,7 +59,7 @@ func TestSubscriptions(t *testing.T) {
t.Parallel()
var (
namespaces = []string{"eth", "bzz"}
namespaces = []string{"eth"}
service = &notificationTestService{}
subCount = len(namespaces)
notificationCount = 3

View file

@ -520,6 +520,16 @@ func (db *Database) Enable(root common.Hash) error {
// Re-construct a new disk layer backed by persistent state
// and schedule the state snapshot generation if it's permitted.
db.tree.init(generateSnapshot(db, root, db.isVerkle || db.config.SnapshotNoBuild))
// After snap sync, the state of the database may have changed completely.
// To ensure the history indexer always matches the current state, we must:
// 1. Close any existing indexer
// 2. Re-initialize the indexer so it starts indexing from the new state root.
if db.indexer != nil && db.freezer != nil && db.config.EnableStateIndexing {
db.indexer.close()
db.indexer = newHistoryIndexer(db.diskdb, db.freezer, db.tree.bottom().stateID())
log.Info("Re-enabled state history indexing")
}
log.Info("Rebuilt trie database", "root", root)
return nil
}

View file

@ -73,8 +73,8 @@ func storeIndexMetadata(db ethdb.KeyValueWriter, last uint64) {
// batchIndexer is a structure designed to perform batch indexing or unindexing
// of state histories atomically.
type batchIndexer struct {
accounts map[common.Hash][]uint64 // History ID list, Keyed by account address
storages map[common.Hash]map[common.Hash][]uint64 // History ID list, Keyed by account address and the hash of raw storage key
accounts map[common.Hash][]uint64 // History ID list, Keyed by the hash of account address
storages map[common.Hash]map[common.Hash][]uint64 // History ID list, Keyed by the hash of account address and the hash of raw storage key
counter int // The counter of processed states
delete bool // Index or unindex mode
lastID uint64 // The ID of latest processed history
@ -494,7 +494,18 @@ func (i *indexIniter) index(done chan struct{}, interrupt *atomic.Int32, lastID
// when the state is reverted manually (chain.SetHead) or the deep reorg is
// encountered. In such cases, no indexing should be scheduled.
if beginID > lastID {
if lastID == 0 && beginID == 1 {
// Initialize the indexing flag if the state history is empty by
// using zero as the disk layer ID. This is a common case that
// can occur after snap sync.
//
// This step is essential to avoid spinning up indexing thread
// endlessly until a history object is produced.
storeIndexMetadata(i.disk, 0)
log.Info("Initialized history indexing flag")
} else {
log.Debug("State history is fully indexed", "last", lastID)
}
return
}
log.Info("Start history indexing", "beginID", beginID, "lastID", lastID)

View file

@ -19,6 +19,6 @@ package version
const (
Major = 1 // Major version component of the current release
Minor = 16 // Minor version component of the current release
Patch = 1 // Patch version component of the current release
Patch = 2 // Patch version component of the current release
Meta = "unstable" // Version metadata to append to the version string
)