Skip to content

cmd/hivechain: use GetBalance() method for tx generation#462

Merged
fjl merged 10 commits intoethereum:masterfrom
renaynay:hivechain_getBalanceAddr
Apr 8, 2021
Merged

cmd/hivechain: use GetBalance() method for tx generation#462
fjl merged 10 commits intoethereum:masterfrom
renaynay:hivechain_getBalanceAddr

Conversation

@renaynay
Copy link
Copy Markdown
Contributor

This PR is dependent on this PR to add a GetBalance() method to block generation in geth, and now allows the hivechain tool to generate chains with a given number of transactions per block (capped at 2000 @todo this is arbitrary, should we increase the cap?) instead of just 1.

Comment thread cmd/hivechain/generate.go Outdated
if gbal.Sub(gbal, spent).Cmp(txCost) < 0 {
continue // no funds left in this account
if gen.GetBalance(addr).Cmp(txCost) > 0 {
tx := generateTx(txType, key, &cfg.genesis, gen)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You can do it better by always creating the tx, then comparing against tx.Cost()

Comment thread go.mod Outdated
gopkg.in/yaml.v2 v2.3.0
)

replace github.com/ethereum/go-ethereum => github.com/renaynay/go-ethereum v1.9.12-0.20210326162836-ac99fed7c3f0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You can remove this now

Comment thread cmd/hivechain/main.go Outdated
// check tx count to make sure it doesn't exceed max, set to max if exceeds
if cfg.txCount > 2000 {
cfg.txCount = 2000
}
Copy link
Copy Markdown
Collaborator

@fjl fjl Mar 30, 2021

Choose a reason for hiding this comment

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

I think the limit here is not necessary. But the generator should check if enough gas is available in the block to add the transaction. That way, the limit would be enforced by the block gas limit instead.

@fjl fjl merged commit 6bf0362 into ethereum:master Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants